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

Function CountLines

sys/amiga/winamenu.c:1176–1237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1174}
1175
1176long
1177CountLines(winid win)
1178{
1179 int txwd;
1180 amii_menu_item *mip;
1181 char *t;
1182 struct amii_WinDesc *cw;
1183 struct Window *w;
1184 int i, disprow, len;
1185 int col = -1;
1186
1187 if (win == WIN_ERR || !(cw = amii_wins[win]) || !(w = cw->win)) {
1188 panic(winpanicstr, win, "No Window in CountLines");
1189 }
1190
1191 txwd = w->RPort->TxWidth;
1192 if (WINVERS_AMIV) {
1193 if (win == WIN_INVEN) {
1194 cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4
1195 - pictdata.xsize - 3) / txwd;
1196 } else
1197 cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4) / txwd;
1198 } else {
1199 cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4) / txwd;
1200 }
1201
1202 disprow = cw->maxrow;
1203 mip = cw->menu.items;
1204 for (col = i = 0; i < cw->maxrow; ++i) {
1205 t = cw->data[i] + SOFF;
1206 if (cw->type == NHW_MESSAGE && cw->data[i][SEL_ITEM] < 0)
1207 --disprow;
1208 else
1209 col = 0;
1210 while (*t) {
1211 len = strlen(t);
1212 if (col + len > cw->cols)
1213 len = cw->cols - col;
1214 while (len > 0) {
1215 if (!t[len] || t[len] == ' ')
1216 break;
1217 --len;
1218 }
1219 if (len == 0) {
1220 while (*t && *t != ' ') {
1221 t++;
1222 col++;
1223 }
1224 } else {
1225 t += len;
1226 col += len;
1227 }
1228 if (*t) {
1229 while (*t == ' ')
1230 ++t;
1231 col = 0;
1232 ++disprow;
1233 }

Callers 3

DoMenuScrollFunction · 0.85
ReDisplayDataFunction · 0.85
amii_putstrFunction · 0.85

Calls 1

panicFunction · 0.70

Tested by

no test coverage detected