Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
- uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: 5.3.0
- name: Pin external dependencies
run: opam pin add ppx_forbid git+https://github.com/atacama-dev/ppx_forbid.git --no-action
- name: Install dependencies
run: opam install --deps-only --with-test -y .
- name: Build & test
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [0.4.1] - Unreleased

### Fixed

- **Table row selection highlighting**: Full row background now displays correctly when `selection_mode = Row`. Previously, only border characters (vertical separators) showed the selection color due to ANSI reset codes from `themed_border` clearing the selection background. Now, border styling is skipped for selected rows, allowing the full row to inherit the selection background color.

## [0.4.0] - Unreleased

### Breaking Changes

- **Box_widget border style**: added `None_` to `Box_widget.border_style` for borderless containers. Pattern matches on `border_style` may need a new case.
Expand Down
9 changes: 1 addition & 8 deletions example/demos/table/page.ml
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,7 @@ module Inner = struct
"↑/↓ to move • Enter logs the selection • t opens tutorial • Esc \
returns"
in
let body =
Miaou_widgets_display.Table_widget.render_table_80
~cols:(Some 80)
~header:("Name", "Score", "Status")
~rows:s.table.rows
~cursor:s.table.cursor
~sel_col:0
in
let body = Miaou_widgets_display.Table_widget.Table.render s.table in
header ^ "\n\n" ^ body

let log_selection table =
Expand Down
19 changes: 15 additions & 4 deletions src/miaou_widgets_display/table_widget.ml
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,12 @@ let render_table_generic_with_opts ?backend ?(wrap = false) ~cols ~header_list
let blank_for_col =
List.mapi (fun idx w -> (idx, String.make w ' ')) col_widths
in
let assemble_columns cols =
let assemble_columns ~is_selected cols =
let buf = Buffer.create inner_w in
let vline = W.themed_border glyphs.vline in
(* When row is selected, don't style vlines - let them inherit selection bg *)
let vline =
if is_selected then glyphs.vline else W.themed_border glyphs.vline
in
Buffer.add_string buf vline ;
List.iteri
(fun idx col ->
Expand All @@ -296,7 +299,10 @@ let render_table_generic_with_opts ?backend ?(wrap = false) ~cols ~header_list
^ String.make copts.pad_right ' ')
cols_cells
in
let line_core = assemble_columns cells in
let is_selected =
match opts.selection_mode with Row when i = cursor -> true | _ -> false
in
let line_core = assemble_columns ~is_selected cells in
let line =
match opts.selection_mode with
| Row when i = cursor -> W.themed_selection line_core
Expand Down Expand Up @@ -347,7 +353,12 @@ let render_table_generic_with_opts ?backend ?(wrap = false) ~cols ~header_list
| None -> ""))
padded_lines
in
let line_core = assemble_columns cols_for_idx in
let is_selected =
match opts.selection_mode with
| Row when i = cursor -> true
| _ -> false
in
let line_core = assemble_columns ~is_selected cols_for_idx in
let line =
match opts.selection_mode with
| Row when i = cursor -> W.themed_selection line_core
Expand Down