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

Function curses_draw_map

win/curses/curswins.c:862–947  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

860boundaries */
861
862void
863curses_draw_map(int sx, int sy, int ex, int ey)
864{
865 int curx, cury;
866 int bspace = 0;
867
868#ifdef MAP_SCROLLBARS
869 int sbsx, sbsy, sbex, sbey, count;
870 nethack_char hsb_back, hsb_bar, vsb_back, vsb_bar;
871#endif
872
873 if (curses_window_has_border(MAP_WIN)) {
874 bspace++;
875 }
876#ifdef MAP_SCROLLBARS
877 hsb_back.ch = '-';
878 hsb_back.color = SCROLLBAR_BACK_COLOR;
879 hsb_back.framecolor = NO_COLOR;
880 hsb_back.attr = A_NORMAL;
881 hsb_back.unicode_representation = NULL;
882 hsb_bar.ch = '*';
883 hsb_bar.color = SCROLLBAR_COLOR;
884 hsb_bar.framecolor = NO_COLOR;
885 hsb_bar.attr = A_NORMAL;
886 hsb_bar.unicode_representation = NULL;
887 vsb_back.ch = '|';
888 vsb_back.color = SCROLLBAR_BACK_COLOR;
889 vsb_back.framecolor = NO_COLOR;
890 vsb_back.attr = A_NORMAL;
891 vsb_back.unicode_representation = NULL;
892 vsb_bar.ch = '*';
893 vsb_bar.color = SCROLLBAR_COLOR;
894 vsb_bar.framecolor = NO_COLOR;
895 vsb_bar.attr = A_NORMAL;
896 vsb_bar.unicode_representation = NULL;
897
898 /* Horizontal scrollbar */
899 if (sx > 0 || ex < (COLNO - 1)) {
900 sbsx = (int) (((long) sx * (long) (ex - sx + 1)) / (long) COLNO);
901 sbex = (int) (((long) ex * (long) (ex - sx + 1)) / (long) COLNO);
902
903 if (sx > 0 && sbsx == 0)
904 ++sbsx;
905 if (ex < COLNO - 1 && sbex == COLNO - 1)
906 --sbex;
907
908 for (count = 0; count < sbsx; count++) {
909 write_char(mapwin, count + bspace, ey - sy + 1 + bspace, hsb_back);
910 }
911 for (count = sbsx; count <= sbex; count++) {
912 write_char(mapwin, count + bspace, ey - sy + 1 + bspace, hsb_bar);
913 }
914 for (count = sbex + 1; count <= (ex - sx); count++) {
915 write_char(mapwin, count + bspace, ey - sy + 1 + bspace, hsb_back);
916 }
917 }
918
919 /* Vertical scrollbar */

Callers 1

curses_cliparoundFunction · 0.85

Calls 2

curses_window_has_borderFunction · 0.85
write_charFunction · 0.85

Tested by

no test coverage detected