diff --git a/polymer/build/src/osd.c b/polymer/build/src/osd.c index 46d608954..c001e46c5 100644 --- a/polymer/build/src/osd.c +++ b/polymer/build/src/osd.c @@ -542,21 +542,21 @@ void OSD_Init(void) osdinited=1; - OSD_RegisterFunction("alias","alias: creates an alias for calling multiple commands",_internal_osdfunc_alias); - OSD_RegisterFunction("clear","clear: clears the console text buffer",_internal_osdfunc_clear); - OSD_RegisterFunction("exec","exec : executes a script", _internal_osdfunc_exec); - OSD_RegisterFunction("help","help: displays help for the specified cvar or command; \"listsymbols\" to show all commands",_internal_osdfunc_help); - OSD_RegisterFunction("history","history: displays the console command history",_internal_osdfunc_history); - OSD_RegisterFunction("listsymbols","listsymbols: lists all the recognized symbols",_internal_osdfunc_listsymbols); - OSD_RegisterFunction("logcutoff","logcutoff: sets the maximal line count of the log file",_internal_osdfunc_vars); - OSD_RegisterFunction("osdeditpal","osdeditpal: sets the palette of the OSD input text",_internal_osdfunc_vars); - OSD_RegisterFunction("osdeditshade","osdeditshade: sets the shade of the OSD input text",_internal_osdfunc_vars); - OSD_RegisterFunction("osdpromptpal","osdpromptpal: sets the palette of the OSD prompt",_internal_osdfunc_vars); - OSD_RegisterFunction("osdpromptshade","osdpromptshade: sets the shade of the OSD prompt",_internal_osdfunc_vars); - OSD_RegisterFunction("osdrows","osdrows: sets the number of visible lines of the OSD",_internal_osdfunc_vars); - OSD_RegisterFunction("osdtextpal","osdtextpal: sets the palette of the OSD text",_internal_osdfunc_vars); - OSD_RegisterFunction("osdtextshade","osdtextshade: sets the shade of the OSD text",_internal_osdfunc_vars); - OSD_RegisterFunction("unalias","unalias: removes an alias created with \"alias\"",_internal_osdfunc_unalias); + OSD_RegisterFunction("alias","alias: creates an alias for calling multiple commands",_internal_osdfunc_alias); + OSD_RegisterFunction("clear","clear: clears the console text buffer",_internal_osdfunc_clear); + OSD_RegisterFunction("exec","exec : executes a script", _internal_osdfunc_exec); + OSD_RegisterFunction("help","help: displays help for the specified cvar or command; \"listsymbols\" to show all commands",_internal_osdfunc_help); + OSD_RegisterFunction("history","history: displays the console command history",_internal_osdfunc_history); + OSD_RegisterFunction("listsymbols","listsymbols: lists all the recognized symbols",_internal_osdfunc_listsymbols); + OSD_RegisterFunction("logcutoff","logcutoff: sets the maximal line count of the log file",_internal_osdfunc_vars); + OSD_RegisterFunction("osdeditpal","osdeditpal: sets the palette of the OSD input text",_internal_osdfunc_vars); + OSD_RegisterFunction("osdeditshade","osdeditshade: sets the shade of the OSD input text",_internal_osdfunc_vars); + OSD_RegisterFunction("osdpromptpal","osdpromptpal: sets the palette of the OSD prompt",_internal_osdfunc_vars); + OSD_RegisterFunction("osdpromptshade","osdpromptshade: sets the shade of the OSD prompt",_internal_osdfunc_vars); + OSD_RegisterFunction("osdrows","osdrows: sets the number of visible lines of the OSD",_internal_osdfunc_vars); + OSD_RegisterFunction("osdtextpal","osdtextpal: sets the palette of the OSD text",_internal_osdfunc_vars); + OSD_RegisterFunction("osdtextshade","osdtextshade: sets the shade of the OSD text",_internal_osdfunc_vars); + OSD_RegisterFunction("unalias","unalias: removes an alias created with \"alias\"",_internal_osdfunc_unalias); atexit(OSD_Cleanup); } @@ -656,59 +656,56 @@ static int OSD_FindDiffPoint(const char *str1, const char *str2) static void OSD_HistoryPrev(void) { - if (osdhistorypos < osdhistorysize-1) - { - osdhistorypos++; - memcpy(osdeditbuf, osdhistorybuf[osdhistorypos], EDITLENGTH+1); - osdeditlen = osdeditcursor = 0; - while (osdeditbuf[osdeditcursor]) osdeditlen++, osdeditcursor++; - if (osdeditcursor= osdhistorysize-1) return; - if (osdeditwinstart<0) - osdeditwinend-=osdeditwinstart, - osdeditwinstart=0; - } - else if (osdeditcursor>=osdeditwinend) - osdeditwinstart+=(osdeditcursor-osdeditwinend), - osdeditwinend+=(osdeditcursor-osdeditwinend); + osdhistorypos++; + memcpy(osdeditbuf, osdhistorybuf[osdhistorypos], EDITLENGTH+1); + osdeditlen = osdeditcursor = 0; + while (osdeditbuf[osdeditcursor]) osdeditlen++, osdeditcursor++; + if (osdeditcursor=osdeditwinend) + osdeditwinstart+=(osdeditcursor-osdeditwinend), + osdeditwinend+=(osdeditcursor-osdeditwinend); } static void OSD_HistoryNext(void) { - if (osdhistorypos >= 0) - { - if (osdhistorypos == 0) - { - osdeditlen=0; - osdeditcursor=0; - osdeditwinstart=0; - osdeditwinend=editlinewidth; - osdhistorypos = -1; - } - else - { - osdhistorypos--; - memcpy(osdeditbuf, osdhistorybuf[osdhistorypos], EDITLENGTH+1); - osdeditlen = osdeditcursor = 0; - while (osdeditbuf[osdeditcursor]) osdeditlen++, osdeditcursor++; - if (osdeditcursor=osdeditwinend) - osdeditwinstart+=(osdeditcursor-osdeditwinend), - osdeditwinend+=(osdeditcursor-osdeditwinend); - } + if (osdhistorypos == 0) + { + osdeditlen=0; + osdeditcursor=0; + osdeditwinstart=0; + osdeditwinend=editlinewidth; + osdhistorypos = -1; + return; } + + osdhistorypos--; + memcpy(osdeditbuf, osdhistorybuf[osdhistorypos], EDITLENGTH+1); + osdeditlen = osdeditcursor = 0; + while (osdeditbuf[osdeditcursor]) osdeditlen++, osdeditcursor++; + if (osdeditcursor=osdeditwinend) + osdeditwinstart+=(osdeditcursor-osdeditwinend), + osdeditwinend+=(osdeditcursor-osdeditwinend); } int OSD_HandleChar(char ch) @@ -781,58 +778,50 @@ int OSD_HandleChar(char ch) { tabc = findsymbol(osdedittmp, NULL); - if (tabc) + if (tabc && tabc->next && findsymbol(osdedittmp, tabc->next)) { - if (tabc->next) + symbol_t *symb=tabc; + int maxwidth = 0, x = 0, num = 0; + + while (symb && symb != lastmatch) { - if (findsymbol(osdedittmp, tabc->next)) + int diffpt; + + num++; + + if (lastmatch) { - symbol_t *symb=tabc; - int maxwidth = 0, x = 0, num = 0; - - while (symb && symb != lastmatch) + diffpt = OSD_FindDiffPoint(symb->name,lastmatch->name); + if (diffpt < commonsize) { - int diffpt; - - num++; - - if (lastmatch) - { - diffpt = OSD_FindDiffPoint(symb->name,lastmatch->name); - if (diffpt < commonsize) - { - commonsize = diffpt; -// OSD_Printf("commonsize %d\n",commonsize); - } - } - - maxwidth = max((unsigned)maxwidth,Bstrlen(symb->name)); - lastmatch = symb; - symb=findsymbol(osdedittmp, lastmatch->next); + commonsize = diffpt; + // OSD_Printf("commonsize %d\n",commonsize); } - OSD_Printf("Found %d possible completions for '%s':\n",num,osdedittmp); - maxwidth += 3; - symb = tabc; - OSD_Printf(" "); - while (symb && symb != lastmatch) - { - tabc = symb; - OSD_Printf("%-*s",maxwidth,symb->name); - x += maxwidth; - lastmatch = symb; - symb=findsymbol(osdedittmp, lastmatch->next); - if (x > osdcols - maxwidth) - { - x = 0; - OSD_Printf("\n"); - if (symb && symb != lastmatch) - OSD_Printf(" "); - } - } - if (x) - OSD_Printf("\n"); + } + + maxwidth = max((unsigned)maxwidth,Bstrlen(symb->name)); + lastmatch = symb; + symb=findsymbol(osdedittmp, lastmatch->next); + } + OSD_Printf("Found %d possible completions for '%s':\n",num,osdedittmp); + maxwidth += 3; + symb = tabc; + OSD_Printf(" "); + while (symb && (symb != lastmatch)) + { + tabc = lastmatch = symb; + OSD_Printf("%-*s",maxwidth,symb->name); + symb=findsymbol(osdedittmp, lastmatch->next); + x += maxwidth; + if (x > (osdcols - maxwidth)) + { + x = 0; + OSD_Printf("\n"); + if (symb && (symb != lastmatch)) + OSD_Printf(" "); } } + if (x) OSD_Printf("\n"); } } }