Skip to content

Commit

Permalink
scrolling 2/3 of a screen only
Browse files Browse the repository at this point in the history
  • Loading branch information
Seth Rider committed Apr 8, 2021
1 parent 2298bd0 commit 20000da
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
16 changes: 9 additions & 7 deletions plover_console_ui/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,20 @@ def on_add_translation(self, engine):

def scroll_amount(self):
# magic number: top frame + bottom frame + prompt line + status line
return get_app().output.get_size().rows - 4
console_size = get_app().output.get_size().rows - 4

return console_size * 2//3

def scroll_up(self):
doc = self.console.body.document
row = doc.cursor_position_row
window_size = self.scroll_amount()
amount = self.scroll_amount()

row -= window_size
row -= amount

if doc.on_last_line:
# first scroll won't move it
row -= window_size
row -= amount

# don't over-scroll
row = row if row >= 0 else 0
Expand All @@ -125,13 +127,13 @@ def scroll_up(self):
def scroll_down(self):
doc = self.console.body.document
row = doc.cursor_position_row
window_size = self.scroll_amount()
amount = self.scroll_amount()

row += window_size
row += amount

if doc.on_first_line:
# first scroll won't move it
row += window_size
row += amount

new_pos = doc.translate_row_col_to_index(row=row, col=0)
self.console.body.document = Document(doc.text, cursor_position=new_pos)
Expand Down
5 changes: 2 additions & 3 deletions plover_console_ui/notification.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from plover import log
from plover.log import logging
from plover.log import logging, LOG_FORMAT


class ConsoleNotificationHandler(logging.Handler):
""" Handler using console to show messages. """

def __init__(self):
def __init__(self, format=LOG_FORMAT):
super().__init__()
self.output = None
self.setFormatter(logging.Formatter(format))
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = plover_console_ui
version = 1.1.2
version = 1.1.3
description = Text User Interface for Plover
long_description = file: README.rst
author = Seth Rider
Expand Down

0 comments on commit 20000da

Please sign in to comment.