Skip to content

Commit fbe982e

Browse files
committed
choose files: Option to display title at top when OS titlebar is not available
1 parent 52b0823 commit fbe982e

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

kittens/choose_files/main.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ type State struct {
120120
sort_by_last_modified bool
121121
global_ignores ignorefiles.IgnoreFile
122122
keyboard_shortcuts []*config.KeyAction
123+
display_title bool
123124

124125
selections []string
125126
current_idx CollectionIndex
@@ -128,6 +129,7 @@ type State struct {
128129
redraw_needed bool
129130
}
130131

132+
func (s State) DisplayTitle() bool { return s.display_title }
131133
func (s State) ShowHidden() bool { return s.show_hidden }
132134
func (s State) RespectIgnores() bool { return s.respect_ignores }
133135
func (s State) SortByLastModified() bool { return s.sort_by_last_modified }
@@ -225,9 +227,14 @@ func (h *Handler) draw_screen() (err error) {
225227
h.lp.SetWindowTitle(h.state.WindowTitle())
226228
defer func() { // so that the cursor ends up in the right place
227229
h.lp.MoveCursorTo(1, 1)
228-
h.draw_search_bar(0)
230+
if h.state.DisplayTitle() {
231+
h.lp.Println(h.state.WindowTitle())
232+
h.draw_search_bar(1)
233+
} else {
234+
h.draw_search_bar(0)
235+
}
229236
}()
230-
y := SEARCH_BAR_HEIGHT
237+
y := SEARCH_BAR_HEIGHT + utils.IfElse(h.state.DisplayTitle(), 1, 0)
231238
footer_height, err := h.draw_footer()
232239
if err != nil {
233240
return err
@@ -683,7 +690,7 @@ func (h *Handler) set_state_from_config(conf *Config, opts *Options) (err error)
683690
return err
684691
}
685692
h.state.keyboard_shortcuts = conf.KeyboardShortcuts
686-
693+
h.state.display_title = opts.DisplayTitle
687694
return
688695
}
689696

kittens/choose_files/main.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ def main(args: list[str]) -> None:
121121
Window title to use for this chooser
122122
123123
124+
--display-title
125+
type=bool-set
126+
Show the window title at the top, useful when this kitten is used in an
127+
OS window without a title bar.
128+
129+
124130
--override -o
125131
type=list
126132
Override individual configuration options, can be specified multiple times.

kittens/choose_files/save-file.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ func (h *Handler) initialize_save_file_name(fname string) {
123123
func (h *Handler) draw_save_file_name_screen() (err error) {
124124
h.lp.AllowLineWrapping(true)
125125
desc := utils.IfElse(h.state.mode == SELECT_SAVE_FILE, "file", "directory")
126+
if h.state.DisplayTitle() {
127+
h.lp.Println(h.state.WindowTitle())
128+
}
126129
h.lp.Println("Enter the name of the", desc, "below, relative to:")
127130
h.lp.Println(h.lp.SprintStyled("fg=green", h.state.CurrentDir()))
128131
if h.state.mode.AllowsMultipleSelection() {

kittens/desktop_ui/portal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ func (self *Portal) run_file_chooser(cfd ChooseFilesData) (response uint32, resu
792792
return nil
793793
}
794794
}
795-
args = append(args, "kitten", `choose-files`, `--mode`, cfd.Mode, `--write-output-to`, output_path, `--output-format=json`)
795+
args = append(args, "kitten", `choose-files`, `--mode`, cfd.Mode, `--write-output-to`, output_path, `--output-format=json`, `--display-title`)
796796
if cfd.SuggestedSaveFileName != "" {
797797
args = append(args, `--suggested-save-file-name`, cfd.SuggestedSaveFileName)
798798
}

0 commit comments

Comments
 (0)