static void handle_key(UCHAR *scan_code, USHORT *key, int up) { //tty *atty=(tty *)current_tty->p_data; *key=(*keymap)[(*scan_code&0x7F)*KEYMAP_STATES+key_state]; if (escape) { if (*key==ALT) altgr=!up; *scan_code|=KEYUP; escape=0; } if (*scan_code==0xE0) escape=1; int i; switch (*key) { case SHIFT: shift=!up; create_key_state(); break; case CTRL: ctrl=!up; create_key_state(); break; case ALT: alt=!up; create_key_state(); break; case CALOCK: shift=!shift; create_key_state(); break; case C('C'): //TODO break; case AF1: case AF2: case AF3: case AF4: case AF5: case AF6: case AF7: case AF8: case AF9: case AF10: case AF11: case AF12: if (!(*scan_code&KEYUP)) { i=((*key)&(~ALT))-0x10; *scan_code|=KEYUP; set_current_tty(i); } *scan_code|=KEYUP; break; } if (*key&0xFF00) *scan_code|=KEYUP; }
void line_edit_control::init( u32 str_buffer_size, init_mode mode ) { m_buffer_size = str_buffer_size; clamp( m_buffer_size, (int)MIN_BUF_SIZE, (int)MAX_BUF_SIZE ); xr_free( m_edit_str ); m_edit_str = (LPSTR)xr_malloc( m_buffer_size * sizeof(char) ); xr_free( m_inserted ); m_inserted = (LPSTR)xr_malloc( m_buffer_size * sizeof(char) ); xr_free( m_undo_buf ); m_undo_buf = (LPSTR)xr_malloc( m_buffer_size * sizeof(char) ); xr_free( m_buf0 ); m_buf0 = (LPSTR)xr_malloc( m_buffer_size * sizeof(char) ); xr_free( m_buf1 ); m_buf1 = (LPSTR)xr_malloc( m_buffer_size * sizeof(char) ); xr_free( m_buf2 ); m_buf2 = (LPSTR)xr_malloc( m_buffer_size * sizeof(char) ); xr_free( m_buf3 ); m_buf3 = (LPSTR)xr_malloc( m_buffer_size * sizeof(char) ); clear_states(); for ( u32 i = 0; i < DIK_COUNT; ++i ) { xr_delete( m_actions[i] ); m_actions[i] = NULL; } if ( mode == im_read_only ) { assign_callback( DIK_A , ks_Ctrl, Callback( this, &line_edit_control::select_all_buf ) ); assign_callback( DIK_C , ks_Ctrl, Callback( this, &line_edit_control::copy_to_clipboard ) ); assign_callback( DIK_INSERT, ks_Ctrl, Callback( this, &line_edit_control::copy_to_clipboard ) ); assign_callback( DIK_HOME , ks_free, Callback( this, &line_edit_control::move_pos_home ) ); assign_callback( DIK_END , ks_free, Callback( this, &line_edit_control::move_pos_end ) ); assign_callback( DIK_LEFT , ks_free, Callback( this, &line_edit_control::move_pos_left ) ); assign_callback( DIK_RIGHT , ks_free, Callback( this, &line_edit_control::move_pos_right ) ); assign_callback( DIK_LEFT , ks_Ctrl, Callback( this, &line_edit_control::move_pos_left_word ) ); assign_callback( DIK_RIGHT , ks_Ctrl, Callback( this, &line_edit_control::move_pos_right_word ) ); } else { assign_char_pairs( mode ); assign_callback( DIK_INSERT, ks_free, Callback( this, &line_edit_control::flip_insert_mode ) ); assign_callback( DIK_A , ks_Ctrl, Callback( this, &line_edit_control::select_all_buf ) ); assign_callback( DIK_Z , ks_Ctrl, Callback( this, &line_edit_control::undo_buf ) ); assign_callback( DIK_C , ks_Ctrl, Callback( this, &line_edit_control::copy_to_clipboard ) ); assign_callback( DIK_V , ks_Ctrl, Callback( this, &line_edit_control::paste_from_clipboard ) ); assign_callback( DIK_X , ks_Ctrl, Callback( this, &line_edit_control::cut_to_clipboard ) ); assign_callback( DIK_INSERT, ks_Ctrl, Callback( this, &line_edit_control::copy_to_clipboard ) ); assign_callback( DIK_INSERT, ks_Shift,Callback( this, &line_edit_control::paste_from_clipboard ) ); assign_callback( DIK_DELETE, ks_Shift,Callback( this, &line_edit_control::cut_to_clipboard ) ); assign_callback( DIK_HOME , ks_free, Callback( this, &line_edit_control::move_pos_home ) ); assign_callback( DIK_END , ks_free, Callback( this, &line_edit_control::move_pos_end ) ); assign_callback( DIK_LEFT , ks_free, Callback( this, &line_edit_control::move_pos_left ) ); assign_callback( DIK_RIGHT , ks_free, Callback( this, &line_edit_control::move_pos_right ) ); assign_callback( DIK_LEFT , ks_Ctrl, Callback( this, &line_edit_control::move_pos_left_word ) ); assign_callback( DIK_RIGHT , ks_Ctrl, Callback( this, &line_edit_control::move_pos_right_word ) ); assign_callback( DIK_BACK , ks_free, Callback( this, &line_edit_control::delete_selected_back ) ); assign_callback( DIK_DELETE, ks_free, Callback( this, &line_edit_control::delete_selected_forward ) ); assign_callback( DIK_BACK , ks_Ctrl, Callback( this, &line_edit_control::delete_word_back ) ); assign_callback( DIK_DELETE, ks_Ctrl, Callback( this, &line_edit_control::delete_word_forward ) ); } // if mode create_key_state( DIK_LSHIFT , ks_LShift ); create_key_state( DIK_RSHIFT , ks_RShift ); create_key_state( DIK_LCONTROL, ks_LCtrl ); create_key_state( DIK_RCONTROL, ks_RCtrl ); create_key_state( DIK_LALT , ks_LAlt ); create_key_state( DIK_RALT , ks_RAlt ); }