📄 tu2_console.c
字号:
/***************************************************************************
** File name : tu2_console.c
** Author : x.cheng
** Create date :
**
** Comment:
** Consoles managemet operators...
**
** Revisions:
** $Log: tu2_console.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\io.h"
#include "..\..\Inc\vga.h"
#include "..\..\Inc\keyb.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: pstTu2GetConsoleAddress
** Author: x.cheng
**
** Comment:
** Get the address of a console structure.
**
** List of parameters:
** iIndex - the console id.
**
** Return value:
** the address of the console structure.
** error: NULL if the console iWhich does not exists
** Revisions:
**
*************************************************************
*************************************************************/
ts_Console *pstTu2GetConsoleAddress(int iIndex)
{
if ( (iIndex>=0) && (iIndex<=TOTAL_VIRTUAL_CONSOLE_NB) )
return( (ts_Console *)(&g_astVirtualConsole[iIndex]) );
return ( (ts_Console*)NULL );
}
/************************************************************
*************************************************************
** Function Name: iTu2SetCurrentConsole
** Author: x.cheng
**
** Comment:
** Set the current console.
**
** List of parameters:
** iIndex - The console index to set as current console.
**
** Return value:
** TRUE - iIndex is a valid console id.
** FALSE - is not a valid console id.
**
** Revisions:
**
*************************************************************
*************************************************************/
int iTu2SetCurrentConsole(int iIndex)
{
if ( (iIndex > 0) && (iIndex <= TOTAL_VIRTUAL_CONSOLE_NB) )
g_iCurrentConsoleIndex = iIndex;
else
return(FALSE);
return(TRUE);
}
//----------------------------------------
int iTu2GetCurrentConsole()
{
return ( g_iCurrentConsoleIndex );
}
/************************************************************
*************************************************************
** Function Name: iTu2SwitchToConsole
** Author: x.cheng
**
** Comment:
** Clear the screen.
**
** List of parameters:
** no
**
** Return value:
** TRUE - iIndex is a valid console id.
** FALSE - is not a valid console id.
**
** Revisions:
**
*************************************************************
*************************************************************/
int iTu2SwitchToConsole(int iIndex)
{
if ( iIndex == g_iCurrentConsoleIndex ) return (TRUE); // Attempt to switch to the current console
if ( iIndex > TOTAL_VIRTUAL_CONSOLE_NB ) return (FALSE);
// Copy old console parameters from video memory
memcpy(g_astVirtualConsole[g_iCurrentConsoleIndex].puiVideoBuffer,
g_astVirtualConsole[0].puiVideoBuffer, VIDEO_BUFFER_SIZE);
g_astVirtualConsole[g_iCurrentConsoleIndex].uiCurrentPos = g_astVirtualConsole[0].uiCurrentPos;
g_astVirtualConsole[g_iCurrentConsoleIndex].ucCurrentColor = g_astVirtualConsole[0].ucCurrentColor;
if ( iTu2SetCurrentConsole(iIndex) )
{
// Set new console parameters to the video memory //
memcpy(g_astVirtualConsole[0].puiVideoBuffer,
g_astVirtualConsole[iIndex].puiVideoBuffer, VIDEO_BUFFER_SIZE);
iVgaConsoleSetPos( (ts_Console *)(&g_astVirtualConsole[0]), g_astVirtualConsole[iIndex].uiCurrentPos );
vVgaConsoleSetColor( (ts_Console *)(&g_astVirtualConsole[0]), g_astVirtualConsole[iIndex].ucCurrentColor );
// Set keyboard parameters of the new selected console //
vKeybUpdateLeds(g_astVirtualConsole[g_iCurrentConsoleIndex].ucLedState);
return( TRUE );
}
return( FALSE );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -