static vi_key specialKeyFilter( input_buffer *input, vi_key event ) { char *tmp; switch( event ) { case VI_KEY( ALT_O ): case VI_KEY( CTRL_O ): InsertTextForSpecialKey( event, input->buffer ); break; case VI_KEY( CTRL_R ): if( !SelRgn.selected || (SelRgn.lines && (SelRgn.start.line != SelRgn.end.line)) ) { MyBeep(); break; } case VI_KEY( CTRL_W ): case VI_KEY( CTRL_E ): case VI_KEY( ALT_L ): case VI_KEY( CTRL_L ): if( input->curr_pos != strlen( input->buffer ) ) { MyBeep(); } else { tmp = MemAlloc( input->buffer_length ); assert( tmp != NULL ); GetTextForSpecialKey( input->buffer_length - strlen( input->buffer ) - 1, event, tmp ); saveStr( input ); insertString( input, tmp ); MemFree( tmp ); } break; default: return( event ); break; } return( VI_KEY( NULL ) ); } /* specialKeyFilter */
/* * handleKey - handle a key press */ static bool handleKey( HWND hwnd, vi_key key, bool process ) { char tmp[MAX_INPUT_LINE]; switch( key ) { case VI_KEY( ALT_O ): case VI_KEY( CTRL_O ): if( process ) { GetWindowText( hwnd, tmp, sizeof( tmp ) ); InsertTextForSpecialKey( key, tmp ); } break; case VI_KEY( CTRL_R ): if( !SelRgn.selected || (SelRgn.lines && (SelRgn.start.line != SelRgn.end.line)) ) { return( FALSE ); } case VI_KEY( CTRL_W ): case VI_KEY( CTRL_E ): case VI_KEY( ALT_L ): case VI_KEY( CTRL_L ): if( process ) { if( GetTextForSpecialKey( sizeof( tmp ), key, tmp ) ) { insertEditText( hwnd, tmp ); } } break; case VI_KEY( CTRL_INS ): if( process ) { SendMessage( hwnd, EM_UNDO, 0, 0L ); } break; case VI_KEY( UP ): if( process ) { currHist--; if( currHist < 0 || currHist < (hData->curr - hData->max) ) { currHist = hData->curr - 1; } setEditText( hwnd, hData->data[currHist % hData->max] ); } break; case VI_KEY( DOWN ): if( process ) { currHist++; if( currHist >= hData->curr ) { currHist = hData->curr - hData->max; if( currHist < 0 ) { currHist = 0; } } setEditText( hwnd, hData->data[currHist % hData->max] ); } break; case VI_KEY( CTRL_F ): case VI_KEY( CTRL_B ): if( process ) { } break; default: return( FALSE ); } return( TRUE ); } /* handleKey */