home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume17 / tcleditr / part05 < prev    next >
Encoding:
Text File  |  1992-03-17  |  54.2 KB  |  1,874 lines

  1. Newsgroups: comp.sources.x
  2. Path: uunet!think.com!mips!msi!dcmartin
  3. From: crowley@chaco.cs.unm.edu (Charlie Crowley)
  4. Subject: v17i006: point text editor (TCL and TK), Part05/16
  5. Message-ID: <1992Mar18.141413.26708@msi.com>
  6. Originator: dcmartin@fascet
  7. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  8. Organization: Molecular Simulations, Inc.
  9. References: <csx-17i002-tcl-editor@uunet.UU.NET>
  10. Date: Wed, 18 Mar 1992 14:14:13 GMT
  11. Approved: dcmartin@msi.com
  12.  
  13. Submitted-by: crowley@chaco.cs.unm.edu (Charlie Crowley)
  14. Posting-number: Volume 17, Issue 6
  15. Archive-name: tcl-editor/part05
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then unpack
  19. # it by saving it into a file and typing "sh file".  To overwrite existing
  20. # files, type "sh file -c".  You can also feed this as standard input via
  21. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  22. # will see the following message at the end:
  23. #        "End of archive 4 (of 15)."
  24. # Contents:  buffers.c options.c point.c select.c
  25. #   tclLib/browserMenu.tcl
  26. # Wrapped by crowley@chaco.cs.unm.edu on Tue Mar 10 15:05:38 1992
  27. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  28. if test -f 'buffers.c' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'buffers.c'\"
  30. else
  31. echo shar: Extracting \"'buffers.c'\" \(10361 characters\)
  32. sed "s/^X//" >'buffers.c' <<'END_OF_FILE'
  33. X/* $Header: /nfs/unmvax/faculty/crowley/x/pt/RCS/buffers.c,v 1.6 1992/03/04 17:07:18 crowley Exp crowley $ */
  34. X
  35. X#include <stdio.h>
  36. X#include "pt.h"
  37. X
  38. X#define hashFn(x,y,z) ((13*(x)+(int)((y)&0x7FFF))%(z))
  39. X
  40. X/* the file block buffers */
  41. struct diskBuffer sBuffers[NBUFFERS];
  42. struct diskBuffer *buffers = sBuffers;
  43. char *bufferSpace;
  44. int nextBuffer;        /* the next buffer to reuse */
  45. X
  46. X/* buffer hash tables */
  47. struct diskBuffer *bufHash[NBUFHASH];
  48. X
  49. void
  50. unlink1(bp)
  51. X    register struct diskBuffer *bp;
  52. X{
  53. X    extern struct diskBuffer *bufHash[];
  54. X    
  55. X    int h2;
  56. X    
  57. X    /* unlink it from its old hash chain */
  58. X    if( bp->forwardHash != NULL )
  59. X        bp->forwardHash->backwardHash = bp->backwardHash;
  60. X    if( bp->backwardHash != NULL )
  61. X        bp->backwardHash->forwardHash = bp->forwardHash;
  62. X    else {    /* first in the hash chain */
  63. X        h2 = hashFn(bp->handle, bp->blockNumber, NBUFHASH);
  64. X        bufHash[h2] = bp->forwardHash;
  65. X    }
  66. X}
  67. X
  68. struct diskBuffer *
  69. getBuffer(handle, blockNumber)
  70. X    int handle;
  71. X    int blockNumber;
  72. X{
  73. X    extern char msgBuffer[];
  74. X    extern struct diskBuffer *buffers;
  75. X    extern struct diskBuffer *bufHash[];
  76. X    extern int nextBuffer;
  77. X    extern struct openFile *files;
  78. X    extern int nBuffers;
  79. X    extern int addHandle;
  80. X    extern int debug;
  81. X    extern int maxFiles;
  82. X    extern int hashChainBuffersScanned;
  83. X    extern int buffersRequested;
  84. X    extern int buffersNotFound;
  85. X    extern int buffersInUse;
  86. X    extern int buffersWritten;
  87. X
  88. X    register int i;
  89. X    register struct diskBuffer *bp;
  90. X    int h;
  91. X    unsigned char *fp;
  92. X    unsigned int bufferBits, fileBits;
  93. X
  94. X
  95. X    /* see if the block is already in a buffer */
  96. X    h = hashFn(handle, blockNumber, NBUFHASH);
  97. X    bp = bufHash[h];
  98. X
  99. X    while( bp != NULL ) {
  100. X++hashChainBuffersScanned;
  101. X        if( bp->handle==handle && bp->blockNumber==blockNumber ) {
  102. X            break;
  103. X        }
  104. X        bp = bp->forwardHash;
  105. X    }
  106. X
  107. X++buffersRequested;
  108. X    if( bp == NULL ) {
  109. X++buffersNotFound;
  110. X
  111. X        /* if not, assign it a buffer and fill it with data */
  112. X/* LATER: use LRU buffer replacment instead of FIFO */
  113. X        if( ++nextBuffer >= nBuffers )
  114. X            nextBuffer = 0;
  115. X        bp = &buffers[nextBuffer];
  116. X
  117. X        if( bp->handle != -1 ) {    /* is the buffer in use? */
  118. X++buffersInUse;
  119. X
  120. X            /* unlink it from its old hash chain */
  121. X            unlink1(bp);
  122. X
  123. X            /* Invalidate any possible buffer caches. */
  124. X            bufferBits = (unsigned int)bp->bufferAddress
  125. X                            >> BUFFERSHIFT;
  126. X            for(i = 0; i < maxFiles; i++) {
  127. X                /* get the buffer block number */
  128. X                fileBits = (unsigned int)files[i].logBuf
  129. X                            >> BUFFERSHIFT;
  130. X                /* see if the block numbers match */
  131. X                if( bufferBits == fileBits ) {
  132. X                    /* if so invalidate the cache */
  133. X                    files[i].hiLogBuffer = -1;
  134. X                }
  135. X            }
  136. X
  137. X            /* write the buffer out to disk */
  138. X            if( bp->written ) {
  139. X++buffersWritten;
  140. X                i = lseek(bp->handle,
  141. X                    (bp->blockNumber)<<BUFFERSHIFT, 0);
  142. X                 i = write(bp->handle, bp->bufferAddress,
  143. X                    BUFFERSIZE);
  144. X                if( i < BUFFERSIZE ) {
  145. X                    perror("getBuffer");
  146. X                }
  147. X            }
  148. X        }
  149. X        bp->handle = handle;
  150. X        bp->blockNumber = blockNumber;
  151. X        bp->written = 0;
  152. X
  153. X        /* read in the new buffer contents */
  154. X        lseek(handle, blockNumber<<BUFFERSHIFT, 0);
  155. X        i = read(handle, (char *)(bp->bufferAddress), BUFFERSIZE);
  156. X        /* read zeros for non-existing chararacters */
  157. X        /* this will occur in the add file only */
  158. X        if( i <= 0 ) {
  159. X            if( i < 0 ) {
  160. X                sprintf(msgBuffer,
  161. X"getBuffer: read error, ret=%d, handle=%d", i, handle);
  162. X                msg(msgBuffer, 1);
  163. X            }
  164. X            /* zero out the buffer */
  165. X            fp = bp->bufferAddress;
  166. X            for(i = 0; i < BUFFERSIZE; ++i)
  167. X                *fp++ = '\0';
  168. X        }
  169. X
  170. X        bp->backwardHash = NULL;
  171. X        bp->forwardHash = bufHash[h];
  172. X        if( bufHash[h] != NULL )
  173. X            bufHash[h]->backwardHash = bp;
  174. X        bufHash[h] = bp;
  175. X    }
  176. X#ifdef SELF_ORGANIZING
  177. X    else if( bp->backwardHash != NULL ) {
  178. X        /* make the hash lists self-organizing by moving this */
  179. X        /* buffer header to the front of the list */
  180. X        unlink1( bp );
  181. X        bp->backwardHash = NULL;
  182. X        bp->forwardHash = bufHash[h];
  183. X        if( bufHash[h] != NULL )
  184. X            bufHash[h]->backwardHash = bp;
  185. X        bufHash[h] = bp;
  186. X    }
  187. X#endif
  188. X    return bp;
  189. X}
  190. X
  191. X/*ARGSUSED*/
  192. void
  193. fidInvalid(handle, fid)
  194. X    int handle;
  195. X    int fid;
  196. X{
  197. X    extern struct diskBuffer *buffers;
  198. X    extern int nBuffers;
  199. X    
  200. X    int i;
  201. X
  202. X    /* invalidate the buffer cache */
  203. X    for(i = 0; i < nBuffers; i++)
  204. X        if( buffers[i].handle == handle ) {
  205. X            unlink1(&buffers[i]);
  206. X            buffers[i].handle = -1;
  207. X        }
  208. X}
  209. X
  210. int
  211. getFileByte( fileId, logicalByte )
  212. X    int fileId;
  213. X    Offset logicalByte;
  214. X{
  215. X    extern int getSpanSize;
  216. X    extern int fileBytesRequested;
  217. X    extern char msgBuffer[];
  218. X
  219. X    int n;
  220. X    unsigned char *firstByte, *lastByte;
  221. X
  222. X++fileBytesRequested;
  223. X    n = getSpan(fileId, logicalByte, &firstByte, &lastByte, 0);
  224. X++getSpanSize;
  225. X    if( n != 0 ) {
  226. X        return BLOCK_EOF;
  227. X    } else {
  228. X        return *firstByte;
  229. X    }
  230. X}
  231. X
  232. static unsigned char *firstByte = (unsigned char *)1;
  233. static unsigned char *lastByte = 0;
  234. static Offset logFirstByte = 1;
  235. static int logLength = -1;
  236. static int logN;
  237. X
  238. void
  239. ClearByteCache()
  240. X{
  241. X    logLength = -1;
  242. X}
  243. X
  244. int
  245. getCachedFileByte( fileId, logicalByte )
  246. X    int fileId;
  247. X    Offset logicalByte;
  248. X{
  249. X    extern int getSpanSize;
  250. X    extern int fileBytesRequested;
  251. X    extern char msgBuffer[];
  252. X
  253. X    unsigned char *addr;
  254. X    int offset =  logicalByte - logFirstByte;
  255. X
  256. X    if( offset < logLength ) {
  257. X        addr = firstByte + offset;
  258. X    } else {
  259. X        logN = getSpan(fileId, logicalByte, &firstByte, &lastByte, 0);
  260. X        if( logN ) {
  261. X            logLength = -1;
  262. X            return BLOCK_EOF;
  263. X        }
  264. X        logFirstByte = logicalByte;
  265. X        logLength = lastByte - firstByte + 1;
  266. X        addr = firstByte;
  267. X    }
  268. X    return *addr;
  269. X}
  270. X
  271. int
  272. getSpan( fileId, logicalByte, firstByte, lastByte, reversed )
  273. X    int fileId, reversed;
  274. X    Offset logicalByte;
  275. X    unsigned char * *firstByte;
  276. X    unsigned char * *lastByte;
  277. X{
  278. X    extern char msgBuffer[];
  279. X    extern struct openFile *files;
  280. X    extern int debug;
  281. X    extern int addHandle;
  282. X    extern int getSpansRequested;
  283. X    extern int spansOutOfRange;
  284. X    extern int spansInBufferCache;
  285. X    extern int spansInPieceCache;
  286. X    extern int cacheBufferSizes;
  287. X    extern int trace_file;
  288. X
  289. register struct openFile *ff;
  290. X    struct diskBuffer *buf;
  291. X    Offset physicalByte, blockNumber, nn, bp;
  292. X    int handle;
  293. X    Offset offset;
  294. X    Piece pp;
  295. X
  296. X++getSpansRequested;
  297. X    /* for efficiency, keep some addresses */
  298. X    ff = &files[fileId];
  299. X
  300. X    /* if file is not open print an error message */
  301. X    if( fileId == -1 || ff->origHandle == -1 ) {
  302. X        sprintf(msgBuffer, "getSpan: file %d is not open", fileId);
  303. X        msg(msgBuffer, 1);
  304. X        return 1;
  305. X    }
  306. X
  307. X    /* see if the logical byte number is invalid */
  308. X    if( logicalByte < 0 || logicalByte >= ff->fileSize  ) {
  309. X++spansOutOfRange;
  310. X        return 1;
  311. X    }
  312. X
  313. X    /* check for optimized special cases */
  314. X    if( ff->loLogBuffer<=logicalByte && logicalByte<=ff->hiLogBuffer ) {
  315. X        unsigned char *temp;
  316. X
  317. X++spansInBufferCache;
  318. X        /* if this logical byte is in the buffer cache then set up */
  319. X        /* the addresses using the saved segment and offset fields */
  320. X        temp = ff->logBuf+(unsigned int)(logicalByte-ff->loLogBuffer);
  321. X        if( reversed ) {
  322. X            *firstByte = ff->logBuf;
  323. X            *lastByte = temp;
  324. X        } else {
  325. X            *firstByte = temp;
  326. X            *lastByte = ff->logBuf
  327. X              + (unsigned int)(ff->hiLogBuffer - ff->loLogBuffer);
  328. X        }
  329. X        if( trace_file > 0 ) {
  330. X            sprintf( msgBuffer, "S %2d %5d %5d\n",
  331. X                fileId, logicalByte, *lastByte - *firstByte + 1 );
  332. X            write( trace_file, msgBuffer, strlen(msgBuffer) );
  333. X        }
  334. X
  335. X        return 0;
  336. X    }
  337. X
  338. X    /* see if we already know what piece it is in */
  339. X    /* findPiece checks this but for speed we do it here anyway */
  340. X    /* since getFileByte is on the critical path of performance */
  341. X    if( ff->loLogPiece<=logicalByte && logicalByte<=ff->hiLogPiece ) {
  342. X++spansInPieceCache;
  343. X        pp = ff->logPiece;
  344. X        physicalByte = pp->position + logicalByte - ff->loLogPiece;
  345. X    } else {
  346. X        pp = findPiece(logicalByte, ff, &nn);
  347. X        physicalByte = pp->position + logicalByte - nn;
  348. X        /* remember this piece as the cached piece */
  349. X        ff->logPiece = pp;
  350. X        ff->loLogPiece = nn;
  351. X        ff->hiLogPiece = nn + pp->length - 1;
  352. X    }
  353. X
  354. X    /* get the physical file block containing this character */
  355. X    blockNumber = physicalByte>>BUFFERSHIFT;
  356. X
  357. X    /* use the appropriate handle */
  358. X    handle = pp->file;
  359. X
  360. X    /* get the buffer that this character is in */
  361. X    buf = getBuffer(handle, blockNumber);
  362. X
  363. X    /* figure out how many bytes into the buffer logicalByte is */
  364. X    offset = physicalByte - (blockNumber<<BUFFERSHIFT);
  365. X    *firstByte = buf->bufferAddress + offset;
  366. X
  367. X    /* Remember the logical byte limits in this buffer. */
  368. X
  369. X    /* Is the beginning of the buffer still in this piece? */
  370. X    bp = logicalByte - offset;
  371. X
  372. X    /* bp = logical byte number of the first physical byte in buffer */
  373. X    /* "buf" ASSUMING all of this buffer is in piece "pp".  Now we */
  374. X    /* check this assumption and adjust things if it is false */
  375. X
  376. X    if( bp >= ff->loLogPiece ) {
  377. X        /* the first byte in this buffer is still in the piece */
  378. X        ff->loLogBuffer = bp;
  379. X        ff->logBuf = buf->bufferAddress;
  380. X    } else {
  381. X        /* the piece begins inside the buffer */
  382. X        ff->loLogBuffer = ff->loLogPiece;
  383. X        ff->logBuf = buf->bufferAddress + (ff->loLogPiece - bp);
  384. X    }
  385. X
  386. X    /* Now check if the last physical byte in this buffer is still */
  387. X    /* in piece "pp" */
  388. X
  389. X    /* bp: logical byte at the end of the buffer */
  390. X    bp += (BUFFERSIZE - 1);
  391. X    if( bp <= ff->hiLogPiece ) {
  392. X        /* the last byte of the buffer is in the piece */
  393. X        ff->hiLogBuffer = bp;
  394. X    } else {
  395. X        /* piece ends before the end of the buffer */
  396. X        ff->hiLogBuffer = ff->hiLogPiece;
  397. X    }
  398. X
  399. X    /* handle the special case of reversed spans to support searching */
  400. X    /* backwards */
  401. X    if( reversed ) {
  402. X        /* lastByte points to the logical character argument */
  403. X        *lastByte = *firstByte;
  404. X        /* firstByte points to the beginning of the buffer */
  405. X        *firstByte = ff->logBuf;
  406. X    } else {
  407. X        *lastByte = *firstByte
  408. X            + (unsigned int)(ff->hiLogBuffer - logicalByte);
  409. X    }
  410. cacheBufferSizes += *lastByte - *firstByte + 1;
  411. X
  412. X    if( trace_file > 0 ) {
  413. X        sprintf( msgBuffer, "S %2d %5d %5d\n", fileId, logicalByte,
  414. X                    *lastByte - *firstByte + 1 );
  415. X        write( trace_file, msgBuffer, strlen(msgBuffer) );
  416. X    }
  417. X
  418. X    return 0;
  419. X}
  420. X
  421. void
  422. writeChar(ch, physicalByte)
  423. X    int ch;
  424. X    Offset physicalByte;
  425. X{
  426. X    extern char msgBuffer[];
  427. X    extern struct openFile *files;
  428. X    extern int addHandle;
  429. X    extern int charsWritten;
  430. X
  431. X    struct diskBuffer *buf;
  432. X    int blockNumber;
  433. X    int offset;
  434. X
  435. X++charsWritten;
  436. X    /* get the physical file block containing this character */
  437. X    blockNumber = physicalByte>>BUFFERSHIFT;
  438. X    buf = getBuffer(addHandle, blockNumber);
  439. X
  440. X    /* mark this buffer as written so it will be flushed before */
  441. X    /* it is reused */
  442. X    buf->written = 1;
  443. X
  444. X    /* figure out how many bytes into the buffer physicalByte is */
  445. X    offset = (int)( physicalByte - (blockNumber<<BUFFERSHIFT) );
  446. X
  447. X    /* now store the byte */
  448. X    *(buf->bufferAddress+offset) = (unsigned char)ch;
  449. X}
  450. END_OF_FILE
  451. if test 10361 -ne `wc -c <'buffers.c'`; then
  452.     echo shar: \"'buffers.c'\" unpacked with wrong size!
  453. fi
  454. # end of 'buffers.c'
  455. fi
  456. if test -f 'options.c' -a "${1}" != "-c" ; then 
  457.   echo shar: Will not clobber existing file \"'options.c'\"
  458. else
  459. echo shar: Extracting \"'options.c'\" \(10886 characters\)
  460. sed "s/^X//" >'options.c' <<'END_OF_FILE'
  461. X/* $Header: /nfs/unmvax/faculty/crowley/x/pt/RCS/options.c,v 1.9 1992/03/04 17:07:18 crowley Exp crowley $ */
  462. X
  463. X#include <string.h>
  464. X#include <stdlib.h>
  465. X#include <sys/types.h>
  466. X#include <sys/dir.h>
  467. X#include <setjmp.h>
  468. X#include "pt.h"
  469. X
  470. unsigned char beginMarkerChar = 0xFF;
  471. unsigned char endMarkerChar = 0xFE;
  472. X
  473. X/* some option flags */
  474. int    autoIndent = 1;
  475. int    autoZoom = 0;
  476. int    backupByCopy = 1;
  477. int    backupDepth = 1;
  478. char * backupNameFormat = NULL;
  479. char * browserFont = NULL;
  480. char * browserGeometry = NULL;
  481. char * thinBrowserGeometry = NULL;
  482. int    button1ScrollsDown = 0;
  483. char * copySpriteName = NULL;
  484. char * databaseName = NULL;
  485. int    debug = 0;
  486. int    eofChar = '\1';
  487. char * filePattern = NULL;
  488. int    findWholeWords = 0;
  489. int    helpMode = 0;
  490. int    hypertextOn = 0;
  491. char * iconFormat = NULL;
  492. int    ignoreCase = 1;
  493. int    insertReplaces = 0;
  494. char * keywordPattern = NULL;
  495. int    linesOverFind = 999;
  496. int    maxFiles = 200;
  497. int    menuDelay = 600;
  498. int    menuTolerance = 10;
  499. int    messageFlags = LINE_MSGS;
  500. int    mouseSpriteMenu = 0;
  501. struct mmData mm1Data[5];
  502. struct mmData mm2Data[5];
  503. char * mouseMenuFont = NULL;
  504. int    nBuffers = 100;
  505. int    noBrowser = 0;
  506. int    thinBrowser = 1;
  507. int    overType = 0;
  508. int    pathNames = 0;
  509. int    readOnly = 0;
  510. char * returnString = NULL;
  511. int    rightMargin = 999;
  512. int    showPartialLines = 0;
  513. char * selectedTextBackground = NULL;
  514. char * selectedTextForeground = NULL;
  515. int    showDirsFirst = 1;
  516. int    showSizes = 0;
  517. char * spriteBackground = NULL;
  518. char * spriteForeground = NULL;
  519. char * spriteName = NULL;
  520. int    tabWidth = 8;
  521. char * textBackground = NULL;
  522. char * textFont = NULL;
  523. char * textForeground = NULL;
  524. char * textGeometry = NULL;
  525. char * titleFormat = NULL;
  526. int    tkScrolling = 0;
  527. int    underlineSelection = 0;
  528. int    undoMotion = 0;
  529. int    undoSize = NHISTORY;
  530. int    wrapAroundSearches = 0;
  531. X
  532. X/* option name and type table */
  533. int optionTableSize;
  534. struct optionTableEntry optionTable[] = {
  535. X    {"autoIndent",        (char *)&autoIndent,    T_BOOLEAN},
  536. X    {"autoZoom",        (char *)&autoZoom,    T_BOOLEAN},
  537. X    {"backupByCopy",    (char *)&backupByCopy,    T_BOOLEAN},
  538. X    {"backupDepth",        (char *)&backupDepth,    T_INTEGER},
  539. X    {"backupNameFormat",    (char *)&backupNameFormat,T_STRING},
  540. X    {"browserFont",        (char *)&browserFont,    T_STRING},
  541. X    {"browserGeometry",    (char *)&browserGeometry,T_STRING},
  542. X    {"thinBrowserGeometry",    (char *)&thinBrowserGeometry,T_STRING},
  543. X    {"button1ScrollsDown",    (char *)&button1ScrollsDown,T_BOOLEAN},
  544. X    {"spriteBackground",    (char *)&spriteBackground,T_STRING},
  545. X    {"spriteForeground",    (char *)&spriteForeground,T_STRING},
  546. X    {"copySpriteName",    (char *)©SpriteName,T_STRING},
  547. X    {"spriteName",        (char *)&spriteName,    T_STRING},
  548. X    {"databaseName",    (char *)&databaseName,    T_STRING},
  549. X    {"debug",        (char *)&debug,        T_INTEGER},
  550. X    {"eofChar",        (char *)&eofChar,    T_INTEGER},
  551. X    {"filePattern",        (char *)&filePattern,    T_STRING},
  552. X    {"findWholeWords",    (char *)&findWholeWords,T_BOOLEAN},
  553. X    {"helpMode",        (char *)&helpMode,    T_INTEGER},
  554. X    {"hypertextOn",        (char *)&hypertextOn,    T_BOOLEAN},
  555. X    {"iconFormat",        (char *)&iconFormat,    T_STRING},
  556. X    {"ignoreCase",        (char *)&ignoreCase,    T_BOOLEAN},
  557. X    {"insertReplaces",    (char *)&insertReplaces,T_BOOLEAN},
  558. X    {"keywordPattern",    (char *)&keywordPattern,T_STRING},
  559. X    {"linesOverFind",    (char *)&linesOverFind,    T_INTEGER},
  560. X    {"maxFiles",        (char *)&maxFiles,    T_INTEGER},
  561. X    {"menuDelay",        (char *)&menuDelay,    T_INTEGER},
  562. X    {"menuTolerance",    (char *)&menuTolerance,    T_INTEGER},
  563. X    {"messageFlags",    (char *)&messageFlags,    T_INTEGER},
  564. X    {"mouseSpriteMenu",    (char *)&mouseSpriteMenu,T_BOOLEAN},
  565. X    {"lmm1",        (char *)&(mm1Data[0].label),T_STRING},
  566. X    {"lmm1n",        (char *)&(mm1Data[1].label),T_STRING},
  567. X    {"lmm1e",        (char *)&(mm1Data[2].label),T_STRING},
  568. X    {"lmm1s",        (char *)&(mm1Data[3].label),T_STRING},
  569. X    {"lmm1w",        (char *)&(mm1Data[4].label),T_STRING},
  570. X    {"lmm2",        (char *)&(mm2Data[0].label),T_STRING},
  571. X    {"lmm2n",        (char *)&(mm2Data[1].label),T_STRING},
  572. X    {"lmm2e",        (char *)&(mm2Data[2].label),T_STRING},
  573. X    {"lmm2s",        (char *)&(mm2Data[3].label),T_STRING},
  574. X    {"lmm2w",        (char *)&(mm2Data[4].label),T_STRING},
  575. X    {"cmm1",        (char *)&(mm1Data[0].tcl_command),T_STRING},
  576. X    {"cmm1n",        (char *)&(mm1Data[1].tcl_command),T_STRING},
  577. X    {"cmm1e",        (char *)&(mm1Data[2].tcl_command),T_STRING},
  578. X    {"cmm1s",        (char *)&(mm1Data[3].tcl_command),T_STRING},
  579. X    {"cmm1w",        (char *)&(mm1Data[4].tcl_command),T_STRING},
  580. X    {"cmm2",        (char *)&(mm2Data[0].tcl_command),T_STRING},
  581. X    {"cmm2n",        (char *)&(mm2Data[1].tcl_command),T_STRING},
  582. X    {"cmm2e",        (char *)&(mm2Data[2].tcl_command),T_STRING},
  583. X    {"cmm2s",        (char *)&(mm2Data[3].tcl_command),T_STRING},
  584. X    {"cmm2w",        (char *)&(mm2Data[4].tcl_command),T_STRING},
  585. X    {"mouseMenuFont",    (char *)&mouseMenuFont,    T_STRING},
  586. X    {"nBuffers",        (char *)&nBuffers,    T_INTEGER},
  587. X    {"noBrowser",        (char *)&noBrowser,    T_BOOLEAN},
  588. X    {"thinBrowser",        (char *)&thinBrowser,    T_BOOLEAN},
  589. X    {"overType",        (char *)&overType,    T_BOOLEAN},
  590. X    {"pathNames",        (char *)&pathNames,    T_BOOLEAN},
  591. X    {"readOnly",        (char *)&readOnly,    T_BOOLEAN},
  592. X    {"returnString",        (char *)&returnString,  T_STRING},
  593. X    {"rightMargin",        (char *)&rightMargin,    T_INTEGER},
  594. X    {"selectedTextBackground",(char *)&selectedTextBackground,T_STRING},
  595. X    {"selectedTextForeground",(char *)&selectedTextForeground,T_STRING},
  596. X    {"showDirsFirst",    (char *)&showDirsFirst,    T_BOOLEAN},
  597. X    {"showPartialLines",    (char *)&showPartialLines,T_BOOLEAN},
  598. X    {"showSizes",        (char *)&showSizes,    T_BOOLEAN},
  599. X    {"tabWidth",        (char *)&tabWidth,    T_INTEGER},
  600. X    {"textBackground",    (char *)&textBackground,T_STRING},
  601. X    {"textForeground",    (char *)&textForeground,T_STRING},
  602. X    {"textFont",        (char *)&textFont,    T_STRING},
  603. X    {"textGeometry",    (char *)&textGeometry,    T_STRING},
  604. X    {"titleFormat",        (char *)&titleFormat,    T_STRING},
  605. X    {"tkScrolling",        (char *)&tkScrolling,    T_BOOLEAN},
  606. X    {"underlineSelection",    (char *)&underlineSelection,T_INTEGER},
  607. X    {"undoMotion",        (char *)&undoMotion,    T_BOOLEAN},
  608. X    {"undoSize",        (char *)&undoSize,    T_INTEGER},
  609. X    {"wrapAroundSearches",    (char *)&wrapAroundSearches,T_BOOLEAN},
  610. X    {"zzzzzzzz",        NULL,            T_END_OF_TABLE}
  611. X};
  612. X
  613. static int
  614. XFindOptionInTable( s )
  615. X    char *s;
  616. X{
  617. X    extern struct optionTableEntry optionTable[];
  618. X    extern int optionTableSize;
  619. X
  620. X    int i, low, high, mid;
  621. X
  622. X    /* use a binary search on the option table */
  623. X    low = 0;
  624. X    high = optionTableSize - 1;
  625. X    while( low <= high ) {
  626. X        /* item in range low..high or not in optionTable */
  627. X        mid = (high+low)/2;
  628. X        i = striccmp( optionTable[mid].option_name, s );
  629. X        if( i == 0 )
  630. X            return mid;
  631. X        if( i < 0 )
  632. X            low = mid + 1;
  633. X        else
  634. X            high = mid - 1;
  635. X    }
  636. X    return -1;    /* failure return */
  637. X}
  638. X
  639. char *
  640. GetPointOption( name )
  641. X    char * name;
  642. X{
  643. X    extern char msgBuffer[];
  644. X
  645. X    int i;
  646. X
  647. X    i = FindOptionInTable( name );
  648. X
  649. X    if( i == -1 ) {
  650. X        printf("GetPointOption: (%s) is not a known Point option\n",
  651. X                                name);
  652. X        sprintf( msgBuffer, "UnknownPointOption(%s)", name);
  653. X        return msgBuffer;
  654. X    }
  655. X
  656. X    switch( optionTable[i].option_type ) {
  657. X    case T_END_OF_TABLE:
  658. X        printf("%s is not a valid point option\n", name);
  659. X        break;
  660. X    case T_STRING:
  661. X        sprintf( msgBuffer, "%s",
  662. X                *(char **)optionTable[i].option_address );
  663. X        return msgBuffer;
  664. X    case T_BOOLEAN:
  665. X    case T_INTEGER:
  666. X        sprintf( msgBuffer, "%d",
  667. X                *(int *)(optionTable[i].option_address) );
  668. X        return msgBuffer;
  669. X    }
  670. X}
  671. X
  672. X
  673. void
  674. SetPointOption( name, value )
  675. X    char * name;
  676. X    char * value;
  677. X{
  678. X    extern BrowserData *activeBrowser;
  679. X
  680. X    int i, n;
  681. X    char * p;
  682. X    char * option_address;
  683. X
  684. X    i = FindOptionInTable( name );
  685. X    if( i == -1 ) {
  686. X        printf("SetPointOption: (%s) is not a known Point option\n",
  687. X                            name);
  688. X        return;
  689. X    }
  690. X
  691. X    option_address = optionTable[i].option_address;
  692. X
  693. X    switch( optionTable[i].option_type ) {
  694. X    case T_END_OF_TABLE:
  695. X        printf("%s is not a valid point option\n", name);
  696. X        break;
  697. X    case T_STRING:
  698. X        p = (char *)PtMalloc( strlen(value)+1, "option string" );
  699. X        if( p == NULL ) { printf("OUT OF SPACE!!\n"); break; }
  700. X        strcpy( p, value );
  701. X        PtFree( *(char **)option_address );
  702. X        *(char **)option_address = p;
  703. X        break;
  704. X    case T_BOOLEAN:
  705. X        n = atoi( value );
  706. X        if( striccmp(value,"true")==0 )
  707. X            n = 1;
  708. X        *(int *)option_address = n;
  709. X        break;
  710. X    case T_INTEGER:
  711. X        *(int *)option_address = atoi( value );
  712. X        break;
  713. X    }
  714. X    
  715. X    /* special processing is required for some changes */
  716. X    if( strcmp(optionTable[i].option_name,"filePattern")==0 ) {
  717. X        NewFilelist( activeBrowser );
  718. X    }
  719. X}
  720. X
  721. static int
  722. optionTableCompare( i, j )
  723. X        char *i, *j;
  724. X{
  725. X        return striccmp( ((struct optionTableEntry *)i)->option_name,
  726. X                    ((struct optionTableEntry *)j)->option_name );
  727. X}
  728. X
  729. X/*SUPPRESS 544*/ /*SUPPRESS 68*/
  730. X
  731. void
  732. InitOptions()
  733. X{
  734. X        /* sort the options table for easy lookup */
  735. X        /* first see how big it is */
  736. X        for( optionTableSize = 0;
  737. X                optionTable[optionTableSize].option_type != T_END_OF_TABLE;
  738. X                ++optionTableSize)
  739. X                        /*EMPTY*/
  740. X                        ;
  741. X
  742. X        /* then sort it with qsort */
  743. X        qsort( (char *)optionTable, optionTableSize,
  744. X            sizeof(struct optionTableEntry), 
  745. X            optionTableCompare);
  746. X
  747. X    if( nBuffers < 25 )
  748. X        nBuffers = 25;
  749. X    else if( nBuffers > NBUFFERS )
  750. X        nBuffers = NBUFFERS;
  751. X
  752. X    SetPointOption( "backupNameFormat",    "%n.%v" );
  753. X    SetPointOption( "browserFont",        "fixed" );
  754. X    SetPointOption( "spriteBackground",    "white" );
  755. X    SetPointOption( "spriteForeground",    "black" );
  756. X    SetPointOption( "spriteName",        "left_ptr" );
  757. X    SetPointOption( "copySpriteName",    "hand1" );
  758. X    SetPointOption( "databaseName",        "anadoc" );
  759. X    SetPointOption( "textFont",        "fixed" );
  760. X    SetPointOption( "textGeometry",        "500x400+0+0" );
  761. X    SetPointOption( "titleFormat",
  762. X        "%n%r. readOnly. [%l-%L]%c. (modified)." );
  763. X    SetPointOption( "iconFormat", "File: %n" );
  764. X    SetPointOption( "browserGeometry",    "490x415+656+0" );
  765. X    SetPointOption( "thinBrowserGeometry",    "140x415+0+0" );
  766. X    SetPointOption( "filePattern",        "*" );
  767. X    SetPointOption( "keywordPattern",    "*.c *.h" );
  768. X
  769. X    SetPointOption( "lmm1",  " Ext" );
  770. X    SetPointOption( "cmm1",  "ExtendSelection" );
  771. X    SetPointOption( "lmm1n", " << " );
  772. X    SetPointOption( "cmm1n", "Search [selection get] backward" );
  773. X    SetPointOption( "lmm1e", "Undo" );
  774. X    SetPointOption( "cmm1e", "Undo" );
  775. X    SetPointOption( "lmm1s", " >> " );
  776. X    SetPointOption( "cmm1s", "Search [selection get] forward" );
  777. X    SetPointOption( "lmm1w", "Again" );
  778. X    SetPointOption( "cmm1w", "Again" );
  779. X
  780. X    SetPointOption( "lmm2",  "Dup " );
  781. X    SetPointOption( "cmm2",  "CopyToHereMode" );
  782. X    SetPointOption( "lmm2n", "Del " );
  783. X    SetPointOption( "cmm2n", "DeleteToScrap" );
  784. X    SetPointOption( "lmm2e", "Copy" );
  785. X    SetPointOption( "cmm2e", "CopySelToMouse" );
  786. X    SetPointOption( "lmm2s", "Ins " );
  787. X    SetPointOption( "cmm2s", "InsertFromScrap" );
  788. X    SetPointOption( "lmm2w", "Move" );
  789. X    SetPointOption( "cmm2w", "MoveSelToMouse" );
  790. X
  791. X    SetPointOption( "mouseMenuFont",      "fixed" );
  792. X    SetPointOption( "selectedTextForeground", "white" );
  793. X    SetPointOption( "selectedTextBackground", "black" );
  794. X    SetPointOption( "textBackground",      "white" );
  795. X    SetPointOption( "textForeground",      "black" );
  796. X    SetPointOption( "returnString",          "" );
  797. X}
  798. END_OF_FILE
  799. if test 10886 -ne `wc -c <'options.c'`; then
  800.     echo shar: \"'options.c'\" unpacked with wrong size!
  801. fi
  802. # end of 'options.c'
  803. fi
  804. if test -f 'point.c' -a "${1}" != "-c" ; then 
  805.   echo shar: Will not clobber existing file \"'point.c'\"
  806. else
  807. echo shar: Extracting \"'point.c'\" \(9314 characters\)
  808. sed "s/^X//" >'point.c' <<'END_OF_FILE'
  809. X/* $Header: /nfs/unmvax/faculty/crowley/x/pt/RCS/point.c,v 1.9 1992/03/04 17:07:18 crowley Exp crowley $ */
  810. X
  811. X#include <setjmp.h>
  812. X#include <sys/types.h>
  813. X#include <sys/time.h>
  814. X#include <sys/file.h>
  815. X#include <string.h>
  816. X#include <time.h>
  817. X#include "pt.h"
  818. X#include <X11/StringDefs.h>
  819. X#include <X11/Xutil.h>
  820. X#include <X11/cursorfont.h>
  821. X#include <X11/Xatom.h>
  822. X#include <stdio.h>
  823. X#ifdef uts
  824. X#include <fcntl.h>
  825. X#endif /* uts */
  826. X#include "tkInt.h"
  827. X#include "tcl.h"
  828. X
  829. X/*SUPPRESS 592*/
  830. static char rcsid[] =
  831. X"$Header: /nfs/unmvax/faculty/crowley/x/pt/RCS/point.c,v 1.9 1992/03/04 17:07:18 crowley Exp crowley $";
  832. X
  833. X/* X stuff */
  834. Display *MainDisplay;
  835. Window MainWindow;
  836. Pixel ptWhitePixel, ptBlackPixel;
  837. Cursor mainCursor;
  838. Cursor dupCursor;
  839. Cursor currentCursor;
  840. Pixmap active_background, inactive_background;
  841. X
  842. X/* display sizes */
  843. int display_width, display_height;
  844. X
  845. X/* to support automatic saving */
  846. long timeOfLastSave;
  847. X
  848. X/* remember directories during getFileName */
  849. char startDirectory[FILENAMESIZE];
  850. char currentDirectory[FILENAMESIZE];
  851. char homeDirectory[FILENAMESIZE];
  852. X
  853. X/* file id for the "pt.msg" command descriptions file */
  854. int descrFileId = -1;
  855. X
  856. X/* text line buffer */
  857. char textBuffer[MSGBUFFERSIZE];
  858. X
  859. X/* message buffer */
  860. char msgBuffer[MSGBUFFERSIZE];
  861. X
  862. int eventCounter = 0;
  863. extern Tcl_Interp * interp;
  864. extern Tk_Window TkMainWindow;
  865. X
  866. int
  867. main(argc, argv)
  868. X    unsigned int argc;
  869. X    char **argv;
  870. X{
  871. X/**************************************************************************/
  872. X/*   Declare the external variables                                       */
  873. X/**************************************************************************/
  874. X    extern struct window *windowList;
  875. X    extern char startDirectory[];
  876. X    extern char currentDirectory[];
  877. X    extern char homeDirectory[];
  878. X    extern struct window *selWindow;
  879. X    extern int addHandle;
  880. X    extern Offset addPosition;
  881. X    extern char backupDir[];
  882. X    extern int descrFileId;
  883. X    extern jmp_buf breakEnv;
  884. X    extern struct menuBlock *menus[];
  885. X    extern int maxFiles;
  886. X    extern struct openFile *files;
  887. X    extern long timeOfLastSave;
  888. X    extern char *tmpnam();
  889. X    extern char *getenv();
  890. X    extern char msgBuffer[];
  891. X    extern struct window *windowList;
  892. X    extern struct window *activeWindow;
  893. X    extern int readOnly;
  894. X    extern int display_width, display_height;
  895. X    extern int debug;
  896. X    extern Pixel ptWhitePixel, ptBlackPixel;
  897. X    extern Cursor currentCursor;
  898. X    extern Cursor mainCursor;
  899. X    extern Cursor dupCursor;
  900. X    extern BrowserData *mainBrowser;
  901. X    extern Display *MainDisplay;
  902. X    extern Window MainWindow;
  903. X    extern int hypertextOn;
  904. X    extern int trace_file;
  905. X    extern char * spriteBackground;
  906. X    extern char * spriteForeground;
  907. X    extern char * copySpriteName;
  908. X    extern char * spriteName;
  909. X    extern char * textGeometry;
  910. X    extern int noBrowser;
  911. X    extern char * returnString;
  912. X
  913. X/**************************************************************************/
  914. X/*   Declare the local variables                                          */
  915. X/**************************************************************************/
  916. X    char *p;
  917. X    char *add_file;
  918. X    int i, k;
  919. X
  920. X    /*********************************************************************/
  921. X    /* Get the current directory and drive so we can restore then on exit*/
  922. X    /*********************************************************************/
  923. X    (void)getcwd(startDirectory, FILENAMESIZE);
  924. X/* LATER: find the length anc PtMalloc the space */
  925. X    strcpy(currentDirectory, startDirectory);
  926. X    p = getenv("HOME");
  927. X    if( p == NULL ) {
  928. X        printf("Cannot find $HOME in the environment\n");
  929. X        homeDirectory[0] = '\0';
  930. X    } else
  931. X        strcpy( homeDirectory, p );
  932. X
  933. X    /*********************************************************************/
  934. X    /*   See if "pt.msg" (the command descriptions file) is present.     */
  935. X    /*********************************************************************/
  936. X
  937. X    p = findFile("pt.msg");
  938. X    if( p == NULL )
  939. X        descrFileId = -1;
  940. X    else
  941. X        descrFileId = getFileId(p);
  942. X
  943. X    /*********************************************************************/
  944. X    /*   create the additions file                                       */
  945. X    /*********************************************************************/
  946. X
  947. X    add_file = tmpnam( NULL );
  948. X    addPosition = 0;
  949. X    addHandle = open(add_file, O_RDWR | O_CREAT, 0644);
  950. X    if( addHandle < 0 ) {
  951. X        printf("Create of %s failed\n", add_file);
  952. X        exit(1);
  953. X    }
  954. X
  955. X    selWindow = NULL;
  956. X
  957. X    /* initialize the timeOfLastSave variable */
  958. X    timeOfLastSave = time(NULL);
  959. X
  960. X    /* get application resources from the resource database */
  961. X    InitCommands();
  962. X    InitOptions();
  963. X
  964. X    /*********************************************************************/
  965. X    /*   allocate the window structures                                  */
  966. X    /*********************************************************************/
  967. X/* LATER -- allocate these as needed */
  968. X    /* allocate an extra file structure for use in copymove.c (insScrap) */
  969. X    files = (struct openFile *)PtMalloc(
  970. X                (maxFiles+1) * sizeof(struct openFile),
  971. X                "open file structures");
  972. X    if( files == NULL ) {
  973. X        printf("Too many files (out of memory). Reduce maxFiles\n");
  974. X        exit(1);
  975. X    }
  976. X
  977. X    /*********************************************************************/
  978. X    /*   call various initialization routines                            */
  979. X    /*********************************************************************/
  980. X
  981. X    InitMouse();
  982. X    initWindows();
  983. X    initFileio();
  984. X    initChanges();
  985. X
  986. X    /********************************************************************/
  987. X    /*   Process the command line options and arguments            */
  988. X    /********************************************************************/
  989. X
  990. for(i = 1; i < argc; i++) {
  991. X    if( argv[i][0] == '-' ) {
  992. X        if( strcmp(argv[i],"-nb")==0
  993. X                    || strcmp(argv[i],"-nobrowser")==0 ) {
  994. X            noBrowser = 1;
  995. X        } else if( strcmp(argv[i],"-debug")==0 ) {
  996. X            debug = atoi( argv[++i] );
  997. X            printf("debug = %d\n", debug );
  998. X        }
  999. X    }
  1000. X    else    /* the end of the comamnd line options */
  1001. X        break;
  1002. X}
  1003. X
  1004. X    /* create the file list window */
  1005. X    CreateFilelist();
  1006. X
  1007. X#ifdef HYPERTEXT
  1008. X    if( hypertextOn )
  1009. X        InitHypertext();
  1010. X#endif
  1011. X    /* Initialize  */
  1012. X    MainDisplay = Tk_Display( mainBrowser->tk_toplevel );
  1013. X    MainWindow = Tk_WindowId( mainBrowser->tk_toplevel );
  1014. X    
  1015. X    /* get the size of the screen */
  1016. X    display_width = DisplayWidth(MainDisplay, MainDisplay->default_screen);
  1017. X    display_height = DisplayHeight(MainDisplay,MainDisplay->default_screen);
  1018. X
  1019. X    /* get some screen information */
  1020. X    ptBlackPixel = BlackPixel( MainDisplay, MainDisplay->default_screen );
  1021. X    ptWhitePixel = WhitePixel( MainDisplay, MainDisplay->default_screen );
  1022. X
  1023. X    /* create the necessary cursors */
  1024. X    sprintf( msgBuffer, "%s %s %s", spriteName, spriteForeground,
  1025. X                            spriteBackground );
  1026. X    mainCursor = Tk_GetCursor(interp, mainBrowser->tk_toplevel,
  1027. X                            Tk_GetUid(msgBuffer) );
  1028. X    currentCursor = mainCursor;
  1029. X    sprintf( msgBuffer, "%s %s %s", copySpriteName, spriteForeground,
  1030. X                            spriteBackground );
  1031. X    dupCursor = Tk_GetCursor( interp, mainBrowser->tk_toplevel,
  1032. X                            Tk_GetUid(msgBuffer) );
  1033. X    
  1034. X    MakeMouseMenuCursors();
  1035. X    
  1036. X    /* create the selection handler */
  1037. X    Tk_CreateSelHandler( mainBrowser->tk_toplevel, XA_STRING,
  1038. X                    SupplySelectionToX, 0, XA_STRING );
  1039. X
  1040. X    /********************************************************************/
  1041. X    /*   create the initial windows                                     */
  1042. X    /********************************************************************/
  1043. X
  1044. X    for(k = i; k < argc; k++) {
  1045. X        if( access(argv[k], 0) == -1) {
  1046. X            sprintf( msgBuffer,
  1047. X                "MakeModalYesNo {%s} {%s %s %s} {%s} {%s}",
  1048. X                "Create file?",
  1049. X                "File", argv[k], "does not exist.",
  1050. X                "Create it",
  1051. X                "Skip this file name" );
  1052. X            (void)ExecTclCommand( msgBuffer );
  1053. X            command( FWAITFORRETURNSTRING, "","","","","","");
  1054. X            if( returnString[0] != 'y' ) {
  1055. X                continue;
  1056. X            }
  1057. X            close(open(argv[k], O_CREAT, 0644));
  1058. X        }
  1059. X        (void)createWindow( NULL, argv[k], textGeometry );
  1060. X    }
  1061. X
  1062. X    /* the top window is the first active window */
  1063. X    MakeWindowActive( windowList );
  1064. X
  1065. X    /* start the main processing loop */
  1066. X    Tk_MainLoop();
  1067. X    
  1068. X    /* TCL/TK CLEANUP */
  1069. X    Tk_DestroyWindow( TkMainWindow );
  1070. X    Tcl_DeleteInterp( interp );
  1071. X};
  1072. X
  1073. int msgInTitleLine = 0;
  1074. X
  1075. X/*ARGSUSED*/
  1076. void
  1077. msg(s, putInPopup)
  1078. X    char *s;
  1079. X    int putInPopup;
  1080. X{
  1081. X    extern struct window *activeWindow;
  1082. X    extern int messageFlags;
  1083. X    extern Display *MainDisplay;
  1084. X    extern BrowserData *browserList;
  1085. X    extern char msgBuffer[];
  1086. X    
  1087. X    char buffer[MSGBUFFERSIZE];
  1088. X    char *from, *to;
  1089. X
  1090. X    /* put the message into the popup shell */
  1091. X
  1092. X    if( messageFlags & LINE_MSGS ) {
  1093. X        /* put the message in the browser message line */
  1094. X        BrowserData *browser = browserList;
  1095. X        for( browser = browserList; browser != NULL;
  1096. X                    browser = browser->nextBrowser) {
  1097. X            if( browser->tk_pathname[0] == '\0' )
  1098. X                continue;
  1099. X            sprintf( buffer,
  1100. X                "%s.msg delete 0 end;%s.msg insert 0 {",
  1101. X                browser->tk_pathname, browser->tk_pathname);
  1102. X            /* copy in string and escape braces */
  1103. X            from = s;
  1104. X            to = buffer + strlen(buffer);
  1105. X            while( 1 ) {
  1106. X                char ch = *from++;
  1107. X                if( ch == '\0' )
  1108. X                    break;
  1109. X                if( ch == '{' || ch == '}' )
  1110. X                    *to++ = '\\';
  1111. X                *to++ = ch;
  1112. X            }
  1113. X            *to++ = '}';
  1114. X            *to = '\0';
  1115. X            (void)ExecTclCommand( buffer );
  1116. X        }
  1117. X    }
  1118. X    
  1119. X    if( messageFlags & WINDOW_MSGS ) {
  1120. X        if( activeWindow!=NULL ) {
  1121. X            printf("Put message <%s> in title bar\n", s);
  1122. X        }
  1123. X        /* also put the message in the title bar of the active window */
  1124. X        if( activeWindow != NULL ) {
  1125. X            printf("Put message <%s> in title bar\n", s);
  1126. X        }
  1127. X        msgInTitleLine = 1;
  1128. X    }
  1129. X
  1130. X    if( messageFlags & PRINTF_MSGS ) {
  1131. X        printf( "%s\n", s );
  1132. X    }
  1133. X    
  1134. X}
  1135. END_OF_FILE
  1136. if test 9314 -ne `wc -c <'point.c'`; then
  1137.     echo shar: \"'point.c'\" unpacked with wrong size!
  1138. fi
  1139. # end of 'point.c'
  1140. fi
  1141. if test -f 'select.c' -a "${1}" != "-c" ; then 
  1142.   echo shar: Will not clobber existing file \"'select.c'\"
  1143. else
  1144. echo shar: Extracting \"'select.c'\" \(9696 characters\)
  1145. sed "s/^X//" >'select.c' <<'END_OF_FILE'
  1146. X/* $Header: /nfs/unmvax/faculty/crowley/x/pt/RCS/select.c,v 1.5 1992/03/04 17:07:18 crowley Exp crowley $ */
  1147. X
  1148. X#include <ctype.h>
  1149. X#include "pt.h"
  1150. X#include <X11/Xatom.h>
  1151. X
  1152. X/* the globals selection */
  1153. struct window *selWindow = NULL;
  1154. Offset selBegin, selEnd;
  1155. Offset selBeginCp;
  1156. int selMode;
  1157. X
  1158. int ptOwnsSelection = 0;
  1159. X
  1160. void 
  1161. XExtendSelection( cp, row, col, beginRowCp )
  1162. X    Offset cp, beginRowCp;
  1163. X    int row, col;
  1164. X{
  1165. X    extern struct window *selWindow;
  1166. X    extern Offset selBegin, selEnd;
  1167. X
  1168. X    int saveSelBegin = selBegin;
  1169. X    int saveSelEnd = selEnd;
  1170. X    Offset begin, end;
  1171. X
  1172. X    /* extend according to the selection mode */
  1173. X    modeExtend( selWindow, cp, row, col, beginRowCp );
  1174. X        /* this call sets selBegin and selEnd */
  1175. X
  1176. X    /* figure out what we have to redraw */
  1177. X    if( saveSelBegin <= selBegin && selEnd < saveSelEnd ) {
  1178. X        /* the selection is being contracted */
  1179. X        begin = selEnd + 1;
  1180. X        end = saveSelEnd;
  1181. X        selBegin = saveSelBegin;
  1182. X    } else if( selBegin < saveSelBegin ) {
  1183. X        /* the selection is being extended to the left */
  1184. X        begin = selBegin;
  1185. X        end = saveSelBegin - 1;
  1186. X        selEnd = saveSelEnd;
  1187. X    } else {
  1188. X        /* the selection is being entended to the right */
  1189. X        begin = saveSelEnd + 1;
  1190. X        end = selEnd;
  1191. X        selBegin = saveSelBegin;
  1192. X    }
  1193. X
  1194. X    if( begin < selWindow->posTopline )
  1195. X        begin = selWindow->posTopline;
  1196. X    if( end >= selWindow->posBotline )
  1197. X        end = selWindow->posBotline - 1;
  1198. X    if( begin <= end ) {
  1199. X        int row1, col1, row2, col2;
  1200. X        int n = -1;
  1201. X        beginRowCp = prevLine( selWindow->fileId, begin, &n );
  1202. X        OffsetToXY( selWindow, begin, &row1, &col1 );
  1203. X        OffsetToXY( selWindow, end, &row2, &col2 );
  1204. X        DrawSection( selWindow, beginRowCp, row1, col1, row2, col2 );
  1205. X    }
  1206. X}
  1207. X
  1208. void
  1209. drawSelection( erase )
  1210. X    int erase;
  1211. X{
  1212. X    extern struct window *selWindow;
  1213. X    extern Offset selBegin, selEnd;
  1214. X
  1215. X    Offset saveSelBegin;
  1216. X    Offset saveSelEnd;
  1217. X    Offset begin = selBegin;
  1218. X    Offset end = selEnd;
  1219. X
  1220. X    if( selWindow == NULL )
  1221. X        return;    /* there is no selection to erase */
  1222. X
  1223. X    /* Turn off the selection, then draw the area.  This will erase */
  1224. X    /* the selection.  Then restore selBegin. */
  1225. X    if( erase ) {
  1226. X        saveSelBegin = selBegin;
  1227. X        saveSelEnd = selEnd;
  1228. X        selBegin = 1;    /* so no selection will draw */
  1229. X        selEnd = 0;
  1230. X    }
  1231. X
  1232. X    if( begin < selWindow->posTopline )
  1233. X        begin = selWindow->posTopline;
  1234. X
  1235. X    if( end >= selWindow->posBotline )
  1236. X        end = selWindow->posBotline - 1;
  1237. X
  1238. X    if( begin <= end ) {
  1239. X        /* some of the selection is showing in the window */
  1240. X        int n = -1;
  1241. X        Offset beginCp = prevLine( selWindow->fileId, begin, &n );
  1242. X        int row1, col1, row2, col2;
  1243. X
  1244. X        OffsetToXY( selWindow, begin, &row1, &col1 );
  1245. X        OffsetToXY( selWindow, end, &row2, &col2 );
  1246. X        DrawSection( selWindow, beginCp, row1, col1, row2, col2);
  1247. X    }
  1248. X
  1249. X    if( erase ) {
  1250. X        selBegin = saveSelBegin;
  1251. X        selEnd = saveSelEnd;
  1252. X    }
  1253. X}    
  1254. X
  1255. X
  1256. void
  1257. DrawSection( w, beginRowCp, beginRow, beginCol, endRow, endCol )
  1258. X    struct window *w;
  1259. X    Offset beginRowCp;
  1260. X    int beginRow, beginCol, endRow, endCol;
  1261. X{
  1262. X    int row, col, y;
  1263. X    Offset cp;
  1264. X
  1265. X    /* if the selection is below the window then do nothing */
  1266. X    if( beginRow >= w->nRows )
  1267. X        return;
  1268. X
  1269. X    /* if the selection is above the window then do nothing */
  1270. X    if( endRow < 0 )
  1271. X        return;
  1272. X
  1273. X    /* if part of the selection is above the window, adjust for it */
  1274. X    if( beginRow < 0 ) {
  1275. X        beginRow = 0;
  1276. X        beginCol = 0;
  1277. X    }
  1278. X
  1279. X    /* if part of the selection is below the window, adjust for it */
  1280. X    if( endRow >= w->nRows ) {
  1281. X        endRow = w->nRows - 1;
  1282. X        endCol = w->nCols;
  1283. X    }
  1284. X    
  1285. X    /* At this point the entire section (to draw) is in the window */
  1286. X    /* draw draw the section */
  1287. X
  1288. X    y = w->topMargin + (w->font).ascent + beginRow * ((w->font).height);
  1289. X    cp = beginRowCp;
  1290. X
  1291. X    /* determine the boundaries to draw text in */
  1292. X    if( beginRow == endRow )
  1293. X        col = endCol;
  1294. X    else
  1295. X        col = w->nCols;
  1296. X    cp = fillLine( w, cp, beginRow, beginCol, col, y, 0 );
  1297. X    for( row = beginRow + 1; row < endRow; ++row ) {
  1298. X        y += (w->font).height;
  1299. X        cp = fillLine( w, cp, row, 0, w->nCols, y, 0 );
  1300. X    }
  1301. X    if( beginRow < endRow ) {
  1302. X        y += (w->font).height;
  1303. X        cp = fillLine( w, cp, row, 0, endCol, y, 0 );
  1304. X    }
  1305. X}
  1306. X
  1307. X/*ARGSUSED*/
  1308. void
  1309. modeExtend(w, cp, row, col, beginRowCp )
  1310. X    struct window *w;
  1311. X    Offset cp;
  1312. X    int row, col;
  1313. X    Offset beginRowCp;
  1314. X{
  1315. X    extern int selMode;
  1316. X    extern struct window *selWindow;
  1317. X    extern Offset selBegin, selEnd;
  1318. X
  1319. X    int uch;
  1320. X    int n;
  1321. X    Offset cpLine;
  1322. X    int fid = w->fileId;
  1323. X
  1324. X    /* determine the initial selection */
  1325. X    switch( selMode ) {
  1326. X
  1327. X    case SELCHAR:
  1328. X        selBegin = cp;
  1329. X        selEnd = cp;
  1330. X        break;
  1331. X
  1332. X    case SELWORD:
  1333. X    {    Offset cpLow, cpHigh;
  1334. X
  1335. X        /* test for the special case of the first character of the */
  1336. X        /* selection not being a digit, letter or '_' */
  1337. X        uch = getFileByte( fid, cp );
  1338. X        if(uch==BLOCK_EOF || !isalnum((char)uch)&&((char)uch != '_')){
  1339. X            selBegin = selEnd = cp;
  1340. X            break;
  1341. X        }
  1342. X        cpLow = cp;
  1343. X        while( 1 ) {
  1344. X            uch = getFileByte( fid, cpLow-- );
  1345. X            /* stop when you: */
  1346. X            /* 1. go past the beginning of the file */
  1347. X            if( uch == BLOCK_EOF )
  1348. X                break;
  1349. X            /* 2. read a non-word character */
  1350. X            if( !isalnum((char)uch) && ((char)uch != '_') )
  1351. X                break;
  1352. X        }
  1353. X        /* we went two too far */
  1354. X        selBegin = cpLow + 2;
  1355. X
  1356. X        cpHigh = cp;
  1357. X        while( 1 ) {
  1358. X            uch = getFileByte( fid, cpHigh++ );
  1359. X            /* stop when you: */
  1360. X            /* 1. go past the beginning of the file */
  1361. X            if( uch == BLOCK_EOF )
  1362. X                break;
  1363. X            /* 2. read a non-word character */
  1364. X            if( !isalnum((char)uch) && ((char)uch != '_') )
  1365. X                break;
  1366. X        }
  1367. X        selEnd = cpHigh - 2;
  1368. X        break;
  1369. X    }
  1370. X
  1371. X    case SELLINE:
  1372. X        /* find the beginning of the line */
  1373. X        cpLine = cp;
  1374. X        n = -1;
  1375. X        cpLine = prevLine( fid, cpLine, &n );
  1376. X        selBegin = cpLine;
  1377. X
  1378. X        /* find the end of the line */
  1379. X        cpLine = cp;
  1380. X        n = 1;
  1381. X        cpLine = nextLine( fid, cpLine, &n );
  1382. X        selEnd = cpLine - 1;
  1383. X        break;
  1384. X
  1385. X    case SELBLOCK:
  1386. X        /* find the beginning of the block */
  1387. X    /* DO NOT DO THIS YET */
  1388. X        selBegin = cp;
  1389. X        selEnd = cp;
  1390. X        break;
  1391. X    }
  1392. X}
  1393. X
  1394. int
  1395. indentToShowSelection(selCol)
  1396. X    int selCol;    /* the column where the first character of */
  1397. X            /* the selection is */
  1398. X{
  1399. X    extern char msgBuffer[];
  1400. X    extern struct window *selWindow;
  1401. X    extern Offset selBegin, selEnd;
  1402. X
  1403. X    int dummy, col, windowWidth, indent, endIndent;
  1404. X    int originalIndent;
  1405. X
  1406. X    originalIndent = selWindow->indent;
  1407. X
  1408. X    /* find the column the selection starts in */
  1409. X    if( selCol == -1 )
  1410. X        OffsetToXY( selWindow, selBegin, &dummy, &col );
  1411. X    else
  1412. X        col = selCol;
  1413. X
  1414. X    /* sourceToXY subtracts the current indent so add it back in */
  1415. X    col += selWindow->indent;
  1416. X    windowWidth = selWindow->nCols;
  1417. X
  1418. X    /* if the selection is right of the window, change the indent */
  1419. X    if( col > (windowWidth + selWindow->indent) ) {
  1420. X        indent = col - (windowWidth>>1);
  1421. X        /* figure the column of the end of the selection */
  1422. X        /*     add window width / 2 to put it in the  */
  1423. X        /*    middle of the window */
  1424. X        endIndent = (selEnd - selBegin) + indent;
  1425. X        if( endIndent < col )
  1426. X            selWindow->indent = endIndent;
  1427. X        else
  1428. X            selWindow->indent = indent;
  1429. X    } else if( col < selWindow->indent ) {
  1430. X        /* if the selection is left of the window change the indent */
  1431. X        /* change the indent back to zero if this will still leave */
  1432. X        /* the beginning of the selection in the left half of the */
  1433. X        /* window */
  1434. X        indent = col - (windowWidth>>1);
  1435. X        if( indent < 0 )
  1436. X            indent = 0;
  1437. X        selWindow->indent = indent;
  1438. X    }
  1439. X    /* indicate on return whether you actually changed the indent */
  1440. X    return (originalIndent != selWindow->indent);
  1441. X}
  1442. X
  1443. Offset
  1444. adjustSelMode( cp )
  1445. X    Offset cp;
  1446. X{
  1447. X    extern char msgBuffer[];
  1448. X    extern struct window *selWindow;
  1449. X    extern int selMode;
  1450. X    
  1451. X    int uch, n;
  1452. X    int fid = selWindow->fileId;
  1453. X
  1454. X    switch( selMode ) {
  1455. X    case SELBLOCK:
  1456. X        break;
  1457. X    case SELLINE:
  1458. X        n = -1;
  1459. X        cp = prevLine( fid, cp, &n );
  1460. X        break;
  1461. X    case SELWORD:
  1462. X        /* only search if cp is inside a word */
  1463. X        uch = getFileByte( fid, cp );
  1464. X        if( isalnum((char)uch) || (char)uch == '_' ) {
  1465. X            while( 1 ) {
  1466. X                uch = getFileByte( fid, --cp );
  1467. X                if( !isalnum((char)uch) && (char)uch != '_' )
  1468. X                    break;
  1469. X            }
  1470. X            ++cp;
  1471. X        }
  1472. X        break;
  1473. X    case SELCHAR:
  1474. X        /* nothing to adjust in char mode */
  1475. X        break;
  1476. X    }
  1477. X    return cp;
  1478. X}
  1479. X
  1480. X/*ARGSUSED*/
  1481. int
  1482. SupplySelectionToX( clientData, offset, buffer, maxBytes )
  1483. X    ClientData clientData;
  1484. X    int offset;
  1485. X    char * buffer;
  1486. X    int maxBytes;
  1487. X{
  1488. X    extern int ptOwnsSelection;
  1489. X
  1490. X    ptOwnsSelection = 1;    /* to be safe */
  1491. X    (void) getSelection( buffer, offset, maxBytes );
  1492. X    return strlen( buffer );
  1493. X}
  1494. X
  1495. X/*ARGSUSED*/
  1496. static void
  1497. LoseXSelection( clientData )
  1498. X    ClientData clientData;
  1499. X{
  1500. X    extern int ptOwnsSelection;
  1501. X
  1502. X    ptOwnsSelection = 0;
  1503. X}
  1504. X
  1505. void
  1506. AssertSelectionOwnership()
  1507. X{
  1508. X    extern int ptOwnsSelection;
  1509. X    extern BrowserData * mainBrowser;
  1510. X
  1511. X    if( !ptOwnsSelection ) {
  1512. X        ptOwnsSelection = 1;
  1513. X        Tk_OwnSelection( mainBrowser->tk_toplevel, LoseXSelection, 0 );
  1514. X    }
  1515. X}
  1516. X
  1517. static int selLength;
  1518. static char * selString;
  1519. X
  1520. X/*ARGSUSED*/
  1521. static int
  1522. ReceiveXSelection( clientData, interp, portion )
  1523. X    ClientData clientData;
  1524. X    Tcl_Interp * interp;
  1525. X    char * portion;
  1526. X{
  1527. X    char ch;
  1528. X
  1529. X    while( (ch = *portion++) != '\0' ) {
  1530. X        if( --selLength <= 0 )
  1531. X            break;
  1532. X        *selString++ = ch;
  1533. X    }
  1534. X    return TCL_OK;
  1535. X}
  1536. X
  1537. int
  1538. getSelection(s, offset, length)
  1539. X    char *s;
  1540. X    int offset;
  1541. X    int length;
  1542. X{
  1543. X    extern Offset selBegin, selEnd;
  1544. X    extern struct window *selWindow;
  1545. X    extern int ptOwnsSelection;
  1546. X    extern BrowserData * mainBrowser;
  1547. X    extern Tcl_Interp * interp;
  1548. X
  1549. X    char *p;
  1550. X    int fid;
  1551. X
  1552. X    /* If we own the selection then get it */
  1553. X    if( ptOwnsSelection ) {
  1554. X        Offset cp = selBegin + offset;
  1555. X
  1556. X        p = s;
  1557. X        if( selWindow != NULL )
  1558. X            fid = selWindow->fileId;
  1559. X        else {
  1560. X            msg("No selection, using ~.", 1);
  1561. X            s[0] = '~';
  1562. X            s[1] = '\0';
  1563. X            return 1;
  1564. X        }
  1565. X        while( cp <= selEnd ) {
  1566. X            *p++ = (char)getFileByte( fid, cp++ );
  1567. X            /* check for string overflow */
  1568. X            if( p-s >= length ) {
  1569. X                --p;
  1570. X                break;
  1571. X            }
  1572. X        }
  1573. X        *p = '\0';
  1574. X        return 1;
  1575. X    }
  1576. X
  1577. X    /* else get it from X */
  1578. X    selString = s;
  1579. X    selLength = length;
  1580. X    fid = Tk_GetSelection( interp, mainBrowser->tk_toplevel,
  1581. X        XA_STRING, ReceiveXSelection, 0 );
  1582. X    *selString = '\0';
  1583. X    /* did we overflow the space alloted? */
  1584. X    return (selLength > 0);
  1585. X}
  1586. X
  1587. X
  1588. END_OF_FILE
  1589. if test 9696 -ne `wc -c <'select.c'`; then
  1590.     echo shar: \"'select.c'\" unpacked with wrong size!
  1591. fi
  1592. # end of 'select.c'
  1593. fi
  1594. if test -f 'tclLib/browserMenu.tcl' -a "${1}" != "-c" ; then 
  1595.   echo shar: Will not clobber existing file \"'tclLib/browserMenu.tcl'\"
  1596. else
  1597. echo shar: Extracting \"'tclLib/browserMenu.tcl'\" \(10008 characters\)
  1598. sed "s/^X//" >'tclLib/browserMenu.tcl' <<'END_OF_FILE'
  1599. X#
  1600. X#
  1601. X# The browser menu bar specification
  1602. X#
  1603. X#
  1604. set PREFS {
  1605. X    {check "Ignore case in searches" ignoreCase \
  1606. X        {Option set ignoreCase $ignoreCase}}
  1607. X    {check "Find whole words only in searches" findWholeWords \
  1608. X        {Option set findWholeWords $findWholeWords}}
  1609. X    {check "Typed characters replace the selection" insertReplaces \
  1610. X        {Option set insertReplaces $insertReplaces}}
  1611. X    {check "Show the sizes of files in browser list" showSizes \
  1612. X        {Option set showSizes $showSizes;CD .}}
  1613. X    {check "Use standard Tk style scroll bars" tkScrolling \
  1614. X        {Option set tkScrolling $tkScrolling}}
  1615. X    {check "Automatic indenting" autoIndent \
  1616. X        {Option set autoIndent $autoIndent}}
  1617. X    {check "Show full path names in window titles" pathNames \
  1618. X        {Option set pathNames $pathNames;Redraw}}
  1619. X    {cascade "Search Options =>" {
  1620. X        {command "Other search options ..." {MakeSearchOptionsBox}}
  1621. X        {check "Ignore case in searches" ignoreCase \
  1622. X            {Option set ignoreCase $ignoreCase}}
  1623. X        {check "Find whole words only in searches" findWholeWords \
  1624. X            {Option set findWholeWords $findWholeWords}}
  1625. X        {check "Wrap around to beginning in searches" \
  1626. X            wrapAroundSearches \
  1627. X            {Option set wrapAroundSearches $wrapAroundSearches}}
  1628. X        {cascade "Placement of found strings =>" {
  1629. X            {radio "Center found strings in the window" \
  1630. X                linesOverFind 999 \
  1631. X                {Option set linesOverFind $linesOverFind}}
  1632. X            {radio "Place found strings at top of window" \
  1633. X                linesOverFind 0 \
  1634. X                {Option set linesOverFind $linesOverFind}}
  1635. X            {radio "Place found strings 2 lines from top of window"\
  1636. X                linesOverFind 2 \
  1637. X                {Option set linesOverFind $linesOverFind}}
  1638. X            {radio "Place found strings 5 lines from top of window"\
  1639. X                linesOverFind 5 \
  1640. X                {Option set linesOverFind $linesOverFind}}
  1641. X            {radio "Place found strings 10 lines from top of window" \
  1642. X                linesOverFind 10 \
  1643. X                {Option set linesOverFind $linesOverFind}}
  1644. X        }}
  1645. X    }}
  1646. X    {cascade "Other boolean options =>" {
  1647. X        {check "Undo motion as well as edits" undoMotion \
  1648. X            {Option set undoMotion $undoMotion}}
  1649. X        {check "Make one column directory browsers" thinBrowser \
  1650. X            {Option set thinBrowser $thinBrowser}}
  1651. X        {check "Use mouse cursor to show mouse menu items" \
  1652. X            mouseSpriteMenu \
  1653. X            {Option set mouseSpriteMenu $mouseSpriteMenu}}
  1654. X        {check "Left button scrolls down" button1ScrollsDown \
  1655. X            {Option set button1ScrollsDown $button1ScrollsDown}}
  1656. X        {separator}
  1657. X        {check "Type over existing characters when inserting" overType \
  1658. X            {Option set overType $overType}}
  1659. X        {check "Show partial line at bottom of text windows" \
  1660. X            showPartialLines \
  1661. X            {Option set showPartialLines $showPartialLines;Redraw}}
  1662. X        {separator}
  1663. X        {check "Show directories before files in browser list" \
  1664. X            showDirsFirst \
  1665. X            {Option set showDirsFirst $showDirsFirst}}
  1666. X        {separator}
  1667. X        {check "Backup with a copy (not a move)" backupByCopy \
  1668. X            {Option set backupByCopy $backupByCopy}}
  1669. X        {check "Make new windows read only" readOnly \
  1670. X            {Option set readOnly $readOnly}}
  1671. X    }}
  1672. X    {command "String valued options ..." {MakeOtherOptionsBox}}
  1673. X    {cascade "Set text colors =>" {
  1674. X        {cascade "Normal foreground color =>" {
  1675. X            {command "Blue" {SetTextColor Blue}}
  1676. X            {command "Black" {SetTextColor Black}}
  1677. X            {command "White" {SetTextColor White}}
  1678. X            {command "Red" {SetTextColor Red}}
  1679. X            {command "Yellow" {SetTextColor Yellow}}
  1680. X            {command "Cyan" {SetTextColor Cyan}}
  1681. X            {command "Magenta" {SetTextColor Magenta}}
  1682. X        }}
  1683. X        {cascade "Normal background color =>" {
  1684. X            {command "Blue" {SetTextColor Blue normal background}}
  1685. X            {command "Black" {SetTextColor Black normal background}}
  1686. X            {command "White" {SetTextColor White normal background}}
  1687. X            {command "Red" {SetTextColor Red normal background}}
  1688. X            {command "Yellow" {SetTextColor Yellow normal background}}
  1689. X            {command "Cyan" {SetTextColor Cyan normal background}}
  1690. X            {command "Magenta" {SetTextColor Magenta normal background}}
  1691. X        }}
  1692. X        {cascade "Selected foreground color =>" {
  1693. X            {command "Blue" {SetTextColor Blue selected}}
  1694. X            {command "Black" {SetTextColor Black selected}}
  1695. X            {command "White" {SetTextColor White selected }}
  1696. X            {command "Red" {SetTextColor Red selected}}
  1697. X            {command "Yellow" {SetTextColor Yellow selected}}
  1698. X            {command "Cyan" {SetTextColor Cyan selected}}
  1699. X            {command "Magenta" {SetTextColor Magenta selected}}
  1700. X        }}
  1701. X        {cascade "Selected background color =>" {
  1702. X            {command "85% Grey" {SetTextColor grey85 selected background}}
  1703. X            {command "Blue" {SetTextColor Blue selected background}}
  1704. X            {command "Black" {SetTextColor Black selected background}}
  1705. X            {command "White" {SetTextColor White selected background}}
  1706. X            {command "Red" {SetTextColor Red selected background}}
  1707. X            {command "Yellow" {SetTextColor Yellow selected background}}
  1708. X            {command "Cyan" {SetTextColor Cyan selected background}}
  1709. X            {command "Magenta" {SetTextColor Magenta selected background}}
  1710. X        }}
  1711. X    }}
  1712. X    {cascade "Number of backups kept =>" {
  1713. X    {radio "None" backupDepth 0 {Option set backupDepth $backupDepth}}
  1714. X    {radio "1" backupDepth 1 {Option set backupDepth $backupDepth}}
  1715. X    {radio "2" backupDepth 2 {Option set backupDepth $backupDepth}}
  1716. X    {radio "3" backupDepth 3 {Option set backupDepth $backupDepth}}
  1717. X    {radio "4" backupDepth 4 {Option set backupDepth $backupDepth}}
  1718. X    {radio "5" backupDepth 5 {Option set backupDepth $backupDepth}}
  1719. X    {radio "6" backupDepth 6 {Option set backupDepth $backupDepth}}
  1720. X    }}
  1721. X    {cascade "Width of a tab =>" {
  1722. X    {radio "1" tabWidth 1 {Option set tabWidth $tabWidth}}
  1723. X    {radio "2" tabWidth 2 {Option set tabWidth $tabWidth}}
  1724. X    {radio "3" tabWidth 3 {Option set tabWidth $tabWidth}}
  1725. X    {radio "4" tabWidth 4 {Option set tabWidth $tabWidth}}
  1726. X    {radio "5" tabWidth 5 {Option set tabWidth $tabWidth}}
  1727. X    {radio "6" tabWidth 6 {Option set tabWidth $tabWidth}}
  1728. X    {radio "8" tabWidth 8 {Option set tabWidth $tabWidth}}
  1729. X    {radio "10" tabWidth 10 {Option set tabWidth $tabWidth}}
  1730. X    {radio "15" tabWidth 15 {Option set tabWidth $tabWidth}}
  1731. X    }}
  1732. X    {cascade "Right margin for automatic CRs =>" {
  1733. X    {radio "None" rightMargin 999 {Option set rightMargin $rightMargin}}
  1734. X    {radio "40" rightMargin 40 {Option set rightMargin $rightMargin}}
  1735. X    {radio "50" rightMargin 50 {Option set rightMargin $rightMargin}}
  1736. X    {radio "60" rightMargin 60 {Option set rightMargin $rightMargin}}
  1737. X    {radio "70" rightMargin 70 {Option set rightMargin $rightMargin}}
  1738. X    {radio "72" rightMargin 72 {Option set rightMargin $rightMargin}}
  1739. X    {radio "74" rightMargin 74 {Option set rightMargin $rightMargin}}
  1740. X    {radio "76" rightMargin 76 {Option set rightMargin $rightMargin}}
  1741. X    {radio "78" rightMargin 78 {Option set rightMargin $rightMargin}}
  1742. X    {radio "80" rightMargin 80 {Option set rightMargin $rightMargin}}
  1743. X    {radio "90" rightMargin 90 {Option set rightMargin $rightMargin}}
  1744. X    {radio "100" rightMargin 100 {Option set rightMargin $rightMargin}}
  1745. X    }}
  1746. X    {cascade "Selection style =>" {
  1747. X    {radio "Show selection in the selected text colors" underlineSelection \
  1748. X        0 {Option set underlineSelection $underlineSelection}}
  1749. X    {radio "Underline the selection with one line" underlineSelection \
  1750. X        1 {Option set underlineSelection $underlineSelection}}
  1751. X    {radio "Underline the selection with two lines" underlineSelection \
  1752. X        2 {Option set underlineSelection $underlineSelection}}
  1753. X    }}
  1754. X}
  1755. X
  1756. set MISC {
  1757. X    {command "Load bugs list" {OpenWindow bugs $location1}}
  1758. X    {command "Load scratch file" {OpenWindow scratch $location1}}
  1759. X    {command "About Point ..." {MakeAboutBox}}
  1760. X    {command "Cancel copy mode" {CancelModes}}
  1761. X    {command "Print Statistics" {PrintStats}}
  1762. X    {separator}
  1763. X    {command "Delete File" {exec rm -f [selection get]}}
  1764. X    {command "Insert ASCII ..." {MakeAsciiBox}}
  1765. X    {command "Save All Unsaved Files" {SaveAllFiles}}
  1766. X    {command "Set debug ..." {MakeDebugBox}}
  1767. X    {command "Information" \
  1768. X            {puts stdout "Selection bounds: [Sel get]"}}
  1769. X    {separator}
  1770. X    {command "6x13" {BrowserFont 6x13}}
  1771. X    {command "6x13bold" {BrowserFont 6x13bold}}
  1772. X    {command "5x8" {BrowserFont 5x8}}
  1773. X    {command "*clean-medium-r*6*50*" {BrowserFont *clean-medium-r*6*50*}}
  1774. X    {command "8x13" {BrowserFont 8x13}}
  1775. X}
  1776. X
  1777. set DIRS {
  1778. X    {command "~"            {CD ~}}
  1779. X    {command "~/bin"        {CD ~/bin}}
  1780. X    {command "~/Mail"        {CD ~/Mail}}
  1781. X    {command "~/News"        {CD ~/News}}
  1782. X    {command "~/src"        {CD ~/src}}
  1783. X    {separator}
  1784. X    {command "/nfs/unmvax/src/X11R4/mit" {CD /nfs/unmvax/src/X11R4/mit}}
  1785. X    {command "/usr/include"        {CD /usr/include}}
  1786. X    {command "/usr/include/sys"    {CD /usr/include/sys}}
  1787. X    {command "/usr/include/X11"    {CD /usr/include/X11}}
  1788. X    {command "CD to selection"    {CD [selection get]}}
  1789. X}
  1790. X
  1791. set BrowserMenuSpec {
  1792. X    {menu   PREFS "PREFS" PREFS}
  1793. X    {button New "  New  " {
  1794. X        {OpenFileOrCD 1}
  1795. X        {OpenFileOrCD 2}
  1796. X        {OpenFileOrCD 3}
  1797. X    }}
  1798. X    {menu   DIRS "DIRS"   DIRS}
  1799. X    {menu   MISC "MISC"   MISC}
  1800. X    {button Star  "   *   "   {{Option set filePattern "*"}
  1801. X        {puts stderr \Cg nonewline} {puts stderr \Cg nonewline} } }
  1802. X    {button Browser " New Browser " {
  1803. X        {global browserBig;Browser $browserBig big}
  1804. X        {global browserBig;Browser $browserBig big}
  1805. X        {global browser1;Browser $browser1 small}
  1806. X    }}
  1807. X    {button DelFile "Del File" {
  1808. X        {exec rm -f [selection get];Option set filePattern "*"}
  1809. X        {puts stderr \Cg nonewline}
  1810. X        {puts stderr \Cg nonewline}
  1811. X    }}
  1812. X    {button Close "  Close  " {
  1813. X        CloseBrowser
  1814. X        {puts stderr \Cg nonewline}
  1815. X        {puts stderr \Cg nonewline}
  1816. X    }}
  1817. X    {menu   QUIT "QUIT"   QuitMenu}
  1818. X}
  1819. X
  1820. set ThinBrowserMenuSpec {
  1821. X    {menu ThinBrowserMenu "MENU" ThinBrowserMenu}
  1822. X    {menu DIRS "DIRS" DIRS}
  1823. X    {button New "New" {
  1824. X        {global browser1;Browser $browser1 small}
  1825. X        {global browser2;Browser $browser2 small}
  1826. X        {global browser3;Browser $browser3 small}
  1827. X    }}
  1828. X}
  1829. X
  1830. set ThinBrowserMenu {
  1831. X    {cascade "PREFS" PREFS}
  1832. X    {command "New" {OpenFileOrCD 1}}
  1833. X    {cascade "DIRS"    DIRS}
  1834. X    {cascade "MISC"    MISC}
  1835. X    {command "*" {Option set filePattern "*"}}
  1836. X    {command "New Browser" {global browser2;Browser $browser2 small}}
  1837. X    {command "Del File" \
  1838. X        {exec rm -f [selection get];Option set filePattern "*"}}
  1839. X    {command "Close" {CloseBrowser}}
  1840. X    {cascade "QUIT" QuitMenu}
  1841. X}
  1842. X
  1843. proc BrowserMenuBindings {w} {
  1844. X}
  1845. X
  1846. END_OF_FILE
  1847. if test 10008 -ne `wc -c <'tclLib/browserMenu.tcl'`; then
  1848.     echo shar: \"'tclLib/browserMenu.tcl'\" unpacked with wrong size!
  1849. fi
  1850. # end of 'tclLib/browserMenu.tcl'
  1851. fi
  1852. echo shar: End of archive 4 \(of 15\).
  1853. cp /dev/null ark4isdone
  1854. MISSING=""
  1855. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ; do
  1856.     if test ! -f ark${I}isdone ; then
  1857.     MISSING="${MISSING} ${I}"
  1858.     fi
  1859. done
  1860. if test "${MISSING}" = "" ; then
  1861.     echo You have unpacked all 15 archives.
  1862.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1863. else
  1864.     echo You still need to unpack the following archives:
  1865.     echo "        " ${MISSING}
  1866. fi
  1867. ##  End of shell archive.
  1868. exit 0
  1869. -- 
  1870. --
  1871. Molecular Simulations, Inc.            mail: dcmartin@msi.com
  1872. 796 N. Pastoria Avenue                uucp: uunet!dcmartin
  1873. Sunnyvale, California 94086            at&t: 408/522-9236
  1874.