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

Function FindLine

sys/amiga/winamenu.c:1115–1174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1113}
1114
1115long
1116FindLine(winid win, int line)
1117{
1118 int txwd;
1119 char *t;
1120 struct amii_WinDesc *cw;
1121 struct Window *w;
1122 int i, disprow, len;
1123 int col = -1;
1124
1125 if (win == WIN_ERR || !(cw = amii_wins[win]) || !(w = cw->win)) {
1126 panic(winpanicstr, win, "No Window in FindLine");
1127 }
1128 txwd = w->RPort->TxWidth;
1129 if (WINVERS_AMIV) {
1130 if (win == WIN_INVEN) {
1131 cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4
1132 - pictdata.xsize - 3) / txwd;
1133 } else
1134 cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4) / txwd;
1135 } else {
1136 cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4) / txwd;
1137 }
1138
1139 disprow = 0;
1140 for (col = i = 0; line > disprow && i < cw->maxrow; ++i) {
1141 t = cw->data[i] + SOFF;
1142 if (cw->data[i][1] >= 0) {
1143 ++disprow;
1144 col = 0;
1145 }
1146
1147 while (*t) {
1148 len = strlen(t);
1149 if (col + len > cw->cols)
1150 len = cw->cols - col;
1151 while (len > 0) {
1152 if (!t[len] || t[len] == ' ')
1153 break;
1154 --len;
1155 }
1156 if (len == 0) {
1157 while (*t && *t != ' ') {
1158 t++;
1159 col++;
1160 }
1161 } else {
1162 t += len;
1163 col += len;
1164 }
1165 if (*t) {
1166 while (*t == ' ')
1167 ++t;
1168 col = 0;
1169 ++disprow;
1170 }
1171 }
1172 }

Callers 1

DisplayDataFunction · 0.85

Calls 1

panicFunction · 0.70

Tested by

no test coverage detected