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
Kernel/VTerm - Switched to using userland VT100 code
[tpg/acess2.git]
/
KernelLand
/
Kernel
/
drv
/
vterm_termbuf.c
diff --git
a/KernelLand/Kernel/drv/vterm_termbuf.c
b/KernelLand/Kernel/drv/vterm_termbuf.c
index
525f1a4
..
e3ddff1
100644
(file)
--- a/
KernelLand/Kernel/drv/vterm_termbuf.c
+++ b/
KernelLand/Kernel/drv/vterm_termbuf.c
@@
-5,8
+5,11
@@
* drv/vterm_termbuf.c
* - Virtual Terminal - Terminal buffer manipulation
*/
* drv/vterm_termbuf.c
* - Virtual Terminal - Terminal buffer manipulation
*/
+#define DEBUG 1
#include "vterm.h"
#include "vterm.h"
+extern int Term_HandleVT100(tVTerm *Term, int Len, const char *Buf);
+
// === CODE ===
/**
// === CODE ===
/**
@@
-15,33
+18,32
@@
*/
void VT_int_PutString(tVTerm *Term, const Uint8 *Buffer, Uint Count)
{
*/
void VT_int_PutString(tVTerm *Term, const Uint8 *Buffer, Uint Count)
{
- int i;
-
// Iterate
// Iterate
- for( i
= 0; i < Count; i++
)
+ for( i
nt ofs = 0; ofs < Count;
)
{
{
- // Handle escape sequences
- if( Buffer[i] == 0x1B && Count - i > 1 )
- {
- int ret = VT_int_ParseEscape(Term, (const char*)&Buffer[i+1], Count-(i+1));
- if( ret > 0 )
- {
- i += ret;
- continue;
- }
+ int esc_len = Term_HandleVT100(Term, Count - ofs, (const void*)(Buffer + ofs));
+ if( esc_len < 0 ) {
+ esc_len = -esc_len;
+ VT_int_PutRawString(Term, Buffer + ofs, esc_len);
+ //Debug("Raw string '%.*s'", esc_len, Buffer+ofs);
}
}
-
- // Fast check for non UTF-8
- if( Buffer[i] < 128 ) // Plain ASCII
- VT_int_PutChar(Term, Buffer[i]);
- else { // UTF-8
- Uint32 val;
- i += ReadUTF8(&Buffer[i], &val) - 1;
- VT_int_PutChar(Term, val);
+ else {
+ //Debug("Escape code '%.*s'", esc_len, Buffer+ofs);
}
}
+ ASSERTCR(esc_len, >, 0, );
+ ofs += esc_len;
}
// Update Screen
}
// Update Screen
- VT_int_UpdateScreen( Term, 0 );
+ VT_int_UpdateScreen( Term, 1 );
+}
+
+void VT_int_PutRawString(tVTerm *Term, const Uint8 *String, size_t Bytes)
+{
+ for( int i = 0; i < Bytes; ) {
+ Uint32 val;
+ i += ReadUTF8(String+i, &val);
+ VT_int_PutChar(Term, val);
+ }
}
/**
}
/**
@@
-53,14
+55,17
@@
void VT_int_PutChar(tVTerm *Term, Uint32 Ch)
int i;
tVT_Char *buffer;
int write_pos;
int i;
tVT_Char *buffer;
int write_pos;
+ int limit;
if(Term->Flags & VT_FLAG_ALTBUF) {
buffer = Term->AltBuf;
write_pos = Term->AltWritePos;
if(Term->Flags & VT_FLAG_ALTBUF) {
buffer = Term->AltBuf;
write_pos = Term->AltWritePos;
+ limit = Term->TextHeight * Term->TextWidth;
}
else {
buffer = Term->Text;
write_pos = Term->WritePos;
}
else {
buffer = Term->Text;
write_pos = Term->WritePos;
+ limit = Term->TextHeight*(giVT_Scrollback+1) * Term->TextWidth;
}
switch(Ch)
}
switch(Ch)
@@
-107,6
+112,7
@@
void VT_int_PutChar(tVTerm *Term, Uint32 Ch)
break;
default:
break;
default:
+ ASSERTC(write_pos,<,limit);
buffer[ write_pos ].Ch = Ch;
buffer[ write_pos ].Colour = Term->CurColour;
// Update the line before wrapping
buffer[ write_pos ].Ch = Ch;
buffer[ write_pos ].Colour = Term->CurColour;
// Update the line before wrapping
@@
-120,19
+126,18
@@
void VT_int_PutChar(tVTerm *Term, Uint32 Ch)
{
Term->AltWritePos = write_pos;
{
Term->AltWritePos = write_pos;
- if(Term->AltWritePos >=
Term->TextWidth*Term->TextHeigh
t)
+ if(Term->AltWritePos >=
limi
t)
{
Term->AltWritePos -= Term->TextWidth;
VT_int_ScrollText(Term, 1);
}
{
Term->AltWritePos -= Term->TextWidth;
VT_int_ScrollText(Term, 1);
}
-
}
else
{
Term->WritePos = write_pos;
// Move Screen
// - Check if we need to scroll the entire scrollback buffer
}
else
{
Term->WritePos = write_pos;
// Move Screen
// - Check if we need to scroll the entire scrollback buffer
- if(Term->WritePos >=
Term->TextWidth*Term->TextHeight*(giVT_Scrollback+1)
)
+ if(Term->WritePos >=
limit
)
{
int base;
{
int base;
@@
-269,15
+274,13
@@
void VT_int_ScrollText(tVTerm *Term, int Count)
*/
void VT_int_ClearLine(tVTerm *Term, int Num)
{
*/
void VT_int_ClearLine(tVTerm *Term, int Num)
{
- int i;
- tVT_Char *cell;
-
- if( Num < 0 || Num >= Term->TextHeight * (giVT_Scrollback + 1) ) return ;
+ int limit = Term->TextHeight * (Term->Flags & VT_FLAG_ALTBUF ? 1 : giVT_Scrollback + 1);
+ tVT_Char *buffer = (Term->Flags & VT_FLAG_ALTBUF ? Term->AltBuf : Term->Text);
+ if( Num < 0 || Num >= limit ) return ;
- cell = (Term->Flags & VT_FLAG_ALTBUF) ? Term->AltBuf : Term->Text;
- cell = &cell[ Num*Term->TextWidth ];
+ tVT_Char *cell = &buffer[ Num*Term->TextWidth ];
- for( i
= Term->TextWidth; i--;
)
+ for( i
nt i = 0; i < Term->TextWidth; i ++
)
{
cell[ i ].Ch = 0;
cell[ i ].Colour = Term->CurColour;
{
cell[ i ].Ch = 0;
cell[ i ].Colour = Term->CurColour;
@@
-291,7
+294,7
@@
void VT_int_ClearLine(tVTerm *Term, int Num)
* \param NewWidth New framebuffer width
* \param NewHeight New framebuffer height
*/
* \param NewWidth New framebuffer width
* \param NewHeight New framebuffer height
*/
-void VT_int_
ChangeMode(tVTerm *Term, int NewMode
, int NewWidth, int NewHeight)
+void VT_int_
Resize(tVTerm *Term
, int NewWidth, int NewHeight)
{
int oldW = Term->Width;
int oldTW = Term->TextWidth;
{
int oldW = Term->Width;
int oldTW = Term->TextWidth;
@@
-305,8
+308,6
@@
void VT_int_ChangeMode(tVTerm *Term, int NewMode, int NewWidth, int NewHeight)
if(NewWidth > giVT_RealWidth) NewWidth = giVT_RealWidth;
if(NewHeight > giVT_RealHeight) NewHeight = giVT_RealHeight;
if(NewWidth > giVT_RealWidth) NewWidth = giVT_RealWidth;
if(NewHeight > giVT_RealHeight) NewHeight = giVT_RealHeight;
- Term->Mode = NewMode;
-
// Fast exit if no resolution change
if(NewWidth == Term->Width && NewHeight == Term->Height)
return ;
// Fast exit if no resolution change
if(NewWidth == Term->Width && NewHeight == Term->Height)
return ;
@@
-365,7
+366,7
@@
void VT_int_ChangeMode(tVTerm *Term, int NewMode, int NewWidth, int NewHeight)
// Debug
#if 0
// Debug
#if 0
- switch(
New
Mode)
+ switch(
Term->
Mode)
{
case TERM_MODE_TEXT:
Log_Log("VTerm", "Set VT %p to text mode (%ix%i)",
{
case TERM_MODE_TEXT:
Log_Log("VTerm", "Set VT %p to text mode (%ix%i)",
UCC
git Repository :: git.ucc.asn.au