╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Files.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
432 const idx = self.selectedRowIndex() orelse return null; 433 const base: usize = if (self.data.dir.len != 0) 1 else 0; // skip the ".." row 434 if (idx < base) return null; 435 const e = idx - base; 436 if (e >= self.data.entries.len) return null; 437 return self.data.entries[e]; 438 } 439 440 pub fn build(self: *View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 441 self.clearGrid(); 442 443 // swap the detail pane to the selected entry when the selection changes. 444 try self.refreshDetail(allocator); 445 446 // mirror the selected file into the url so it updates as the selection 447 // moves, but only while focus is inside this view (so landing on the tab 448 // keeps the page's base route). a file selection carries the file path and 449 // its content window offset; a directory / ".." row (or no selection) 450 // stays at the directory with no offset. the path is joined in a stack 451 // buffer since build runs every frame on the web. 452 if (root_focus.grandchild_id) |g| { 453 if (self.box.getFocus().children.contains(g)) { 454 var buf: [ui.RoutablePage.repo_route_max_len]u8 = undefined; 455 var sel_path = self.data.dir; 456 var sel_after: usize = 0; 457 if (self.selectedEntry()) |entry| { 458 if (!entry.is_dir) { 459 sel_path = if (self.data.dir.len == 0) 460 entry.name 461 else 462 std.fmt.bufPrint(&buf, "{s}/{s}", .{ self.data.dir, entry.name }) catch self.data.dir; 463 sel_after = entry.window_start; 464 } 465 } 466 if (ui.RoutablePage.repoFilesRoute(self.data.identity, self.data.ref_or_oid, self.data.ref_or_oid_value, sel_path, sel_after)) |route| 467 self.session.data.current_page = route; 468 } 469 } 470 471 // the selected list row shows a border (the focused TextBox upgrades it 472 // to a double border itself); the rest stay borderless. 473 const lb = self.listBox(); 474 for (lb.children.keys(), lb.children.values()) |id, *child| { 475 switch (child.widget) { 476 .text_box => |*tb| tb.options.border_style = if (lb.getFocus().child_id == id) .single else .hidden, 477 else => {}, 478 } 479 } 480 481 // the content scroll's border is single normally and double when the 482 // content is focused (the content box itself is borderless). 483 const has_content = self.detailInner().children.count() > 0; 484 const content_focused = if (root_focus.grandchild_id) |g| self.detailInner().children.contains(g) else false; 485 self.detailScrollFrame().options.border_style = if (!has_content) null else if (content_focused) .double else .single; 486 487 // same for the "next" link above the content. 488 const nav_box = self.navBox(); 489 for (nav_box.children.keys(), nav_box.children.values()) |id, *child| { 490 switch (child.widget) { 491 .text_box => |*tb| tb.options.border_style = if (nav_box.getFocus().child_id == id) .single else .hidden, 492 else => {}, 493 } 494 } 495 496 // cap the list at list_max_width only while the detail pane fits beside 497 // it. the box drops the detail pane when the width can't hold both 498 // minimums, so when it's that narrow we lift the cap and let the list 499 // fill the whole width. 500 const both_panes_fit = if (constraint.max_size.width) |w| w >= list_max_width + detail_min_width else true; 501 self.contentBox().children.values()[list_index].max_size = if (both_panes_fit) .{ .width = list_max_width, .height = null } else null; 502 503 // stretch the detail pane and its bordered scroll frame across the rest 504 // of the width so the pane fills the area rather than shrinking to its 505 // content, like the refs view's columns. the content scroll inside keeps 506 // its natural width: forcing it to the full inner width would make it one 507 // column too wide whenever the vertical scrollbar appears, leaving a 508 // phantom horizontal scroll. (height fills via the scroll clipping to the 509 // viewport.) 510 if (constraint.max_size.width) |w| { 511 const detail_w = if (both_panes_fit) w - list_max_width else w; 512 self.contentBox().children.values()[detail_index].min_size = .{ .width = detail_w, .height = null }; 513 self.detailOuter().children.values()[detail_scroll_index].min_size = .{ .width = detail_w, .height = null }; 514 } else { 515 self.contentBox().children.values()[detail_index].min_size = .{ .width = detail_min_width, .height = null }; 516 self.detailOuter().children.values()[detail_scroll_index].min_size = null; 517 } 518 519 // crossing panes only re-selects the content box's child (focusList / 520 // focusDetail); when the window is too narrow to show both, the pane that 521 // was holding focus is dropped here. the framework recovers focus after 522 // the top-level build by re-deriving it down the selected-child chain, so 523 // there's nothing to fix up afterward. 524 try self.box.build(allocator, constraint, root_focus); 525 } 526 527 fn refreshDetail(self: *View, allocator: std.mem.Allocator) !void { 528 const cur = self.selectedRowIndex(); 529 if (std.meta.eql(cur, self.shown_index)) return; 530 try self.populateDetail(allocator); 531 self.shown_index = cur; 532 } 533 534 fn populateDetail(self: *View, allocator: std.mem.Allocator) !void { 535 const nav_box = self.navBox(); 536 const inner = self.detailInner(); 537 538 for (nav_box.children.values()) |*child| child.widget.deinit(allocator); 539 nav_box.children.clearAndFree(allocator); 540 nav_box.getFocus().child_id = null; 541 for (inner.children.values()) |*child| child.widget.deinit(allocator); 542 inner.children.clearAndFree(allocator); 543 inner.getFocus().child_id = null; 544 545 // only files have contents to show; directories and the ".." row leave 546 // the pane empty. 547 if (self.selectedEntry()) |entry| { 548 if (!entry.is_dir) { 549 // the "next" window link sits above the scroll, so it stays put 550 // while the content scrolls. 551 if (entry.has_more) try self.addNavLink(allocator, nav_box, "next lines →", entry, entry.window_start + file_page); 552 if (entry.is_binary) { 553 try self.addContentBox(allocator, inner, "(binary file)"); 554 } else { 555 const text = try numberedContent(self.session.page_arena.allocator(), entry.lines, entry.window_start); 556 try self.addContentBox(allocator, inner, text); 557 } 558 } 559 } 560 // point each box at its first child so focus can descend into it. 561 if (nav_box.children.count() > 0) nav_box.getFocus().child_id = nav_box.children.keys()[0]; 562 if (inner.children.count() > 0) inner.getFocus().child_id = inner.children.keys()[0]; 563 564 // reset the scroll to the top for the newly-shown file: directly on the 565 // terminal (the wasm offset), and via a version bump on the web (so the 566 // renderer's scroll id changes and JS drops the preserved position). 567 const sc = self.detailScroll(); 568 sc.x = 0; 569 sc.y = 0; 570 sc.getFocus().version +%= 1; 571 } 572 573 // a focusable "next" link above the content. it's an `a:` link to the 574 // selected file at `target_after`, so activating it (the host follows the 575 // link) reloads the page on the next window. 576 fn addNavLink(self: *View, allocator: std.mem.Allocator, box: *wgt.Box(ui.Widget), label: []const u8, entry: Entry, target_after: usize) !void { 577 const page_arena = self.session.page_arena; 578 const path = try childDir(page_arena.allocator(), self.data.dir, entry.name); 579 const route = ui.RoutablePage.repoFilesRoute(self.data.identity, self.data.ref_or_oid, self.data.ref_or_oid_value, path, target_after) orelse return error.RouteTooLong; 580 const link = try std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{try route.urlAlloc(page_arena)}); 581 var tb = try wgt.TextBox(ui.Widget).init(allocator, label, .{ .border_style = .hidden, .rounded_corners = true, .wrap_kind = .none }); 582 errdefer tb.deinit(allocator); 583 tb.getFocus().focusable = true; 584 tb.getFocus().kind = .{ .custom = link }; 585 try box.children.put(allocator, tb.getFocus().id, .{ .widget = .{ .text_box = tb }, .rect = null, .min_size = null }); 586 } 587 588 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 589 _ = allocator; 590 if (self.detailActive()) { 591 try self.detailInput(key, root_focus); 592 } else { 593 try self.listInput(key, root_focus); 594 } 595 } 596 597 fn listInput(self: *View, key: Key, root_focus: *Focus) !void { 598 // up/down (and the scroll wheel) move the selection; page up/down jump a 599 // fixed amount. right/Enter cross into the detail pane. Enter/clicks on a 600 // directory (or "..") row are turned into navigation by the host 601 // (crossPageLink) before reaching here. 602 if (inp.rowDelta(key, @intCast(self.listBox().children.count()))) |delta| { 603 ui.moveRowFocus(self.listBox(), self.listScroll(), root_focus, delta); 604 return; 605 } 606 switch (key) { 607 .enter, .arrow_right => try self.focusDetail(root_focus), 608 else => {}, 609 } 610 } 611 612 // whether focus is on the content box (vs. a "previous"/"next" nav link). 613 fn focusOnContent(self: *View, root_focus: *Focus) bool { 614 const g = root_focus.grandchild_id orelse return false; 615 return self.detailInner().children.contains(g); 616 } 617 618 fn detailInput(self: *View, key: Key, root_focus: *Focus) !void { 619 const sc = self.detailScroll(); 620 const on_content = self.focusOnContent(root_focus); 621 // the "next" link sits above the content scroll. on the link, left returns 622 // to the file list and down drops into the content. in the content, the 623 // terminal scrolls by offset and reaching the top then pressing up crosses 624 // back up to the link; on the web vertical scrolling is the browser's job 625 // so up just crosses to the link. 626 switch (key) { 627 .arrow_left => { 628 if (on_content) { 629 if (sc.x > 0) { 630 sc.x -= 1; 631 self.detailScroll().clampToContent(); 632 } else try self.focusList(root_focus); 633 } else if (!self.moveNav(root_focus, -1)) { 634 try self.focusList(root_focus); 635 } 636 }, 637 .arrow_right => { 638 if (on_content) { 639 sc.x += 1; 640 self.detailScroll().clampToContent(); 641 } else _ = self.moveNav(root_focus, 1); 642 }, 643 .arrow_up => { 644 if (on_content) { 645 if (self.session.is_terminal and sc.y > 0) { 646 sc.y -= 1; 647 self.detailScroll().clampToContent(); 648 } else self.focusNav(root_focus); // cross up to the links 649 } 650 }, 651 .arrow_down => { 652 if (on_content) { 653 if (self.session.is_terminal) { 654 sc.y += 1; 655 self.detailScroll().clampToContent(); 656 } 657 } else self.focusContent(root_focus); // links -> content 658 }, 659 .page_up => if (on_content and self.session.is_terminal) { 660 sc.y -= 10; 661 self.detailScroll().clampToContent(); 662 }, 663 .page_down => if (on_content and self.session.is_terminal) { 664 sc.y += 10; 665 self.detailScroll().clampToContent(); 666 }, 667 .home => if (on_content and self.session.is_terminal) { 668 sc.y = 0; 669 self.detailScroll().clampToContent(); 670 }, 671 .end => if (on_content and self.session.is_terminal) { 672 sc.y = std.math.maxInt(isize); 673 self.detailScroll().clampToContent(); 674 }, 675 .mouse => |mouse| switch (mouse.action) { 676 .scroll => |dir| if (on_content and self.session.is_terminal) { 677 sc.y += if (dir == .up) -5 else 5; 678 self.detailScroll().clampToContent(); 679 }, 680 else => {}, 681 }, 682 else => {}, 683 } 684 } 685 686 // focus the first (left-most) nav link; a no-op when there are none, leaving 687 // focus on the content. 688 fn focusNav(self: *View, root_focus: *Focus) void { 689 const nav_box = self.navBox(); 690 if (nav_box.children.count() == 0) return; 691 root_focus.setFocus(nav_box.children.keys()[0]); 692 } 693 694 fn focusContent(self: *View, root_focus: *Focus) void { 695 const inner = self.detailInner(); 696 const id = inner.getFocus().child_id orelse (if (inner.children.count() > 0) inner.children.keys()[0] else return); 697 root_focus.setFocus(id); 698 } 699 700 // move focus `delta` rows within the nav box; returns false (without moving) 701 // when that would step off either end. 702 fn moveNav(self: *View, root_focus: *Focus, delta: isize) bool { 703 const nav_box = self.navBox(); 704 const keys = nav_box.children.keys(); 705 const cur_id = nav_box.getFocus().child_id orelse return false; 706 const cur: isize = @intCast(nav_box.children.getIndex(cur_id) orelse return false); 707 const target = cur + delta; 708 if (target < 0 or target >= @as(isize, @intCast(keys.len))) return false; 709 root_focus.setFocus(keys[@intCast(target)]); 710 return true; 711 } 712 713 // enter the detail pane, landing on the "next" link when there is one (so 714 // right-arrow reaches it), else on the content. a directory or ".." row has 715 // neither, so there's nothing to enter. selecting the frame's child (then 716 // focusing the frame) also handles the too-narrow case where the pane isn't 717 // laid out yet — focus lands inside it after the next build. 718 fn focusDetail(self: *View, root_focus: *Focus) !void { 719 const frame = self.detailOuter(); 720 if (self.navBox().children.count() > 0) { 721 frame.getFocus().child_id = self.navBox().getFocus().id; 722 } else if (self.detailInner().children.count() > 0) { 723 frame.getFocus().child_id = self.detailScrollFrame().getFocus().id; 724 } else return; 725 root_focus.setFocus(frame.getFocus().id); 726 } 727 728 // return to the list. 729 fn focusList(self: *View, root_focus: *Focus) !void { 730 root_focus.setFocus(self.listScroll().getFocus().id); 731 } 732 733 pub fn clearGrid(self: *View) void { 734 self.box.clearGrid(); 735 } 736 737 pub fn getGrid(self: View) ?Grid { 738 return self.box.getGrid(); 739 } 740 741 pub fn getFocus(self: *View) *Focus { 742 return self.box.getFocus(); 743 } 744 745 // for the parent's "scroll up at the top jumps to the header" check. inside 746 // the detail pane up-arrow stays in the pane (scrolling); when the list holds 747 // focus, report its selection directly so up-arrow at the top row ascends. 748 pub fn getSelectedIndex(self: *View) ?usize { 749 if (self.detailActive()) return 1; 750 const lb = self.listBox(); 751 const cid = lb.getFocus().child_id orelse return null; 752 return lb.children.getIndex(cid); 753 } 754 }; 755 756 // join `lines` into one string, each prefixed with its 1-based file line number 757 // (right-aligned in a column wide enough for the last number, then a space), 758 // like the diffs view. `start` is the window's 0-based first line, so numbers 759 // continue across paginated windows. 760 fn numberedContent(arena: std.mem.Allocator, lines: []const []const u8, start: usize) ![]const u8 { 761 if (lines.len == 0) return ""; 762 const width = std.fmt.count("{d}", .{start + lines.len}); 763 const indent = try arena.alloc(u8, width); 764 @memset(indent, ' '); 765 766 var out: std.ArrayList(u8) = .empty; 767 for (lines, 0..) |line, i| { 768 if (i != 0) try out.append(arena, '\n'); 769 const num_str = try std.fmt.allocPrint(arena, "{d}", .{start + i + 1}); 770 try out.appendSlice(arena, indent[0 .. width - num_str.len]); 771 try out.appendSlice(arena, num_str); 772 try out.append(arena, ' '); 773 try out.appendSlice(arena, line); 774 } 775 return out.toOwnedSlice(arena); 776 } 777 778 // the index of the "README"/"README.md" file entry (case-insensitive), or null 779 // if none. used to pick the default selection at the repo root. 780 fn readmeIndex(entries: []const Entry) ?usize { 781 for (entries, 0..) |entry, i| { 782 if (entry.is_dir) continue; 783 if (std.ascii.eqlIgnoreCase(entry.name, "README") or std.ascii.eqlIgnoreCase(entry.name, "README.md")) 784 return i; 785 } 786 return null; 787 } 788 789 // the index of the entry the route named (data.selected_file), or null if none. 790 fn selectedFileIndex(data: *const Self) ?usize { 791 const name = data.selected_file orelse return null; 792 for (data.entries, 0..) |entry, i| { 793 if (!entry.is_dir and std.mem.eql(u8, entry.name, name)) return i; 794 } 795 return null; 796 } 797 798 // an "a:" link to the files route at `path`, pinned to the listing's ref, so 799 // following it navigates to that directory's listing. 800 fn dirLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, path: []const u8) ![]const u8 { 801 const route = ui.RoutablePage.repoFilesRoute(data.identity, data.ref_or_oid, data.ref_or_oid_value, path, 0) orelse return error.RouteTooLong; 802 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{try route.urlAlloc(page_arena)}); 803 } 804 805 // an "ai:" link to the file's route: crossPageLink ignores it, so a wasm click 806 // selects the row in place and shows its contents in the detail pane. 807 fn fileLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, path: []const u8) ![]const u8 { 808 const route = ui.RoutablePage.repoFilesRoute(data.identity, data.ref_or_oid, data.ref_or_oid_value, path, 0) orelse return error.RouteTooLong; 809 return std.fmt.allocPrint(page_arena.allocator(), "ai:{s}", .{try route.urlAlloc(page_arena)}); 810 } 811 812 // `dir`/`name`, or just `name` at the root. 813 pub fn childDir(arena: std.mem.Allocator, dir: []const u8, name: []const u8) ![]const u8 { 814 return if (dir.len == 0) name else std.fmt.allocPrint(arena, "{s}/{s}", .{ dir, name }); 815 } 816 817 // `dir` with its last segment removed ("" when `dir` has a single segment). 818 fn parentDir(dir: []const u8) []const u8 { 819 const slash = std.mem.lastIndexOfScalar(u8, dir, '/') orelse return ""; 820 return dir[0..slash]; 821 } 822 823 // the "viewing <ref_or_oid> <value>" banner shown above the listing. 824 pub const Header = struct { 825 content: []const u8, 826 827 pub fn init(aa: std.mem.Allocator, ref_or_oid: ui.RoutablePage.RefOrOid, value: []const u8) !Header { 828 return .{ 829 .content = try std.fmt.allocPrint(aa, "viewing {s} {s}", .{ @tagName(ref_or_oid), value }), 830 }; 831 } 832 833 pub const View = struct { 834 text_box: wgt.TextBox(ui.Widget), 835 data: *const Header, 836 837 pub fn init(allocator: std.mem.Allocator, data: *const Header, session: *ui.Session) !Header.View { 838 _ = session; 839 var text_box = try wgt.TextBox(ui.Widget).init(allocator, data.content, .{ .border_style = .hidden, .wrap_kind = .none }); 840 errdefer text_box.deinit(allocator); 841 return .{ .text_box = text_box, .data = data }; 842 } 843 844 pub fn deinit(self: *Header.View, allocator: std.mem.Allocator) void { 845 self.text_box.deinit(allocator); 846 } 847 848 pub fn build(self: *Header.View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 849 // a single line plus the hidden border is 3 rows tall; stretch the box to 850 // the full width by handing the available width down as a min width. 851 try self.text_box.build(allocator, .{ 852 .min_size = .{ .width = constraint.max_size.width, .height = null }, 853 .max_size = constraint.max_size, 854 }, root_focus); 855 } 856 857 pub fn input(self: *Header.View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 858 _ = self; 859 _ = allocator; 860 _ = key; 861 _ = root_focus; 862 } 863 864 pub fn clearGrid(self: *Header.View) void { 865 self.text_box.clearGrid(); 866 } 867 868 pub fn getGrid(self: Header.View) ?Grid { 869 return self.text_box.getGrid(); 870 } 871 872 pub fn getFocus(self: *Header.View) *Focus { 873 return self.text_box.getFocus(); 874 } 875 }; 876 }; 877