Class: Changelogger::BranchWindow
- Inherits:
-
Object
- Object
- Changelogger::BranchWindow
- Defined in:
- lib/changelogger/branches_window.rb
Overview
Changelogger::BranchWindow is the left-right split TUI with live preview.
Constant Summary collapse
- CP_HELP =
Color pair IDs used within curses
2- CP_HIGHLIGHT =
current cursor commit block
3- CP_SELECTED =
selected anchor commit header
4- CP_SEP =
thin separators
5- CP_ALT =
zebra alt shading
6
Instance Attribute Summary collapse
-
#selected_shas ⇒ Array<String>?
readonly
Selected SHAs after Enter, or nil if cancelled.
Instance Method Summary collapse
-
#initialize(max_height: 50, top: 1, left: 0, left_width: nil) ⇒ BranchWindow
constructor
Changelogger::BranchWindow.new-> Changelogger::BranchWindow. -
#select_commits ⇒ Array<String>?
Changelogger::BranchWindow#select_commits -> Array<String>, nil.
Constructor Details
#initialize(max_height: 50, top: 1, left: 0, left_width: nil) ⇒ BranchWindow
Changelogger::BranchWindow.new -> Changelogger::BranchWindow
Builds the UI panes (graph on the left, preview on the right) and prepares state for selection and scrolling.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/changelogger/branches_window.rb', line 74 def initialize(max_height: 50, top: 1, left: 0, left_width: nil) @top = top @left = left @width = Curses.cols - @left screen_height = Curses.lines @height = [screen_height - @top, max_height].min @repo = Changelogger::Repo.info @lines = Graph.build.split("\n") preferred_left = Graph.width + 4 @left_min = 24 @right_min = 28 @left_w = compute_left_width(requested_left: left_width || preferred_left) # Graph state @headers = detect_headers(@lines) @selected_header_idx = 0 @selected_header_idxs = [] @offset = 0 @fit_full_block = true @zebra_blocks = true recompute_blocks! # Preview state @commits = Changelogger::Git.commits @preview_lines = [] @preview_offset = 0 @focus = :left @cancelled = false setup_windows init_colors update_titles update_preview(reset_offset: true) ensure_visible redraw end |
Instance Attribute Details
#selected_shas ⇒ Array<String>? (readonly)
Returns selected SHAs after Enter, or nil if cancelled.
56 57 58 |
# File 'lib/changelogger/branches_window.rb', line 56 def selected_shas @selected_shas end |
Instance Method Details
#select_commits ⇒ Array<String>?
Changelogger::BranchWindow#select_commits -> Array<String>, nil
Enters the TUI input loop and returns when user confirms or cancels.
119 120 121 122 123 124 |
# File 'lib/changelogger/branches_window.rb', line 119 def select_commits handle_keyboard_input @cancelled ? nil : (@selected_shas || []) ensure teardown end |