X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Fdrv%2Fvterm_output.c;h=79afaa74ff23f94838124790483e3fdfe99abb2f;hb=e47f509e07718893b837826f981085829cf16c84;hp=95a2bce887e070043eb0c296f3dac69677ca8d6d;hpb=48743e39650eb1ef988380e9d95f27fd40d3a9ce;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/drv/vterm_output.c b/KernelLand/Kernel/drv/vterm_output.c index 95a2bce8..79afaa74 100644 --- a/KernelLand/Kernel/drv/vterm_output.c +++ b/KernelLand/Kernel/drv/vterm_output.c @@ -7,6 +7,7 @@ */ #include "vterm.h" #include +#define DEBUG 0 // === CODE === /** @@ -23,6 +24,7 @@ void VT_InitOutput() VT_SetResolution( giVT_RealWidth, giVT_RealHeight ); VT_SetTerminal( 0 ); VT_SetMode( VIDEO_BUFFMT_TEXT ); + LOG("VTerm output initialised"); } /** @@ -50,8 +52,12 @@ void VT_int_ScrollFramebuffer( tVTerm *Term, int Count ) // Only update if this is the current terminal if( Term != gpVT_CurTerm ) return; + ENTER("pTerm iCount", + Term, Count); + if( Count > Term->ScrollHeight ) Count = Term->ScrollHeight; if( Count < -Term->ScrollHeight ) Count = -Term->ScrollHeight; + LOG("Count = %i", Count); // Switch to 2D Command Stream tmp = VIDEO_BUFFMT_2DSTREAM; @@ -79,6 +85,7 @@ void VT_int_ScrollFramebuffer( tVTerm *Term, int Count ) // Restore old mode (this function is only called during text mode) tmp = VIDEO_BUFFMT_TEXT; VFS_IOCtl(giVT_OutputDevHandle, VIDEO_IOCTL_SETBUFFORMAT, &tmp); + LEAVE('-'); } void VT_int_UpdateCursor( tVTerm *Term, int bShow ) @@ -86,6 +93,8 @@ void VT_int_UpdateCursor( tVTerm *Term, int bShow ) tVideo_IOCtl_Pos csr_pos; if( Term != gpVT_CurTerm ) return ; + + ENTER("pTerm bShow", Term, Show); if( !bShow ) { @@ -94,8 +103,6 @@ void VT_int_UpdateCursor( tVTerm *Term, int bShow ) } else if( Term->Mode == TERM_MODE_TEXT ) { - int offset; - // if( !(Term->Flags & VT_FLAG_SHOWCSR) // && ( (Term->Flags & VT_FLAG_HIDECSR) || !Term->Node.ReadThreads) // ) @@ -106,13 +113,9 @@ void VT_int_UpdateCursor( tVTerm *Term, int bShow ) } else { - if(Term->Flags & VT_FLAG_ALTBUF) - offset = Term->AltWritePos; - else - offset = Term->WritePos - Term->ViewPos; - - csr_pos.x = offset % Term->TextWidth; - csr_pos.y = offset / Term->TextWidth; + const tVT_Pos *wrpos = VT_int_GetWritePosPtr(Term); + csr_pos.x = wrpos->Col; + csr_pos.y = wrpos->Row - (Term->Flags & VT_FLAG_ALTBUF ? 0 : Term->ViewTopRow); if( 0 > csr_pos.y || csr_pos.y >= Term->TextHeight ) csr_pos.y = -1, csr_pos.x = -1; } @@ -123,6 +126,7 @@ void VT_int_UpdateCursor( tVTerm *Term, int bShow ) csr_pos.y = Term->VideoCursorY; } VFS_IOCtl(giVT_OutputDevHandle, VIDEO_IOCTL_SETCURSOR, &csr_pos); + LEAVE('-'); } /** @@ -131,17 +135,18 @@ void VT_int_UpdateCursor( tVTerm *Term, int bShow ) */ void VT_int_UpdateScreen( tVTerm *Term, int UpdateAll ) { - tVT_Char *buffer; - int view_pos, write_pos; // Only update if this is the current terminal if( Term != gpVT_CurTerm ) return; - + + ENTER("pTerm iUpdateAll", Term, UpdateAll); + switch( Term->Mode ) { - case TERM_MODE_TEXT: - view_pos = (Term->Flags & VT_FLAG_ALTBUF) ? 0 : Term->ViewPos; - write_pos = (Term->Flags & VT_FLAG_ALTBUF) ? Term->AltWritePos : Term->WritePos; - buffer = (Term->Flags & VT_FLAG_ALTBUF) ? Term->AltBuf : Term->Text; + case TERM_MODE_TEXT: { + size_t view_pos = (Term->Flags & VT_FLAG_ALTBUF) ? 0 : Term->ViewTopRow*Term->TextWidth; + const tVT_Pos *wrpos = VT_int_GetWritePosPtr(Term); + const tVT_Char *buffer = (Term->Flags & VT_FLAG_ALTBUF) ? Term->AltBuf : Term->Text; + LOG("view_pos = %i, wrpos = %p, buffer=%p", view_pos, wrpos, buffer); // Re copy the entire screen? if(UpdateAll) { VFS_WriteAt( @@ -153,7 +158,7 @@ void VT_int_UpdateScreen( tVTerm *Term, int UpdateAll ) } // Only copy the current line else { - int ofs = write_pos - write_pos % Term->TextWidth; + size_t ofs = wrpos->Row * Term->TextWidth; VFS_WriteAt( giVT_OutputDevHandle, (ofs - view_pos)*sizeof(tVT_Char), @@ -161,11 +166,12 @@ void VT_int_UpdateScreen( tVTerm *Term, int UpdateAll ) &buffer[ofs] ); } - break; + break; } case TERM_MODE_FB: break; } VT_int_UpdateCursor(Term, 1); + LEAVE('-'); }