diff --git a/polymer/build/include/osd.h b/polymer/build/include/osd.h index e7b0c58ee..fcfdb86dd 100644 --- a/polymer/build/include/osd.h +++ b/polymer/build/include/osd.h @@ -67,7 +67,7 @@ void OSD_CaptureKey(int sc); // handles keyboard input when capturing input. returns 0 if key was handled // or the scancode if it should be handled by the game. int OSD_HandleScanCode(int sc, int press); -int OSD_HandleChars(void); +int OSD_HandleChars(char ch); // handles the readjustment when screen resolution changes void OSD_ResizeDisplay(int w,int h); diff --git a/polymer/build/src/osd.c b/polymer/build/src/osd.c index 29e43d0d7..b84aaf024 100644 --- a/polymer/build/src/osd.c +++ b/polymer/build/src/osd.c @@ -641,227 +641,220 @@ static int OSD_FindDiffPoint(const char *str1, const char *str2) // be passed on to the game. // -int OSD_HandleChars(void) +int OSD_HandleChar(char ch) { int i,j; symbol_t *tabc = NULL; static symbol_t *lastmatch = NULL; - char ch; - if (!osdinited) return 1; + if (!osdinited || !osdinput) return ch; - if (!osdinput) - return 1; - - while ((ch = bgetchar())) + if (ch != 9) lastmatch = NULL; // tab + if (ch == 1) // control a. jump to beginning of line { - if (ch != 9) lastmatch = NULL; // tab - if (ch == 1) // control a. jump to beginning of line + } + else if (ch == 2) // control b, move one character left + { + } + else if (ch == 5) // control e, jump to end of line + { + } + else if (ch == 6) // control f, move one character right + { + } + else if (ch == 8 || ch == 127) // control h, backspace + { + if (!osdeditcursor || !osdeditlen) return 0; + if (!osdovertype) { + if (osdeditcursor < osdeditlen) + Bmemmove(osdeditbuf+osdeditcursor-1, osdeditbuf+osdeditcursor, osdeditlen-osdeditcursor); + osdeditlen--; } - else if (ch == 2) // control b, move one character left - { - } - else if (ch == 5) // control e, jump to end of line - { - } - else if (ch == 6) // control f, move one character right - { - } - else if (ch == 8 || ch == 127) // control h, backspace - { - if (!osdeditcursor || !osdeditlen) continue; - if (!osdovertype) - { - if (osdeditcursor < osdeditlen) - Bmemmove(osdeditbuf+osdeditcursor-1, osdeditbuf+osdeditcursor, osdeditlen-osdeditcursor); - osdeditlen--; - } - osdeditcursor--; - if (osdeditcursor0;i--) if (osdeditbuf[i-1] == ' ') break; - for (j=0;osdeditbuf[i] != ' ' && i < osdeditlen;j++,i++) - osdedittmp[j] = osdeditbuf[i]; - osdedittmp[j] = 0; + if (!lastmatch) + { + for (i=osdeditcursor;i>0;i--) if (osdeditbuf[i-1] == ' ') break; + for (j=0;osdeditbuf[i] != ' ' && i < osdeditlen;j++,i++) + osdedittmp[j] = osdeditbuf[i]; + osdedittmp[j] = 0; - if (j > 0) + if (j > 0) + { + tabc = findsymbol(osdedittmp, NULL); + + if (tabc) { - tabc = findsymbol(osdedittmp, NULL); - - if (tabc) + if (tabc->next) { - if (tabc->next) + if (findsymbol(osdedittmp, tabc->next)) { - if (findsymbol(osdedittmp, tabc->next)) + symbol_t *symb=tabc; + int maxwidth = 0, x = 0, num = 0; + + while (symb && symb != lastmatch) { - symbol_t *symb=tabc; - int maxwidth = 0, x = 0, num = 0; + int diffpt; - while (symb && symb != lastmatch) + num++; + + if (lastmatch) { - int diffpt; - - num++; - - if (lastmatch) + diffpt = OSD_FindDiffPoint(symb->name,lastmatch->name); + if (diffpt < commonsize) { - diffpt = OSD_FindDiffPoint(symb->name,lastmatch->name); - if (diffpt < commonsize) - { - commonsize = diffpt; + commonsize = diffpt; // OSD_Printf("commonsize %d\n",commonsize); - } } + } - maxwidth = max((unsigned)maxwidth,Bstrlen(symb->name)); - lastmatch = symb; - symb=findsymbol(osdedittmp, lastmatch->next); - } - OSD_Printf("Found %d 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 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"); } } } } - else - { - tabc = findsymbol(osdedittmp, lastmatch->next); - if (!tabc && lastmatch) - tabc = findsymbol(osdedittmp, NULL); // wrap */ - } + } + else + { + tabc = findsymbol(osdedittmp, lastmatch->next); + if (!tabc && lastmatch) + tabc = findsymbol(osdedittmp, NULL); // wrap */ + } - if (tabc) + if (tabc) + { + for (i=osdeditcursor;i>0;i--) if (osdeditbuf[i-1] == ' ') break; + osdeditlen = i; + for (j=0;tabc->name[j] && osdeditlen <= EDITLENGTH + && (osdeditlen < commonsize);i++,j++,osdeditlen++) + osdeditbuf[i] = tabc->name[j]; + osdeditcursor = osdeditlen; + osdeditwinend = osdeditcursor; + osdeditwinstart = osdeditwinend-editlinewidth; + if (osdeditwinstart<0) { - for (i=osdeditcursor;i>0;i--) if (osdeditbuf[i-1] == ' ') break; - osdeditlen = i; - for (j=0;tabc->name[j] && osdeditlen <= EDITLENGTH - && (osdeditlen < commonsize);i++,j++,osdeditlen++) - osdeditbuf[i] = tabc->name[j]; - osdeditcursor = osdeditlen; - osdeditwinend = osdeditcursor; - osdeditwinstart = osdeditwinend-editlinewidth; - if (osdeditwinstart<0) - { - osdeditwinstart=0; - osdeditwinend = editlinewidth; - } - - lastmatch = tabc; - } - } - else if (ch == 11) // control k, delete all to end of line - { - } - else if (ch == 12) // control l, clear screen - { - Bmemset(osdtext,0,sizeof(osdtext)); - osdlines = 1; - } - else if (ch == 13) // control m, enter - { - if (osdeditlen>0) - { - osdeditbuf[osdeditlen] = 0; - Bmemmove(osdhistorybuf[1], osdhistorybuf[0], HISTORYDEPTH*(EDITLENGTH+1)); - Bmemmove(osdhistorybuf[0], osdeditbuf, EDITLENGTH+1); - if (osdhistorysize < HISTORYDEPTH) osdhistorysize++; - if (osdexeccount == HISTORYDEPTH) - OSD_Printf("Command Buffer Warning: Failed queueing command " - "for execution. Buffer full.\n"); - else - osdexeccount++; - osdhistorypos=-1; - } - - osdeditlen=0; - osdeditcursor=0; - osdeditwinstart=0; - osdeditwinend=editlinewidth; - } - else if (ch == 16) // control p, previous (ie. up arrow) - { - } - else if (ch == 20) // control t, swap previous two chars - { - } - else if (ch == 21) // control u, delete all to beginning - { - if (osdeditcursor>0 && osdeditlen) - { - if (osdeditcursor0 && osdeditlen>0) - { - i=osdeditcursor; - while (i>0 && osdeditbuf[i-1]==32) i--; - while (i>0 && osdeditbuf[i-1]!=32) i--; - if (osdeditcursor= 32) // text char - { - if (!osdovertype && osdeditlen == EDITLENGTH) // buffer full, can't insert another char - continue; - if (!osdovertype) - { - if (osdeditcursor < osdeditlen) - Bmemmove(osdeditbuf+osdeditcursor+1, osdeditbuf+osdeditcursor, osdeditlen-osdeditcursor); - osdeditlen++; - } - else - { - if (osdeditcursor == osdeditlen) - osdeditlen++; - } - osdeditbuf[osdeditcursor] = ch; - osdeditcursor++; - if (osdeditcursor>osdeditwinend) osdeditwinstart++,osdeditwinend++; + lastmatch = tabc; } } + else if (ch == 11) // control k, delete all to end of line + { + } + else if (ch == 12) // control l, clear screen + { + Bmemset(osdtext,0,sizeof(osdtext)); + osdlines = 1; + } + else if (ch == 13) // control m, enter + { + if (osdeditlen>0) + { + osdeditbuf[osdeditlen] = 0; + Bmemmove(osdhistorybuf[1], osdhistorybuf[0], HISTORYDEPTH*(EDITLENGTH+1)); + Bmemmove(osdhistorybuf[0], osdeditbuf, EDITLENGTH+1); + if (osdhistorysize < HISTORYDEPTH) osdhistorysize++; + if (osdexeccount == HISTORYDEPTH) + OSD_Printf("Command Buffer Warning: Failed queueing command " + "for execution. Buffer full.\n"); + else + osdexeccount++; + osdhistorypos=-1; + } + + osdeditlen=0; + osdeditcursor=0; + osdeditwinstart=0; + osdeditwinend=editlinewidth; + } + else if (ch == 16) // control p, previous (ie. up arrow) + { + } + else if (ch == 20) // control t, swap previous two chars + { + } + else if (ch == 21) // control u, delete all to beginning + { + if (osdeditcursor>0 && osdeditlen) + { + if (osdeditcursor0 && osdeditlen>0) + { + i=osdeditcursor; + while (i>0 && osdeditbuf[i-1]==32) i--; + while (i>0 && osdeditbuf[i-1]!=32) i--; + if (osdeditcursor= 32) // text char + { + if (!osdovertype && osdeditlen == EDITLENGTH) // buffer full, can't insert another char + return 0; + + if (!osdovertype) + { + if (osdeditcursor < osdeditlen) + Bmemmove(osdeditbuf+osdeditcursor+1, osdeditbuf+osdeditcursor, osdeditlen-osdeditcursor); + osdeditlen++; + } + else + { + if (osdeditcursor == osdeditlen) + osdeditlen++; + } + osdeditbuf[osdeditcursor] = ch; + osdeditcursor++; + if (osdeditcursor>osdeditwinend) osdeditwinstart++,osdeditwinend++; + } return 0; } diff --git a/polymer/build/src/sdlayer.c b/polymer/build/src/sdlayer.c index 98627f043..ba5af081f 100644 --- a/polymer/build/src/sdlayer.c +++ b/polymer/build/src/sdlayer.c @@ -1420,9 +1420,11 @@ int handleevents(void) (ev.key.keysym.unicode & 0xff80) == 0 && ((keyasciififoend+1)&(KEYFIFOSIZ-1)) != keyasciififoplc) { - keyasciififo[keyasciififoend] = ev.key.keysym.unicode & 0x7f; - keyasciififoend = ((keyasciififoend+1)&(KEYFIFOSIZ-1)); - OSD_HandleChars(); + if (OSD_HandleChars(ev.key.keysym.unicode & 0x7f)) + { + keyasciififo[keyasciififoend] = ev.key.keysym.unicode & 0x7f; + keyasciififoend = ((keyasciififoend+1)&(KEYFIFOSIZ-1)); + } } // hook in the osd diff --git a/polymer/build/src/winlayer.c b/polymer/build/src/winlayer.c index 54a7600bd..c83af1de7 100644 --- a/polymer/build/src/winlayer.c +++ b/polymer/build/src/winlayer.c @@ -4125,9 +4125,9 @@ static LRESULT CALLBACK WndProcCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPA if (((keyasciififoend+1)&(KEYFIFOSIZ-1)) == keyasciififoplc) return 0; if ((keyasciififoend - keyasciififoplc) > 0) return 0; if (Btolower(scantoasc[osdkey]) == Btolower((unsigned char)wParam)) return 0; + if (!OSD_HandleChar((unsigned char)wParam)) return 0; keyasciififo[keyasciififoend] = (unsigned char)wParam; keyasciififoend = ((keyasciififoend+1)&(KEYFIFOSIZ-1)); - OSD_HandleChars(); //OSD_Printf("WM_CHAR %d, %d-%d\n",wParam,keyasciififoplc,keyasciififoend); return 0;