scroll when selection reaches top/bottom
This commit is contained in:
10
bigtext.py
10
bigtext.py
@@ -117,6 +117,11 @@ class InnerBigText(QWidget):
|
||||
self.selection_highlight.set_end_byte(current_byte)
|
||||
self.update()
|
||||
# print("-> %s,%s" %(self._selection_start_byte, self._selection_end_byte))
|
||||
line_number = self.y_pos_to_line(e.pos().y())
|
||||
if line_number == 0:
|
||||
self.scroll_by_lines(-1)
|
||||
if line_number+1 >= int(self.lines_shown()):
|
||||
self.scroll_by_lines(1)
|
||||
|
||||
def h_scroll_event(self, left_offset: int):
|
||||
self._left_offset = left_offset
|
||||
@@ -135,8 +140,11 @@ class InnerBigText(QWidget):
|
||||
maximum = max(0, length - width_in_chars+1)
|
||||
self.parent.h_scroll_bar.setMaximum(maximum)
|
||||
|
||||
def y_pos_to_line(self, y: int):
|
||||
return int(y / self.char_height)
|
||||
|
||||
def to_byte_offset(self, e: QMouseEvent) -> int:
|
||||
line_number = int(e.pos().y() / self.char_height)
|
||||
line_number = self.y_pos_to_line(e.pos().y())
|
||||
|
||||
if line_number < len(self.lines):
|
||||
line = self.lines[line_number]
|
||||
|
||||
Reference in New Issue
Block a user