mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-05-13 16:37:27 +00:00
unicode_input kitten: Fix scrolling over multiple screens not working
Fixes #6497
This commit is contained in:
parent
6fda8d7e23
commit
737e4cdbd3
2 changed files with 31 additions and 19 deletions
|
|
@ -44,6 +44,8 @@ Detailed list of changes
|
|||
|
||||
- Detect .tex and Makefiles as plain text files (:iss:`6492`)
|
||||
|
||||
- unicode_input kitten: Fix scrolling over multiple screens not working (:iss:`6497`)
|
||||
|
||||
0.29.1 [2023-07-17]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
|||
|
|
@ -51,15 +51,21 @@ func ljust(s string, sz int) string {
|
|||
return s
|
||||
}
|
||||
|
||||
type scroll_data struct {
|
||||
num_items_per_page int
|
||||
scroll_rows int
|
||||
}
|
||||
|
||||
type table struct {
|
||||
emoji_variation string
|
||||
layout_dirty bool
|
||||
last_rows, last_cols int
|
||||
codepoints []rune
|
||||
current_idx, scroll_rows int
|
||||
text string
|
||||
num_cols, num_rows int
|
||||
mode Mode
|
||||
emoji_variation string
|
||||
layout_dirty bool
|
||||
last_rows, last_cols int
|
||||
codepoints []rune
|
||||
current_idx int
|
||||
scroll_data scroll_data
|
||||
text string
|
||||
num_cols, num_rows int
|
||||
mode Mode
|
||||
|
||||
green, reversed, intense_gray func(...any) string
|
||||
}
|
||||
|
|
@ -81,6 +87,7 @@ func (self *table) current_codepoint() rune {
|
|||
}
|
||||
|
||||
func (self *table) set_codepoints(codepoints []rune, mode Mode, current_idx int) {
|
||||
delta := len(codepoints) - len(self.codepoints)
|
||||
self.codepoints = codepoints
|
||||
if self.codepoints != nil && mode != FAVORITES && mode != HEX {
|
||||
slices.Sort(self.codepoints)
|
||||
|
|
@ -93,7 +100,9 @@ func (self *table) set_codepoints(codepoints []rune, mode Mode, current_idx int)
|
|||
if self.current_idx >= len(self.codepoints) {
|
||||
self.current_idx = 0
|
||||
}
|
||||
self.scroll_rows = 0
|
||||
if delta != 0 {
|
||||
self.scroll_data = scroll_data{}
|
||||
}
|
||||
}
|
||||
|
||||
func (self *table) codepoint_at_hint(hint string) rune {
|
||||
|
|
@ -201,7 +210,10 @@ func (self *table) layout(rows, cols int) string {
|
|||
space_for_desc = col_width - 2 - idx_size - 4
|
||||
self.num_rows = rows
|
||||
rows_left := rows
|
||||
skip_scroll := self.scroll_rows * self.num_cols
|
||||
if self.scroll_data.num_items_per_page != self.num_cols*self.num_rows {
|
||||
self.update_scroll_data()
|
||||
}
|
||||
skip_scroll := self.scroll_data.scroll_rows * self.num_cols
|
||||
|
||||
for i, cd := range parts {
|
||||
if skip_scroll > 0 {
|
||||
|
|
@ -223,6 +235,12 @@ func (self *table) layout(rows, cols int) string {
|
|||
return self.text
|
||||
}
|
||||
|
||||
func (self *table) update_scroll_data() {
|
||||
self.scroll_data.num_items_per_page = self.num_rows * self.num_cols
|
||||
page_num := self.current_idx / self.scroll_data.num_items_per_page
|
||||
self.scroll_data.scroll_rows = self.num_rows * page_num
|
||||
}
|
||||
|
||||
func (self *table) move_current(rows, cols int) {
|
||||
if len(self.codepoints) == 0 {
|
||||
return
|
||||
|
|
@ -237,13 +255,5 @@ func (self *table) move_current(rows, cols int) {
|
|||
self.current_idx = utils.Max(0, utils.Min(self.current_idx, len(self.codepoints)-1))
|
||||
self.layout_dirty = true
|
||||
}
|
||||
first_visible := self.scroll_rows * self.num_cols
|
||||
last_visible := first_visible + ((self.num_cols * self.num_rows) - 1)
|
||||
scroll_amount := self.num_rows
|
||||
if self.current_idx < first_visible {
|
||||
self.scroll_rows = utils.Max(self.scroll_rows-scroll_amount, 0)
|
||||
}
|
||||
if self.current_idx > last_visible {
|
||||
self.scroll_rows += scroll_amount
|
||||
}
|
||||
self.update_scroll_data()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue