(ctx context.Context, shellName string, rows []table.Row)
| 690 | } |
| 691 | |
| 692 | func makeTable(ctx context.Context, shellName string, rows []table.Row) (table.Model, error) { |
| 693 | config := hctx.GetConf(ctx) |
| 694 | columns, err := makeTableColumns(ctx, shellName, config.DisplayedColumns, rows) |
| 695 | if err != nil { |
| 696 | return table.Model{}, err |
| 697 | } |
| 698 | km := table.KeyMap{ |
| 699 | LineUp: loadedKeyBindings.Up, |
| 700 | LineDown: loadedKeyBindings.Down, |
| 701 | PageUp: loadedKeyBindings.PageUp, |
| 702 | PageDown: loadedKeyBindings.PageDown, |
| 703 | GotoTop: key.NewBinding( |
| 704 | key.WithKeys("home"), |
| 705 | key.WithHelp("home", "go to start"), |
| 706 | ), |
| 707 | GotoBottom: key.NewBinding( |
| 708 | key.WithKeys("end"), |
| 709 | key.WithHelp("end", "go to end"), |
| 710 | ), |
| 711 | MoveLeft: loadedKeyBindings.TableLeft, |
| 712 | MoveRight: loadedKeyBindings.TableRight, |
| 713 | } |
| 714 | _, terminalHeight, err := getTerminalSize() |
| 715 | if err != nil { |
| 716 | return table.Model{}, err |
| 717 | } |
| 718 | tuiSize := 12 |
| 719 | if isCompactHeightMode(ctx) { |
| 720 | tuiSize -= 2 |
| 721 | } |
| 722 | if isExtraCompactHeightMode(ctx) { |
| 723 | tuiSize -= 3 |
| 724 | } |
| 725 | tableHeight := min(getTableHeight(ctx), terminalHeight-tuiSize) |
| 726 | t := table.New( |
| 727 | table.WithColumns(columns), |
| 728 | table.WithRows(rows), |
| 729 | table.WithFocused(true), |
| 730 | table.WithHeight(tableHeight), |
| 731 | table.WithKeyMap(km), |
| 732 | ) |
| 733 | |
| 734 | s := table.DefaultStyles() |
| 735 | s.Header = s.Header. |
| 736 | BorderStyle(lipgloss.NormalBorder()). |
| 737 | BorderForeground(lipgloss.Color(config.ColorScheme.BorderColor)). |
| 738 | BorderBottom(true). |
| 739 | Bold(false) |
| 740 | s.Selected = s.Selected. |
| 741 | Foreground(lipgloss.Color(config.ColorScheme.SelectedText)). |
| 742 | Background(lipgloss.Color(config.ColorScheme.SelectedBackground)). |
| 743 | Bold(false) |
| 744 | if config.HighlightMatches { |
| 745 | MATCH_NOTHING_REGEXP := regexp.MustCompile("a^") |
| 746 | s.RenderCell = func(model table.Model, value string, position table.CellPosition) string { |
| 747 | var re *regexp.Regexp |
| 748 | CURRENT_QUERY_FOR_HIGHLIGHTING = strings.TrimSpace(CURRENT_QUERY_FOR_HIGHLIGHTING) |
| 749 | if CURRENT_QUERY_FOR_HIGHLIGHTING == "" { |
no test coverage detected