diff --git a/kittens/choose_files/main.go b/kittens/choose_files/main.go index d63f3f0bc..d3a465921 100644 --- a/kittens/choose_files/main.go +++ b/kittens/choose_files/main.go @@ -120,6 +120,7 @@ type State struct { sort_by_last_modified bool global_ignores ignorefiles.IgnoreFile keyboard_shortcuts []*config.KeyAction + display_title bool selections []string current_idx CollectionIndex @@ -128,6 +129,7 @@ type State struct { redraw_needed bool } +func (s State) DisplayTitle() bool { return s.display_title } func (s State) ShowHidden() bool { return s.show_hidden } func (s State) RespectIgnores() bool { return s.respect_ignores } func (s State) SortByLastModified() bool { return s.sort_by_last_modified } @@ -225,9 +227,14 @@ func (h *Handler) draw_screen() (err error) { h.lp.SetWindowTitle(h.state.WindowTitle()) defer func() { // so that the cursor ends up in the right place h.lp.MoveCursorTo(1, 1) - h.draw_search_bar(0) + if h.state.DisplayTitle() { + h.lp.Println(h.state.WindowTitle()) + h.draw_search_bar(1) + } else { + h.draw_search_bar(0) + } }() - y := SEARCH_BAR_HEIGHT + y := SEARCH_BAR_HEIGHT + utils.IfElse(h.state.DisplayTitle(), 1, 0) footer_height, err := h.draw_footer() if err != nil { return err @@ -683,7 +690,7 @@ func (h *Handler) set_state_from_config(conf *Config, opts *Options) (err error) return err } h.state.keyboard_shortcuts = conf.KeyboardShortcuts - + h.state.display_title = opts.DisplayTitle return } diff --git a/kittens/choose_files/main.py b/kittens/choose_files/main.py index 84bb423e4..28ebac7ee 100644 --- a/kittens/choose_files/main.py +++ b/kittens/choose_files/main.py @@ -121,6 +121,12 @@ Path to an existing file to use as the save file. Window title to use for this chooser +--display-title +type=bool-set +Show the window title at the top, useful when this kitten is used in an +OS window without a title bar. + + --override -o type=list Override individual configuration options, can be specified multiple times. diff --git a/kittens/choose_files/save-file.go b/kittens/choose_files/save-file.go index f59dcf065..4f90db91a 100644 --- a/kittens/choose_files/save-file.go +++ b/kittens/choose_files/save-file.go @@ -123,6 +123,9 @@ func (h *Handler) initialize_save_file_name(fname string) { func (h *Handler) draw_save_file_name_screen() (err error) { h.lp.AllowLineWrapping(true) desc := utils.IfElse(h.state.mode == SELECT_SAVE_FILE, "file", "directory") + if h.state.DisplayTitle() { + h.lp.Println(h.state.WindowTitle()) + } h.lp.Println("Enter the name of the", desc, "below, relative to:") h.lp.Println(h.lp.SprintStyled("fg=green", h.state.CurrentDir())) if h.state.mode.AllowsMultipleSelection() { diff --git a/kittens/desktop_ui/portal.go b/kittens/desktop_ui/portal.go index 6202e2323..40041886c 100644 --- a/kittens/desktop_ui/portal.go +++ b/kittens/desktop_ui/portal.go @@ -792,7 +792,7 @@ func (self *Portal) run_file_chooser(cfd ChooseFilesData) (response uint32, resu return nil } } - args = append(args, "kitten", `choose-files`, `--mode`, cfd.Mode, `--write-output-to`, output_path, `--output-format=json`) + args = append(args, "kitten", `choose-files`, `--mode`, cfd.Mode, `--write-output-to`, output_path, `--output-format=json`, `--display-title`) if cfd.SuggestedSaveFileName != "" { args = append(args, `--suggested-save-file-name`, cfd.SuggestedSaveFileName) }