git.ucc.asn.au
/
tpg
/
acess2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix clean all script for renamed armv7 arch
[tpg/acess2.git]
/
Kernel
/
drv
/
vterm.c
diff --git
a/Kernel/drv/vterm.c
b/Kernel/drv/vterm.c
index
d2bdd81
..
1d4b367
100644
(file)
--- a/
Kernel/drv/vterm.c
+++ b/
Kernel/drv/vterm.c
@@
-5,9
+5,9
@@
#include <acess.h>
#include <fs_devfs.h>
#include <modules.h>
#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>
#include <errno.h>
#include <semaphore.h>
@@
-19,10
+19,12
@@
#define MAX_INPUT_CHARS8 (MAX_INPUT_CHARS32*4)
//#define DEFAULT_OUTPUT "BochsGA"
#define DEFAULT_OUTPUT "Vesa"
#define MAX_INPUT_CHARS8 (MAX_INPUT_CHARS32*4)
//#define DEFAULT_OUTPUT "BochsGA"
#define DEFAULT_OUTPUT "Vesa"
+#define FALLBACK_OUTPUT "x86_VGAText"
#define DEFAULT_INPUT "PS2Keyboard"
#define DEFAULT_WIDTH 640
#define DEFAULT_HEIGHT 480
#define DEFAULT_SCROLLBACK 2 // 2 Screens of text + current screen
#define DEFAULT_INPUT "PS2Keyboard"
#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
#define DEFAULT_COLOUR (VT_COL_BLACK|(0xAAA<<16))
#define VT_FLAG_HIDECSR 0x01
@@
-108,7
+110,7
@@
const Uint16 caVT100Colours[] = {
};
// === GLOBALS ===
};
// === GLOBALS ===
-MODULE_DEFINE(0, VERSION, VTerm, VT_Install, NULL, DEFAULT_
OUTPUT, DEFAULT_IN
PUT, NULL);
+MODULE_DEFINE(0, VERSION, VTerm, VT_Install, NULL, DEFAULT_
INPUT, FALLBACK_OUT
PUT, NULL);
tDevFS_Driver gVT_DrvInfo = {
NULL, "VTerm",
{
tDevFS_Driver gVT_DrvInfo = {
NULL, "VTerm",
{
@@
-168,11
+170,11
@@
int VT_Install(char **Arguments)
Log_Debug("VTerm", "Argument '%s'", arg);
if( strcmp(opt, "Video") == 0 ) {
Log_Debug("VTerm", "Argument '%s'", arg);
if( strcmp(opt, "Video") == 0 ) {
- if( !gsVT_OutputDevice
&& Modules_InitialiseBuiltin( val ) == 0
)
+ if( !gsVT_OutputDevice )
gsVT_OutputDevice = strdup(val);
}
else if( strcmp(opt, "Input") == 0 ) {
gsVT_OutputDevice = strdup(val);
}
else if( strcmp(opt, "Input") == 0 ) {
- if( !gsVT_InputDevice
&& Modules_InitialiseBuiltin( val ) == 0
)
+ if( !gsVT_InputDevice )
gsVT_InputDevice = strdup(val);
}
else if( strcmp(opt, "Width") == 0 ) {
gsVT_InputDevice = strdup(val);
}
else if( strcmp(opt, "Width") == 0 ) {
@@
-188,16
+190,21
@@
int VT_Install(char **Arguments)
}
// Apply Defaults
}
// Apply Defaults
- if(!gsVT_OutputDevice) gsVT_OutputDevice = strdup(DEFAULT_OUTPUT);
- if(!gsVT_InputDevice) gsVT_InputDevice = strdup(DEFAULT_INPUT);
+ if(!gsVT_OutputDevice) gsVT_OutputDevice = (char*)DEFAULT_OUTPUT;
+ else if( Module_EnsureLoaded( gsVT_OutputDevice ) ) gsVT_OutputDevice = (char*)DEFAULT_OUTPUT;
+ if( Module_EnsureLoaded( gsVT_OutputDevice ) ) gsVT_OutputDevice = (char*)FALLBACK_OUTPUT;
- // Create paths
+ if(!gsVT_InputDevice) gsVT_InputDevice = (char*)DEFAULT_INPUT;
+ else if( Module_EnsureLoaded( gsVT_InputDevice ) ) gsVT_InputDevice = (char*)DEFAULT_INPUT;
+
+ // Create device paths
{
char *tmp;
tmp = malloc( 9 + strlen(gsVT_OutputDevice) + 1 );
strcpy(tmp, "/Devices/");
strcpy(&tmp[9], gsVT_OutputDevice);
gsVT_OutputDevice = tmp;
{
char *tmp;
tmp = malloc( 9 + strlen(gsVT_OutputDevice) + 1 );
strcpy(tmp, "/Devices/");
strcpy(&tmp[9], gsVT_OutputDevice);
gsVT_OutputDevice = tmp;
+
tmp = malloc( 9 + strlen(gsVT_InputDevice) + 1 );
strcpy(tmp, "/Devices/");
strcpy(&tmp[9], gsVT_InputDevice);
tmp = malloc( 9 + strlen(gsVT_InputDevice) + 1 );
strcpy(tmp, "/Devices/");
strcpy(&tmp[9], gsVT_InputDevice);
@@
-244,7
+251,6
@@
int VT_Install(char **Arguments)
// Set kernel output to VT0
Debug_SetKTerminal("/Devices/VTerm/0");
// Set kernel output to VT0
Debug_SetKTerminal("/Devices/VTerm/0");
- Log_Log("VTerm", "Returning %i", MODULE_ERR_OK);
return MODULE_ERR_OK;
}
return MODULE_ERR_OK;
}
@@
-318,12
+324,15
@@
void VT_SetResolution(int Width, int Height)
// Resize the text terminals
giVT_RealWidth = mode.width;
giVT_RealHeight = mode.height;
// Resize the text terminals
giVT_RealWidth = mode.width;
giVT_RealHeight = mode.height;
+ Log_Debug("VTerm", "Resizing terminals to %ix%i",
+ giVT_RealWidth/giVT_CharWidth, giVT_RealHeight/giVT_CharHeight);
for( i = 0; i < NUM_VTS; i ++ )
{
if( gVT_Terminals[i].Mode != TERM_MODE_TEXT ) continue;
gVT_Terminals[i].TextWidth = giVT_RealWidth/giVT_CharWidth;
gVT_Terminals[i].TextHeight = giVT_RealHeight/giVT_CharHeight;
for( i = 0; i < NUM_VTS; i ++ )
{
if( gVT_Terminals[i].Mode != TERM_MODE_TEXT ) continue;
gVT_Terminals[i].TextWidth = giVT_RealWidth/giVT_CharWidth;
gVT_Terminals[i].TextHeight = giVT_RealHeight/giVT_CharHeight;
+ gVT_Terminals[i].ScrollHeight = gVT_Terminals[i].TextHeight;
gVT_Terminals[i].Text = realloc(
gVT_Terminals[i].Text,
gVT_Terminals[i].Text = realloc(
gVT_Terminals[i].Text,
@@
-794,10
+803,10
@@
void VT_KBCallBack(Uint32 Codepoint)
case KEY_PGDOWN:
if( gpVT_CurTerm->Flags & VT_FLAG_ALTBUF )
return ;
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;
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;
}
}
return;
}
}
@@
-896,11
+905,6
@@
void VT_KBCallBack(Uint32 Codepoint)
}
VFS_MarkAvaliable(&term->Node, 1);
}
VFS_MarkAvaliable(&term->Node, 1);
-
- // Wake up the thread waiting on us
- //if( term->ReadingThread >= 0 ) {
- // Threads_WakeTID(term->ReadingThread);
- //}
}
/**
}
/**
@@
-960,7
+964,7
@@
int VT_int_ParseEscape(tVTerm *Term, char *Buffer)
}
// Get Command
}
// Get Command
- if(
('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'))
+ if( ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'))
{
if( bQuestionMark )
{
{
if( bQuestionMark )
{
@@
-1347,47
+1351,55
@@
void VT_int_ScrollText(tVTerm *Term, int Count)
tVT_Char *buf;
int height, init_write_pos;
int len, i;
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;
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;
}
else
{
buf = Term->Text;
- height = Term->TextHeight*
giVT_Scrollback
;
+ height = Term->TextHeight*
(giVT_Scrollback+1)
;
init_write_pos = Term->WritePos;
init_write_pos = Term->WritePos;
+ scroll_top = 0;
+ scroll_height = height;
}
}
-
+
+ // Scroll text downwards
if( Count > 0 )
{
int base;
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
// Scroll terminal cache
- mem
cpy
(
- &buf[Term->TextWidth*
Term->ScrollT
op],
- &buf[Term->TextWidth*(
Term->ScrollT
op+Count)],
+ mem
move
(
+ &buf[Term->TextWidth*
scroll_t
op],
+ &buf[Term->TextWidth*(
scroll_t
op+Count)],
len*sizeof(tVT_Char)
);
// Clear last rows
for( i = 0; i < Term->TextWidth*Count; i ++ )
{
len*sizeof(tVT_Char)
);
// Clear last rows
for( i = 0; i < Term->TextWidth*Count; i ++ )
{
-
Term->AltB
uf[ base + i ].Ch = 0;
-
Term->AltB
uf[ base + i ].Colour = Term->CurColour;
+
b
uf[ base + i ].Ch = 0;
+
b
uf[ base + i ].Colour = Term->CurColour;
}
// Update Screen
VT_int_ScrollFramebuffer( Term, Count );
if( Term->Flags & VT_FLAG_ALTBUF )
}
// 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
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 );
for( i = 0; i < Count; i ++ )
{
VT_int_UpdateScreen( Term, 0 );
@@
-1400,28
+1412,28
@@
void VT_int_ScrollText(tVTerm *Term, int Count)
else
{
Count = -Count;
else
{
Count = -Count;
- if(Count >
Term->ScrollHeight) Count = Term->ScrollH
eight;
+ if(Count >
scroll_height) Count = scroll_h
eight;
- len = Term->TextWidth*(
Term->ScrollH
eight - Count);
+ len = Term->TextWidth*(
scroll_h
eight - Count);
// Scroll terminal cache
// Scroll terminal cache
- mem
cpy
(
- &buf[Term->TextWidth*(
Term->ScrollT
op+Count)],
- &buf[Term->TextWidth*
Term->ScrollT
op],
+ mem
move
(
+ &buf[Term->TextWidth*(
scroll_t
op+Count)],
+ &buf[Term->TextWidth*
scroll_t
op],
len*sizeof(tVT_Char)
);
// Clear preceding rows
for( i = 0; i < Term->TextWidth*Count; i ++ )
{
len*sizeof(tVT_Char)
);
// Clear preceding rows
for( i = 0; i < Term->TextWidth*Count; i ++ )
{
-
Term->AltB
uf[ i ].Ch = 0;
-
Term->AltB
uf[ i ].Colour = Term->CurColour;
+
b
uf[ i ].Ch = 0;
+
b
uf[ i ].Colour = Term->CurColour;
}
VT_int_ScrollFramebuffer( Term, -Count );
if( Term->Flags & VT_FLAG_ALTBUF )
}
VT_int_ScrollFramebuffer( Term, -Count );
if( Term->Flags & VT_FLAG_ALTBUF )
- Term->AltWritePos = Term->TextWidth*
Term->ScrollT
op;
+ Term->AltWritePos = Term->TextWidth*
scroll_t
op;
else
else
- Term->WritePos = Term->ViewPos
+ Term->TextWidth*Term->ScrollTop
;
+ Term->WritePos = Term->ViewPos;
for( i = 0; i < Count; i ++ )
{
VT_int_UpdateScreen( Term, 0 );
for( i = 0; i < Count; i ++ )
{
VT_int_UpdateScreen( Term, 0 );
@@
-1465,6
+1477,7
@@
void VT_int_ScrollFramebuffer( tVTerm *Term, int Count )
// BLIT to 0,0 from 0,giVT_CharHeight
buf.Op = VIDEO_2DOP_BLIT;
buf.SrcX = 0; buf.DstX = 0;
// BLIT to 0,0 from 0,giVT_CharHeight
buf.Op = VIDEO_2DOP_BLIT;
buf.SrcX = 0; buf.DstX = 0;
+ // TODO: Don't assume character dimensions
buf.W = Term->TextWidth * giVT_CharWidth;
if( Count > 0 )
{
buf.W = Term->TextWidth * giVT_CharWidth;
if( Count > 0 )
{
UCC
git Repository :: git.ucc.asn.au