struct sLine *AltBuf;
};
+// === PROTOTYPES ===
+void Display_int_SetCursor(tTerminal *Term, int Row, int Col);
+
// === GLOBALS ===
tTerminal gMainBuffer;
int giCurrentLine;
lineptr->Size = newsize;
void *tmp = realloc(lineptr->Data, lineptr->Size);
if( !tmp ) perror("Display_int_PushCharacter - realloc");
+ //_SysDebug("realloc gave %p from %p for line %i", tmp, lineptr->Data,
+ // Term->CursorRow);
lineptr->Data = tmp;
}
}
}
else {
// Don't go down a line
- Term->CursorRow --;
}
}
else {
// No scroll needed
+ Term->CursorRow ++;
}
}
else
if( Term->CursorRow == Term->TotalLines-1 ) {
Display_ScrollDown(Term, 1);
}
+ else {
+ Term->CursorRow ++;
+ }
}
- Term->CursorRow ++;
if( bCarriageReturn )
{
buffer += top;
- if( Term->CursorRow >= top && Term->CursorRow < top+max ) {
- Term->CursorRow -= Count;
- Term->CursorRow = MAX(Term->CursorRow, top);
- Term->CursorRow = MIN(Term->CursorRow, top+max);
- }
-
int clear_top, clear_max;
if( Count < 0 )
{
// -ve: Scroll up, move buffer contents down
Count = -Count;
+ for( int i = max-Count; i < max; i ++ )
+ free(buffer[i].Data);
memmove(buffer+Count, buffer, (max-Count)*sizeof(*buffer));
clear_top = 0;
}
else
{
+ for( int i = 0; i < Count; i ++ )
+ free(buffer[i].Data);
memmove(buffer, buffer+Count, (max-Count)*sizeof(*buffer));
clear_top = max-Count;
clear_max = max;
// Clear exposed lines
for( int i = clear_top; i < clear_max; i ++ )
{
- free(buffer[i].Data);
buffer[i].Data = NULL;
buffer[i].Len = 0;
buffer[i].Size = 0;
buffer[i].IsDirty = true;
- if( Term->CursorRow == i ) {
- Term->CursorCol = 0;
- Term->CursorByte = 0;
- }
}
+ // TODO: Send scroll command to GUI
+
+ Display_int_SetCursor(Term, Term->CursorRow, Term->CursorCol);
}
void Display_SetCursor(tTerminal *Term, int Row, int 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)
+{
tLine *line = Display_int_GetCurLine(Term);
size_t ofs = 0;
- for( int i = 0; i < Col; i ++ )
+ int i;
+ for( i = 0; i < Col; i ++ )
{
size_t clen = _GetCharLength(line->Len-ofs, line->Data+ofs, NULL);
if( clen == 0 ) {
- // TODO: Should moving the cursor up to an unoccupied cell cause a jump?
- Col = i;
break;
}
ofs += clen;
}
-
- Term->CursorCol = Col;
+ Term->CursorCol = i;
Term->CursorByte = ofs;
+ // Move to exactly the column specified
+ for( ; i < Col; i ++ ) {
+ Display_int_PushCharacter(Term, 1, " ");
+ Term->CursorCol ++;
+ }
}
void Display_MoveCursor(tTerminal *Term, int RelRow, int RelCol)
// Swapping buffers should cause a full resend
if( !Term->bHaveSwappedBuffers && !lineptr->IsDirty )
continue;
- _SysDebug("Line %i+%i '%.*s'", viewOfs, i, lineptr->Len, lineptr->Data);
+ _SysDebug("Line %i+%i %p '%.*s'", viewOfs, i, lineptr->Data, lineptr->Len, lineptr->Data);
AxWin3_RichText_SendLine(gMainWindow, viewOfs + i,
lineptr->Data ? lineptr->Data : "" );
lineptr->IsDirty = 0;