mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-05-13 08:26:56 +00:00
[diff kitten] move next/prev file
This commit is contained in:
parent
1f656eccbb
commit
bbe29dbc7b
2 changed files with 31 additions and 1 deletions
|
|
@ -221,6 +221,14 @@ map('Scroll to previous change',
|
|||
'prev_change p scroll_to prev-change',
|
||||
)
|
||||
|
||||
map('Scroll to next file',
|
||||
'next_file shift+j scroll_to next-file',
|
||||
)
|
||||
|
||||
map('Scroll to previous file',
|
||||
'prev_file shift+k scroll_to prev-file',
|
||||
)
|
||||
|
||||
map('Show all context',
|
||||
'all_context a change_context all',
|
||||
)
|
||||
|
|
|
|||
|
|
@ -184,7 +184,6 @@ func (self *Handler) highlight_all() {
|
|||
self.async_results <- r
|
||||
self.lp.WakeupMainThread()
|
||||
}()
|
||||
|
||||
}
|
||||
|
||||
func (self *Handler) load_all_images() {
|
||||
|
|
@ -523,6 +522,27 @@ func (self *Handler) scroll_to_next_change(backwards bool) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (self *Handler) scroll_to_next_file(backwards bool) bool {
|
||||
if backwards {
|
||||
for i := self.scroll_pos.logical_line - 1; i >= 0; i-- {
|
||||
line := self.logical_lines.At(i)
|
||||
if line.line_type == TITLE_LINE {
|
||||
self.scroll_pos = ScrollPos{i, 0}
|
||||
return true
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for i := self.scroll_pos.logical_line + 1; i < self.logical_lines.Len(); i++ {
|
||||
line := self.logical_lines.At(i)
|
||||
if line.line_type == TITLE_LINE {
|
||||
self.scroll_pos = ScrollPos{i, 0}
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *Handler) scroll_to_next_match(backwards, include_current_match bool) bool {
|
||||
if self.current_search == nil {
|
||||
return false
|
||||
|
|
@ -616,6 +636,8 @@ func (self *Handler) dispatch_action(name, args string) error {
|
|||
case `scroll_to`:
|
||||
done := false
|
||||
switch {
|
||||
case strings.Contains(args, "file"):
|
||||
done = self.scroll_to_next_file(strings.Contains(args, `prev`))
|
||||
case strings.Contains(args, `change`):
|
||||
done = self.scroll_to_next_change(strings.Contains(args, `prev`))
|
||||
case strings.Contains(args, `match`):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue