From c405e36dcfffe1b5f608b827f0442c71ed2283c4 Mon Sep 17 00:00:00 2001 From: serr Date: Wed, 5 Feb 2025 23:18:49 +0300 Subject: [PATCH] =?UTF-8?q?n=20->=20=D0=BF=D0=BE=D0=B2=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=B8=D1=82=D1=8C=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA,=20N=20->?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=B2=D1=82=D0=BE=D1=80=D0=B8=D1=82=D1=8C=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=20=D0=B2=20=D0=BE=D0=B1=D1=80?= =?UTF-8?q?=D0=B0=D1=82=D0=BD=D0=BE=D0=BC=20=D0=BD=D0=B0=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mvc/models.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/mvc/models.py b/mvc/models.py index c28127e..6c8a769 100644 --- a/mvc/models.py +++ b/mvc/models.py @@ -15,6 +15,7 @@ class VimModel: self.displayLinesCount = displayLinesCount self.displayColsCount = displayColsCount self.showLineNumbers = True + self.lastSearch = () self.displayBuffer = [] # буфер для хранения всех строк self.dump = [] self.currentLine = 0 # текущий индекс строки @@ -181,6 +182,26 @@ class VimModel: case "h": self.LoadFile("config/usage.txt") return ReturnCode.SET_BASIC_MODE + case "n": + if self.lastSearch != (): + index = tools.findSublistIndex(self.displayBuffer, + list(self.lastSearch[0]), + self.currentLine, + direction=self.lastSearch[1]) + if index != -1: + self.currentLine = index + self.currentCol = 0 + self.lastSearch = (self.lastSearch[0], self.lastSearch[1]) + case "N": + if self.lastSearch != (): + index = tools.findSublistIndex(self.displayBuffer, + list(self.lastSearch[0]), + self.currentLine, + direction=(self.lastSearch[1]+1)%2) + if index != -1: + self.currentLine = index + self.currentCol = 0 + self.lastSearch = (self.lastSearch[0], (self.lastSearch[1]+1)%2) case "e!": self.displayBuffer = [sublist.copy() for sublist in self.dump] case "set num": @@ -210,6 +231,7 @@ class VimModel: if index != -1: self.currentLine = index self.currentCol = 0 + self.lastSearch = (cmd[1:], 1) # Поиск строки от курсора до начала файла elif len(cmd) > 1 and cmd[0] == '?': index = tools.findSublistIndex(self.displayBuffer, @@ -219,6 +241,7 @@ class VimModel: if index != -1: self.currentLine = index self.currentCol = 0 + self.lastSearch = (cmd[1:], 0) return ReturnCode.GOOD @@ -325,5 +348,6 @@ class VimModel: self.scrollX = 0 self.file_path = "" self.mode = "" + self.lastSearch = () self.commandBuffer = [] self.exchangeBuffer = [] \ No newline at end of file