init.c
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 576 行 · 第 1/2 页
C
576 行
/*
* initial configuration
*/
SetMajickString( NULL );
FileEndString = MemStrDup( "[END_OF_FILE]" );
MatchData[0] = MemStrDup( "{" );
MatchData[1] = MemStrDup( "}" );
MatchData[2] = MemStrDup( "\\(" );
MatchData[3] = MemStrDup( "\\)" );
if( cfgFN[0] != 0 ) {
c[0] = 0;
ln = 0;
rc = Source( cfgFN, c, &ln );
if( rc == ERR_FILE_NOT_FOUND ) {
#ifdef __WIN__
CloseStartupDialog();
MessageBox( (HWND) NULL, "Could not locate configuration information; please make sure your EDPATH environment variable is set correctly",
EditorName, MB_OK );
ExitEditor( -1 );
#else
rc = ERR_NO_ERR;
#endif
}
} else {
rc = ERR_NO_ERR;
}
SetGadgetString( NULL );
if( wantNoReadEntireFile ) {
EditFlags.ReadEntireFile = FALSE;
}
VerifyTmpDir();
while( LostFileCheck() );
HookScriptCheck();
if( EditFlags.Quiet ) {
EditFlags.Spinning = EditFlags.Clock = FALSE;
}
ExtendedMemoryInit();
/*
* more misc. setup
*/
if( WordDefn == NULL ) {
AddString( &WordDefn, &WordDefnDefault[6] );
InitWordSearch( WordDefn );
}
if( WordAltDefn == NULL ) {
AddString( &WordAltDefn, WordDefnDefault );
}
if( TagFileName == NULL ) {
AddString( &TagFileName, "tags" );
}
WorkLine = MemAlloc( LINE_SIZE + MaxLine+2 );
DotBuffer = MemAlloc( ( maxdotbuffer + 2 ) * sizeof( vi_key ) );
AltDotBuffer = MemAlloc( ( maxdotbuffer + 2 ) * sizeof( vi_key ) );
DotCmd = MemAlloc( ( maxdotbuffer + 2 ) * sizeof( vi_key ) );
WorkLine->len = -1;
SwapBlockInit( MaxSwapBlocks );
ReadBuffer = MemAlloc( MAX_IO_BUFFER+6 );
WriteBuffer = MemAlloc( MAX_IO_BUFFER+6 );
FindHistInit( FindHist.max );
FilterHistInit( FilterHist.max );
CLHistInit( CLHist.max );
LastFilesHistInit( LastFilesHist.max );
GetClockStart();
GetSpinStart();
SelRgnInit();
SSInitAfterConfig();
#if defined( VI_RCS )
ViRCSInit();
#endif
/*
* create windows
*/
StartWindows();
InitMouse();
i = NewMessageWindow();
if( i ) {
FatalError( i );
}
DoVersion();
i = InitMenu();
if( i ) {
FatalError( i );
}
EditFlags.SpinningOurWheels = TRUE;
EditFlags.ClockActive = TRUE;
EditFlags.DisplayHold = TRUE;
i = NewStatusWindow();
if( i ) {
FatalError( i );
}
EditFlags.DisplayHold = FALSE;
MaxMemFreeAfterInit = MemSize();
/*
* start specified file(s)
*/
arg = argc-1;
k = 1;
cmd[0] = 'e';
cmd[1] = 0;
EditFlags.WatchForBreak = TRUE;
/*
* look for a tag: if there is one, set it up as the file to start
*/
if( cTag != NULL && !EditFlags.NoInitialFileLoad ) {
#if defined( __NT__ ) && !defined( __WIN__ )
{
if( !EditFlags.Quiet ) {
extern HANDLE OutputHandle;
SetConsoleActiveScreenBuffer( OutputHandle );
}
}
#endif
i = LocateTag( cTag, file, buff );
cFN = file;
if( i ) {
if( i == ERR_TAG_NOT_FOUND ) {
Error( GetErrorMsg(i), cTag );
ExitEditor( 0 );
}
FatalError( i );
}
}
while( TRUE && !EditFlags.NoInitialFileLoad ) {
if( cFN == nullFN && !EditFlags.UseNoName ) {
break;
}
strcat( cmd, SingleBlank );
strcat( cmd, cFN );
ocnt = cnt = ExpandFileNames( cFN, &list );
if( !cnt ) {
cnt = 1;
} else {
cFN = list[0];
}
for( j=0;j<cnt;j++ ) {
i = NewFile( cFN, FALSE );
if( i && i != NEW_FILE ) {
FatalError( i );
}
if( EditFlags.BreakPressed ) {
break;
}
if( cnt > 0 && j < cnt-1 ) {
cFN = list[j+1];
}
}
if( ocnt > 0 ) {
MemFreeList( ocnt, list );
}
if( EditFlags.BreakPressed ) {
ClearBreak();
break;
}
k++;
arg--;
if( cTag != NULL || arg < 1 ) {
break;
}
cFN = argv[ k ];
}
if( EditFlags.StdIOMode ) {
i = NewFile( "stdio", FALSE );
if( i ) {
FatalError( i );
}
}
EditFlags.WatchForBreak = EditFlags.Starting = FALSE;
/*
* if there was a tag, do the appropriate search
*/
if( cTag != NULL && !EditFlags.NoInitialFileLoad ) {
if( buff[0] != '/' ) {
i = atoi( buff );
i = GoToLineNoRelCurs( i );
} else {
i = FindTag( buff );
}
if( i > 0 ) {
Error( GetErrorMsg( i ) );
}
}
/*
* try to run startup file
*/
if( EditFlags.RecoverLostFiles ) {
startcnt = 0;
}
for( i=0;i<startcnt;i++ ) {
GetFromEnv( startup[i], tmp );
AddString2( &cfgFN, tmp );
if( cfgFN[0] != 0 ) {
if( startup_parms[i] != NULL ) {
parm = startup_parms[i];
} else {
c[0] = 0;
parm = c;
}
#if defined( __NT__ ) && !defined( __WIN__ )
{
if( !EditFlags.Quiet ) {
extern HANDLE OutputHandle;
SetConsoleActiveScreenBuffer( OutputHandle );
}
}
#endif
rc = Source( cfgFN, parm, &ln );
}
}
if( rc > 0 ) {
Error( "%s on line %d of \"%s\"", GetErrorMsg( rc ), ln, cfgFN );
}
if( argc == 1 ) {
LoadHistory( NULL );
} else {
LoadHistory( cmd );
}
if( GrepDefault == NULL ) {
AddString( &GrepDefault, "*.(c|h)" );
}
if( goCmd[0] != 0 ) {
KeyAddString( goCmd );
}
if( keysToPush != NULL ) {
KeyAddString( keysToPush );
}
#ifdef __WIN__
if( lineToGoTo != 0 ) {
SetCurrentLine( lineToGoTo );
NewCursor( CurrentWindow, NormalCursorType );
}
#endif
AutoSaveInit();
HalfPageLines = WindowAuxInfo( CurrentWindow, WIND_INFO_TEXT_LINES )/2-1;
#ifdef __386__
VarAddGlobalStr( "OS386", "1" );
#endif
if( StatusString == NULL ) {
AddString( &StatusString, "L:$6L$nC:$6C" );
}
UpdateStatusWindow();
#ifdef __WIN__
if( CurrentInfo == NULL ) {
// no file loaded - screen is disconcertenly empty - reassure
DisplayFileStatus();
}
#endif
NewCursor( CurrentWindow, NormalCursorType );
#if defined( __NT__ ) && !defined( __WIN__ )
{
extern HANDLE OutputHandle;
SetConsoleActiveScreenBuffer( OutputHandle );
}
#endif
#if defined( PREBUILD )
if( startcnt == 0 ) {
ExitEditor( 0 );
}
#endif
} /* doInitializeEditor */
/*
* InitializeEditor - start up
*/
void InitializeEditor( void )
{
extern int _argc;
extern char ** _argv;
doInitializeEditor( _argc, _argv );
} /* InitializeEditor */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?