void uip_displaybank(int bank) { if (bank == -1) bank = uip_displaybanknum ^ 1; uip_writebank = bank ? uip_bank0 : uip_bank1; if (show_video_bitmap(bank ? uip_bank1 : uip_bank0)) ui_err("Failed to page flip"); uip_uipinfo->screenmem_w = bank ? uip_uipinfo->screenmem0 : uip_uipinfo->screenmem1; uip_displaybanknum = bank; }
void k_winsel(const keyarg_u *a, unsigned repeat, const int from_ch) { enum neighbour dir = pos2dir(&a->pos); window *const curwin = windows_cur(); window *found = NULL; switch(dir){ case neighbour_up: found = curwin->neighbours.above; break; case neighbour_down: found = curwin->neighbours.below; break; case neighbour_left: case neighbour_right: for(found = curwin; found->neighbours.above; found = found->neighbours.above); found = (dir == neighbour_left ? found->neighbours.left : found->neighbours.right); if(!found) break; const int to_match = curwin->screen_coord.y + curwin->ui_pos->y - curwin->ui_start.y; while(found->neighbours.below) { if(found->screen_coord.y <= to_match && to_match <= found->screen_coord.y + found->screen_coord.h) { break; } found = found->neighbours.below; } } if(found && found != curwin){ windows_set_cur(found); ui_redraw(); ui_cur_changed(); }else{ ui_err("no buffers in that direction"); } }
static const motion *motion_read_or_visual(unsigned *repeat, bool apply_maps) { window *win = windows_cur(); if(win->ui_mode & UI_VISUAL_ANY){ static motion visual = { .func = m_visual, .arg.phow = &visual.how }; *repeat = 0; return &visual; } return motion_read(repeat, apply_maps); } void k_prompt_cmd(const keyarg_u *arg, unsigned repeat, const int from_ch) { char *initial = NULL; char initial_buf[32]; window *win = windows_cur(); if(win->ui_mode & UI_VISUAL_ANY){ int y1 = 1 + win->ui_pos->y; int y2 = 1 + window_uipos_alt(win)->y; if(y2 < y1){ int tmp = y1; y1 = y2; y2 = tmp; } snprintf(initial_buf, sizeof initial_buf, "%d,%d", y1, y2); initial = initial_buf; } char *const cmd = prompt(from_ch, initial); if(!cmd) goto cancel_cmd; const cmd_t *cmd_f; char **argv; int argc; bool force; struct range rstore, *range = &rstore; if(parse_ranged_cmd( cmd, &cmd_f, &argv, &argc, &force, &range)) { cmd_dispatch(cmd_f, argc, argv, force, range); } else { ui_err("unknown command %s", cmd); } free_argv(argv, argc); cancel_cmd: free(cmd); }