Skip to content

Commit

Permalink
added back tab functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
SilenZcience committed Jan 29, 2024
1 parent 552ed6d commit d29c30b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
18 changes: 18 additions & 0 deletions cat_win/util/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,24 @@ def _scroll_key_home(self) -> None:
self.wpos.row = 0
self.wpos.col = 0

def _key_btab(self, _) -> str:
c_row = self.window_content[self.cpos.row]
if c_row[:1] == '\t':
self.window_content[self.cpos.row] = c_row[1:]
self.cpos.col = max(self.cpos.col-1, 0)
return '\t'
if c_row[:4] == ' ':
self.window_content[self.cpos.row] = c_row[4:]
self.cpos.col = max(self.cpos.col-4, 0)
return ' '
return None

def _key_btab_reverse(self, tab) -> str:
c_row = self.window_content[self.cpos.row]
self.window_content[self.cpos.row] = tab + c_row
self.cpos.col += len(tab)
return tab

def _key_string(self, wchars) -> str:
"""
tries to append (a) char(s) to the screen.
Expand Down
6 changes: 5 additions & 1 deletion cat_win/util/editorhelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@
# shift - pos/home
b'KEY_SHOME' : b'_scroll_key_home', # windows & xterm

# shift + tab
b'KEY_BTAB' : b'_key_btab', # windows & xterm

# default alnum key
b'_key_string' : b'_key_string',
# history
Expand All @@ -152,7 +155,8 @@
b'_key_dl' : b'_key_string',
b'_key_backspace' : b'_key_string',
b'_key_ctl_backspace': b'_key_string',
b'_key_string' : b'_key_backspace',
b'_key_string' : b'_key_backspace',
b'_key_btab' : b'_key_btab_reverse',
} # defines the counter action if the file has the same amount of lines

REVERSE_ACTION_SIZE_CHANGE = {
Expand Down

0 comments on commit d29c30b

Please sign in to comment.