Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1228 #1229

Merged
merged 2 commits into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions src/moepkg/configmode.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions tests/tconfigmode.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand Down