/*** Move cursor down/up one page ***/ void pg_updown(Project p, BYTE dir) { LONG newtop = p->top_line, newcrs; if(dir>0) /* One page down */ if(newtop+gui.nbline >= p->max_lines) newcrs = p->max_lines-1; else { newtop += gui.nbline; if(newtop+gui.nbline >= p->max_lines) newtop = p->max_lines - gui.nbline; newcrs = newtop - p->top_line + p->nbl; } else /* One page up */ if(newtop == 0) newcrs=0; else { newtop -= gui.nbline; if(newtop<0) newtop=0; newcrs = newtop - p->top_line + p->nbl; } if(newcrs != p->nbl) inv_curs(p,FALSE),set_cursor_line(p,newcrs,newtop); scroll_xy(p,center_horiz(p),newtop,TRUE); if(p->ccp.select) move_selection(p, p->nbrc, p->nbl); inv_curs(p,TRUE); draw_info( p ); }
/*** Move cursor down ***/ void curs_down(Project p) { LINE *ln; if( ( ln = p->edited->next) ) { LONG newx; BYTE scroll=0; inv_curs(p, FALSE); /* Is the cursor at the bottom of the display? */ if( p->ycurs < gui.botcurs) p->ycurs += YSIZE; else scroll=1; p->nbl++; p->edited=ln; p->nbrc = adjust_rc(ln, p->nbrwc, &p->nbc, FALSE); p->xcurs = (p->nbrc-p->left_pos)*XSIZE + gui.left; /* Minimise calls to scroll_xy */ if((newx=center_horiz(p))!=p->left_pos || scroll) scroll_xy(p, newx, p->top_line+scroll, scroll); /* Update selection */ if(p->ccp.select) move_selection(p, p->nbrc, p->nbl); inv_curs(p, TRUE); draw_info( p ); } }
/*** Jump the cursor far left or far right ***/ void jump_horiz(Project p, BYTE dir) { if( dir >= 0 ) { /* If cursor is already at rightmost position, scroll display */ if( p->nbrwc == p->left_pos+gui.nbcol-1 ) { p->nbrwc += gui.nbcol-1; } else p->nbrwc = p->left_pos+gui.nbcol-1; } else { /* Check if cursor is already at leftmost position */ if( p->nbrwc == p->left_pos ) { p->nbrwc = p->left_pos - (gui.nbcol-1); if( (LONG)p->nbrwc < 0 ) p->nbrwc = 0; } else p->nbrwc = p->left_pos; } inv_curs(p,FALSE); p->nbrc = adjust_rc(p->edited, p->nbrwc, &p->nbc, dir<0); p->xcurs = (p->nbrc-p->left_pos)*XSIZE + gui.left; { LONG newleft = center_horiz( p ); if( newleft != p->left_pos ) scroll_xy(p, newleft, p->top_line, 0); } /* Move selection or cursor? */ if(p->ccp.select) move_selection(p, p->nbrwc, p->nbl); inv_curs(p,TRUE); draw_info( p ); }
/*** Move cursor to absolute position ***/ void move_to_line(Project p, ULONG nbline, char dirtiness) { ULONG newtop; if(!p->ccp.select) inv_curs(p,FALSE); /* Get the new top line */ { register ULONG old_nbl = p->nbl; p->nbl = nbline; newtop = center_vert(p); p->nbl = old_nbl; } set_cursor_line(p, nbline, newtop); if(dirtiness == LINE_AS_IS) scroll_xy(p, center_horiz(p), newtop, TRUE); else { /* Some lines are modified: redraw in one pass */ if( newtop == p->top_line ) { REDRAW_CURLINE(p); if( dirtiness == LINES_DIRTY ) scroll_up(p, p->edited->next, p->ycurs, center_horiz(p)), prop_adj(p); else if( p->left_pos != (newtop = center_horiz(p)) ) scroll_xy(p, newtop, p->top_line, FALSE); } else if( dirtiness == LINE_DIRTY ) scroll_xy(p, center_horiz(p), newtop, TRUE); else set_top_line(p, newtop, center_horiz(p)); } /* Move cursor or selection */ if(p->ccp.select) move_selection(p, p->nbrwc, p->nbl); inv_curs(p,TRUE); draw_info( p ); }
/*** Move cursor up ***/ void curs_up(Project p) { LINE *ln; if( ( ln = p->edited->prev) ) { LONG newx; BYTE scroll=0; inv_curs(p, FALSE); /* Is the cursor on top of display? */ if(p->ycurs > gui.topcurs) p->ycurs -= YSIZE; else scroll=1; p->nbl--; p->edited=ln; p->nbrc = adjust_rc(ln, p->nbrwc, &p->nbc, FALSE); p->xcurs = (p->nbrc-p->left_pos)*XSIZE + gui.left; /* If cursor exits edit area due to horizontal ** ** adjustment, scroll the display accordingly: */ if((newx=center_horiz(p))!=p->left_pos || scroll) scroll_xy(p, newx, p->top_line-scroll, scroll); /* Update selection */ if(p->ccp.select) move_selection(p, p->nbrc, p->nbl); inv_curs(p, TRUE); draw_info( p ); } }
void enter_archive(const char *name, struct_panel *panel, int update_config) { char *saved_work_dir=xgetcwd(NULL); #ifdef debug_printf printf("Entering into '%s'\n", name); #endif (void)chdir(panel->path); /* Переходим в каталог где лежит архив */ if (get_archive_list(name, panel->archive_list)) { char *text; if(update_config) { panel->archive_depth++; strcpy(panel->archive_stack[panel->archive_depth], name); if ( panel == &top_panel ) write_archive_stack("top_panel.archive_stack", &top_panel); else write_archive_stack("bottom_panel.archive_stack", &bottom_panel); (void)chdir(saved_work_dir); /* Переходим в каталог откуда нас дёрнули */ } update(panel); /* Строим список */ move_selection("1", panel); /* Переходим на первый же файл в списке, чтобы не прокручивать */ text=xconcat_path_file(panel->archive_stack[panel->archive_depth],panel->archive_cwd); gtk_label_set_text (GTK_LABEL(panel->path_label), text); /* Пишем имя архива с путём в поле снизу */ free(text); } free(saved_work_dir); }
void leave_archive(struct_panel *panel) { char *iter; TRACE("Leaving archive '%s' to dir '%s'\n",panel->archive_stack[panel->archive_depth], panel->path); panel->archive_depth=panel->archive_depth-1; archive_list_free(panel->archive_list); if (panel->archive_depth > 0) /* Если мы ешё не достигли ФС */ { (void)remove(panel->archive_stack[panel->archive_depth+1]); /* То удаляем архив который покинули - он был вложеным! */ enter_archive(panel->archive_stack[panel->archive_depth], panel, FALSE); } else { update(panel); /* Обновляем список файлов */ gtk_label_set_text (GTK_LABEL(panel->path_label), panel->path); /* Пишем текущий каталог в поле снизу */ } TRACE("move_selection call '%s'\n",panel->archive_stack[panel->archive_depth+1]); iter=iter_from_filename (panel->archive_stack[panel->archive_depth+1], panel); move_selection(iter, panel); /* И выбираем файл архива курсором FIXME: Сработает только если покинутый вложенный архив в корне родительского архива, или же при покидании архива в реальную ФС. FIXME: этот прискорбный баг породит глюки при автоматическом переходе в следующий каталог! */ free(iter); panel->archive_stack[panel->archive_depth+1][0]='\0'; /*Затираем имя покидаемого архива в стеке */ if (panel == &top_panel) { write_archive_stack("top_panel.archive_stack", &top_panel); write_config_string("top_panel.archive_cwd", ""); /* FIXME: По идее надо бы завести ещё и стек путей в архивах, но это геморно( */ } else { write_archive_stack("bottom_panel.archive_stack", &bottom_panel); write_config_string("bottom_panel.archive_cwd", ""); } }
// ---------------------------------------------------------------------- // Move the selection N slots but never stop on a sleeping army // ---------------------------------------------------------------------- void t_army_list_window::move_selection_over_sleepers( int step_size, bool wrap_selection ) { t_army * army = 0; int increment_count = 0; // avoid infinite loops do { army = move_selection( step_size, wrap_selection ); increment_count += step_size; } while( increment_count < m_armies->size() && army->get_sleeping() ); select( 0, m_selected_army - m_first_army ); }
void file_menu::select_file(const std::string& begin_of_filename) { size_t additional_index = is_root(current_dir_) ? 0 : 1; std::vector<std::string>::iterator it; it = std::find_if(dirs_in_current_dir_.begin(), dirs_in_current_dir_.end(), match_begin(begin_of_filename)); if (it != dirs_in_current_dir_.end()) { type_a_head_ = additional_index + it - dirs_in_current_dir_.begin(); move_selection(type_a_head_); return; } additional_index += dirs_in_current_dir_.size(); it = std::find_if(files_in_current_dir_.begin(), files_in_current_dir_.end(), match_begin(begin_of_filename)); if (it != files_in_current_dir_.end()) { type_a_head_ = it - files_in_current_dir_.begin() + additional_index; move_selection(type_a_head_); return; } }
/*** Jump cursor to an absolute position in line (ie: beginning or end) ***/ void horiz_pos( Project p, ULONG newpos ) { if( newpos != p->nbrwc ) { inv_curs(p, FALSE); p->nbrc = adjust_rc(p->edited, p->nbrwc = newpos, &p->nbc, FALSE); scroll_xy(p, center_horiz(p), p->top_line, FALSE); p->xcurs = (p->nbrc-p->left_pos)*XSIZE + gui.left; if(p->ccp.select) move_selection(p, p->nbrwc, p->nbl); inv_curs(p, TRUE); draw_info( p ); } }
int enter_archive(const char *name, struct_panel *panel, int update_config) { char *saved_work_dir=xgetcwd(NULL); TRACE("Entering into '%s'\n", name); if (chdir(panel->path) == -1) /* Переходим в каталог где лежит архив */ { char *message; asprintf(&message, UNABLE_TO_CHANGE_DIRECTORY_TO, panel->path, strerror(errno)); Message(ERROR, message); free (message); return FALSE; } if (access(name, R_OK) == -1 ) { char *message; asprintf(&message, UNABLE_TO_ACCESS_FILE, name, strerror(errno)); Message(ERROR, message); free (message); return FALSE; } int res = FALSE; if (archive_supported(name)) { char *text; if(update_config) { panel->archive_depth++; strcpy(panel->archive_stack[panel->archive_depth], name); if ( panel == &top_panel ) write_archive_stack("top_panel.archive_stack", &top_panel); else write_archive_stack("bottom_panel.archive_stack", &bottom_panel); (void)chdir(saved_work_dir); /* Переходим в каталог откуда нас дёрнули */ } panel->archive_list=archive_list_get(name); update(panel); /* Строим список */ move_selection("0", panel); /* Переходим на первый же файл в списке */ text=xconcat_path_file(panel->archive_stack[panel->archive_depth],panel->archive_cwd); gtk_label_set_text (GTK_LABEL(panel->path_label), text); /* Пишем имя архива с путём в поле снизу */ free(text); res = TRUE; } else { TRACE("Archive is unsupported: %s", name); } free(saved_work_dir); return res; }
static void lightout_post_action(struct module_configuration *mc, cairo_surface_t *cs, enum framework_action action) { const unsigned max_object=BOARD_W*BOARD_H; /* fprintf(stderr, "key = %d\n", action); */ /* check that selection is in range */ if(mc->current_selected_object<0 || (unsigned)mc->current_selected_object>=max_object) { mc->current_selected_object=BOARD_W*BOARD_H/2; /* highlight a default object */ } switch(action) { case ACT_RIGHT: move_selection(mc, 1, 0); break; case ACT_LEFT: move_selection(mc, -1, 0); break; case ACT_UP: move_selection(mc, 0, -1); break; case ACT_DOWN: move_selection(mc, 0, 1); break; case ACT_SELECT: { unsigned x, y; x=mc->current_selected_object%BOARD_W; y=mc->current_selected_object/BOARD_W; lightout_do_move(x, y); break; } case ACT_NONE: ; } lightout_paint(mc, cs); lightout_do_if_win(mc, cs); }
void archive_enter_subdir(const char *subdir, struct_panel *panel) { char *path, *temp; TRACE("archive_enter_subdir '%s'\n", subdir); temp=panel->archive_cwd; panel->archive_cwd=xconcat(temp, subdir); free(temp); if ( panel == &top_panel ) write_config_string("top_panel.archive_cwd", panel->archive_cwd); else write_config_string("bottom_panel.archive_cwd", panel->archive_cwd); update(panel); /* Перерисовываем список */ move_selection("0", panel); /* Выбираем первый элемент */ path=xconcat_path_file(panel->archive_stack[panel->archive_depth], panel->archive_cwd); gtk_label_set_text (GTK_LABEL(panel->path_label), path); /* Пишем имя архива с путём в поле снизу */ free(path); }
/*** Jump the cursor at bottom or top of display ***/ void jump_vert(Project p, BYTE dir) { LONG newline, newtop=p->top_line; if( dir>=0 ) { /* Move cursor to bottom of display or scroll one page if it's already here */ newline=newtop+gui.nbline-1; if( p->nbl==newline ) newline+=gui.nbline, newtop+=gui.nbline; /* Want to jump after the last line? */ if(newline>=p->max_lines) { newline=p->max_lines-1; newtop=(p->top_line + gui.nbline > p->max_lines ? p->top_line : newline-gui.nbline+1); if(newtop<0) newtop=0; } } else { /* Same fight with reverse direction */ newline=newtop; if( p->nbl==newline ) { newtop-=gui.nbline; if(newtop<0) newtop=0; newline=newtop; } } /* Adjust display according to cursor position */ if(newline != p->nbl) { inv_curs(p,FALSE); set_cursor_line(p, newline, newtop); /* Set the selection flags before to scroll display */ if(p->ccp.select) move_selection(p, p->nbrwc, p->nbl); scroll_xy(p,center_horiz(p), newtop, TRUE); inv_curs(p,TRUE); draw_info( p ); } }
/*** One pos right ***/ void curs_right(Project p, BYTE word) { if(p->nbc < p->edited->size) { inv_curs(p,FALSE); if(word) p->nbc = forward_word(p->edited, p->nbc); else p->nbc++; p->nbrwc = p->nbrc = x2pos(p->edited, p->nbc); p->xcurs = (p->nbrc-p->left_pos) * XSIZE + gui.left; /* Move the cursor */ /* Is it gone outside edit area? */ if(p->nbrc>=p->left_pos+gui.nbcol) scroll_xy(p, adjust_leftpos(p, gui.xstep), p->top_line, FALSE); if(p->ccp.select) move_selection(p, p->nbrc, p->nbl); inv_curs(p,TRUE); draw_info( p ); } else if(p->edited->next) { /* jump down to next line */ p->nbrwc = 0; curs_down(p); } }
void archive_go_upper(struct_panel *panel) /* Переходим на уровень выше внутри архива */ { if (panel->archive_cwd[0] == '\0') /* Если на верхнем уровне архива - то покидаем его*/ leave_archive(panel); else /* А если нет - */ { char *slash=NULL, *path, *iter; trim_line(panel->archive_cwd); /* Удяляем последний символ (слэш) из текущего имени */ archive_cwd_prev=xconcat(basename(panel->archive_cwd),"/"); slash=strrchr(panel->archive_cwd, '/'); /* Ищем последний слэш в пути */ if (slash==NULL) /* Если значение пути вырождается в NULL (слэша больше не оказалось) то делаем archive_cwd нулевой строкой*/ panel->archive_cwd[0]='\0'; else /* А иначе просто обрезаем путь в архиве на один уровень */ *(slash+1)='\0'; if (panel == &top_panel) { write_config_string("top_panel.archive_cwd", panel->archive_cwd); top_panel.last_name[0]='\0'; write_config_string("top_panel.last_name", top_panel.last_name); } else { write_config_string("bottom_panel.archive_cwd", panel->archive_cwd); bottom_panel.last_name[0]='\0'; write_config_string("bottom_panel.last_name", bottom_panel.last_name); } update(panel); /* Перерисовываем список */ iter=iter_from_filename (archive_cwd_prev, panel); move_selection(iter, panel); /* И выделяем предыдущий каталог в архиве */ free(iter); path=xconcat_path_file(panel->archive_stack[panel->archive_depth],panel->archive_cwd); gtk_label_set_text (GTK_LABEL(panel->path_label), path); /* Пишем имя архива с путём в поле снизу */ free(path); } }
/*** Move cursor to the left ***/ void curs_left(Project p, BYTE word) { register LINE *prev; if(p->nbc != 0) { inv_curs(p,FALSE); if(word) p->nbc = backward_word(p->edited, p->nbc-1); else p->nbc--; p->nbrwc = p->nbrc = x2pos(p->edited, p->nbc); p->xcurs = (p->nbrc-p->left_pos) * XSIZE + gui.left; /* Is it gone outside edit area? */ if(p->nbrc<p->left_pos) scroll_xy(p, adjust_leftpos(p, -gui.xstep), p->top_line, FALSE); if(p->ccp.select) move_selection(p, p->nbrc, p->nbl); inv_curs(p,TRUE); draw_info( p ); } else if( ( prev = p->edited->prev ) ) { /* jump up */ p->nbrwc = x2pos(prev, prev->size); curs_up(p); } }
int Desktop::handle(int event) { switch(event) { case FL_FOCUS: case FL_UNFOCUS: case FL_SHORTCUT: return 1; case FL_PUSH: { /* * First check where we clicked. If we do it on desktop unfocus any possible focused childs, and handle * specific clicks. Otherwise, do rest for childs. */ Fl_Widget* clicked = Fl::belowmouse(); if(NOT_SELECTABLE(clicked)) { //E_DEBUG(E_STRLOC ": DESKTOP CLICK !!!\n"); if(!selectionbuf.empty()) { /* * Only focused are in selectionbuf, so this is fine to do; also will prevent * full redraw when is clicked on desktop */ unfocus_all(); selectionbuf.clear(); } /* track position so moving can be deduced */ if(Fl::event_button() == 1) { selbox->x = Fl::event_x(); selbox->y = Fl::event_y(); } else if(Fl::event_button() == 3) { last_px = Fl::event_x(); last_py = Fl::event_y(); damage(EDE_DESKTOP_DAMAGE_OVERLAY); const edelib::MenuItem* item = dmenu->menu()->popup(Fl::event_x(), Fl::event_y()); dmenu->picked(item); } return 1; } /* from here, all events are managed for icons */ DesktopIcon* tmp_icon = (DesktopIcon*)clicked; /* do no use assertion on this, since fltk::belowmouse() can miss our icon */ if(!tmp_icon) return 1; if(SELECTION_MULTI) { Fl::event_is_click(0); select(tmp_icon); return 1; } else if(SELECTION_SINGLE) { if(!in_selection(tmp_icon)) { select_only(tmp_icon); } } else if(Fl::event_button() == 3) { select_only(tmp_icon); } /* * Let child handle the rest. * Also prevent click on other mouse buttons during move. */ if(!moving) tmp_icon->handle(FL_PUSH); //E_DEBUG(E_STRLOC ": FL_PUSH from desktop\n"); selection_x = Fl::event_x_root(); selection_y = Fl::event_y_root(); return 1; } case FL_DRAG: moving = true; if(!selectionbuf.empty()) { //E_DEBUG(E_STRLOC ": DRAG icon from desktop\n"); move_selection(Fl::event_x_root(), Fl::event_y_root(), false); } else { //E_DEBUG(E_STRLOC ": DRAG from desktop\n"); /* * Moving is started with pushed button. * From this point selection box is created and is rolled until release */ if(selbox->x != 0 || selbox->y != 0) { selbox->w = Fl::event_x() - selbox->x; selbox->h = Fl::event_y() - selbox->y; selbox->show = true; /* see if there some icons inside selection area */ select_in_area(); /* redraw selection box */ damage(EDE_DESKTOP_DAMAGE_OVERLAY); } } return 1; case FL_RELEASE: //E_DEBUG(E_STRLOC ": RELEASE from desktop\n"); //E_DEBUG(E_STRLOC ": clicks: %i\n", Fl::event_is_click()); if(selbox->show) { selbox->x = selbox->y = selbox->w = selbox->h = 0; selbox->show = false; damage(EDE_DESKTOP_DAMAGE_OVERLAY); /* * Now pickup those who are in is_focused() state. * * Possible flickers due overlay will be later removed when is called move_selection(), which * will in turn redraw icons again after position them. */ if(!selectionbuf.empty()) selectionbuf.clear(); DesktopIcon *o; for(int i = 0; i < children(); i++) { if(NOT_SELECTABLE(child(i))) continue; o = (DesktopIcon*)child(i); if(o->is_focused()) select(o, false); } return 1; } if(!selectionbuf.empty() && moving) move_selection(Fl::event_x_root(), Fl::event_y_root(), true); /* * Do not send FL_RELEASE during move * TODO: should be alowed FL_RELEASE to multiple icons? (aka. run command for all selected icons)? */ if(selectionbuf.size() == 1 && !moving) selectionbuf.front()->handle(FL_RELEASE); moving = false; return 1; case FL_DND_ENTER: case FL_DND_DRAG: case FL_DND_LEAVE: return 1; case FL_DND_RELEASE: { DesktopIcon* di = below_mouse(Fl::event_x(), Fl::event_y()); if(di) return di->handle(event); return 1; } case FL_PASTE: { DesktopIcon* di = below_mouse(Fl::event_x(), Fl::event_y()); if(di) return di->handle(event); return 1; } case FL_ENTER: case FL_LEAVE: case FL_MOVE: return EDE_DESKTOP_WINDOW::handle(event); default: break; } return 0; }
int main() { int ch; initscr(); /* start curses */ raw(); /* disable line buffering */ keypad(stdscr, TRUE); noecho(); start_color(); use_default_colors(); init_pair(10, COLOR_WHITE, COLOR_RED); statuswin = subwin(stdscr, 1, 0, 0, 0); hdrwin = subwin(stdscr, 1, 0, 1, 0); blockpad = newpad(1000, 60); errorw = statuswin; wclear(stdscr); db_connect(); if (db_is_connected()) { reporterror("connected"); rels = db_fetch_relations(&nrels); if (rels) display_relations(hdrwin, blockpad, rels, nrels); } move_selection(0); refresh(); for (;;) { refresh_screen(); ch = getch(); werase(statuswin); wrefresh(statuswin); switch (ch) { case KEY_UP: if (displayed_block != InvalidBlockNumber) scroll_blockpad(-1); else move_selection(-1); break; case KEY_DOWN: if (displayed_block != InvalidBlockNumber) scroll_blockpad(1); else move_selection(1); break; case KEY_NPAGE: if (displayed_block != InvalidBlockNumber) scroll_blockpad(15); else move_selection(15); break; case KEY_PPAGE: if (displayed_block != InvalidBlockNumber) scroll_blockpad(-15); else move_selection(-15); break; case KEY_ENTER: case KEY_RIGHT: if (displayed_block == InvalidBlockNumber) { block = db_fetch_block(rels[selected_rel].relname, "main", 0); if (block) { blockpad_pos_save = blockpad_pos; blockpad_pos = 0; displayed_block = 0; display_block(hdrwin, blockpad, block, displayed_block); } } else { displayed_block++; block = db_fetch_block(rels[selected_rel].relname, "main", displayed_block); if (block) { blockpad_pos_save = blockpad_pos; blockpad_pos = 0; display_block(hdrwin, blockpad, block, displayed_block); } } break; case KEY_LEFT: if (displayed_block != InvalidBlockNumber) { displayed_block--; if (displayed_block == InvalidBlockNumber) { blockpad_pos = blockpad_pos_save; if (displayed_block == InvalidBlockNumber) { display_relations(hdrwin, blockpad, rels, nrels); mvwchgat(blockpad, selected_rel, 0, 40, A_REVERSE, 0, NULL); } } else { block = db_fetch_block(rels[selected_rel].relname, "main", displayed_block); if (block) { blockpad_pos_save = blockpad_pos; blockpad_pos = 0; display_block(hdrwin, blockpad, block, displayed_block); } } } break; case 'g': /* goto block */ if (displayed_block != InvalidBlockNumber) { char str[11]; BlockNumber blkno; char *endptr; werase(hdrwin); mvwprintw(hdrwin, 0, 0, "Goto block: "); refresh_screen(); echo(); getnstr(str, sizeof(str) - 1); noecho(); blkno = strtoul(str, &endptr, 10); if (*endptr != '\0') { werase(hdrwin); mvwprintw(hdrwin, 0, 0, "Invalid block number"); } else { block = db_fetch_block(rels[selected_rel].relname, "main", blkno); if (block) { displayed_block = blkno; blockpad_pos_save = blockpad_pos; blockpad_pos = 0; display_block(hdrwin, blockpad, block, displayed_block); } } } break; case 'q': endwin(); /* End curses mode */ exit(0); break; default: reporterror("unknown key: %c", ch); } } endwin(); /* End curses mode */ return 0; }
/** * e_selection_model_key_press * @selection: #ESelectionModel to affect. * @key: The event. * * This routine does whatever is appropriate as if the user pressed * the given key. * * Returns: %TRUE if the #ESelectionModel used the key. */ gint e_selection_model_key_press (ESelectionModel *selection, GdkEventKey *key) { selection->old_selection = -1; switch (key->keyval) { case GDK_Up: case GDK_KP_Up: return move_selection(selection, TRUE, key->state); case GDK_Down: case GDK_KP_Down: return move_selection(selection, FALSE, key->state); case GDK_space: case GDK_KP_Space: if (selection->mode != GTK_SELECTION_SINGLE) { int row = e_selection_model_cursor_row(selection); int col = e_selection_model_cursor_col(selection); if (row == -1) break; e_selection_model_toggle_single_row (selection, row); g_signal_emit(selection, e_selection_model_signals[CURSOR_ACTIVATED], 0, row, col); return TRUE; } break; case GDK_Return: case GDK_KP_Enter: if (selection->mode != GTK_SELECTION_SINGLE) { int row = e_selection_model_cursor_row(selection); int col = e_selection_model_cursor_col(selection); e_selection_model_select_single_row (selection, row); g_signal_emit(selection, e_selection_model_signals[CURSOR_ACTIVATED], 0, row, col); return TRUE; } break; case GDK_Home: case GDK_KP_Home: if (selection->cursor_mode == E_CURSOR_LINE) { int row = 0; int cursor_col = e_selection_model_cursor_col(selection); row = e_sorter_sorted_to_model(selection->sorter, row); e_selection_model_select_as_key_press (selection, row, cursor_col, key->state); return TRUE; } break; case GDK_End: case GDK_KP_End: if (selection->cursor_mode == E_CURSOR_LINE) { int row = e_selection_model_row_count(selection) - 1; int cursor_col = e_selection_model_cursor_col(selection); row = e_sorter_sorted_to_model(selection->sorter, row); e_selection_model_select_as_key_press (selection, row, cursor_col, key->state); return TRUE; } break; } return FALSE; }