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

Function mac_clear_nhwindow

outdated/sys/mac/macwin.c:886–961  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

884}
885
886void
887mac_clear_nhwindow(winid win)
888{
889 long l;
890 Rect r;
891 NhWindow *aWin = &theWindows[win];
892 WindowPtr theWindow = aWin->its_window;
893
894 if (win < 0 || win >= NUM_MACWINDOWS || !theWindow) {
895 error("clr_win: Invalid win %d.", win);
896 return;
897 }
898 if (theWindow == _mt_window) {
899 tty_clear_nhwindow(win);
900 return;
901 }
902 if (!aWin->drawn)
903 return;
904
905 SetPortWindowPort(theWindow);
906 GetWindowBounds(theWindow, kWindowContentRgn, &r);
907 OffsetRect(&r, -r.left, -r.top);
908 if (aWin->scrollBar)
909 r.right -= SBARWIDTH;
910
911 switch (GetWindowKind(theWindow) - WIN_BASE_KIND) {
912 case NHW_MESSAGE:
913 if (aWin->scrollPos
914 == aWin->y_size - 1) /* if no change since last clear */
915 return; /* don't bother with redraw */
916 r.bottom -= SBARHEIGHT;
917 for (l = 0; aWin->y_size > iflags.msg_history;) {
918 const char cr = CHAR_CR;
919 l = Munger(aWin->windowText, l, &cr, 1, nil, 0) + 1;
920 --aWin->y_size;
921 }
922 if (l) {
923 aWin->windowTextLen -= l;
924 BlockMove(*aWin->windowText + l, *aWin->windowText,
925 aWin->windowTextLen);
926 }
927 aWin->last_more_lin = aWin->y_size;
928 aWin->save_lin = aWin->y_size;
929 aWin->scrollPos = aWin->y_size ? aWin->y_size - 1 : 0;
930 break;
931 case NHW_MENU:
932 if (aWin->menuInfo) {
933 DisposeHandle((Handle) aWin->menuInfo);
934 aWin->menuInfo = NULL;
935 }
936 if (aWin->menuSelected) {
937 DisposeHandle((Handle) aWin->menuSelected);
938 aWin->menuSelected = NULL;
939 }
940 aWin->menuChar = 'a';
941 aWin->miSelLen = 0;
942 aWin->miLen = 0;
943 aWin->miSize = 0;

Callers 2

mac_create_nhwindowFunction · 0.85
mac_start_menuFunction · 0.85

Calls 2

tty_clear_nhwindowFunction · 0.85
errorFunction · 0.70

Tested by

no test coverage detected