(ctx context.Context, shellName, initialQuery string)
| 128 | } |
| 129 | |
| 130 | func initialModel(ctx context.Context, shellName, initialQuery string) model { |
| 131 | s := spinner.New() |
| 132 | s.Spinner = spinner.Dot |
| 133 | s.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("205")) |
| 134 | queryInput := textinput.New() |
| 135 | cfg := hctx.GetConf(ctx) |
| 136 | defaultFilter := cfg.DefaultFilter |
| 137 | if defaultFilter != "" { |
| 138 | queryInput.Prompt = "[" + defaultFilter + "] " |
| 139 | } |
| 140 | queryInput.PromptStyle = queryInput.PlaceholderStyle |
| 141 | if defaultFilter == "" { |
| 142 | queryInput.Placeholder = "ls" |
| 143 | } |
| 144 | queryInput.Focus() |
| 145 | queryInput.CharLimit = 200 |
| 146 | width, _, err := getTerminalSize() |
| 147 | if err == nil { |
| 148 | queryInput.Width = width |
| 149 | } else { |
| 150 | hctx.GetLogger().Warnf("getTerminalSize() return err=%#v, defaulting queryInput to a width of 50", err) |
| 151 | queryInput.Width = 50 |
| 152 | } |
| 153 | if initialQuery != "" { |
| 154 | queryInput.SetValue(initialQuery) |
| 155 | } |
| 156 | CURRENT_QUERY_FOR_HIGHLIGHTING = initialQuery |
| 157 | return model{ctx: ctx, spinner: s, isLoading: true, table: nil, tableEntries: []*data.HistoryEntry{}, runQuery: &initialQuery, queryInput: queryInput, help: help.New(), shellName: shellName, hasFinishedFirstLoad: false} |
| 158 | } |
| 159 | |
| 160 | func (m model) Init() tea.Cmd { |
| 161 | return m.spinner.Tick |
no test coverage detected