From e0c0d8cfa3e7d9456d618929b7b5ea8cb6ec6b1d Mon Sep 17 00:00:00 2001 From: Nathan Cannon Date: Sun, 22 Oct 2017 18:50:01 +0100 Subject: [PATCH] Removed code duplication in terminalWriteChar. --- kernel/arch/i386/tty.nim | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/kernel/arch/i386/tty.nim b/kernel/arch/i386/tty.nim index fbbf421..fee3c7a 100644 --- a/kernel/arch/i386/tty.nim +++ b/kernel/arch/i386/tty.nim @@ -43,19 +43,20 @@ proc setTerminalColour(newColour: int) = terminalColour = newColour proc terminalWriteChar(writeChar: char) = - if(writeChar == '\L'): + + proc scrollCheckAndSet() = if(terminalRow < vgaHeight - 1): inc(terminalRow) else: # If we are at the bottom of the screen then scroll the screen. terminalScroll() terminalColumn = 0 + + if(writeChar == '\L'): + scrollCheckAndSet() return terminalWriteAtPoint(writeChar, terminalColour, terminalColumn, terminalRow) inc(terminalColumn) if(terminalColumn == vgaWidth): - terminalColumn = 0 - if(terminalRow < vgaHeight - 1): inc(terminalRow) - else: # If we are at the bottom of the screen then scroll the screen. - terminalScroll() + scrollCheckAndSet() proc terminalWrite*(data: string) = for character in data: