188 |
|
|
189 |
static int |
static int |
190 |
calccost (srcy, srcx, dsty, dstx, doit) |
calccost (srcy, srcx, dsty, dstx, doit) |
191 |
|
int srcy, srcx, dsty, dstx, doit; |
192 |
{ |
{ |
193 |
register int deltay, |
register int deltay, |
194 |
deltax, |
deltax, |
224 |
if (doit) |
if (doit) |
225 |
while (--deltay >= 0) |
while (--deltay >= 0) |
226 |
tputs (p, 1, cmputc); |
tputs (p, 1, cmputc); |
227 |
x: |
x: |
228 |
if ((deltax = dstx - srcx) == 0) |
if ((deltax = dstx - srcx) == 0) |
229 |
goto done; |
goto done; |
230 |
if (deltax < 0) { |
if (deltax < 0) { |
235 |
if (Wcm.cc_tab >= BIG || !Wcm.cm_usetabs) |
if (Wcm.cc_tab >= BIG || !Wcm.cm_usetabs) |
236 |
goto olddelta; /* forget it! */ |
goto olddelta; /* forget it! */ |
237 |
|
|
238 |
/* |
/* |
239 |
* ntabs is # tabs towards but not past dstx; n2tabs is one more |
* ntabs is # tabs towards but not past dstx; n2tabs is one more |
240 |
* (ie past dstx), but this is only valid if that is not past the |
* (ie past dstx), but this is only valid if that is not past the |
241 |
* right edge of the screen. We can check that at the same time |
* right edge of the screen. We can check that at the same time |
251 |
if (tab2x >= Wcm.cm_cols) /* too far (past edge) */ |
if (tab2x >= Wcm.cm_cols) /* too far (past edge) */ |
252 |
n2tabs = 0; |
n2tabs = 0; |
253 |
|
|
254 |
/* |
/* |
255 |
* Now set tabcost to the cost for using ntabs, and c to the cost |
* Now set tabcost to the cost for using ntabs, and c to the cost |
256 |
* for using n2tabs, then pick the minimum. |
* for using n2tabs, then pick the minimum. |
257 |
*/ |
*/ |
270 |
if (tabcost >= BIG) /* caint use tabs */ |
if (tabcost >= BIG) /* caint use tabs */ |
271 |
goto newdelta; |
goto newdelta; |
272 |
|
|
273 |
/* |
/* |
274 |
* See if tabcost is less than just moving right |
* See if tabcost is less than just moving right |
275 |
*/ |
*/ |
276 |
|
|
282 |
srcx = tabx; |
srcx = tabx; |
283 |
} |
} |
284 |
|
|
285 |
/* |
/* |
286 |
* Now might as well just recompute the delta. |
* Now might as well just recompute the delta. |
287 |
*/ |
*/ |
288 |
|
|
289 |
newdelta: |
newdelta: |
290 |
if ((deltax = dstx - srcx) == 0) |
if ((deltax = dstx - srcx) == 0) |
291 |
goto done; |
goto done; |
292 |
olddelta: |
olddelta: |
293 |
if (deltax > 0) |
if (deltax > 0) |
294 |
p = Wcm.cm_right, c = Wcm.cc_right; |
p = Wcm.cm_right, c = Wcm.cc_right; |
295 |
else |
else |
296 |
p = Wcm.cm_left, c = Wcm.cc_left, deltax = -deltax; |
p = Wcm.cm_left, c = Wcm.cc_left, deltax = -deltax; |
297 |
|
|
298 |
dodelta: |
dodelta: |
299 |
if (c == BIG) { /* caint get thar from here */ |
if (c == BIG) { /* caint get thar from here */ |
300 |
fail: |
fail: |
301 |
if (doit) |
if (doit) |
306 |
if (doit) |
if (doit) |
307 |
while (--deltax >= 0) |
while (--deltax >= 0) |
308 |
tputs (p, 1, cmputc); |
tputs (p, 1, cmputc); |
309 |
done: |
done: |
310 |
return totalcost; |
return totalcost; |
311 |
} |
} |
312 |
|
|
324 |
|
|
325 |
void |
void |
326 |
cmgoto (row, col) |
cmgoto (row, col) |
327 |
|
int row, col; |
328 |
{ |
{ |
329 |
int homecost, |
int homecost, |
330 |
crcost, |
crcost, |
379 |
dcm = Wcm.cm_abs; |
dcm = Wcm.cm_abs; |
380 |
} |
} |
381 |
|
|
382 |
/* |
/* |
383 |
* In the following comparison, the = in <= is because when the costs |
* In the following comparison, the = in <= is because when the costs |
384 |
* are the same, it looks nicer (I think) to move directly there. |
* are the same, it looks nicer (I think) to move directly there. |
385 |
*/ |
*/ |
400 |
|
|
401 |
switch (use) |
switch (use) |
402 |
{ |
{ |
403 |
case USEHOME: |
case USEHOME: |
404 |
tputs (Wcm.cm_home, 1, cmputc); |
tputs (Wcm.cm_home, 1, cmputc); |
405 |
curY = 0, curX = 0; |
curY = 0, curX = 0; |
406 |
break; |
break; |
407 |
|
|
408 |
case USELL: |
case USELL: |
409 |
tputs (Wcm.cm_ll, 1, cmputc); |
tputs (Wcm.cm_ll, 1, cmputc); |
410 |
curY = Wcm.cm_rows - 1, curX = 0; |
curY = Wcm.cm_rows - 1, curX = 0; |
411 |
break; |
break; |
412 |
|
|
413 |
case USECR: |
case USECR: |
414 |
tputs (Wcm.cm_cr, 1, cmputc); |
tputs (Wcm.cm_cr, 1, cmputc); |
415 |
if (Wcm.cm_autolf) |
if (Wcm.cm_autolf) |
416 |
curY++; |
curY++; |