mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-18 22:44:50 +02:00
unicode_input kitten: Fix scrolling over multiple screens not working
Fixes #6497
This commit is contained in:
@@ -44,6 +44,8 @@ Detailed list of changes
|
|||||||
|
|
||||||
- Detect .tex and Makefiles as plain text files (:iss:`6492`)
|
- 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]
|
0.29.1 [2023-07-17]
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|||||||
@@ -51,15 +51,21 @@ func ljust(s string, sz int) string {
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type scroll_data struct {
|
||||||
|
num_items_per_page int
|
||||||
|
scroll_rows int
|
||||||
|
}
|
||||||
|
|
||||||
type table struct {
|
type table struct {
|
||||||
emoji_variation string
|
emoji_variation string
|
||||||
layout_dirty bool
|
layout_dirty bool
|
||||||
last_rows, last_cols int
|
last_rows, last_cols int
|
||||||
codepoints []rune
|
codepoints []rune
|
||||||
current_idx, scroll_rows int
|
current_idx int
|
||||||
text string
|
scroll_data scroll_data
|
||||||
num_cols, num_rows int
|
text string
|
||||||
mode Mode
|
num_cols, num_rows int
|
||||||
|
mode Mode
|
||||||
|
|
||||||
green, reversed, intense_gray func(...any) string
|
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) {
|
func (self *table) set_codepoints(codepoints []rune, mode Mode, current_idx int) {
|
||||||
|
delta := len(codepoints) - len(self.codepoints)
|
||||||
self.codepoints = codepoints
|
self.codepoints = codepoints
|
||||||
if self.codepoints != nil && mode != FAVORITES && mode != HEX {
|
if self.codepoints != nil && mode != FAVORITES && mode != HEX {
|
||||||
slices.Sort(self.codepoints)
|
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) {
|
if self.current_idx >= len(self.codepoints) {
|
||||||
self.current_idx = 0
|
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 {
|
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
|
space_for_desc = col_width - 2 - idx_size - 4
|
||||||
self.num_rows = rows
|
self.num_rows = rows
|
||||||
rows_left := 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 {
|
for i, cd := range parts {
|
||||||
if skip_scroll > 0 {
|
if skip_scroll > 0 {
|
||||||
@@ -223,6 +235,12 @@ func (self *table) layout(rows, cols int) string {
|
|||||||
return self.text
|
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) {
|
func (self *table) move_current(rows, cols int) {
|
||||||
if len(self.codepoints) == 0 {
|
if len(self.codepoints) == 0 {
|
||||||
return
|
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.current_idx = utils.Max(0, utils.Min(self.current_idx, len(self.codepoints)-1))
|
||||||
self.layout_dirty = true
|
self.layout_dirty = true
|
||||||
}
|
}
|
||||||
first_visible := self.scroll_rows * self.num_cols
|
self.update_scroll_data()
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user