mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-05-13 08:26:56 +00:00
choose files: Option to display title at top when OS titlebar is not available
This commit is contained in:
parent
52b0823470
commit
fbe982e1aa
4 changed files with 20 additions and 4 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue