#include <acess.h>
#include <fs_devfs.h>
#include <modules.h>
-#include <tpl_drv_video.h>
-#include <tpl_drv_keyboard.h>
-#include <tpl_drv_terminal.h>
+#include <api_drv_video.h>
+#include <api_drv_keyboard.h>
+#include <api_drv_terminal.h>
#include <errno.h>
#include <semaphore.h>
#define DEFAULT_WIDTH 640
#define DEFAULT_HEIGHT 480
#define DEFAULT_SCROLLBACK 2 // 2 Screens of text + current screen
+//#define DEFAULT_SCROLLBACK 0
#define DEFAULT_COLOUR (VT_COL_BLACK|(0xAAA<<16))
#define VT_FLAG_HIDECSR 0x01
};
// === GLOBALS ===
-MODULE_DEFINE(0, VERSION, VTerm, VT_Install, NULL, FALLBACK_OUTPUT, DEFAULT_INPUT, NULL);
+MODULE_DEFINE(0, VERSION, VTerm, VT_Install, NULL, DEFAULT_INPUT, FALLBACK_OUTPUT, NULL);
tDevFS_Driver gVT_DrvInfo = {
NULL, "VTerm",
{
case KEY_PGDOWN:
if( gpVT_CurTerm->Flags & VT_FLAG_ALTBUF )
return ;
- if( gpVT_CurTerm->ViewPos < gpVT_CurTerm->Width*gpVT_CurTerm->Height*(giVT_Scrollback-1) )
+ if( gpVT_CurTerm->ViewPos < gpVT_CurTerm->Width*gpVT_CurTerm->Height*(giVT_Scrollback) )
gpVT_CurTerm->ViewPos += gpVT_CurTerm->Width;
else
- gpVT_CurTerm->ViewPos = gpVT_CurTerm->Width*gpVT_CurTerm->Height*(giVT_Scrollback-1);
+ gpVT_CurTerm->ViewPos = gpVT_CurTerm->Width*gpVT_CurTerm->Height*(giVT_Scrollback);
return;
}
}
}
VFS_MarkAvaliable(&term->Node, 1);
-
- // Wake up the thread waiting on us
- //if( term->ReadingThread >= 0 ) {
- // Threads_WakeTID(term->ReadingThread);
- //}
}
/**
}
// Get Command
- if( ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'))
+ if( ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'))
{
if( bQuestionMark )
{
tVT_Char *buf;
int height, init_write_pos;
int len, i;
-
+ int scroll_top, scroll_height;
+
+ // Get buffer pointer and attributes
if( Term->Flags & VT_FLAG_ALTBUF )
{
buf = Term->AltBuf;
height = Term->TextHeight;
init_write_pos = Term->AltWritePos;
+ scroll_top = Term->ScrollTop;
+ scroll_height = Term->ScrollHeight;
}
else
{
buf = Term->Text;
- height = Term->TextHeight*giVT_Scrollback;
+ height = Term->TextHeight*(giVT_Scrollback+1);
init_write_pos = Term->WritePos;
+ scroll_top = 0;
+ scroll_height = height;
}
-
+
+ // Scroll text downwards
if( Count > 0 )
{
int base;
- if(Count > Term->ScrollHeight) Count = Term->ScrollHeight;
- base = Term->TextWidth*(Term->ScrollTop + Term->ScrollHeight - Count);
- len = Term->TextWidth*(Term->ScrollHeight - Count);
+
+ // Set up
+ if(Count > scroll_height) Count = scroll_height;
+ base = Term->TextWidth*(scroll_top + scroll_height - Count);
+ len = Term->TextWidth*(scroll_height - Count);
// Scroll terminal cache
- memcpy(
- &buf[Term->TextWidth*Term->ScrollTop],
- &buf[Term->TextWidth*(Term->ScrollTop+Count)],
+ memmove(
+ &buf[Term->TextWidth*scroll_top],
+ &buf[Term->TextWidth*(scroll_top+Count)],
len*sizeof(tVT_Char)
);
// Clear last rows
for( i = 0; i < Term->TextWidth*Count; i ++ )
{
- Term->AltBuf[ base + i ].Ch = 0;
- Term->AltBuf[ base + i ].Colour = Term->CurColour;
+ buf[ base + i ].Ch = 0;
+ buf[ base + i ].Colour = Term->CurColour;
}
// Update Screen
VT_int_ScrollFramebuffer( Term, Count );
if( Term->Flags & VT_FLAG_ALTBUF )
- Term->AltWritePos = Term->TextWidth*(Term->ScrollTop + Term->ScrollHeight - Count);
+ Term->AltWritePos = base;
else
- Term->WritePos = Term->ViewPos + Term->TextWidth*(Term->ScrollTop + Term->ScrollHeight - Count);
-// Log_Debug("VTerm", "Term->WritePos = %i/%i = %i", Term->WritePos, Term->TextWidth, Term->WritePos/Term->TextWidth);
+ Term->WritePos = Term->ViewPos + Term->TextWidth*(Term->TextHeight - Count);
for( i = 0; i < Count; i ++ )
{
VT_int_UpdateScreen( Term, 0 );
else
{
Count = -Count;
- if(Count > Term->ScrollHeight) Count = Term->ScrollHeight;
+ if(Count > scroll_height) Count = scroll_height;
- len = Term->TextWidth*(Term->ScrollHeight - Count);
+ len = Term->TextWidth*(scroll_height - Count);
// Scroll terminal cache
- memcpy(
- &buf[Term->TextWidth*(Term->ScrollTop+Count)],
- &buf[Term->TextWidth*Term->ScrollTop],
+ memmove(
+ &buf[Term->TextWidth*(scroll_top+Count)],
+ &buf[Term->TextWidth*scroll_top],
len*sizeof(tVT_Char)
);
// Clear preceding rows
for( i = 0; i < Term->TextWidth*Count; i ++ )
{
- Term->AltBuf[ i ].Ch = 0;
- Term->AltBuf[ i ].Colour = Term->CurColour;
+ buf[ i ].Ch = 0;
+ buf[ i ].Colour = Term->CurColour;
}
VT_int_ScrollFramebuffer( Term, -Count );
if( Term->Flags & VT_FLAG_ALTBUF )
- Term->AltWritePos = Term->TextWidth*Term->ScrollTop;
+ Term->AltWritePos = Term->TextWidth*scroll_top;
else
- Term->WritePos = Term->ViewPos + Term->TextWidth*Term->ScrollTop;
+ Term->WritePos = Term->ViewPos;
for( i = 0; i < Count; i ++ )
{
VT_int_UpdateScreen( Term, 0 );