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
ACPICA - Replace acacess.h with a modified version of the ForgeOS one, no longer...
[tpg/acess2.git]
/
Usermode
/
Applications
/
gui_terminal_src
/
display.c
diff --git
a/Usermode/Applications/gui_terminal_src/display.c
b/Usermode/Applications/gui_terminal_src/display.c
index
ab39f9f
..
1b026d5
100644
(file)
--- a/
Usermode/Applications/gui_terminal_src/display.c
+++ b/
Usermode/Applications/gui_terminal_src/display.c
@@
-5,6
+5,7
@@
* display.c
* - Abstract display manipulation methods
*/
* display.c
* - Abstract display manipulation methods
*/
+#define DEBUG 0
#include "include/display.h"
#include <acess/sys.h> // _SysDebug
#include <stdlib.h> // exit
#include "include/display.h"
#include <acess/sys.h> // _SysDebug
#include <stdlib.h> // exit
@@
-16,6
+17,12
@@
#include <stdbool.h>
#include <assert.h>
#include <stdbool.h>
#include <assert.h>
+#if DEBUG
+# define DEBUGS(v...) _SysDebug(v)
+#else
+# define DEBUGS(v...) do{}while(0)
+#endif
+
#define UNIMPLIMENTED() do{_SysDebug("UNIMPLIMENTED %s", __func__); exit(-1);}while(0)
static inline int MIN(int a, int b) { return (a < b ? a : b); }
#define UNIMPLIMENTED() do{_SysDebug("UNIMPLIMENTED %s", __func__); exit(-1);}while(0)
static inline int MIN(int a, int b) { return (a < b ? a : b); }
@@
-35,6
+42,8
@@
struct sLine {
};
struct sTerminal {
};
struct sTerminal {
+ void *TermState;
+
int ViewCols;
int ViewRows;
int ViewCols;
int ViewRows;
@@
-51,6
+60,9
@@
struct sTerminal {
bool bUsingAltBuf;
bool bHaveSwappedBuffers;
bool bUsingAltBuf;
bool bHaveSwappedBuffers;
+
+ int OtherBufRow;
+ int OtherBufCol;
size_t ViewOffset;
size_t TotalLines;
size_t ViewOffset;
size_t TotalLines;
@@
-87,6
+99,13
@@
tTerminal *Display_Init(int Cols, int Lines, int ExtraScrollbackLines)
return term;
}
return term;
}
+void *Display_GetTermState(tTerminal *Term) {
+ return Term->TermState;
+}
+void Display_SetTermState(tTerminal *Term, void *State) {
+ Term->TermState = State;
+}
+
// Return the byte length of a single on-screen character
size_t _GetCharLength(size_t AvailLength, const char *Text, uint32_t *BaseCodepoint)
{
// Return the byte length of a single on-screen character
size_t _GetCharLength(size_t AvailLength, const char *Text, uint32_t *BaseCodepoint)
{
@@
-126,6
+145,8
@@
size_t Display_int_PushCharacter(tTerminal *Term, size_t AvailLength, const char
if( bOverwrite ) {
//_SysDebug("GetCharLen(%i-%i, %p+%i, NULL)", lineptr->Len, Term->CursorByte,
// lineptr->Data, Term->CursorByte);
if( bOverwrite ) {
//_SysDebug("GetCharLen(%i-%i, %p+%i, NULL)", lineptr->Len, Term->CursorByte,
// lineptr->Data, Term->CursorByte);
+ if( Term->CursorByte )
+ assert(lineptr->Data);
size_t nextlen = _GetCharLength(
lineptr->Len-Term->CursorByte,
lineptr->Data+Term->CursorByte,
size_t nextlen = _GetCharLength(
lineptr->Len-Term->CursorByte,
lineptr->Data+Term->CursorByte,
@@
-181,7
+202,7
@@
size_t Display_int_PushCharacter(tTerminal *Term, size_t AvailLength, const char
void Display_AddText(tTerminal *Term, size_t Length, const char *UTF8Text)
{
void Display_AddText(tTerminal *Term, size_t Length, const char *UTF8Text)
{
-
_SysDebug("%i '%.*s'"
, Length, Length, UTF8Text);
+
DEBUGS("%i += %i '%.*s'", Term->CursorRow
, Length, Length, UTF8Text);
while( Length > 0 )
{
if( Term->CursorCol == Term->ViewCols ) {
while( Length > 0 )
{
if( Term->CursorCol == Term->ViewCols ) {
@@
-282,7
+303,7
@@
void Display_ScrollDown(tTerminal *Term, int Count)
assert(Count < max);
assert(Count > -max);
assert(Count < max);
assert(Count > -max);
-
_SysDebug
("Scroll %p %i-%i down by %i", buffer, top, max, Count);
+
DEBUGS
("Scroll %p %i-%i down by %i", buffer, top, max, Count);
buffer += top;
buffer += top;
@@
-314,7
+335,8
@@
void Display_ScrollDown(tTerminal *Term, int Count)
buffer[i].Size = 0;
buffer[i].IsDirty = true;
}
buffer[i].Size = 0;
buffer[i].IsDirty = true;
}
- // TODO: Send scroll command to GUI
+ // Send scroll command to GUI
+ AxWin3_RichText_ScrollRange(gMainWindow, top, max, Count);
Display_int_SetCursor(Term, Term->CursorRow, Term->CursorCol);
}
Display_int_SetCursor(Term, Term->CursorRow, Term->CursorCol);
}
@@
-324,19
+346,18
@@
void Display_SetCursor(tTerminal *Term, int Row, int Col)
assert(Row >= 0);
assert(Col >= 0);
assert(Row >= 0);
assert(Col >= 0);
- _SysDebug("Set cursor R%i,C%i", Row, Col);
+ DEBUGS("Set cursor R%i,C%i", Row, Col);
if( !Term->bUsingAltBuf ) {
_SysDebug("NOTE: Using \\e[%i;%iH outside of alternat buffer is undefined", Row, Col);
}
// NOTE: This may be interesting outside of AltBuffer
if( !Term->bUsingAltBuf ) {
_SysDebug("NOTE: Using \\e[%i;%iH outside of alternat buffer is undefined", Row, Col);
}
// NOTE: This may be interesting outside of AltBuffer
- Term->CursorRow = Row;
-
Display_int_SetCursor(Term, Row, Col);
}
void Display_int_SetCursor(tTerminal *Term, int Row, int Col)
{
Display_int_SetCursor(Term, Row, Col);
}
void Display_int_SetCursor(tTerminal *Term, int Row, int Col)
{
+ Term->CursorRow = Row;
tLine *line = Display_int_GetCurLine(Term);
size_t ofs = 0;
int i;
tLine *line = Display_int_GetCurLine(Term);
size_t ofs = 0;
int i;
@@
-408,6
+429,8
@@
void Display_ClearLine(tTerminal *Term, int Dir) // 0: All, 1: Forward, -1: Reve
free(line->Data);
line->Data = NULL;
line->IsDirty = true;
free(line->Data);
line->Data = NULL;
line->IsDirty = true;
+ Term->CursorCol = 0;
+ Term->CursorByte = 0;
}
else if( Dir == 1 )
{
}
else if( Dir == 1 )
{
@@
-444,6
+467,10
@@
void Display_ClearLines(tTerminal *Term, int Dir) // 0: All, 1: Forward, -1: Rev
}
}
}
}
+void Display_ResetAttributes(tTerminal *Term)
+{
+ UNIMPLIMENTED();
+}
void Display_SetForeground(tTerminal *Term, uint32_t RGB)
{
char buf[7+1];
void Display_SetForeground(tTerminal *Term, uint32_t RGB)
{
char buf[7+1];
@@
-462,6
+489,7
@@
void Display_Flush(tTerminal *Term)
{
int viewOfs = (Term->bUsingAltBuf ? 0 : Term->ViewOffset);
tLine *buffer = (Term->bUsingAltBuf ? Term->AltBuf : Term->PriBuf );
{
int viewOfs = (Term->bUsingAltBuf ? 0 : Term->ViewOffset);
tLine *buffer = (Term->bUsingAltBuf ? Term->AltBuf : Term->PriBuf );
+ AxWin3_RichText_SetLineCount(gMainWindow, (Term->bUsingAltBuf ? Term->ViewRows : Term->TotalLines));
for( int i = 0; i < Term->ViewRows; i ++ )
{
int line = (viewOfs + i) % Term->TotalLines;
for( int i = 0; i < Term->ViewRows; i ++ )
{
int line = (viewOfs + i) % Term->TotalLines;
@@
-469,10
+497,10
@@
void Display_Flush(tTerminal *Term)
// Swapping buffers should cause a full resend
if( !Term->bHaveSwappedBuffers && !lineptr->IsDirty )
continue;
// Swapping buffers should cause a full resend
if( !Term->bHaveSwappedBuffers && !lineptr->IsDirty )
continue;
-
_SysDebug
("Line %i+%i %p '%.*s'", viewOfs, i, lineptr->Data, lineptr->Len, lineptr->Data);
+
DEBUGS
("Line %i+%i %p '%.*s'", viewOfs, i, lineptr->Data, lineptr->Len, lineptr->Data);
AxWin3_RichText_SendLine(gMainWindow, viewOfs + i,
lineptr->Data ? lineptr->Data : "" );
AxWin3_RichText_SendLine(gMainWindow, viewOfs + i,
lineptr->Data ? lineptr->Data : "" );
- lineptr->IsDirty =
0
;
+ lineptr->IsDirty =
false
;
}
AxWin3_RichText_SetCursorPos(gMainWindow, Term->CursorRow, Term->CursorCol);
Term->bHaveSwappedBuffers = false;
}
AxWin3_RichText_SetCursorPos(gMainWindow, Term->CursorRow, Term->CursorCol);
Term->bHaveSwappedBuffers = false;
@@
-485,6
+513,11
@@
void Display_ShowAltBuffer(tTerminal *Term, bool AltBufEnabled)
// Nothing to do, so do nothing
return ;
}
// Nothing to do, so do nothing
return ;
}
+
+ int row = Term->OtherBufRow;
+ int col = Term->OtherBufCol;
+ Term->OtherBufRow = Term->CursorRow;
+ Term->OtherBufCol = Term->CursorCol;
Term->bUsingAltBuf = AltBufEnabled;
Term->bHaveSwappedBuffers = true;
Term->bUsingAltBuf = AltBufEnabled;
Term->bHaveSwappedBuffers = true;
@@
-494,6
+527,17
@@
void Display_ShowAltBuffer(tTerminal *Term, bool AltBufEnabled)
{
Term->AltBuf = calloc( sizeof(Term->AltBuf[0]), Term->ViewRows );
}
{
Term->AltBuf = calloc( sizeof(Term->AltBuf[0]), Term->ViewRows );
}
+ AxWin3_RichText_SetLineCount(gMainWindow, Term->ViewRows);
+ }
+ else
+ {
+ AxWin3_RichText_SetLineCount(gMainWindow, Term->TotalLines);
}
}
+ Display_int_SetCursor(Term, row, col);
+}
+
+void Display_SetTitle(tTerminal *Term, const char *Title)
+{
+ _SysDebug("TODO: Set window title to '%s'", Title);
}
}
UCC
git Repository :: git.ucc.asn.au