diff --git a/kaleid/kernel/io/vga.c b/kaleid/kernel/io/vga.c index 2edb9cc..40308f9 100644 --- a/kaleid/kernel/io/vga.c +++ b/kaleid/kernel/io/vga.c @@ -43,10 +43,10 @@ error_t bvgaflusher(Buffer_t *buf) ushort *fbp = BtVideoInfo.framebufferAddr; uchar color = 0xf; - uchar *currentLine = buf->wp - buf->lineLen - buf->lastLF; + uchar *currentLine = buf->wp - buf->lastLF; uchar *bufStart = (uchar *)lmax((size_t)buf->buf, (size_t)currentLine - - (buf->nLines - 2 + bscroll) * buf->lineLen); + - (buf->nLines - 1 + bscroll) * buf->lineLen); uchar *ptr = bufStart; @@ -87,10 +87,21 @@ void IoScrollDown(void) void IoScrollUp(void) { - // Keep the 8 below the 10 given to BOpenTermBufEx - if (bscroll < BtVideoInfo.framebufferHeight * 8) /* XXX */ + BLockBuf(BStdOut); + + uchar *currentLine = BStdOut->wp - BStdOut->lastLF; + assert(currentLine >= BStdOut->buf); + + // Scrollable lines + uint scrabble = max(0, (currentLine-BStdOut->buf)/BStdOut->lineLen + - BStdOut->nLines + 1); + + if (bscroll < scrabble) bscroll++; + bvgaflusher(BStdOut); + + BUnlockBuf(BStdOut); } diff --git a/kaleid/kernel/sh/shcmds.c b/kaleid/kernel/sh/shcmds.c index d4cff47..eefbaae 100644 --- a/kaleid/kernel/sh/shcmds.c +++ b/kaleid/kernel/sh/shcmds.c @@ -65,9 +65,12 @@ error_t CmdHelp(int argc, char **argv, char *cmdline) error_t CmdClear(int argc, char **argv, char *cmdline) { - size_t i; - for (i = 0; i < BtVideoInfo.framebufferHeight; i++) - KernLog("\n"); + BLockBuf(BStdOut); + + BStdOut->wp = BStdOut->rp = BStdOut->buf; + BStdOut->lastLF = 0; + + BUnlockBuf(BStdOut); return EOK; }