+ break;
+ }
+}
+
+/**
+ * \brief Update the screen mode
+ * \param Term Terminal to update
+ * \param NewMode New mode to set
+ * \param NewWidth New framebuffer width
+ * \param NewHeight New framebuffer height
+ */
+void VT_int_ChangeMode(tVTerm *Term, int NewMode, int NewWidth, int NewHeight)
+{
+ int oldW = Term->Width;
+ int oldTW = oldW / giVT_CharWidth;
+ int oldH = Term->Height;
+ int oldTH = oldH / giVT_CharWidth;
+ tVT_Char *oldTBuf = Term->Text;
+ Uint32 *oldFB = Term->Buffer;
+ int w, h, i;
+
+ // TODO: Increase RealWidth/RealHeight when this happens
+ if(NewWidth > giVT_RealWidth) NewWidth = giVT_RealWidth;
+ if(NewHeight > giVT_RealHeight) NewHeight = giVT_RealHeight;
+
+ // Calculate new dimensions
+ Term->TextWidth = NewWidth / giVT_CharWidth;
+ Term->TextHeight = NewHeight / giVT_CharHeight;
+ Term->Width = NewWidth;
+ Term->Height = NewHeight;
+ Term->Mode = NewMode;
+
+ // Allocate new buffers
+ // - Text
+ Term->Text = calloc(
+ Term->TextWidth * Term->TextHeight * (giVT_Scrollback+1),
+ sizeof(tVT_Char)
+ );
+ if(oldTBuf) {
+ // Copy old buffer
+ w = oldTW;
+ if( w > Term->TextWidth ) w = Term->TextWidth;
+ h = oldTH;
+ if( h > Term->TextHeight ) h = Term->TextHeight;
+ h *= giVT_Scrollback + 1;
+ for( i = 0; i < h; i ++ )
+ {
+ memcpy(
+ &Term->Text[i*Term->TextWidth],
+ &oldTBuf[i*oldTW],
+ w*sizeof(tVT_Char)
+ );
+
+ }
+ }
+
+ // - Framebuffer
+ Term->Buffer = calloc( Term->Width * Term->Height, sizeof(Uint32) );
+ if(oldFB) {
+ // Copy old buffer
+ w = oldW;
+ if( w > Term->Width ) w = Term->Width;
+ h = oldH;
+ if( h > Term->Height ) h = Term->Height;
+ for( i = 0; i < h; i ++ )
+ {
+ memcpy(
+ &Term->Buffer[i*Term->Width],
+ &oldFB[i*oldW],
+ w*sizeof(Uint32)
+ );
+ }
+ }
+
+
+ // Debug
+ switch(NewMode)
+ {
+ case TERM_MODE_TEXT:
+ Log_Log("VTerm", "Set VT %p to text mode (%ix%i)",
+ Term, Term->TextWidth, Term->TextHeight);
+ break;
+ case TERM_MODE_FB:
+ Log_Log("VTerm", "Set VT %p to framebuffer mode (%ix%i)",
+ Term, Term->Width, Term->Height);
+ break;
+ //case TERM_MODE_2DACCEL:
+ //case TERM_MODE_3DACCEL:
+ // return;