MCPcopy Create free account
hub / github.com/NetHack/NetHack / curses_move_cursor

Function curses_move_cursor

win/curses/cursmisc.c:575–613  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

573/* Move text cursor to specified coordinates in the given NetHack window */
574
575void
576curses_move_cursor(winid wid, int x, int y)
577{
578 int sx, sy, ex, ey;
579 int xadj = 0;
580 int yadj = 0;
581
582#ifndef PDCURSES
583 WINDOW *win = curses_get_nhwin(MAP_WIN);
584#endif
585
586 if (wid != MAP_WIN) {
587 return;
588 }
589#ifdef PDCURSES
590 /* PDCurses seems to not handle wmove correctly, so we use move and
591 physical screen coordinates instead */
592 curses_get_window_xy(wid, &xadj, &yadj);
593#endif
594 curs_x = x + xadj;
595 curs_y = y + yadj;
596 curses_map_borders(&sx, &sy, &ex, &ey, x, y);
597
598 if (curses_window_has_border(wid)) {
599 curs_x++;
600 curs_y++;
601 }
602
603 if (x >= sx && x <= ex && y >= sy && y <= ey) {
604 /* map column #0 isn't used; shift column #1 to first screen column */
605 curs_x -= (sx + 1);
606 curs_y -= sy;
607#ifdef PDCURSES
608 move(curs_y, curs_x);
609#else
610 wmove(win, curs_y, curs_x);
611#endif
612 }
613}
614
615/* update the ncurses stdscr cursor to where the cursor in our map is */
616void

Callers 1

curses_cursFunction · 0.85

Calls 4

curses_get_nhwinFunction · 0.85
curses_get_window_xyFunction · 0.85
curses_map_bordersFunction · 0.85
curses_window_has_borderFunction · 0.85

Tested by

no test coverage detected