void ttext_::copy_selection(const bool mouse) { int length = selection_length_; unsigned start = selection_start_; if(length == 0) { return; } if(length < 0) { length = - length; start -= length; } const wide_string& wtext = utils::string_to_wstring(text_.text()); const std::string& text = utils::wstring_to_string( wide_string(wtext.begin() + start, wtext.begin() + start + length)); copy_to_clipboard(text, mouse); }
static gint set_key_press(GtkWidget* wid, GdkEventKey *event, gpointer data) { if((event->keyval == GDK_Control_L || event->keyval == GDK_Control_R) ) g_object_set_data(G_OBJECT (wid), "ControlKeyPressed", GINT_TO_POINTER(1)); if((event->keyval == GDK_Alt_L || event->keyval == GDK_Alt_R) ) g_object_set_data(G_OBJECT (wid), "ControlKeyPressed", GINT_TO_POINTER(1)); if((event->keyval == GDK_c || event->keyval == GDK_C) ) { gint ControlKeyPressed = GPOINTER_TO_INT(g_object_get_data(G_OBJECT (wid), "ControlKeyPressed")); if(ControlKeyPressed) { /* printf("Copy to clipboard\n");*/ copy_to_clipboard(); } } GTK_WIDGET_GET_CLASS(wid)->key_press_event(wid, event); return TRUE; }
void textbox::handle_event(const SDL_Event& event) { scrollarea::handle_event(event); if(hidden()) return; bool changed = false; const int old_selstart = selstart_; const int old_selend = selend_; //Sanity check: verify that selection start and end are within text //boundaries if(is_selection() && !(size_t(selstart_) <= text_.size() && size_t(selend_) <= text_.size())) { WRN_DP << "out-of-boundary selection\n"; selstart_ = selend_ = -1; } int mousex, mousey; const Uint8 mousebuttons = SDL_GetMouseState(&mousex,&mousey); if(!(mousebuttons & SDL_BUTTON(1))) { grabmouse_ = false; } SDL_Rect const &loc = inner_location(); bool clicked_inside = !mouse_locked() && (event.type == SDL_MOUSEBUTTONDOWN && (mousebuttons & SDL_BUTTON(1)) && point_in_rect(mousex, mousey, loc)); if(clicked_inside) { set_focus(true); } if ((grabmouse_ && (!mouse_locked() && event.type == SDL_MOUSEMOTION)) || clicked_inside) { const int x = mousex - loc.x + text_pos_; const int y = mousey - loc.y; int pos = 0; int distance = x; for(unsigned int i = 1; i < char_x_.size(); ++i) { if(static_cast<int>(yscroll_) + y < char_y_[i]) { break; } // Check individually each distance (if, one day, we support // RTL languages, char_x_[c] may not be monotonous.) if(abs(x - char_x_[i]) < distance && yscroll_ + y < char_y_[i] + line_height_) { pos = i; distance = abs(x - char_x_[i]); } } cursor_ = pos; if(grabmouse_) selend_ = cursor_; update_text_cache(false); if(!grabmouse_ && mousebuttons & SDL_BUTTON(1)) { grabmouse_ = true; selstart_ = selend_ = cursor_; } else if (! (mousebuttons & SDL_BUTTON(1))) { grabmouse_ = false; } set_dirty(); } if(editable_ == false) { return; } //if we don't have the focus, then see if we gain the focus, //otherwise return if(focus(&event) == false) { if (!mouse_locked() && event.type == SDL_MOUSEMOTION && point_in_rect(mousex, mousey, loc)) events::focus_handler(this); return; } if(event.type != SDL_KEYDOWN || focus(&event) != true) { draw(); return; } const SDL_keysym& key = reinterpret_cast<const SDL_KeyboardEvent&>(event).keysym; const SDLMod modifiers = SDL_GetModState(); const int c = key.sym; const int old_cursor = cursor_; if(c == SDLK_LEFT && cursor_ > 0) --cursor_; if(c == SDLK_RIGHT && cursor_ < static_cast<int>(text_.size())) ++cursor_; // ctrl-a, ctrl-e and ctrl-u are readline style shortcuts, even on Macs if(c == SDLK_END || (c == SDLK_e && (modifiers & KMOD_CTRL))) cursor_ = text_.size(); if(c == SDLK_HOME || (c == SDLK_a && (modifiers & KMOD_CTRL))) cursor_ = 0; if((old_cursor != cursor_) && (modifiers & KMOD_SHIFT)) { if(selstart_ == -1) selstart_ = old_cursor; selend_ = cursor_; } if(c == SDLK_BACKSPACE) { changed = true; if(is_selection()) { erase_selection(); } else if(cursor_ > 0) { --cursor_; text_.erase(text_.begin()+cursor_); } } if(c == SDLK_u && (modifiers & KMOD_CTRL)) { // clear line changed = true; cursor_ = 0; text_.resize(0); } if(c == SDLK_DELETE && !text_.empty()) { changed = true; if(is_selection()) { erase_selection(); } else { if(cursor_ < static_cast<int>(text_.size())) { text_.erase(text_.begin()+cursor_); } } } wchar_t character = key.unicode; //movement characters may have a "Unicode" field on some platforms, so ignore it. if(!(c == SDLK_UP || c == SDLK_DOWN || c == SDLK_LEFT || c == SDLK_RIGHT || c == SDLK_DELETE || c == SDLK_BACKSPACE || c == SDLK_END || c == SDLK_HOME || c == SDLK_PAGEUP || c == SDLK_PAGEDOWN)) { if(character != 0) { DBG_G << "Char: " << character << ", c = " << c << "\n"; } if(event.key.keysym.mod & copypaste_modifier) { switch(c) { case SDLK_v: // paste { changed = true; if(is_selection()) erase_selection(); std::string str = copy_from_clipboard(false); //cut off anything after the first newline str.erase(std::find_if(str.begin(),str.end(),utils::isnewline),str.end()); wide_string s = utils::string_to_wstring(str); if(text_.size() < max_size_) { if(s.size() + text_.size() > max_size_) { s.resize(max_size_ - text_.size()); } text_.insert(text_.begin()+cursor_, s.begin(), s.end()); cursor_ += s.size(); } } break; case SDLK_c: // copy { const size_t beg = std::min<size_t>(size_t(selstart_),size_t(selend_)); const size_t end = std::max<size_t>(size_t(selstart_),size_t(selend_)); wide_string ws = wide_string(text_.begin() + beg, text_.begin() + end); std::string s = utils::wstring_to_string(ws); copy_to_clipboard(s, false); } break; } } else { if(character >= 32 && character != 127) { changed = true; if(is_selection()) erase_selection(); if(text_.size() + 1 <= max_size_) { text_.insert(text_.begin()+cursor_,character); ++cursor_; } } } } if(is_selection() && (selend_ != cursor_)) selstart_ = selend_ = -1; //since there has been cursor activity, make the cursor appear for //at least the next 500ms. show_cursor_ = true; show_cursor_at_ = SDL_GetTicks(); if(changed || old_cursor != cursor_ || old_selstart != selstart_ || old_selend != selend_) { text_image_ = NULL; handle_text_changed(text_); } set_dirty(true); }
int filter_or_ignore_text (char *text_to_add, int len, int size, Uint8 channel) { int l, idx; if (len <= 0) return 0; // no point //check for auto receiving #help for (idx = 0; idx < len; idx++) { if (!is_color (text_to_add[idx])) break; } l = len - idx; if (l >= strlen(help_request_str) && text_to_add[idx] == '#' && (strncasecmp (&text_to_add[idx], help_request_str, strlen(help_request_str)) == 0 || strncasecmp (&text_to_add[idx], "#mod chat", 9) == 0)) { auto_open_encyclopedia = 0; } /* DANGER, WILL ROBINSON! The below code should not exist in it's present form. I'd change it, but I'd need access to the server. Simply checking text output (which is used for all sorts of things) for the phrase "Game Date" is very dangerous. Example: what if, in the future, we allow spaces in character names? Someone chooses the name "Game Date" and walks around saying "hi". Everyone's clients in the area interpret this as being a Game Date command. I've made the below code not *as* dangerous. Had a user been able to fake out the below code, previously, it would have caused a buffer overflow in their client if they didn't write in only numbers after it. Now, they won't crash; it'll just be misparsed. General practice recommendation: don't mix server commands with user input. - Karen */ /* ed (ttlanhil): made it check if it's a server colour. still not perfect (this should have been done server-side instead of parsing the date), but safer */ if (from_color_char (text_to_add[0]) == c_green1 && my_strncompare(text_to_add+1,"Game Date", 9)) { //we assume that the server will still send little-endian dd/mm/yyyy... we could make it safer by parsing the format too, but it's simpler to assume const char * const month_names[] = { "Aluwia", "Seedar", "Akbar", "Zartia", "Elandra", "Viasia", "Fruitfall", "Mortia", "Carnelar", "Nimlos", "Chimar", "Vespia" }; const char * const day_names[] = { "1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th", "10th", "11th", "12th", "13th", "14th", "15th", "16th", "17th", "18th", "19th", "20th", "21st", "22nd", "23rd", "24th", "25th", "26th", "27th", "28th", "29th", "30th" }; char new_str[100]; const char *ptr=text_to_add; short unsigned int day=1, month=1, year=0; int offset = 0; while(!isdigit(ptr[offset])) { offset++; if (offset >= sizeof(new_str)) { LOG_ERROR("error (1) parsing date string: %s",text_to_add); //something evil this way comes... return 0; } } ptr += offset; if (sscanf (ptr,"%hu%*[-/]%hu%*[-/]%hu",&day,&month,&year) < 3 || day <= 0 || month <= 0 || day > 30 || month > 12 || year > 9999) { LOG_ERROR("error (2) parsing date string: %s",text_to_add); //something evil this way comes... } else { // only display initial or "#date" user requested date if (!set_date(ptr)) { safe_snprintf(new_str, sizeof(new_str), date_format, day_names[day-1], month_names[month-1], year); LOG_TO_CONSOLE(c_green1, new_str); } //Calculate fraction Big Lunar month (2 conjunction months) less game clock time //Represented in Degrees. skybox_time_d = (SDL_GetTicks()%( 1296000 * 1000 )); skybox_time_d *= 360.0/( 1296000.0 * 1000.0); skybox_time_d = -skybox_time_d; skybox_time_d += 360.0 * (((month%2)*30 + day-1)*360 + game_minute)/21600.0; skybox_update_positions(); return 0; } } if (from_color_char (text_to_add[0]) == c_green1 && my_strncompare(text_to_add+1,"Game Time", 9)) { real_game_second = atoi(&text_to_add[18]); next_second_time = cur_time + 1000; new_second(); } // Check for local messages to be translated into actor movements (contains [somthing]) if (channel == CHAT_LOCAL) { if(parse_text_for_emote_commands(text_to_add, len)) return 0; } if (channel == CHAT_SERVER) { if (my_strncompare(text_to_add+1, "You started to harvest ", 23)) { strncpy(harvest_name, text_to_add+1+23, len-1-23-1); harvest_name[len-1-23-1] = '\0'; harvesting = 1; } else if ((my_strncompare(text_to_add+1, "You stopped harvesting.", 23)) || (my_strncompare(text_to_add+1, "You can't harvest while fighting (duh)!", 39)) || (my_strncompare(text_to_add+1, "You can't do that while trading!", 32)) || (my_strncompare(text_to_add+1, "You are too far away! Get closer!", 33)) || (my_strncompare(text_to_add+1, "You can't harvest here", 22)) || (my_strncompare(text_to_add+1, "You lack the knowledge of ", 26)) || ((my_strncompare(text_to_add+1, "You need to wear ", 17) && strstr(text_to_add, "order to harvest") != NULL)) || ((my_strncompare(text_to_add+1, "You need to have a ", 19) && strstr(text_to_add, "order to harvest") != NULL))) { harvesting = 0; } else if (is_death_message(text_to_add+1)) { // nothing to be done here cause all is done in the test function } else if (my_strncompare(text_to_add+1, "You found ", 10) && strstr(text_to_add+1, " coins.")) { decrement_harvest_counter(atoi(text_to_add+11)); } else if (my_strncompare(text_to_add+1, "Send Item UIDs ", 15)) { if (text_to_add[1+15] == '0') item_uid_enabled = 0; else if (text_to_add[1+15] == '1') item_uid_enabled = 1; printf("item_uid_enabled=%d\n", item_uid_enabled); } else if ((copy_next_LOCATE_ME > 0) && my_strncompare(text_to_add+1, "You are in ", 11)) { char buffer[4096]; switch (copy_next_LOCATE_ME) { case 1: copy_to_clipboard(text_to_add+1); break; case 2: snprintf(buffer, sizeof(buffer), "@My Position: %s", text_to_add + 12); send_input_text_line(buffer, strlen(buffer)); break; } copy_next_LOCATE_ME = 0; return 0; } else if (my_strncompare(text_to_add+1, "You see: ", 9)) { achievements_player_name(text_to_add+10, len-10); } else if (my_strncompare(text_to_add+1, "You just got food poisoned!", 27)) { increment_poison_incidence(); } else if (strstr(text_to_add+1, "aborted the trade.")) { trade_aborted(text_to_add+1); } else if (strstr(text_to_add+1, "Trade session failed")) { trade_aborted(text_to_add+1); } else if (strstr(text_to_add+1, "You have been saved!")) { last_save_time = time(NULL); } } else if (channel == CHAT_LOCAL) { if (harvesting && my_strncompare(text_to_add+1, username_str, strlen(username_str))) { char *ptr = text_to_add+1+strlen(username_str); if (my_strncompare(ptr, " found a ", 9)) { ptr += 9; if (my_strncompare(ptr, "bag of gold, getting ", 21)) { decrement_harvest_counter(atoi(ptr+21)); } else if (!strstr(ptr, " could not carry ")) { decrement_harvest_counter(1); } } } else if (my_strncompare(text_to_add+1, "(*) ", 4)) { increment_summon_counter(text_to_add+1+4); if (summoning_filter) return 0; } } /* check for misc counter strings */ catch_counters_text(text_to_add+1); /* put #mpm in a popup box, on top of all else */ if ((channel == CHAT_MODPM) && (my_strncompare(text_to_add+1, "[Mod PM from", 12))) { display_server_popup_win(text_to_add); } //Make sure we don't check our own messages. if( !(channel == CHAT_PERSONAL && len >= strlen(pm_from_str) && strncasecmp (text_to_add+1, pm_from_str, strlen(pm_from_str)) != 0) && !(channel == CHAT_MODPM && len >= strlen(mod_pm_from_str) && strncasecmp (text_to_add+1, mod_pm_from_str, strlen(mod_pm_from_str)) != 0) ) { //check if ignored - pre_check_if_ignored() checks for Mod PM's etc to not ignore (or it would be asking for trouble) if (pre_check_if_ignored (text_to_add, len, channel)) { return 0; } //All right, we do not ignore the person if (afk) { if (channel == CHAT_PERSONAL || channel == CHAT_MODPM) { // player sent us a PM add_message_to_pm_log (text_to_add, len, channel); if (afk_snd_warning) { do_afk_sound(); } } else if (channel == CHAT_LOCAL && from_color_char (text_to_add[0]) == c_grey1 && is_talking_about_me (&text_to_add[1], len-1, 0)) { // player mentions our name in local chat if (afk_local) { add_message_to_pm_log (&text_to_add[1], len - 1, channel); if (afk_snd_warning) { do_afk_sound(); } } else { send_afk_message (&text_to_add[1], len - 1, channel); } } else if (channel == CHAT_SERVER) { // check if this was a trade attempt int i; for (i = 1; i < len; i++) { if (text_to_add[i] == ' ' || text_to_add[i] == ':' || is_color (text_to_add[i])) { break; } } if (i < len-15 && strncasecmp (&text_to_add[i], " wants to trade", 15) == 0) { send_afk_message (&text_to_add[1], len - 1, channel); if (afk_snd_warning) { do_afk_sound(); } } } } } else { //We sent this PM or MODPM. Can we expect a reply? int len = 0; char name[MAX_USERNAME_LENGTH]; for(;text_to_add[len+8] != ':' && len < MAX_USERNAME_LENGTH - 1; ++len); safe_strncpy(name, text_to_add+8, len+1); if(check_if_ignored(name)){ char msg[65]; safe_snprintf(msg, sizeof(msg), warn_currently_ignoring, name); LOG_TO_CONSOLE(c_red2, msg); } } // parse for URLs find_all_url (text_to_add, len); // look for buddy-wants-to-add-you messages if(channel == CHAT_SERVER && from_color_char (text_to_add[0]) == c_green1) { for (l = 1; l < len; l++) { if (text_to_add[l] == ' ') break; } if (len - l >= strlen(msg_accept_buddy_str) && strncmp (&text_to_add[l], msg_accept_buddy_str, strlen(msg_accept_buddy_str)) == 0 && l <=32) { char name[32]; int i; int cur_char; /*entropy says: I really fail to understand the logic of that safe_snprintf. And gcc can't understand it either because the name is corrupted. so we implement it the old fashioned way. Grum responds: actually it's the MingW compiler on windows that doesn't understand it, because it doesn't terminate the string when the buffer threatens to overflow. It works fine with gcc on Unix, and using sane_safe_snprintf should also fix it on windows. safe_snprintf (name, l, "%s", &text_to_add[1]); */ for (i = 0; i < sizeof (name); i++) { cur_char = text_to_add[i+1]; name[i] = cur_char; if (cur_char == ' ') { name[i] = '\0'; break; } } add_buddy_confirmation (name); } } // look for astrology messages if((channel == CHAT_SERVER) && is_astrology_message (text_to_add)) { return 0; } // filter any naughty words out return filter_text (text_to_add, len, size); }
void chat_message_list_to_clipboard(int first, int last) { std::ostringstream s; stream_log(s, first, last, true); copy_to_clipboard(s.str(), false); }
/////////////////// // Net Internet frame void Menu_Net_NETFrame(int mouse) { gui_event_t *ev = NULL; std::string addr; // Process & Draw the gui ev = cInternet.Process(); cInternet.Draw( VideoPostProcessor::videoSurface() ); // Process the server list static bool wasLoadedBefore = false; if( SvrList_Process() || (tIpToCountryDB->Loaded() && !wasLoadedBefore) ) { // Add the servers to the listview Menu_Net_NET_ServerList_Refresher(); wasLoadedBefore = tIpToCountryDB->Loaded(); } // Process any events if(ev) { switch(ev->iControlID) { // Add Server case mi_AddServer: if(ev->iEventMsg == BTN_CLICKED) { // Click! PlaySoundSample(sfxGeneral.smpClick); Menu_Net_NETAddServer(); } break; // Back case mi_Back: if(ev->iEventMsg == BTN_CLICKED) { // Shutdown Menu_Net_NETShutdown(); // Click! PlaySoundSample(sfxGeneral.smpClick); // Back to main menu Menu_MainInitialize(); } break; // Refresh case mi_Refresh: if(ev->iEventMsg == BTN_CLICKED) { // Click! PlaySoundSample(sfxGeneral.smpClick); // Refresh the currently visible servers SvrList_RefreshList(); Menu_Net_NET_ServerList_Refresher(); } break; // Join case mi_Join: if(ev->iEventMsg == BTN_CLICKED) { addr = ""; int result = cInternet.SendMessage(mi_ServerList, LVS_GETCURSINDEX, &addr, 0); if(result != -1 && addr != "") { // Save the list SvrList_Save(); // Click! PlaySoundSample(sfxGeneral.smpClick); lv_subitem_t *sub = ((CListview *)cInternet.getWidget(mi_ServerList))->getCurSubitem(1); // Join if (sub) Menu_Net_NETJoinServer(addr,sub->sText); return; } } break; // Serverlist case mi_ServerList: // Double click if(ev->iEventMsg == LV_DOUBLECLK) { /* Now.... Should a double click refresh the server (like tribes)? Or should it join the server like other games??? */ // Just join for the moment addr = ""; int result = cInternet.SendMessage(mi_ServerList, LVS_GETCURSINDEX, &addr, 0); lv_subitem_t *sub = ((CListview *)cInternet.getWidget(mi_ServerList))->getCurSubitem(1); if(result != -1 && addr != "" && sub) { // Save the list SvrList_Save(); Menu_Net_NETJoinServer(addr,sub->sText); return; } } // Right click if( ev->iEventMsg == LV_RIGHTCLK ) { addr = ""; int result = cInternet.SendMessage(mi_ServerList, LVS_GETCURSINDEX, &addr, 0); if(result && addr != "") { // Display a menu szNetCurServer = addr; mouse_t *m = GetMouse(); cInternet.Add( new CMenu(m->X, m->Y), mi_PopupMenu, 0,0, 640,480 ); cInternet.SendMessage( mi_PopupMenu, MNS_ADDITEM, "Delete server", 0 ); cInternet.SendMessage( mi_PopupMenu, MNS_ADDITEM, "Refresh server", 1 ); cInternet.SendMessage( mi_PopupMenu, MNS_ADDITEM, "Join server", 2 ); cInternet.SendMessage( mi_PopupMenu, MNS_ADDITEM, "Add to favourites", 3 ); cInternet.SendMessage( mi_PopupMenu, MNS_ADDITEM, "Send \"I want to join message\"",4 ); cInternet.SendMessage( mi_PopupMenu, MNS_ADDITEM, "Copy IP to clipboard", 5 ); cInternet.SendMessage( mi_PopupMenu, MNS_ADDITEM, "Server details", 6 ); } } // Enter key if( ev->iEventMsg == LV_ENTER ) { // Join addr = ""; int result = cInternet.SendMessage(mi_ServerList, LVS_GETCURSINDEX, &addr, 0); lv_subitem_t *sub = ((CListview *)cInternet.getWidget(mi_ServerList))->getCurSubitem(1); if(result != -1 && addr != "" && sub) { // Save the list SvrList_Save(); Menu_Net_NETJoinServer(addr,sub->sText); return; } } // Delete if( ev->iEventMsg == LV_DELETE ) { addr = ""; int result = cInternet.SendMessage(mi_ServerList, LVS_GETCURSINDEX, &addr, 0); if(result && addr != "") { SvrList_RemoveServer(addr); // Re-Fill the server list Menu_Net_NET_ServerList_Refresher(); } } break; // Popup menu case mi_PopupMenu: switch( ev->iEventMsg ) { // Delete the server case MNU_USER+0: SvrList_RemoveServer(szNetCurServer); break; // Refresh the server case MNU_USER+1: { server_t::Ptr sv = SvrList_FindServerStr(szNetCurServer); if(sv) SvrList_RefreshServer(sv); } break; // Join a server case MNU_USER+2: { // Save the list SvrList_Save(); lv_subitem_t *sub = ((CListview *)cInternet.getWidget(mi_ServerList))->getCurSubitem(1); if (sub) Menu_Net_NETJoinServer(szNetCurServer,sub->sText); } return; // Add server to favourites case MNU_USER+3: { server_t::Ptr sv = SvrList_FindServerStr(szNetCurServer); if (sv) SvrList_AddFavourite(sv->szName,sv->szAddress); } break; // Send a "wants to join" message case MNU_USER+4: { server_t::Ptr sv = SvrList_FindServerStr(szNetCurServer); std::string Nick; cInternet.SendMessage(mi_PlayerSelection, CBS_GETCURNAME, &Nick, 0); if (sv) SvrList_WantsJoin(Nick, sv); } break; // Copy the IP to clipboard case MNU_USER+5: { copy_to_clipboard(szNetCurServer); } break; // Show server details case MNU_USER+6: cInternet.removeWidget(mi_PopupMenu); Menu_Net_NETShowServer(szNetCurServer); break; } // Re-Fill the server list Menu_Net_NET_ServerList_Refresher(); // Remove the menu widget cInternet.SendMessage( mi_PopupMenu, MNM_REDRAWBUFFER, (DWORD)0, 0); cInternet.removeWidget(mi_PopupMenu); break; // Update server list case mi_UpdateList: if(ev->iEventMsg == BTN_CLICKED) { // Click! PlaySoundSample(sfxGeneral.smpClick); Menu_Net_NETUpdateList(); } break; } } // F5 updates the list if (WasKeyboardEventHappening(SDLK_F5)) Menu_Net_NETUpdateList(); // Draw the mouse DrawCursor(VideoPostProcessor::videoSurface()); }
void line_edit_control::cut_to_clipboard() { copy_to_clipboard(); delete_selected_forward(); }
command(TableUI *tui, int cmd) { switch (cmd) { case CmdClearFile: clear_file(tui); break; case CmdOpenFile: clear_and_open(tui, tui->filename); if (row_count(tui->table) < MAX_ROWS_FOR_FIT && max_col_count(tui->table) < MAX_COLS_FOR_FIT) { unsigned i; for (i = 0; i < max_col_count(tui->table); i++) auto_resize_col(tui, i); } break; case CmdSaveFile: save_csv(tui, tui->filename); break; case CmdSetAnchor: set_anchor(tui); break; case CmdClearAnchor: clear_anchor(tui); break; case CmdClearRow: clear_selected_rows(tui); break; case CmdDeleteRow: delete_selected_rows(tui); break; case CmdDeleteCell: delete_selected_cells(tui); break; case CmdClearCell: clear_selected_cells(tui); break; case CmdCopy: copy_to_clipboard(tui); break; case CmdCutClear: copy_to_clipboard(tui); clear_selected_cells(tui); break; case CmdCutDelete: copy_to_clipboard(tui); delete_selected_cells(tui); break; case CmdPaste: clear_anchor(tui); paste_clipboard(tui); break; case CmdReturn: clear_anchor(tui); move_cursor(tui, 1, 0); break; case CmdTab: clear_anchor(tui); move_cursor(tui, 0, 1); break; case CmdUnReturn: clear_anchor(tui); move_cursor(tui, -1, 0); break; case CmdUnTab: clear_anchor(tui); move_cursor(tui, 0, -1); break; case CmdEditCell: start_edit(tui, 1); break; case CmdEditCellClear: start_edit(tui, 0); break; case CmdCommitEdit: end_edit(tui); break; case CmdCancelEdit: cancel_edit(tui); break; case CmdMoveUp: move_cursor(tui, -1, 0); break; case CmdMoveDown: move_cursor(tui, 1, 0); break; case CmdMoveLeft: move_cursor(tui, 0, -1); break; case CmdMoveRight: move_cursor(tui, 0, 1); break; case CmdScrollUp: scroll(tui, -1, 0); break; case CmdScrollDown: scroll(tui, 1, 0); break; case CmdScrollLeft: scroll(tui, 0, -1); break; case CmdScrollRight: scroll(tui, 0, 1); break; case CmdHomeCol: jump_cursor(tui, 0, tui->cur_col); break; case CmdHomeRow: jump_cursor(tui, tui->cur_row, 0); break; case CmdEndCol: jump_cursor(tui, row_count(tui->table) - 1, tui->cur_col); break; case CmdEndRow: jump_cursor(tui, tui->cur_row, col_count(tui->table, tui->cur_row) - 1); break; case CmdInsertDate: insert_datetime(tui, 0); break; case CmdInsertDateTime: insert_datetime(tui, 1); break; case CmdInsertCell: insert_cells(tui->table, tui->cur_row, tui->cur_col, 1); redraw_rows(tui, tui->cur_row, tui->cur_row); break; case CmdInsertRow: insert_rows(tui->table, tui->cur_row, 1); redraw_rows(tui, tui->cur_row, -1); break; case CmdFindColumn: find_cell_text_col(tui, tui->cur_row, tui->cur_col, tui->find_text); break; case CmdFindRow: find_cell_text_row(tui, tui->cur_row, tui->cur_col, tui->find_text); break; } }