From 4b0a915486c66f874e96fd3a24cbedeee6ee53da Mon Sep 17 00:00:00 2001 From: fox0430 Date: Tue, 12 Jan 2021 17:33:01 +0900 Subject: [PATCH 1/2] Fix compile error in Nim devel (#1228) --- src/moepkg/configmode.nim | 42 ++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/moepkg/configmode.nim b/src/moepkg/configmode.nim index 313bbebfc..4f6959318 100644 --- a/src/moepkg/configmode.nim +++ b/src/moepkg/configmode.nim @@ -1653,6 +1653,26 @@ proc initConfigModeBuffer*(settings: EditorSettings): GapBuffer[seq[Rune]] = result = initGapBuffer(buffer) +proc keyUp(bufStatus: BufferStatus, windowNode: var WindowNode) = + let currentLine = windowNode.currentLine + if currentLine > 1: + bufStatus.keyUp(windowNode) + + # Skip empty line and table name line + while bufStatus.buffer[windowNode.currentLine].len == 0 or + bufStatus.buffer[windowNode.currentLine][0] != ' ': + bufStatus.keyUp(windowNode) + +proc keyDown(bufStatus: BufferStatus, windowNode: var WindowNode) = + let currentLine = windowNode.currentLine + if currentLine < bufStatus.buffer.high - 1: + bufStatus.keyDown(windowNode) + + # Skip empty line and table name line + while bufStatus.buffer[windowNode.currentLine].len == 0 or + bufStatus.buffer[windowNode.currentLine][0] != ' ': + bufStatus.keyDown(windowNode) + proc isConfigMode(mode: Mode): bool {.inline.} = mode == Mode.config @@ -1666,24 +1686,6 @@ proc configMode*(status: var Editorstatus) = currentBufferIndex = currentMainWindowNode.bufferIndex currentWorkSpace = status.currentWorkSpaceIndex - template keyUp() = - if currentLine > 1: - currentBufStatus.keyUp(windowNode) - - # Skip empty line and table name line - while currentBufStatus.buffer[windowNode.currentLine].len == 0 or - currentBufStatus.buffer[windowNode.currentLine][0] != ' ': - currentBufStatus.keyUp(windowNode) - - template keyDown() = - if currentLine < currentBufStatus.buffer.high - 1: - currentBufStatus.keyDown(windowNode) - - # Skip empty line and table name line - while currentBufStatus.buffer[windowNode.currentLine].len == 0 or - currentBufStatus.buffer[windowNode.currentLine][0] != ' ': - currentBufStatus.keyDown(windowNode) - while isConfigMode(currentBufStatus.mode) and currentWorkSpace == status.currentWorkSpaceIndex and currentBufferIndex == status.bufferIndexInCurrentWindow: @@ -1732,9 +1734,9 @@ proc configMode*(status: var Editorstatus) = elif isPageDownKey(key): ## Page down and Ctrl - F status.pageDown elif key == ord('k') or isUpKey(key): - keyUp() + currentBufStatus.keyUp(currentMainWindowNode) elif key == ord('j') or isDownKey(key): - keyDown() + currentBufStatus.keyDown(currentMainWindowNode) elif key == ord('g'): let secondKey = getKey(currentMainWindowNode) if secondKey == 'g': status.moveToFirstLine From 43b69ac8833c7549d40806f277b5e0ef1cff756f Mon Sep 17 00:00:00 2001 From: fox0430 Date: Tue, 12 Jan 2021 17:33:10 +0900 Subject: [PATCH 2/2] Fix unit tests --- tests/tconfigmode.nim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/tconfigmode.nim b/tests/tconfigmode.nim index e56022258..67cb13f55 100644 --- a/tests/tconfigmode.nim +++ b/tests/tconfigmode.nim @@ -1325,7 +1325,8 @@ suite "Config mode: Get Theme table setting values": let testTitle = "Get " & $`colorPair` & "." & $`position` & " values" test testTitle: let - (fg, bg) = getColorFromEditorColorPair(theme, `colorPair`) + theme = settings.editorColorTheme + (fg, bg) = theme.getColorFromEditorColorPair(`colorPair`) values = settings.getThemeTableSettingValues($`colorPair`, $`position`) # values[0] should be current setting default = $values[0] @@ -1345,11 +1346,11 @@ suite "Config mode: Get Theme table setting values": let status = initEditorStatus() settings = status.settings - theme = settings.editorColorTheme # Check Theme.editorBg test "Get editorBg.background values": let + theme = settings.editorColorTheme bg = ColorThemeTable[theme].editorBg values = settings.getThemeTableSettingValues("editorBg", "background") # values[0] should be current setting