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