void LangSetFini( void ) { _Free( Language ); LangFini(); }
/* * processSetToken - set value for set token */ static vi_rc processSetToken( int j, char *value, int *winflag, bool isnonbool ) { char fn[MAX_STR], str[MAX_STR]; #ifndef VICOMP char tmp[3]; char settokstr[TOK_MAX_LEN + 1]; char save[MAX_STR]; vi_rc rc = ERR_NO_ERR; int i, clr, k; bool newset; bool set1, toggle, *ptr; jmp_buf jmpaddr; cursor_type ct; char *name; command_rtn fptr; event_bits eb; bool redisplay = FALSE; #endif bool bvalue; #ifdef VICOMP winflag = winflag; isnonbool = isnonbool; #endif /* * set up value for boolean set commands */ if( j < 0 ) { j *= -1; bvalue = FALSE; } else { bvalue = TRUE; } #ifndef VICOMP if( !(*winflag) ) { toggle = TRUE; set1 = isnonbool; } else { toggle = FALSE; #endif if( j >= SET1_T_ ) { #ifndef VICOMP if( EditFlags.CompileScript ) { #endif if( !bvalue ) { j *= -1; } itoa( j, str, 10 ); StrMerge( 2, WorkLine->data, str, SingleBlank ); return( ERR_NO_ERR ); #ifndef VICOMP } set1 = FALSE; j -= SET1_T_; } else { set1 = TRUE; #endif } #ifndef VICOMP } *winflag = FALSE; /* * process boolean settings */ if( !set1 ) { if( j >= SET2_T_ ) { return( ERR_INVALID_SET_COMMAND ); } ptr = &(((bool *)&EditFlags)[j]); newset = bvalue; if( toggle ) { newset = !(*ptr); } switch( j ) { case SET2_T_MODELESS: if( (newset && !EditFlags.Modeless) || (!newset && EditFlags.Modeless) ) { for( k = 0; k < MAX_EVENTS; k++ ) { fptr = EventList[k].rtn; eb = EventList[k].b; EventList[k].rtn = EventList[k].alt_rtn; EventList[k].alt_rtn = fptr; EventList[k].b = EventList[k].alt_b; EventList[k].alt_b = eb; } if( !EditFlags.Modeless ) { if( MenuWindow != NO_WINDOW ) { UpdateCurrentStatus( CSTATUS_INSERT ); } EditFlags.WasOverstrike = FALSE; NewCursor( CurrentWindow, EditVars.InsertCursorType ); } else { if( MenuWindow != NO_WINDOW ) { UpdateCurrentStatus( CSTATUS_COMMAND ); } NewCursor( CurrentWindow, EditVars.NormalCursorType ); // nomodeless must be line based or it dies! EditFlags.LineBased = TRUE; } /* re-position cursor in window */ SetWindowCursor(); } EditFlags.Modeless = newset; break; case SET2_T_UNDO: if( EditFlags.Undo && !newset ) { FreeAllUndos(); } EditFlags.Undo = newset; break; case SET2_T_STATUSINFO: EditFlags.StatusInfo = newset; #ifdef __WIN__ ResizeRoot(); #endif rc = NewStatusWindow(); break; case SET2_T_WINDOWGADGETS: EditFlags.WindowGadgets = newset; ResetAllWindows(); *winflag = TRUE; redisplay = TRUE; break; case SET2_T_REALTABS: EditFlags.RealTabs = newset; redisplay = TRUE; break; case SET2_T_CLOCK: EditFlags.Clock = newset; redisplay = TRUE; break; case SET2_T_TOOLBAR: EditFlags.Toolbar = newset; #ifdef __WIN__ ResizeRoot(); #endif break; case SET2_T_COLORBAR: EditFlags.Colorbar = newset; #ifdef __WIN__ if( Root == NULL ) { EditFlags.Colorbar = FALSE; } else { RefreshColorbar(); } #endif break; case SET2_T_SSBAR: EditFlags.SSbar = newset; #ifdef __WIN__ if( Root == NULL ) { EditFlags.SSbar = FALSE; } else { RefreshSSbar(); } #endif break; case SET2_T_FONTBAR: EditFlags.Fontbar = newset; #ifdef __WIN__ if( Root == NULL ) { EditFlags.Fontbar = FALSE; } else { RefreshFontbar(); } #endif break; case SET2_T_MARKLONGLINES: EditFlags.MarkLongLines = newset; break; case SET2_T_MENUS: EditFlags.Menus = newset; InitMenu(); break; case SET2_T_LINENUMBERS: if( toggle ) { newset = !EditFlags.LineNumbers; } if( newset != EditFlags.LineNumbers ) { EditFlags.LineNumbers = newset; rc = LineNumbersSetup(); *winflag = TRUE; } break; case SET2_T_CURRENTSTATUS: EditFlags.CurrentStatus = newset; InitMenu(); break; case SET2_T_DISPLAYSECONDS: EditFlags.DisplaySeconds = newset; redisplay = TRUE; break; case SET2_T_PPKEYWORDONLY: EditFlags.PPKeywordOnly = newset; redisplay = TRUE; break; case SET2_T_LASTEOL: #ifndef __WIN__ *ptr = TRUE; toggle = FALSE; break; #endif default: *ptr = newset; break; } if( msgFlag ) { if( !newset ) { tmp[0] = 'n'; tmp[1] = 'o'; tmp[2] = 0; } else { tmp[0] = 0; } MySprintf( fn, "%s%s set", tmp, GetTokenStringCVT( SetTokens2, j, settokstr, TRUE ) ); } if( toggle ) { strcpy( save, BoolStr[(int) newset] ); (*winflag) += 1; } /* * process value settings */ } else { if( toggle ) { rc = GetNewValueDialog( value ); if( rc != ERR_NO_ERR ) { return( rc ); } strcpy( save, value ); } #endif /* VICOMP */ RemoveLeadingSpaces( value ); if( value[0] == '"' ) { NextWord( value, fn, "\"" ); EliminateFirstN( value, 1 ); } else { NextWord1( value, fn ); } #ifndef VICOMP if( EditFlags.CompileScript ) { #endif itoa( j, str, 10 ); strcat( WorkLine->data, str ); if( fn[0] == '\0' ) return( ERR_NO_ERR ); switch( j ) { case SET1_T_STATUSSTRING: case SET1_T_FILEENDSTRING: case SET1_T_HISTORYFILE: case SET1_T_TMPDIR: case SET1_T_TAGFILENAME: StrMerge( 4, WorkLine->data, SingleBlank, SingleQuote, fn, SingleQuote ); break; case SET1_T_COMMANDCURSORTYPE: case SET1_T_OVERSTRIKECURSORTYPE: case SET1_T_INSERTCURSORTYPE: StrMerge( 2, WorkLine->data, SingleBlank, fn ); if( NextWord1( value, fn ) <= 0 ) { break; } StrMerge( 2, WorkLine->data, SingleBlank, fn ); break; case SET1_T_TILECOLOR: StrMerge( 2, WorkLine->data, SingleBlank, fn ); if( NextWord1( value, fn ) <= 0 ) { return( ERR_INVALID_SET_COMMAND ); } if( NextWord1( value, str ) <= 0 ) { return( ERR_INVALID_SET_COMMAND ); } StrMerge( 4, WorkLine->data, fn, SingleBlank, str, SingleBlank ); break; case SET1_T_STATUSSECTIONS: StrMerge( 2, WorkLine->data, SingleBlank, fn ); while( NextWord1( value, fn ) > 0 ) { #ifdef VICOMP int k; #endif k = atoi( fn ); if( k <= 0 ) { break; } StrMerge( 2, WorkLine->data, SingleBlank, fn ); } break; default: StrMerge( 2, WorkLine->data, SingleBlank, fn ); break; } return( ERR_NO_ERR ); #ifndef VICOMP } switch( j ) { case SET1_T_STATUSSECTIONS: if( EditVars.StatusSections != NULL ) { MemFree( EditVars.StatusSections ); EditVars.StatusSections = NULL; EditVars.NumStatusSections = 0; } for( ;; ) { k = atoi( fn ); if( k <= 0 ) { break; } EditVars.StatusSections = MemReAlloc( EditVars.StatusSections, sizeof( short ) * (EditVars.NumStatusSections + 1) ); EditVars.StatusSections[EditVars.NumStatusSections] = k; EditVars.NumStatusSections++; if( NextWord1( value, fn ) <= 0 ) { break; } } if( EditVars.StatusSections == NULL ) { MySprintf( fn, "statussections turned off" ); } else { MySprintf( fn, "statussections set" ); } break; case SET1_T_FILEENDSTRING: AddString2( &EditVars.FileEndString, fn ); ResetAllWindows(); redisplay = TRUE; break; case SET1_T_STATUSSTRING: AddString2( &EditVars.StatusString, fn ); if( StatusWindow != NO_WINDOW ) { ClearWindow( StatusWindow ); UpdateStatusWindow(); } if( msgFlag ) { MySprintf( fn, "statusstring set to %s", EditVars.StatusString ); } break; case SET1_T_GREPDEFAULT: AddString2( &EditVars.GrepDefault, fn ); break; case SET1_T_TILECOLOR: if( EditVars.TileColors == NULL ) { EditVars.TileColors = (type_style *) MemAlloc( sizeof( type_style ) * ( EditVars.MaxTileColors + 1 ) ); for( i = 0; i <= EditVars.MaxTileColors; ++i ) { EditVars.TileColors[i].foreground = -1; EditVars.TileColors[i].background = -1; EditVars.TileColors[i].font = -1; } } clr = atoi( fn ); if( clr > EditVars.MaxTileColors ) { return( ERR_INVALID_SET_COMMAND ); } if( NextWord1( value, fn ) <= 0 ) { return( ERR_INVALID_SET_COMMAND ); } EditVars.TileColors[clr].foreground = atoi( fn ); if( NextWord1( value, fn ) <= 0 ) { return( ERR_INVALID_SET_COMMAND ); } EditVars.TileColors[clr].background = atoi( fn ); EditVars.TileColors[clr].font = FONT_DEFAULT; if( msgFlag ) { MySprintf( fn, "tilecolor %d set", clr ); } break; case SET1_T_GADGETSTRING: SetGadgetString( fn ); if( msgFlag ) { MySprintf( fn, "gadget string set to %s", EditVars.GadgetString ); } ResetAllWindows(); break; case SET1_T_SHELLPROMPT: AddString2( &EditVars.SpawnPrompt, fn ); if( msgFlag ) { MySprintf( fn, "prompt string set to %s", EditVars.SpawnPrompt ); } break; case SET1_T_FIGNORE: if( fn[0] == 0 ) { MemFreePtr( (void **)&EditVars.FIgnore ); EditVars.CurrFIgnore = 0; if( msgFlag ) { MySprintf( fn, "fignore reset" ); } } else { EditVars.FIgnore = MemReAlloc( EditVars.FIgnore, EXTENSION_LENGTH * (EditVars.CurrFIgnore + 1) ); str[0] = '.'; str[1] = 0; strcat( str, fn ); str[EXTENSION_LENGTH - 1] = 0; strcpy( &EditVars.FIgnore[EXTENSION_LENGTH * EditVars.CurrFIgnore], str ); EditVars.CurrFIgnore++; if( msgFlag ) { MySprintf( fn, "%s added to fignore", str ); } } break; case SET1_T_HISTORYFILE: AddString2( &EditVars.HistoryFile, fn ); if( msgFlag ) { MySprintf( fn, "history file set to %s", EditVars.HistoryFile ); } break; case SET1_T_TAGFILENAME: AddString2( &EditVars.TagFileName, fn ); if( msgFlag ) { MySprintf( fn, "tag file name set to %s", EditVars.TagFileName ); } break; case SET1_T_FILENAME: if( CurrentFile != NULL ) { AddString2( &(CurrentFile->name), fn ); SetFileWindowTitle( CurrentWindow, CurrentInfo, TRUE ); if( msgFlag ) { MySprintf( fn, "filename set to %s", CurrentFile->name ); } FileSPVAR(); } break; case SET1_T_TMPDIR: AddString2( &EditVars.TmpDir, fn ); VerifyTmpDir(); if( msgFlag ) { MySprintf( fn, "tmpdir set to %s", EditVars.TmpDir ); } break; case SET1_T_WORD: AddString2( &EditVars.WordDefn, fn ); InitWordSearch( EditVars.WordDefn ); if( msgFlag ) { MySprintf( fn, "word set to %s", EditVars.WordDefn ); } break; case SET1_T_WORDALT: AddString2( &EditVars.WordAltDefn, fn ); if( msgFlag ) { MySprintf( fn, "wordalt set to %s", EditVars.WordAltDefn ); } break; case SET1_T_MAGICSTRING: AddString2( &EditVars.Majick, fn ); if( msgFlag ) { MySprintf( fn, "magicstring set to %s", EditVars.Majick ); } break; case SET1_T_COMMANDCURSORTYPE: case SET1_T_OVERSTRIKECURSORTYPE: case SET1_T_INSERTCURSORTYPE: i = setjmp( jmpaddr ); if( i != 0 ) { return( ERR_INVALID_SET_COMMAND ); } StartExprParse( fn, jmpaddr ); ct.height = GetConstExpr(); if( NextWord1( value, fn ) <= 0 ) { ct.width = 100; } else { i = setjmp( jmpaddr ); if( i != 0 ) { return( ERR_INVALID_SET_COMMAND ); } StartExprParse( fn, jmpaddr ); ct.width = GetConstExpr(); } if( j == SET1_T_COMMANDCURSORTYPE ) { EditVars.NormalCursorType = ct; name = "command"; } else if( j == SET1_T_OVERSTRIKECURSORTYPE ) { EditVars.OverstrikeCursorType = ct; name = "overstrike"; } else { EditVars.InsertCursorType = ct; name = "insert"; } if( msgFlag ) { MySprintf( fn, "%s cursor type set to %d,%d", name, ct.height, ct.width ); } break; default: i = setjmp( jmpaddr ); if( i != 0 ) { return( ERR_INVALID_SET_COMMAND ); } StartExprParse( fn, jmpaddr ); i = GetConstExpr(); if( i < 0 ) { i = 0; } switch( j ) { case SET1_T_WRAPMARGIN: EditVars.WrapMargin = i; break; case SET1_T_CURSORBLINKRATE: SetCursorBlinkRate( i ); break; case SET1_T_MAXPUSH: EditVars.MaxPush = i; if( EditVars.MaxPush < 1 ) { EditVars.MaxPush = 1; } InitFileStack(); break; case SET1_T_RADIX: EditVars.Radix = i; break; case SET1_T_AUTOSAVEINTERVAL: EditVars.AutoSaveInterval = i; SetNextAutoSaveTime(); break; case SET1_T_LANGUAGE: if( i < LANG_NONE || i >= LANG_MAX ) { return( ERR_INVALID_SET_COMMAND ); } if( CurrentInfo != NULL ) { LangFini( CurrentInfo->fsi.Language ); LangInit( i ); redisplay = TRUE; } break; case SET1_T_MOVECOLOR: EditVars.MoveColor = i; break; case SET1_T_RESIZECOLOR: EditVars.ResizeColor = i; break; case SET1_T_MOUSEDCLICKSPEED: EditVars.MouseDoubleClickSpeed = i; break; case SET1_T_MOUSESPEED: SetMouseSpeed( i ); break; case SET1_T_MOUSEREPEATDELAY: EditVars.MouseRepeatDelay = i; break; case SET1_T_CURRENTSTATUSCOLUMN: EditVars.CurrentStatusColumn = i; InitMenu(); break; case SET1_T_ENDOFLINECHAR: EditVars.EndOfLineChar = i; break; case SET1_T_EXITATTR: EditVars.ExitAttr = (char) i; break; case SET1_T_INACTIVEWINDOWCOLOR: EditVars.InactiveWindowColor = i; break; case SET1_T_TABAMOUNT: EditVars.TabAmount = i; break; case SET1_T_SHIFTWIDTH: EditVars.ShiftWidth = i; break; case SET1_T_PAGELINESEXPOSED: EditVars.PageLinesExposed = i; break; case SET1_T_HARDTAB: EditVars.HardTab = i; redisplay = TRUE; break; case SET1_T_STACKK: if( EditFlags.Starting ) { EditVars.StackK = i; } break; case SET1_T_LINENUMWINWIDTH: EditVars.LineNumWinWidth = i; break; case SET1_T_MAXWINDOWTILEX: EditVars.MaxWindowTileX = i; break; case SET1_T_MAXWINDOWTILEY: EditVars.MaxWindowTileY = i; break; case SET1_T_MAXSWAPK: SwapBlockInit( i ); break; case SET1_T_MAXEMSK: #ifndef NOEMS EMSBlockInit( i ); #endif break; case SET1_T_MAXXMSK: #ifndef NOXMS XMSBlockInit( i ); #endif break; case SET1_T_MAXFILTERHISTORY: FilterHistInit( i ); break; case SET1_T_MAXCLHISTORY: CLHistInit( i ); break; case SET1_T_MAXFINDHISTORY: FindHistInit( i ); break; case SET1_T_MAXLASTFILESHISTORY: LastFilesHistInit( i ); break; case SET1_T_MAXTILECOLORS: k = (EditVars.TileColors == NULL) ? 0 : EditVars.MaxTileColors + 1; EditVars.MaxTileColors = i; EditVars.TileColors = MemReAlloc( EditVars.TileColors, sizeof( type_style ) * ( EditVars.MaxTileColors + 1 ) ); for( ; k <= EditVars.MaxTileColors; ++k ) { EditVars.TileColors[k].foreground = -1; EditVars.TileColors[k].background = -1; EditVars.TileColors[k].font = -1; } break; case SET1_T_CLOCKX: EditVars.ClockX = i; GetClockStart(); break; case SET1_T_CLOCKY: EditVars.ClockY = i; GetClockStart(); break; case SET1_T_SPINX: EditVars.SpinX = i; GetSpinStart(); break; case SET1_T_SPINY: EditVars.SpinY = i; GetSpinStart(); break; case SET1_T_MAXLINELEN: /* file save fails if 1 line is > MAX_IO_BUFFER */ i = __min( i, MAX_IO_BUFFER ); EditVars.MaxLine = i; StaticStart(); WorkLine = MemReAlloc( WorkLine, sizeof( line ) + EditVars.MaxLine + 2 ); break; case SET1_T_TOOLBARBUTTONHEIGHT: EditVars.ToolBarButtonHeight = i; #ifdef __WIN__ ResizeRoot(); #endif break; case SET1_T_TOOLBARBUTTONWIDTH: EditVars.ToolBarButtonWidth = i; #ifdef __WIN__ ResizeRoot(); #endif break; case SET1_T_TOOLBARCOLOR: EditVars.ToolBarColor = i; #ifdef __WIN__ if( GetToolbarWindow() != NULL ) { InvalidateRect( GetToolbarWindow(), NULL, TRUE ); UpdateWindow( GetToolbarWindow() ); } #endif break; default: return( ERR_INVALID_SET_COMMAND ); } if( msgFlag ) { MySprintf( fn, "%s set to %d", GetTokenStringCVT( SetTokens1, j, settokstr, TRUE ), i ); } break; } } if( msgFlag && rc == ERR_NO_ERR && !EditFlags.Quiet ) { setMessage( fn, redisplay ); rc = DO_NOT_CLEAR_MESSAGE_WINDOW; } if( rc == ERR_NO_ERR && toggle ) { strcpy( value, save ); } return( rc ); #endif /* VICOMP */ } /* processSetToken */