static void DELETE_A_CHAR(void) { int x, y; getsyx(y, x); x -= 1; mvdelch(y,x); }
void backspace() { noraw(); move(cursor_row,cursor_col-1); delch(); raw(); refresh(); getsyx(cursor_row,cursor_col); }
/* Get the location of the virtual screen cursor */ SCM gucu_getsyx () { int y = 0, x = 0; getsyx (y, x); return (scm_list_2 (scm_from_int (y), scm_from_int (x))); }
void GetCurs(int *x, int *y) { #ifdef UNIX getsyx(*y, *x); #else /* X and Y are zero-based */ *x = wherex() - 1; *y = wherey() - 1; #endif }
void diag(int c) { getsyx(cursor_row,cursor_col); mvprintw(LINES - 9, 0, "row:%d col:%d", cursor_row,cursor_col); mvprintw(LINES - 8, 0, "# tags: %d", num_tags); mvprintw(LINES - 7, 0, "# matches: %d", num_matches); mvprintw(LINES - 6, 0, "sizeof matches: %d", sizeof(matches)); mvprintw(LINES - 5, 0, "current: %s", current); mvprintw(LINES - 4, 0, "current_len: %d", current_length); mvprintw(LINES - 3, 0, "c: %d", c); move(cursor_row,cursor_col); }
int mapgetch() { int x,y; morecount = 0; getsyx(y,x); int cy,cx; getyx(msgwindow,cy,cx); int m = wmove(msgwindow,0,COLS-1); if (m == ERR) beep(); int c = getch(); wmove(msgwindow,cy,cx); setsyx(y,x); return c; }
void get_current() { int c,lc,i=0; raw(); noecho(); keypad(stdscr, TRUE); while ((c=getch())) { if (c == '\t') // Tab { if (showing) tab_hits_down(); else { clrtobot(); if (current_length > 1) { hunt_current(); show_hits(); tab_hits_down(); } } } else if (c == '\n' && lc == '\n') break; // two-returns to quit else if (c == 27) { exiting=1;break;break; } // ESC quit else if (c == 'J' || c == 258) // J | d-arrow down hit list tab_hits_down(); else if (c == 'K' || c == 353 || c == 259) // K | <shift-TAB> | u-arrow up hit list tab_hits_up(); else if (c == 32) // SPACE to reset search { memset(current,'\0',MAX_LINE); current_length = 0; clear_matches(); setup_screen(); mvprintw(LINES - 2, 0, "!: %s", items); move(cursor_row,cursor_col+3); refresh(); i=0; } else if (c == 127 || c == 8) // DELETE or BACKSPACE { if (current_length > 0 ) { i--; current_length--; current[i] = '\0'; clrtobot(); mvprintw(LINES - 2, 0, "!: %s", items); backspace(); move(cursor_row,cursor_col); getsyx(cursor_row,cursor_col); if (showing && current_length > 1) { hunt_current(); show_hits(); tab_hits_down(); } } } else if (c=='\n') // SELECT hightlighted hit or typed word { if (showing && sel_match>-1) strcat(items,tags[matches[sel_match].index]); else strcat(items,current); memset(current,'\0',MAX_LINE); current_length=i=0; setup_screen(); showing=FALSE; strcat(items," "); mvprintw(LINES - 2, 0, "!: %s", items); move(cursor_row,cursor_col+3); refresh(); } else // regular key-typed { addch(c); current[i]=c; ++i; ++current_length; refresh(); getsyx(cursor_row,cursor_col); if (showing && (current_length > 1)) { noraw(); delch(); raw(); refresh(); hunt_current(); show_hits(); tab_hits_down(); } else showing=FALSE; } lc = c; if (diags) diag(c); } current[i] = '\0'; }
int draw_map(struct t_map* map, struct t_map_entity* persp, bool show_vis, bool show_fov, bool show_targets, bool show_heatmaps, bool hl_persp) { int cs = curs_set(0); int x,y; getsyx(y,x); wmove(mapwindow,0,0); for (int iy=0; iy< MAP_HEIGHT; iy++) { for (int ix=0; ix < MAP_WIDTH; ix++) { chtype tilech = mapchar[map->sq[iy*(MAP_WIDTH)+ix].type]; int tilevis = 1; tilevis = map->aidata.p_viewarr[iy * MAP_WIDTH + ix]; if (!show_vis && (tilevis<1)) tilevis = 1; chtype tileflags = 0; switch (tilevis) { case 1: tileflags = CP_BLUE; break; case 2: tileflags = CP_LIGHTGRAY; break; case 3: case 4: tileflags = CP_WHITE; break; default: break; } if (tilevis) mvwaddch(mapwindow,iy,ix, tileflags | tilech ); else if (dbgmode) mvwaddch (mapwindow,iy,ix,' '); } } if (show_heatmaps) { for (int yx=0; yx < HEATMAP_SIZE; yx++) { uint8_t y = yx / MAP_WIDTH; uint8_t x = yx % MAP_WIDTH; uint8_t m = map->aidata.e_hm[yx]; if (m) mvwaddch(mapwindow,y,x,'&' | ( (m > 2) ? CP_RED : ((m == 2) ? CP_GREEN : CP_YELLOW) ) ) ; } } for (int i=0; i < MAX_ENTITIES; i++) { if (map->ent[i].type == ET_NONE) continue; if ((map->ent[i].aidata) != NULL) { if (show_targets) { if (vtile(map->ent[i].aidata->dx,map->ent[i].aidata->dy)) mvwaddch(mapwindow,map->ent[i].aidata->dy,map->ent[i].aidata->dx,'%' | CP_PURPLE); } if (show_fov && (map->aidata.p_viewarr[map->ent[i].y * MAP_WIDTH + map->ent[i].x] >= 3)) { // if we can see the entity, that means we can see what direction it is currently looking at. // the next tile in that direction will be redrawn with a cyan color. uint8_t vx = map->ent[i].x + movediff[map->ent[i].aidata->viewdir][0]; uint8_t vy = map->ent[i].y + movediff[map->ent[i].aidata->viewdir][1]; if (vtile(vx,vy)) { chtype t = mvwinch(mapwindow,vy,vx); // we strip the original character of all previous attributes, // except the "alternate charset" one. chtype fcol = 0; switch(map->ent[i].aidata->task) { case AIT_WORKING: fcol = CP_BLUE; break; case AIT_PATROLLING: fcol = CP_CYAN; break; case AIT_CHECKING_OUT: case AIT_LOOKING_FOR: fcol = CP_YELLOW; break; case AIT_PLEASE_LEAVE: case AIT_PURSUING: case AIT_ATTACKING: fcol = CP_RED; break; case AIT_FLEEING: fcol = CP_MAGENTA; break; default: fcol = CP_GREEN; break; } mvwaddch(mapwindow,vy,vx,(t & (A_ALTCHARSET | A_CHARTEXT)) | fcol); } } } } for (int i= (MAX_ENTITIES - 1); i >= 0; i--) { if (map->ent[i].type == ET_NONE) continue; int ex = map->ent[i].x; int ey = map->ent[i].y; if ( (persp == NULL) || (map->ent[i].flags & EF_ALWAYSVISIBLE) || ((map->aidata.p_viewarr[ey * (MAP_WIDTH) + ex] >= 3) ) ) { int highlight = (hl_persp) && (&map->ent[i] == persp); mvwaddch(mapwindow,ey,ex,entchar(&map->ent[i]) | (highlight ? A_REVERSE : 0) ); } } wnoutrefresh(mapwindow); setsyx(y,x); curs_set(cs); doupdate(); return 0; }