(entryPtr, x)
| 1360 | * |
| 1361 | * Given a y-coordinate (presumably of the curent mouse location) |
| 1362 | * drag the view in the window to implement the scan operation. |
| 1363 | * |
| 1364 | * Results: |
| 1365 | * None. |
| 1366 | * |
| 1367 | * Side effects: |
| 1368 | * The view in the window may change. |
| 1369 | * |
| 1370 | *---------------------------------------------------------------------- |
| 1371 | */ |
| 1372 | |
| 1373 | static void |
| 1374 | EntryScanTo(entryPtr, x) |
| 1375 | register Entry *entryPtr; /* Information about widget. */ |
| 1376 | int x; /* X-coordinate to use for scan |
| 1377 | * operation. */ |
| 1378 | { |
| 1379 | int newLeftIndex; |
| 1380 | |
| 1381 | /* |
| 1382 | * Compute new leftIndex for entry by amplifying the difference |
| 1383 | * between the current position and the place where the scan |
| 1384 | * started (the "mark" position). If we run off the left or right |
| 1385 | * side of the entry, then reset the mark point so that the current |
| 1386 | * position continues to correspond to the edge of the window. |
| 1387 | * This means that the picture will start dragging as soon as the |
| 1388 | * mouse reverses direction (without this reset, might have to slide |
| 1389 | * mouse a long ways back before the picture starts moving again). |
| 1390 | */ |
| 1391 | |
| 1392 | newLeftIndex = entryPtr->scanMarkIndex |
| 1393 | - (10*(x - entryPtr->scanMarkX))/entryPtr->avgWidth; |
| 1394 | if (newLeftIndex >= entryPtr->numChars) { |
| 1395 | newLeftIndex = entryPtr->scanMarkIndex = entryPtr->numChars-1; |
| 1396 | entryPtr->scanMarkX = x; |
| 1397 | } |
| 1398 | if (newLeftIndex < 0) { |
| 1399 | newLeftIndex = entryPtr->scanMarkIndex = 0; |
no test coverage detected