From 3d1fdee7d59d87cef30939bce0b9112846ddf032 Mon Sep 17 00:00:00 2001 From: Ian Jauslin Date: Sat, 16 Oct 2021 12:16:30 -0400 Subject: [PATCH] command prompt: wrap text --- command_prompt.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/command_prompt.py b/command_prompt.py index 65e42f0..3cbe64f 100644 --- a/command_prompt.py +++ b/command_prompt.py @@ -27,6 +27,9 @@ class Command_prompt(Label): # array of command with arguments self.argv=[] + # display characters from window_offset onwards (for text wrapping) + self.window_offset=0 + # init Label super(Command_prompt,self).__init__(**kwargs) @@ -37,19 +40,31 @@ class Command_prompt(Label): def draw(self): + # wrap text + window_size=int(self.width/self.char_width) + if self.cursor>=self.window_offset+window_size: + self.window_offset=self.cursor-window_size+1 + elif self.cursor