gg -> переход в начало файла

master
serr 2025-02-04 21:26:55 +03:00
parent f76504249b
commit b043994381
1 changed files with 4 additions and 7 deletions

View File

@ -51,10 +51,8 @@ class VimModel:
match cmd:
case "$": # Перемещение в конец строки
self.currentCol = len(self.displayBuffer[self.currentLine])
return ReturnCode.GOOD
case "^" | "0": # Перемещение в начало строки
self.currentCol = 0
return ReturnCode.GOOD
case "q": # Выход из программы
return ReturnCode.EXIT_CODE
case "i": # Вход в режим редактирования
@ -65,23 +63,19 @@ class VimModel:
return ReturnCode.SET_EDIT_MODE
case "RIGHT": # Перемещение курсора на 1 позицию вправо
self.currentCol += 1
return ReturnCode.GOOD
case "LEFT": # Перемещение курсора на 1 позицию влево
if self.currentCol > 0:
self.currentCol -= 1
return ReturnCode.GOOD
case "UP": # Перемещение курсора на 1 пизицию вверх
if self.currentLine > 0:
self.currentLine -= 1
if self.currentCol > len(self.displayBuffer[self.currentLine]):
self.currentCol = len(self.displayBuffer[self.currentLine])
return ReturnCode.GOOD
case "DOWN": # Перемещение курсора на 1 пизицию вниз
if self.currentLine < len(self.displayBuffer) - 1:
self.currentLine += 1
if self.currentCol > len(self.displayBuffer[self.currentLine]):
self.currentCol = len(self.displayBuffer[self.currentLine])
return ReturnCode.GOOD
case "w": # Перемещение курсора в конец слова справа от курсора
line = ''.join(self.displayBuffer[self.currentLine])
# Находим ближайший непробельный символ
@ -102,7 +96,10 @@ class VimModel:
self.currentCol = left_space_index + 1
else:
self.currentCol = 0
case "gg": # Переход в начало файла
self.currentLine = 0
self.currentCol = 0
return ReturnCode.GOOD
def Enter(self) -> None:
# Разделяем текущую строку на две части