- // Update view position
- base = Term->TextWidth*Term->TextHeight*(giVT_Scrollback);
- if(Term->ViewPos < base)
- Term->ViewPos += Term->Width;
- if(Term->ViewPos > base)
- Term->ViewPos = base;
+ }
+ else
+ {
+ Term->Text = buffer;
+ 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))
+ {
+ int base;
+
+ // Update previous line
+ Term->WritePos -= Term->TextWidth;
+ VT_int_UpdateScreen( Term, 0 );
+
+ // Update view position
+ base = Term->TextWidth*Term->TextHeight*(giVT_Scrollback);
+ if(Term->ViewPos < base)
+ Term->ViewPos += Term->Width;
+ if(Term->ViewPos > base)
+ Term->ViewPos = base;
+
+ VT_int_ScrollText(Term, 1);
+ }
+ // Ok, so we only need to scroll the screen
+ else if(Term->WritePos >= Term->ViewPos + Term->TextWidth*Term->TextHeight)
+ {
+ // Update the last line
+ Term->WritePos -= Term->TextWidth;
+ VT_int_UpdateScreen( Term, 0 );
+
+ VT_int_ScrollText(Term, 1);
+ }
+ }
+
+ //LEAVE('-');
+}
+
+void VT_int_ScrollText(tVTerm *Term, int Count)
+{
+ tVT_Char *buf;
+ int height, init_write_pos;
+ int base, len, i;
+
+ if( Term->Flags & VT_FLAG_ALTBUF )
+ {
+ buf = Term->AltBuf;
+ height = Term->TextHeight;
+ init_write_pos = Term->AltWritePos;
+ }
+ else
+ {
+ buf = Term->Text;
+ height = Term->TextHeight*giVT_Scrollback;
+ init_write_pos = Term->WritePos;
+ }
+
+ if( Count > 0 )
+ {
+ if(Count > Term->ScrollHeight) Count = Term->ScrollHeight;
+ base = Term->TextWidth*(Term->ScrollTop + Term->ScrollHeight - Count);
+ len = Term->TextWidth*(height - Term->ScrollHeight - Count - Term->ScrollTop);