Skip to content

Commit

Permalink
Merge pull request #231 from fox0430/fix-window
Browse files Browse the repository at this point in the history
Fix split window resize bug
  • Loading branch information
fox0430 authored Apr 22, 2019
2 parents fbaeb87 + 0bba0eb commit 1f460bd
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/moepkg/editorstatus.nim
Original file line number Diff line number Diff line change
Expand Up @@ -242,29 +242,24 @@ proc writeStatusBar*(status: var EditorStatus) =
import tab

proc resize*(status: var EditorStatus, height, width: int) =

let totalViewWidth = (proc (status: EditorStatus): int =
result = 0
for i in 0 ..< status.displayBuffer.len: result = result + status.bufStatus[status.displayBuffer[i]].view.widthOfLineNum + 4
)
let
adjustedHeight = max(height, 4)
useStatusBar = if status.settings.statusBar.useBar: 1 else: 0
useTab = if status.bufStatus[status.currentBuffer].mode != Mode.filer and status.settings.tabLine.useTab: 1 else: 0
adjustedWidth = max(int(width / status.mainWindow.len), totalViewWidth(status))

for i in 0 ..< status.displayBuffer.len:
let
bufIndex = status.displayBuffer[i]
beginX = i * int(terminalWidth() / status.mainWindow.len)
widthOfLineNum = status.bufStatus[bufIndex].view.widthOfLineNum
adjustedWidth = max(int(width / status.mainWindow.len), widthOfLineNum + 4)

status.mainWindow[i].resize(adjustedHeight - useStatusBar - useTab - 1, adjustedWidth, useTab, beginX)

if status.settings.statusBar.useBar: resize(status.statusWindow, 1, terminalWidth(), adjustedHeight - 2, 0)
if status.bufStatus[status.currentBuffer].mode != Mode.filer and status.settings.tabLine.useTab: resize(status.tabWindow, 1, terminalWidth(), 0, 0)

if status.bufStatus[status.currentBuffer].mode != Mode.filer:
let widthOfLineNum = status.bufStatus[bufIndex].view.widthOfLineNum
status.bufStatus[bufIndex].view.resize(status.bufStatus[bufIndex].buffer, adjustedHeight - useStatusBar - 1, adjustedWidth - widthOfLineNum - 1, widthOfLineNum)
status.bufStatus[bufIndex].view.seekCursor(status.bufStatus[bufIndex].buffer, status.bufStatus[bufIndex].currentLine, status.bufStatus[bufIndex].currentColumn)

Expand Down

0 comments on commit 1f460bd

Please sign in to comment.