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

Function curses_map_borders

win/curses/curswins.c:971–1058  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

969based on the location of the player. */
970
971boolean
972curses_map_borders(int *sx, int *sy, int *ex, int *ey, int ux, int uy)
973{
974 static int width = 0;
975 static int height = 0;
976 static int osx = 0;
977 static int osy = 0;
978 static int oex = 0;
979 static int oey = 0;
980 static int oux = -1;
981 static int ouy = -1;
982
983 if ((oux == -1) || (ouy == -1)) {
984 oux = u.ux;
985 ouy = u.uy;
986 }
987
988 if (ux == -1) {
989 ux = oux;
990 } else {
991 oux = ux;
992 }
993
994 if (uy == -1) {
995 uy = ouy;
996 } else {
997 ouy = uy;
998 }
999
1000 curses_get_window_size(MAP_WIN, &height, &width);
1001
1002#ifdef MAP_SCROLLBARS
1003 if (width < COLNO) {
1004 height--; /* room for horizontal scrollbar */
1005 }
1006
1007 if (height < ROWNO) {
1008 width--; /* room for vertical scrollbar */
1009
1010 if (width == COLNO) {
1011 height--;
1012 }
1013 }
1014#endif /* MAP_SCROLLBARS */
1015
1016 if (width >= COLNO) {
1017 *sx = 0;
1018 *ex = COLNO - 1;
1019 } else {
1020 *ex = (width / 2) + ux;
1021 *sx = *ex - (width - 1);
1022
1023 if (*ex >= COLNO) {
1024 *sx = COLNO - width;
1025 *ex = COLNO - 1;
1026 } else if (*sx < 0) {
1027 *sx = 0;
1028 *ex = width - 1;

Callers 3

curses_putchFunction · 0.85
curses_cliparoundFunction · 0.85
curses_move_cursorFunction · 0.85

Calls 1

curses_get_window_sizeFunction · 0.85

Tested by

no test coverage detected