void line_edit_control::on_key_hold( int dik ) { update_bufs(); switch ( dik ) { case DIK_TAB: case DIK_LSHIFT: case DIK_RSHIFT: case DIK_LCONTROL: case DIK_RCONTROL: case DIK_LALT: case DIK_RALT: return; break; } if ( m_repeat_mode && m_last_key_time > 5.0f * g_console_sensitive ) { float buf_time = m_rep_time; m_hold_mode = true; on_key_press( dik ); m_hold_mode = false; m_rep_time = buf_time; } }
bool window::dispatch_event ( XEvent& evt ) { switch ( evt.type ) { case Expose: exposed(); break; case ButtonPress: if ( evt.xbutton.button & Button2 ) on_right_button_down ( evt.xbutton.x, evt.xbutton.y ); else if ( evt.xbutton.button & Button1 ) on_left_button_down ( evt.xbutton.x, evt.xbutton.y ); break; case ButtonRelease: if ( evt.xbutton.button & Button2 ) on_right_button_up ( evt.xbutton.x, evt.xbutton.y ); else if ( evt.xbutton.button & Button1 ) on_left_button_up ( evt.xbutton.x, evt.xbutton.y ); break; case EnterNotify: on_mouse_enter ( evt.xcrossing.x, evt.xcrossing.y ); break; case LeaveNotify: on_mouse_exit ( evt.xcrossing.x, evt.xcrossing.y ); break; case MotionNotify: on_mouse_move ( evt.xmotion.x, evt.xmotion.y ); break; case FocusIn: on_got_focus(); break; case FocusOut: on_lost_focus(); break; case KeyPress: case KeyRelease: { character cp; KeySym keysym; XComposeStatus status; int count = XLookupString ( &evt.xkey, cp.text, character::MAX_CHAR_TEXT, &keysym, &status ); cp.text[count] = 0; if ( evt.type == KeyPress ) on_key_press ( cp ); else on_key_release ( cp ); } break; case MapNotify: state = WINDOW_SHOWN; shown(); break; case UnmapNotify: state = WINDOW_HIDDEN; hidden(); break; case ConfigureNotify: //XClearWindow ( env, hwnd ); //XFlush ( env ); position_changed(); break; case ClientMessage: { if ( atomDelete == (Atom)evt.xclient.data.l[0] ) destroy(); break; } } return true; }
int main(int argc, char* argv[]) { char c; bNeedUpdate = true; bTickMode = false; bDefMode = false; bRandomMode = false; bCnMode = false; bQuit = false; eScrType = scr_list; iCurrIndex = 0; setlocale(LC_ALL, ""); if (argc < 2) { std::cout << "Please input the file name!" << std::endl; return 0; } else if (argc > 2) { //command line mode int mpos;//pos for -m int opos;//pos for -o QStringList ParamList; QString Object; QString Tmp; bool mfound = false, ofound = false; for (int i = 1; i < argc; ++i) { Tmp = argv[i]; if (Tmp == "-m") { mfound = true; } else if (Tmp == "-o") { if (++i < argc) { ofound = true; Object = argv[i]; } } else { ParamList.push_back(QString(argv[i])); } } if (!mfound) { std::cout << "Too many file names. Use -m if you mean to merge these files." << std::endl; return 0; } else if (!ofound) { std::cout << "Use -o to specify a target file." << std::endl; return 0; } for (int i = 0; i < ParamList.size(); ++i) { load_file_to_vec(word_vec, ParamList[i]); merge_vec_to_file(word_vec, Object); clear_vecs(); } return 1; } //save the file name; file_name = argv[1]; //Handle the resize event signal(SIGWINCH, do_resize); //init the new word vector load_file_to_vec(word_vec, argv[1]); init_seq(); setlocale(LC_ALL, ""); //init the screen initscr(); noecho(); curs_set(0); start_color(); //init highlight color; use_default_colors(); init_pair(1, COLOR_GREEN, -1); //init bottom line color; init_pair(2, COLOR_BLUE, -1); timeout(500); //set getch() to non-block mode, timeout is 0.5 sec. while(!bQuit) { if (bNeedUpdate) { update_screen(); bNeedUpdate = false; } c = getch(); if (c != ERR) { bNeedUpdate = on_key_press(c); } } save_vec_to_file(word_vec, argv[1]); //release resourse clear_vecs(); endwin(); curs_set(1); return 0; }