📄 tu3_video.c
字号:
/***************************************************************************
** File name : tu3_video.c
** Author : x.cheng
** Create date :
**
** Comment:
** Video operators...
**
** Revisions:
** $Log: tu3_video.c,v $
** Revision 1.1.1.1 2005/07/27 06:53:15 x.cheng
** add into repositories
**
**
***************************************************************************/
#include "const.h"
#include "type.h"
#include "stdarg.h"
#include "string.h"
#include "..\..\Inc\i386\system.h"
#include "..\..\Inc\vga.h"
#include "..\..\Inc\tui.h"
#include "..\..\Inc\vmm.h"
#include "..\..\Inc\mts.h"
#include "..\inc\def_tui.h"
/* debug preprocessor instrument
#ifdef _DEBUG__
#ifdef _DEBUG_TUI__
#endif
#endif
***************************/
/*********************************************
* global variable declaration
*********************************************/
extern ts_Console g_astVirtualConsole[TOTAL_VIRTUAL_CONSOLE_NB+1]; //(console #0 is the special console).
extern int g_iCurrentConsoleIndex; //index of current console.
/************************************************************
*************************************************************
** Function Name: iTu3PutChar
** Author: x.cheng
**
** Comment:
** Put a character on the current console.
**
** List of parameters:
** ch - The ASCII value of the character.
**
** Return value:
** 0
**
** Revisions:
**
*************************************************************
*************************************************************/
int iTu3PutChar( const char ch )
{
ts_Task *pstTask = pstMtsGetCurrentTask();
unsigned long ulFlags;
SaveEflagsAndCli(ulFlags);
if ( !pstTask ) {
// If there is no task print to the video buffer.
vVgaConsolePutChar( (ts_Console *)(&g_astVirtualConsole[0]), ch);
RestoreEflags(ulFlags);
return ( 0 );
}
if ( pstTask->iConsole == g_iCurrentConsoleIndex ) {
// The task is running in the current console.
// So print directly to the video memory.
vVgaConsolePutChar( (ts_Console *)(&g_astVirtualConsole[0]), ch);
} else {
// The task is not running in the current console.
// Print into its video buffer.
vVgaConsolePutChar( (ts_Console *)(&g_astVirtualConsole[pstTask->iConsole]), ch);
}
RestoreEflags(ulFlags);
return ( 0 );
}
/************************************************************
*************************************************************
** Function Name: iTu3Printf
** Author: x.cheng
**
** Comment:
** Print a string to the current console.
**
** List of parameters:
** message The format of the message.
** ... The variables to print.
**
** Return value:
** 0
**
** Revisions:
**
*************************************************************
*************************************************************/
//int iTu3Printf(const char *szFormat, ...)
int iTuiPrintf(const char *szFormat, ...)
{
char szBuffer[1024];
va_list args;
int i;
va_start( args, szFormat );
iVSPrintf(szBuffer, szFormat, args);
va_end( args );
for( i=0; i<1024; i++ ) {
if( !szBuffer[i] ) break;
iTu3PutChar( szBuffer[i] );
}
return( i );
}
//-----------------------------------------------------------
int kprintf(const char *fmt, ...)
{
char szBuffer[1024];
va_list args;
int i;
va_start( args, fmt );
iVSPrintf( szBuffer, fmt, args );
va_end( args );
for( i=0; i<1024; i++ )
{
if( !szBuffer[i] ) break;
iTu3PutChar( szBuffer[i] );
}
return( i );
}
/************************************************************
*************************************************************
** Function Name: vTu3GotoXy
** Author: x.cheng
**
** Comment:
** Place the cursor at the (x, y) coordinates.
** If x or y get a value of -1 they does not change their value.
**
** List of parameters:
** iX.
** iY.
**
** Return value:
** 0
**
** Revisions:
**
*************************************************************
*************************************************************/
void vTu3GotoXy(int iX, int iY)
{
ts_Task *pstTask = pstMtsGetCurrentTask();
if ( !pstTask ) {
// If there is no task print to the video buffer
vVgaConsoleGotoXy( (ts_Console *)(&g_astVirtualConsole[0]), iX, iY);
return;
}
if ( pstTask->iConsole==g_iCurrentConsoleIndex ) {
// The task is running in the current console. //
// So execute directly to the video memory //
vVgaConsoleGotoXy( (ts_Console *)(&g_astVirtualConsole[0]), iX, iY);
} else {
// The task is not running in the current console. //
// Execute into its video buffer //
vVgaConsoleGotoXy( (ts_Console *)(&g_astVirtualConsole[pstTask->iConsole]), iX, iY);
}
}
/************************************************************
*************************************************************
** Function Name: vTu3ScrollUp
** Author: x.cheng
**
** Comment:
** Scroll the console up.
**
** List of parameters:
** no
**
** Return value:
** no
**
** Revisions:
**
*************************************************************
*************************************************************/
void vTu3ScrollUp()
{
ts_Task *pstTask = pstMtsGetCurrentTask();
if ( !pstTask ) {
// If there is no task print to the video buffer
vVgaConsoleScrollUp( (ts_Console *)(&g_astVirtualConsole[0]) );
return;
}
if ( pstTask->iConsole==g_iCurrentConsoleIndex ) {
// The task is running in the current console. //
// So execute directly to the video memory //
vVgaConsoleScrollUp( (ts_Console *)(&g_astVirtualConsole[0]));
} else {
// The task is not running in the current console. //
// Execute into its video buffer //
vVgaConsoleScrollUp( (ts_Console *)(&g_astVirtualConsole[pstTask->iConsole]) );
}
}
/************************************************************
*************************************************************
** Function Name: vTu3SetColor
** Author: x.cheng
**
** Comment:
** Set the text color for the current console.
**
** List of parameters:
** ucColor - the color value.
**
** Return value:
** no
**
** Revisions:
**
*************************************************************
*************************************************************/
void vTu3SetColor(unsigned char ucColor)
{
ts_Task *pstTask = pstMtsGetCurrentTask();
if ( !pstTask ) {
#ifdef _DEBUG__
#ifdef _DEBUG_TUI__
kprintf("g_astVirtualConsole[0].puiVideoBuffer =%p\n", g_astVirtualConsole[0].puiVideoBuffer);
vDbgDummy();
#endif
#endif
// If there is no task set the main console color
vVgaConsoleSetColor( (ts_Console *)(&g_astVirtualConsole[0]), ucColor );
return;
}
if ( pstTask->iConsole==g_iCurrentConsoleIndex ) {
// The task is running in the current console.
// So set the main console color
vVgaConsoleSetColor( (ts_Console *)(&g_astVirtualConsole[0]), ucColor );
} else {
// The task is not running in the current console.
// Set the task console color
vVgaConsoleSetColor( (ts_Console *)(&g_astVirtualConsole[pstTask->iConsole]), ucColor );
}
}
/************************************************************
*************************************************************
** Function Name: vTu3ClearScr
** Author: x.cheng
**
** Comment:
** Clear the screen.
**
** List of parameters:
** no
**
** Return value:
** no
**
** Revisions:
**
*************************************************************
*************************************************************/
void vTu3ClearScr()
{
ts_Task *pstTask = pstMtsGetCurrentTask();
if ( !pstTask ) {
// If there is no task clear the main console
vVgaConsoleClr( (ts_Console *)(&g_astVirtualConsole[0]) );
}
if ( pstTask->iConsole==g_iCurrentConsoleIndex ) {
// The task is running in the current console.
// Clear the task console
vVgaConsoleClr( (ts_Console *)(&g_astVirtualConsole[0]) );
} else {
// The task is not running in the current console.
// Clear the task console
vVgaConsoleClr( (ts_Console *)(&g_astVirtualConsole[pstTask->iConsole]) );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -