home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume17 / tcleditr / part10 < prev    next >
Encoding:
Text File  |  1992-03-17  |  52.2 KB  |  1,735 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: v17i011: point text editor (TCL and TK), Part10/16
  5. Message-ID: <1992Mar18.141632.27235@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:16:32 GMT
  11. Approved: dcmartin@msi.com
  12.  
  13. Submitted-by: crowley@chaco.cs.unm.edu (Charlie Crowley)
  14. Posting-number: Volume 17, Issue 11
  15. Archive-name: tcl-editor/part10
  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 9 (of 15)."
  24. # Contents:  anaSources.c doc/point.n
  25. # Wrapped by crowley@chaco.cs.unm.edu on Tue Mar 10 15:05:46 1992
  26. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  27. if test -f 'anaSources.c' -a "${1}" != "-c" ; then 
  28.   echo shar: Will not clobber existing file \"'anaSources.c'\"
  29. else
  30. echo shar: Extracting \"'anaSources.c'\" \(26116 characters\)
  31. sed "s/^X//" >'anaSources.c' <<'END_OF_FILE'
  32. X/* $Header: /nfs/unmvax/faculty/crowley/x/pt/RCS/anaSources.c,v 1.5 1992/03/04 17:07:18 crowley Exp crowley $ */
  33. X
  34. X#ifdef HYPERTEXT
  35. X#include <string.h>
  36. X#include <stdio.h>
  37. X#include "pt.h"
  38. X
  39. X/*********************************************************************/
  40. X/* This routines takes the selection (selBegin and selEnd) in terms  */
  41. X/* of the view (ff) and translates it to a new selection (selBegin   */
  42. X/* and selEnd) that are relative to the underlying (real) file that  */
  43. X/* the pieces in ff were clones from.  Along the way it makes some   */
  44. X/* checks about the selection and returns a value based on these.    */
  45. X/*                                                                   */
  46. X/* Return values: the OR of:                                         */
  47. X/*    1 if selBegin or selEnd is in synthetic text                   */
  48. X/*    2 if selBegin and selEnd are in different blocks               */
  49. X/*********************************************************************/
  50. int
  51. GetRealSelection( ff, selBeginOnly )
  52. X    struct openFile *ff;
  53. X    int selBeginOnly;
  54. X{
  55. X    extern Offset selBegin, selEnd;
  56. X    extern int debug;
  57. X
  58. X    Piece pp, ppBegin, ppEnd;
  59. X    Offset offsetBegin, offsetEnd;
  60. X    BlockID blockIDBegin;
  61. X    int nBeforePPBegin, nBetweenBeginAndEnd;
  62. X    int ret_value = 0;
  63. X    int beginPieceOffset;
  64. X
  65. X    /* find the cloned piece the selection starts in */
  66. X    ppBegin = findPiece( selBegin, ff, &beginPieceOffset );
  67. X    offsetBegin = selBegin - beginPieceOffset;
  68. X
  69. X    /* remember this so we can check it later */
  70. X    blockIDBegin = ppBegin->blockID;
  71. X
  72. X    /* do not allow the selection to begin in synthetic text since */
  73. X    /* it has no analog in the real file */
  74. X    if( ppBegin->flags & IS_DECORATION ) {
  75. X        ret_value |= 1;
  76. X        return ret_value;
  77. X    }
  78. X
  79. X    /* find the real piece in the chain of cloned pieces */
  80. X    while( ppBegin->flags & IS_CLONED_PIECE )
  81. X        ppBegin = ppBegin->nextClone;
  82. X
  83. X    /* count the number of file bytes in front of this piece */
  84. X    pp = ppBegin->prevPiece;
  85. X    nBeforePPBegin = 0;
  86. X    while( pp != NULL ) {
  87. X        nBeforePPBegin += pp->length;
  88. X        pp = pp->prevPiece;
  89. X    }
  90. printf("selBegin=%d, ", selBegin);
  91. X    selBegin = nBeforePPBegin + offsetBegin;
  92. printf("real selBegin=%d\n", selBegin);
  93. X
  94. X    if( selBeginOnly )
  95. X        return ret_value;
  96. X
  97. X    /* now do the same stuff with selEnd */
  98. X
  99. X    /* find the cloned piece the selection ends in */
  100. X    ppEnd = findPiece( selEnd, ff, &beginPieceOffset );
  101. X    offsetEnd = selEnd - beginPieceOffset;
  102. X
  103. X    /* check if the selection begins and ends in the same block */
  104. X    if( blockIDBegin != ppEnd->blockID )
  105. X        ret_value |= 2;
  106. X
  107. X    /* do not allow the selection to end in synthetic text since */
  108. X    /* it has no analog in the real file */
  109. X    if( ppEnd->flags & IS_DECORATION ) {
  110. X        ret_value |= 1;
  111. X        return ret_value;
  112. X    }
  113. X
  114. X    /* find the real piece in the chain of cloned pieces */
  115. X    while( ppEnd->flags & IS_CLONED_PIECE )
  116. X        ppEnd = ppEnd->nextClone;
  117. X
  118. X    /* figure out how many bytes between selBegin and selEnd */
  119. X    if( ppBegin == ppEnd ) {
  120. X        /* the selection begins and ends in the same real piece */
  121. printf("selEnd=%d, ", selEnd);
  122. X        selEnd = nBeforePPBegin + offsetEnd;
  123. printf("real selEnd=%d\n", selEnd);
  124. X    } else {
  125. X        pp = ppEnd->prevPiece;
  126. X        nBetweenBeginAndEnd = 0;
  127. X        while( pp != ppBegin ) {
  128. X            nBetweenBeginAndEnd += pp->length;
  129. X            pp = pp->prevPiece;
  130. X        }
  131. X printf("selEnd=%d, ", selEnd);
  132. X        selEnd = nBeforePPBegin + ppBegin->length
  133. X                    + nBetweenBeginAndEnd + offsetEnd;
  134. printf("real selEnd=%d\n", selEnd);
  135. X    }
  136. X
  137. X    return ret_value;
  138. X}
  139. X
  140. void
  141. InitHypertext()
  142. X{
  143. X    extern char * databaseName;
  144. X    extern DBM *currentDB;
  145. X    extern Document currentDocument;
  146. X    extern AttributeID mainFileBlock;
  147. X    extern MapID naturalMap;
  148. X
  149. X    Attribute main_file_block, procedure_header, procedure_body;
  150. X    Attribute comment, level0, level1, level2, level3, level4;
  151. X    Map block_map;
  152. X
  153. X    if( databaseName == NULL || databaseName[0] == '\0' ) {
  154. X        char *m = "NULL or empty hypertext database name\n";
  155. X        msg( m, 1 );
  156. X        printf( m );
  157. X        return;
  158. X    }
  159. X    currentDB = OpenObjects( databaseName );
  160. X    /* the document record always has key == 1 */
  161. X    currentDocument = GetDocument( currentDB, 1, ALLOCATE );
  162. X    if( currentDocument != NULL ) {
  163. X        /* this is an existing document */
  164. X        mainFileBlock = LookupAttributeByName( currentDB,
  165. X                    currentDocument, "Main File Block" );
  166. X        if( mainFileBlock == NullObject )
  167. X            printf(
  168. X"InitHypertext: ERROR! Could not find Main File Block attribute.\n");
  169. X        naturalMap = LookupMapByName( currentDB,
  170. X                    currentDocument, "Natural" );
  171. X        if( naturalMap == NullObject )
  172. X            printf(
  173. X"InitHypertext: ERROR! Could not find Natural map.\n");
  174. X        return;
  175. X    }
  176. X
  177. X    /* create the document structure and store it */
  178. X    currentDocument = CreateDocument( currentDB, databaseName );
  179. X
  180. X    /* create some predefined attributes */
  181. X    main_file_block = CreateAttribute( currentDB, currentDocument,
  182. X            "Main File Block" );
  183. X    mainFileBlock = main_file_block->this_one;
  184. X    procedure_header = CreateAttribute( currentDB, currentDocument,
  185. X            "Procedure Header" );
  186. X    procedure_body = CreateAttribute( currentDB, currentDocument,
  187. X            "Procedure Body" );
  188. X    comment = CreateAttribute( currentDB, currentDocument,
  189. X            "Comment" );
  190. X    level0 = CreateAttribute( currentDB, currentDocument,
  191. X            "Level 0" );
  192. X    level1 = CreateAttribute( currentDB, currentDocument,
  193. X            "Level 1" );
  194. X    level2 = CreateAttribute( currentDB, currentDocument,
  195. X            "Level 2" );
  196. X    level3 = CreateAttribute( currentDB, currentDocument,
  197. X            "Level 3" );
  198. X    level4 = CreateAttribute( currentDB, currentDocument,
  199. X            "Level 4" );
  200. X
  201. X    /* create some predefined maps */
  202. X
  203. X    block_map = CreateMap( currentDB, currentDocument, "Natural" );
  204. X    /* Set up the initial block map */
  205. X    strcpy( block_map->defaultRange, "[$a:$b:$a]" );
  206. X    naturalMap = block_map->this_one;
  207. X    PutMap( currentDB, block_map, RELEASE );
  208. X    
  209. X    block_map = CreateMap( currentDB, currentDocument, "Block numbers" );
  210. X    /* Set up the initial block map */
  211. X    strcpy( block_map->defaultRange, "[$i:$b:$i]" );
  212. X    PutMap( currentDB, block_map, RELEASE );
  213. X
  214. X    block_map = CreateMap( currentDB, currentDocument, "Verbose" );
  215. X    /* Set up the initial block map */
  216. X    strcpy( block_map->defaultRange, "[$a,$n,$i:$b:$a,$n,$i]" );
  217. X    PutMap( currentDB, block_map, RELEASE );
  218. X
  219. X    block_map = CreateMap( currentDB, currentDocument,
  220. X                        "No procedure bodies" );
  221. X    /* Set up the initial block map */
  222. X    block_map->domain[0] = procedure_body->this_one;
  223. X    strcpy( block_map->range[0], "...Body..." );
  224. X    strcpy( block_map->defaultRange, "[$a:$b:$a]" );
  225. X    PutMap( currentDB, block_map, RELEASE );
  226. X
  227. X    block_map = CreateMap( currentDB, currentDocument, "No comments" );
  228. X    /* Set up the initial block map */
  229. X    block_map->domain[0] = comment->this_one;
  230. X    strcpy( block_map->range[0], "/*...*/" );
  231. X    strcpy( block_map->defaultRange, "[$a:$b:$a]" );
  232. X    PutMap( currentDB, block_map, RELEASE );
  233. X
  234. X    block_map = CreateMap( currentDB, currentDocument, "Level 0-3 only" );
  235. X    /* Set up the initial block map */
  236. X    block_map->domain[0] = level4->this_one;
  237. X    strcpy( block_map->range[0], "...4..." );
  238. X    strcpy( block_map->defaultRange, "[$a:$b:$a]" );
  239. X    PutMap( currentDB, block_map, RELEASE );
  240. X
  241. X    block_map = CreateMap( currentDB, currentDocument, "Level 0-2 only" );
  242. X    /* Set up the initial block map */
  243. X    block_map->domain[0] = level4->this_one;
  244. X    strcpy( block_map->range[0], "...4..." );
  245. X    block_map->domain[0] = level3->this_one;
  246. X    strcpy( block_map->range[0], "...3..." );
  247. X    strcpy( block_map->defaultRange, "[$a:$b:$a]" );
  248. X    PutMap( currentDB, block_map, RELEASE );
  249. X
  250. X    block_map = CreateMap( currentDB, currentDocument, "Level 0-1 only" );
  251. X    /* Set up the initial block map */
  252. X    block_map->domain[0] = level4->this_one;
  253. X    strcpy( block_map->range[0], "...4..." );
  254. X    block_map->domain[0] = level3->this_one;
  255. X    strcpy( block_map->range[0], "...3..." );
  256. X    block_map->domain[0] = level2->this_one;
  257. X    strcpy( block_map->range[0], "...2..." );
  258. X    strcpy( block_map->defaultRange, "[$a:$b:$a]" );
  259. X    PutMap( currentDB, block_map, RELEASE );
  260. X
  261. X    block_map = CreateMap( currentDB, currentDocument, "Level 0 only" );
  262. X    /* Set up the initial block map */
  263. X    block_map->domain[0] = level4->this_one;
  264. X    strcpy( block_map->range[0], "...4..." );
  265. X    block_map->domain[0] = level3->this_one;
  266. X    strcpy( block_map->range[0], "...3..." );
  267. X    block_map->domain[0] = level2->this_one;
  268. X    strcpy( block_map->range[0], "...2..." );
  269. X    block_map->domain[0] = level1->this_one;
  270. X    strcpy( block_map->range[0], "...1..." );
  271. X    strcpy( block_map->defaultRange, "[$a:$b:$a]" );
  272. X    PutMap( currentDB, block_map, RELEASE );
  273. X
  274. X    /* free the attribute structures */
  275. X    PtFree( (char *)main_file_block );
  276. X    PtFree( (char *)procedure_header );
  277. X    PtFree( (char *)procedure_body );
  278. X    PtFree( (char *)comment );
  279. X    PtFree( (char *)level0 );
  280. X    PtFree( (char *)level1 );
  281. X    PtFree( (char *)level2 );
  282. X    PtFree( (char *)level3 );
  283. X    PtFree( (char *)level4 );
  284. X
  285. X    /* LATER: create some predefined views */
  286. X    PutDocument( currentDB, currentDocument, NO_RELEASE );
  287. printf("InitHypertext: currentDB=0X%X  currentDocument=0X%X\n");
  288. printf("*********** Dump of database opened **************\n");
  289. DumpDB( currentDB );
  290. X}
  291. X
  292. void
  293. CloseHypertext()
  294. X{
  295. X    extern DBM *currentDB;
  296. X
  297. X    CloseObjects( currentDB );
  298. X}
  299. X
  300. X#define EN_MAX 1000
  301. static unsigned long en_addrs[EN_MAX];
  302. static int last_en = 0;
  303. X
  304. static int
  305. XEncodeAddress( addr )
  306. X    unsigned long addr;
  307. X{
  308. X    int i;
  309. X
  310. X    /* a 1 resets the table */
  311. X    if( addr == 1 ) {
  312. X        last_en = 0;
  313. X        return 0;
  314. X    }
  315. X    
  316. X    /* search for this address */
  317. X    for( i = 0; i < last_en; ++i ) {
  318. X        if( en_addrs[i] == addr )
  319. X            return i;
  320. X    }
  321. X    /* have we overflowed the table? */
  322. X    if( i >= EN_MAX ) {
  323. X        return addr;
  324. X    }
  325. X    /* else install it in the table */
  326. X    en_addrs[last_en] = addr;
  327. X    return last_en++;
  328. X}
  329. X
  330. void
  331. DumpPieces( w )
  332. X    struct window *w;
  333. X{
  334. X    extern struct openFile *files;
  335. X    int fid = w->fileId;
  336. X    struct openFile *ff = &(files[fid]);
  337. X    
  338. X    PrintPieceChain( "************ fileId pieces ************",
  339. X        ff->pieceList, fid );
  340. X}
  341. void
  342. DumpRealPieces( w )
  343. X    struct window *w;
  344. X{
  345. X    extern struct openFile *files;
  346. X    int fid = w->realFileId;
  347. X    struct openFile *ff = &(files[fid]);
  348. X    
  349. X    PrintPieceChain( "************ realFileId pieces ************",
  350. X        ff->pieceList, fid );
  351. X}
  352. X
  353. void
  354. DumpTables()
  355. X{
  356. X    extern struct window *selWindow;
  357. X    
  358. X    DumpPieces( selWindow );
  359. X    DumpRealPieces( selWindow );
  360. X}
  361. X
  362. static char *
  363. ReadViewText( start, len, fid )
  364. X    int start;
  365. X    int len;
  366. X    int fid;
  367. X{
  368. X    int i;
  369. X    static char buffer[100];
  370. X    char *p = buffer;
  371. X    char ch;
  372. X
  373. X    if( len > 49 )
  374. X        len = 49;
  375. X    for( i = 0; i < len; ++i ) {
  376. X        ch = getFileByte( fid, start++ );
  377. X        if( ch == '\n' ) {
  378. X            *p++ = '\\';
  379. X            ch = 'n';
  380. X        } else if( ch == '\t' ) {
  381. X            *p++ = '\\';
  382. X            ch = 't';
  383. X        }
  384. X        *p++ = ch;
  385. X    }
  386. X    *p = '\0';
  387. X    return buffer;
  388. X}
  389. X
  390. void
  391. PrintPieceChain( title, pp, fid )
  392. X    char *title;
  393. X    Piece pp;
  394. X    int fid;
  395. X{
  396. X    int offset = 0;
  397. X
  398. X    printf("%s\n", title);
  399. X    printf("%7s%7s%3s%3s%4s%5s%4s%5s %s\n",
  400. X            "addr  ", "clone>", "fi", "fl",
  401. X            "bID", "pos", "len", "offs", "Contents" );
  402. X    while( pp != NULL ) {
  403. X        printf( "%7x%7x%3d%3x%4d%5d%4d%5d %s\n",
  404. X            EncodeAddress((unsigned int)pp),
  405. X            EncodeAddress((unsigned int)pp->nextClone),
  406. X            pp->file, pp->flags,
  407. X            pp->blockID, pp->position, pp->length, offset,
  408. X            ReadViewText(offset,pp->length,fid)
  409. X        );
  410. X        offset += pp->length;
  411. X        pp = pp->nextPiece;
  412. X    }
  413. X}
  414. X
  415. static Piece first_pp, last_pp;
  416. static int orig_handle;
  417. X
  418. static void
  419. AddPieceToChain( pos, len )
  420. X    Offset pos;
  421. X    int len;
  422. X{
  423. X    Piece pp;
  424. X
  425. X    pp = getFreePiece();
  426. X    pp->file = orig_handle;
  427. X    pp->position = pos;
  428. X    pp->length = len;
  429. X    /* put at the end of the list of pieces */
  430. X    if( last_pp == NULL ) {
  431. X        first_pp = pp;
  432. X        last_pp = pp;
  433. X    } else {
  434. X        pp->prevPiece = last_pp;
  435. X        last_pp->nextPiece = pp;
  436. X        last_pp = pp;
  437. X    }
  438. X}
  439. X
  440. void
  441. SeparateBlockMarkers( w )
  442. X    struct window *w;
  443. X{
  444. X    extern unsigned char beginMarkerChar;
  445. X    extern unsigned char endMarkerChar;
  446. X    extern struct openFile *files;
  447. X
  448. X    Offset pos, begin_pos;
  449. X    int fid = w->realFileId;
  450. X    struct openFile *ff = &files[fid];
  451. X    int flags;
  452. X    BlockID blockID;
  453. X    int uch, len;
  454. X
  455. X    /* get the file handle for the file */
  456. X    /* we ASSUME that there is only one piece in the piece table */
  457. X    orig_handle = ff->pieceList->file;
  458. X    begin_pos = pos = 0;
  459. X    last_pp = NULL;
  460. X    while( 1 ) {
  461. X        uch = getFileByte(fid, pos);
  462. X        if( uch == BLOCK_EOF || uch == beginMarkerChar ) {
  463. X            /* adjust pos if a character was not really read */
  464. X            /* (that is, if BLOCK_EOF was read) */
  465. X            if( uch == BLOCK_EOF )
  466. X                --pos;
  467. X            len = pos - begin_pos;
  468. X            if( len > 0 ) {
  469. X                AddPieceToChain( begin_pos, len );
  470. X                begin_pos = pos;
  471. X            }
  472. X            if( uch == BLOCK_EOF )
  473. X                break;
  474. X            if( uch == beginMarkerChar ) {
  475. X                begin_pos = pos;
  476. X                pos = ReadBlockMarker( fid, pos+1, &blockID,
  477. X                    (unsigned int *)&flags );
  478. X                /* LATER: verify and save blockID and flags */
  479. X                AddPieceToChain( begin_pos, MARKER_SIZE );
  480. X                begin_pos = pos;
  481. X            }
  482. X        }
  483. X        ++pos;
  484. X    }
  485. X    /* install the new piece table */
  486. X    freePieces( ff->pieceList );
  487. X    ff->pieceList = first_pp;
  488. X    /* initialize the optimization fields */
  489. X    ff->loLogPiece = 0;
  490. X    ff->hiLogPiece = first_pp->length - 1;
  491. X    ff->logPiece = first_pp;
  492. X    ff->hiLogBuffer = -1;
  493. X    ff->loLogBuffer = -1;
  494. X    ff->logBuf = NULL;
  495. X}
  496. X
  497. Offset
  498. ReadBlockMarker( fid, pos, blockID, flags )
  499. X    int fid;
  500. X    Offset pos;
  501. X    BlockID *blockID;
  502. X    unsigned int *flags;
  503. X{
  504. X    extern unsigned char endMarkerChar;
  505. X
  506. X    unsigned int n;
  507. X    unsigned char uch;
  508. X    int i;
  509. X
  510. X    /* read the block number */
  511. X    n = 0;
  512. X    for( i = 0; i < 6; ++i )
  513. X        n = 10*n + getFileByte(fid, pos++) - '0';
  514. X    *blockID = (BlockID)n;
  515. X    ++pos;    /* skip the ',' */
  516. X
  517. X    /* read the flags */
  518. X    *flags = (int)getFileByte( fid, pos++ );
  519. X
  520. X    /* move past the end of marker character */
  521. X    uch = (unsigned char)getFileByte( fid, pos++ );
  522. X    if( uch != endMarkerChar )
  523. X        printf("ReadBlockMarker: marker ends with %x not %X\n",
  524. X            uch, endMarkerChar);
  525. X    return pos;
  526. X}
  527. X
  528. Offset
  529. XFindBlock( blockID, fid )
  530. X    BlockID blockID;
  531. X    int fid;
  532. X{
  533. X    extern unsigned char beginMarkerChar;
  534. X
  535. X    Offset offset = 0;
  536. X    int uch;
  537. X    unsigned int blockNumber, flags;
  538. X
  539. X    while( 1 ) {
  540. X        uch = getFileByte( fid, offset++ );
  541. X        if( uch == BLOCK_EOF ) {
  542. X            printf("FindBlock: blockID %d not found in file\n",
  543. X                blockID);
  544. X            return -1;
  545. X        }
  546. X        if( (unsigned char)uch == beginMarkerChar ) {
  547. X            /* read the block number */
  548. X            offset = ReadBlockMarker( fid, offset, &blockNumber,
  549. X                                &flags );
  550. X            if( flags == (int)BeginBlockFlag
  551. X                        && blockNumber == blockID )
  552. X                return offset - MARKER_SIZE;
  553. X        }
  554. X    }
  555. X    /*NOTREACHED*/
  556. X}
  557. X
  558. Offset
  559. SkipToEndOfBlock( fid, offset, endBlockID )
  560. X    int fid;
  561. X    Offset offset;
  562. X    BlockID endBlockID;
  563. X{
  564. X    extern unsigned char beginMarkerChar;
  565. X
  566. X    int uch;
  567. X    unsigned int flags;
  568. X    BlockID blockID;
  569. X    
  570. X    while( 1 ) {
  571. X        uch = getFileByte( fid, offset++ );
  572. X        if( uch == BLOCK_EOF ) {
  573. X            printf(
  574. X"SkipToEndOfBlock: end of block %d not found in file\n",
  575. X                endBlockID );
  576. X            /* and end of file automatically ends any blocks */
  577. X            break;
  578. X        }
  579. X        if( uch == beginMarkerChar ) {
  580. X            offset = ReadBlockMarker( fid, offset, &blockID, &flags );
  581. X            if( (endBlockID == 0 || blockID == endBlockID) ) {
  582. X                if( flags != EndBlockFlag )
  583. X                    printf(
  584. X"SkipToEndOfBlock: found another beginning for block %d (%d)\n",
  585. X                        endBlockID, blockID );
  586. X                break;
  587. X            }
  588. X            /* else keep looking */
  589. X        }
  590. X        /* else keep looking */
  591. X    }
  592. X    return offset;
  593. X}
  594. X
  595. void
  596. CreateViewPieceTable( w, ff )
  597. X    struct window *w;
  598. X    struct openFile *ff;
  599. X{
  600. X    extern int debug;
  601. X
  602. X    Offset offset;
  603. X    Piece pp;
  604. X    int length;
  605. X
  606. X    offset = FindBlock( w->block->this_one, w->realFileId );
  607. X    (void)CreatePieceTableForBlock( w, offset, &(ff->pieceList), NULL );
  608. X    
  609. X    /* find out the length of the file */
  610. X    length = 0;
  611. X    pp = ff->pieceList;
  612. X    while( pp != NULL ) {
  613. X        length += pp->length;
  614. X        pp = pp->nextPiece;
  615. X    }
  616. X    ff->fileSize = length;
  617. X    ff->origFileSize = length;
  618. X}
  619. X
  620. Offset
  621. ProcessOneBlock( blockID, w, offset, firstPiece, lastPiece )
  622. X    BlockID blockID;
  623. X    struct window *w;
  624. X    Offset offset;
  625. X    Piece *firstPiece;
  626. X    Piece *lastPiece;
  627. X{
  628. X    extern unsigned char beginMarkerChar;
  629. X    extern int debug;
  630. X
  631. X    Piece firstpp = NULL;
  632. X    Piece lastpp = NULL;
  633. X    Piece fp, lp;
  634. X    Offset beginOffset;
  635. X    int uch;
  636. X    unsigned int id, flags;
  637. X    int fid = w->realFileId;
  638. X
  639. X    while( 1 ) {    /* loop through each run of characters or subblock */
  640. X        beginOffset = offset;    /* remember for later */
  641. X        /* scan characters until EOF or a block marker is found */
  642. X        while( 1 ) {
  643. X            uch = getFileByte( fid, offset++ );
  644. X            if( uch == BLOCK_EOF || uch == beginMarkerChar )
  645. X                break;
  646. X        }
  647. X        CreateSpanPieces(blockID, fid, beginOffset, offset-2, &fp, &lp);
  648. X            /* CreateSpanPieces handles empty runs */
  649. X        if( fp != NULL ) {
  650. X            if( lastpp == NULL ) {
  651. X                firstpp = fp;
  652. X                lastpp = lp;
  653. X            } else {
  654. X                fp->prevPiece = lastpp;
  655. X                lastpp->nextPiece = fp;
  656. X                lastpp = lp;
  657. X            }
  658. X        }
  659. X        if( uch == BLOCK_EOF ) {
  660. X            printf("ProcessOneBlock: hit EOF looking for block\n");
  661. X            break;
  662. X        }
  663. X        offset = ReadBlockMarker( fid, offset, &id, &flags );
  664. X        if( id == blockID ) {
  665. X            /* same id -- should be the end of the block */
  666. X            if( flags != EndBlockFlag )
  667. X                printf("ProcessOneBlock: wrong block marker\n");
  668. X            break;
  669. X        }
  670. X        if( flags != BeginBlockFlag ) {
  671. X            printf( "ProcessOneBlock: block end should be begin\n");
  672. X            break;
  673. X        }
  674. X        offset = CreatePieceTableForBlock( w, offset-MARKER_SIZE, &fp,
  675. X                                    &lp );
  676. X        if( fp != NULL ) {
  677. X            if( lastpp == NULL ) {
  678. X                firstpp = fp;
  679. X                lastpp = lp;
  680. X            } else {
  681. X                fp->prevPiece = lastpp;
  682. X                lastpp->nextPiece = fp;
  683. X                lastpp = lp;
  684. X            }
  685. X        }
  686. X    }
  687. X    *firstPiece = firstpp;
  688. X    *lastPiece = lastpp;
  689. X    return offset;
  690. X}
  691. X
  692. void
  693. CreateSpanPieces( blockID, fid, begin, end, fp, lp )
  694. X    BlockID blockID;
  695. X    int fid;
  696. X    Offset begin, end;
  697. X    Piece *fp, *lp;
  698. X{
  699. X    extern struct openFile *files;
  700. X    extern int debug;
  701. X
  702. X    Piece firstpp = NULL;
  703. X    Piece lastpp = NULL;
  704. X    Piece newpp, oldpp;
  705. X    struct openFile *ff;
  706. X    Offset beginPiece;
  707. X    Offset pieceOffset;
  708. X    Offset pieceLength;
  709. X    Offset size;
  710. X
  711. X    ff = &files[fid];
  712. X    while( begin <= end ) {
  713. X        oldpp = findPiece( begin, ff, &beginPiece );
  714. X        pieceOffset = begin - beginPiece;
  715. X        newpp = getFreePiece();
  716. X        newpp->flags = IS_CLONED_PIECE;
  717. X        newpp->blockID = blockID;
  718. X        newpp->position = oldpp->position + pieceOffset;
  719. X        pieceLength = oldpp->length - pieceOffset;
  720. X        size = end - begin + 1;
  721. X        if( pieceLength > size )
  722. X            pieceLength = size;
  723. X        begin += pieceLength;
  724. X        newpp->length = pieceLength;
  725. X        newpp->file = oldpp->file;
  726. X        /* link into the chain of cloned pieces */
  727. X        newpp->nextClone = oldpp->nextClone;
  728. X        oldpp->nextClone = newpp;
  729. X        /* link onto the chain of pieces for this span */
  730. X        if( lastpp == NULL ) {
  731. X            lastpp = newpp;
  732. X            firstpp = newpp;
  733. X        } else {
  734. X            lastpp->nextPiece = newpp;
  735. X            newpp->prevPiece = lastpp;
  736. X            lastpp = newpp;
  737. X        }
  738. X    }
  739. X    *fp = firstpp;
  740. X    *lp = lastpp;
  741. X}
  742. X
  743. Offset
  744. CreatePieceTableForBlock( w, offset, firstPiece, lastPiece )
  745. X    struct window *w;
  746. X    Offset offset;
  747. X    Piece *firstPiece;
  748. X    Piece *lastPiece;
  749. X{
  750. X    extern struct openFile *files;
  751. X    extern unsigned char beginMarkerChar;
  752. X    extern unsigned char endMarkerChar;
  753. X    extern Offset addPosition;
  754. X    extern int addHandle;
  755. X    extern int debug;
  756. X    extern char msgBuffer[];
  757. X
  758. X    int uch;
  759. X    char ch2;
  760. X    Block block;
  761. X    ID attrID;
  762. X    unsigned char *s;
  763. X    int i;
  764. X    int blockSkipped;
  765. X    Map blockMap;
  766. X    Attribute attribute;
  767. X    unsigned int flags;
  768. X    char *p;
  769. X    Offset stringBegin, size;
  770. X    Piece firstpp = NULL;
  771. X    Piece lastpp = NULL;
  772. X    Piece pp, fp, lp;
  773. X    BlockID blockID;
  774. X    int fid = w->realFileId;
  775. X    DBM *db = w->db;
  776. X
  777. X    uch = getFileByte( fid, offset++ );    /* read beginMarkerChar */
  778. X    if( uch != beginMarkerChar ) {
  779. X        printf("CreatePieceTableForBlock: no block marker\n");
  780. X        return NULL;
  781. X    }
  782. X
  783. X    offset = ReadBlockMarker( fid, offset, &blockID, &flags );
  784. X        /* get the block to get the attribute IDs */
  785. X    block = GetBlock( db, blockID, NO_ALLOCATE);
  786. X    if( block != NULL ) {
  787. X        attrID = block->attribute[0];
  788. X    } else {
  789. X        printf("Cannot find block %d\n", blockID);
  790. X        attrID = 0;
  791. X    }
  792. X
  793. X    /* get the block map and look for our attribute */
  794. X    blockMap = w->blockMap;
  795. X    s = (unsigned char *)blockMap->defaultRange;
  796. X    for( i = 0; i < MAP_SIZE; ++i ) {
  797. X        if( blockMap->domain[i] == attrID ) {
  798. X            s = (unsigned char *)blockMap->range[i];
  799. X            break;
  800. X        }
  801. X    }
  802. X    
  803. X    blockSkipped = 0;
  804. X    stringBegin = addPosition;
  805. X
  806. X    /* process the format string */
  807. X    while( (ch2 = *s++) != '\0' ) {
  808. X        if( ch2 != FormatMarker ) {
  809. X            writeChar( ch2, addPosition++ );
  810. X            continue;
  811. X        }
  812. X        /* else it is a format character, so get the control char */
  813. X        ch2 = *s++;
  814. X        /* this is to guard against a malformed format */
  815. X        if( ch2 == '\0' ) {
  816. X            printf(
  817. X"CreatePieceTableForBlock: format char (%c) at end of format string\n",
  818. X                FormatMarker );
  819. X            break;
  820. X        }
  821. X        switch( ch2 ) {
  822. X        case PutBlockContents:
  823. X            /* create a piece for the inital block string */
  824. X            size = addPosition - stringBegin;
  825. X            if( size > 0 ) {
  826. X                pp = getFreePiece();
  827. X                pp->file = addHandle;
  828. X                pp->position = stringBegin;
  829. X                pp->length = size;
  830. X                pp->flags |= IS_DECORATION;
  831. X                pp->blockID = blockID;
  832. X                if( lastpp == NULL ) {
  833. X                    /* still empty */
  834. X                    firstpp = pp;
  835. X                    lastpp = pp;
  836. X                } else {
  837. X                    pp->prevPiece = lastpp;
  838. X                    lastpp->nextPiece = pp;
  839. X                    lastpp = pp;
  840. X                }
  841. X            }
  842. X            /* put in the pieces for the block */
  843. X            offset = ProcessOneBlock(blockID, w, offset, &fp, &lp);
  844. X            if( fp != NULL ) {
  845. X                if( lastpp == NULL ) {
  846. X                    firstpp = fp;
  847. X                    lastpp = lp;
  848. X                } else {
  849. X                    fp->prevPiece = lastpp;
  850. X                    lastpp->nextPiece = fp;
  851. X                    lastpp = lp;
  852. X                }
  853. X            }
  854. X            /* indicate we have passed over the block */
  855. X            blockSkipped = 1;
  856. X            /* start a new string for the stuff after */
  857. X            /* the block contents */
  858. X            stringBegin = addPosition;
  859. X            break;
  860. X        case PutBlockID:
  861. X            sprintf( msgBuffer, "%d", blockID );
  862. X            goto InsertString;
  863. X        case PutBlockName:
  864. X            block = GetBlock( db, blockID, NO_ALLOCATE);
  865. X            sprintf( msgBuffer, "%s", block->name );
  866. X            goto InsertString;
  867. X        case PutAttributeName:
  868. X            block = GetBlock( db, blockID, NO_ALLOCATE);
  869. X            attribute = GetAttribute( db, block->attribute[0],
  870. X                                NO_ALLOCATE);
  871. X            sprintf( msgBuffer, "%s", attribute->name );
  872. X        InsertString:
  873. X            p = msgBuffer;
  874. X            while( (ch2 = *p++) != '\0' )
  875. X                writeChar(ch2, addPosition++);
  876. X            break;
  877. X        default:
  878. X            printf("Unknown format (%c) in block format string\n",
  879. X                ch2);
  880. X            break;
  881. X        }
  882. X    }
  883. X    size = addPosition - stringBegin;
  884. X    if( size > 0 ) {
  885. X        pp = getFreePiece();
  886. X        pp->file = addHandle;
  887. X        pp->position = stringBegin;
  888. X        pp->flags |= IS_DECORATION;
  889. X        pp->blockID = blockID;
  890. X        pp->length = size;
  891. X        if( lastpp == NULL ) {
  892. X            /* still empty */
  893. X            firstpp = pp;
  894. X            lastpp = pp;
  895. X        } else {
  896. X            pp->prevPiece = lastpp;
  897. X            lastpp->nextPiece = pp;
  898. X            lastpp = pp;
  899. X        }
  900. X    }
  901. X
  902. X    if( !blockSkipped )
  903. X        offset = SkipToEndOfBlock( fid, offset, blockID );
  904. X    if( firstPiece != NULL )
  905. X        *firstPiece = firstpp;
  906. X    if( lastPiece != NULL )
  907. X        *lastPiece = lastpp;
  908. X    return offset;
  909. X}
  910. X
  911. void
  912. XFreeOldViewPieces( ff )
  913. X    struct openFile *ff;
  914. X{
  915. X    Piece pp = ff->pieceList;
  916. X    Piece pp_prev;
  917. X    
  918. X    while( pp != NULL ) {
  919. X        /* go around the circular list to find the previous piece */
  920. X        pp_prev = pp->nextClone;
  921. X        while( pp_prev->nextClone != pp )
  922. X            pp_prev = pp->nextClone;
  923. X        if( pp_prev != pp ) {    /* check this to be safe */
  924. X            pp_prev->nextClone = pp->nextClone;
  925. X        }
  926. X        pp = pp->nextPiece;
  927. X    }
  928. X    freePieces( ff->pieceList );
  929. X    ff->pieceList = NULL;    /* just to be safe */
  930. X}
  931. X
  932. int
  933. CreateViewFile( w )
  934. X    struct window *w;
  935. X{
  936. X    extern struct openFile *files;
  937. X    extern int maxFiles;
  938. X
  939. X    int fileNumber;
  940. X    struct openFile *ff;
  941. X
  942. X    /* find a free file structure */
  943. X    for(fileNumber = 0; fileNumber < maxFiles; fileNumber++) {
  944. X        if( files[fileNumber].origHandle == -1 )
  945. X            break;
  946. X    }
  947. X    if( fileNumber == maxFiles ) {
  948. X        msg("openFile: out of file structures", 3);
  949. X        return -1;
  950. X    }
  951. X    ff = &files[fileNumber];
  952. X    strncpy( ff->origName, w->file->name, FILENAMESIZE );
  953. X    ff->origHandle = -2;    /* invalid handle -- not used */
  954. X    ff->isView = 1;
  955. X    ff->useCount = 1;
  956. X    ff->flags = 0;
  957. X
  958. X    /* now build the pieces of this view */
  959. X    CreateViewPieceTable( w, ff );
  960. X
  961. X    /* initialize the optimization fields to first piece */
  962. X    ff->loLogPiece = 0;
  963. X    ff->hiLogPiece = ff->pieceList->length - 1;
  964. X    ff->logPiece = ff->pieceList;
  965. X    ff->hiLogBuffer = -1;
  966. X    ff->loLogBuffer = -1;
  967. X    ff->logBuf = NULL;
  968. X
  969. X    /* return the fileId */
  970. X    return fileNumber;
  971. X}
  972. X
  973. void
  974. AddFileToDocument( w )
  975. X    struct window *w;
  976. X{
  977. X    extern DBM *currentDB;
  978. X    extern Document currentDocument;
  979. X    extern Offset selBegin, selEnd;
  980. X    extern struct openFile *files;
  981. X    extern AttributeID mainFileBlock;
  982. X    extern MapID naturalMap;
  983. X
  984. X    char *name, *long_name;
  985. X
  986. X    if( w->db != NULL ) {
  987. X        printf("db is not NULL, is this already a Anasazi document?\n");
  988. X        return;
  989. X    }
  990. X    w->db = currentDB;
  991. X    w->document = currentDocument;
  992. X
  993. X    long_name = files[w->fileId].origName;
  994. X    name = &(files[w->fileId].origName[w->nameOffset]);
  995. X
  996. X    /* create the file and store it */
  997. X    w->file = CreateFile( w->db, w->document, long_name );
  998. X    
  999. X    /* create a block out of the whole file (and store it) */
  1000. X    w->block = CreateBlock( w->db, w->document, name, mainFileBlock, 0,
  1001. X                            w->file->this_one );
  1002. X    /* select the whole file */
  1003. X    selBegin = 0;
  1004. X    selEnd = fileSize( w->fileId ) - 1;
  1005. X    InsertBlock( w->block->this_one );
  1006. X    
  1007. X    /* use the default (Natural) map */
  1008. X    w->blockMap = GetMap( w->db, naturalMap, ALLOCATE );
  1009. X
  1010. X    /* the link maps are initially empty */
  1011. X    w->fromLinkMap = NULL;
  1012. X    w->toLinkMap = NULL;
  1013. X
  1014. X    /* create the initial view and store it */
  1015. X    w->view = CreateView( w->db, w->document, name, w->block->this_one,
  1016. X                NullObject, NullObject, w->blockMap->this_one );
  1017. X    
  1018. X    /* set up the cloned piece table */
  1019. X    w->realFileId = w->fileId;    /* save the real fid */
  1020. X    w->fileId = CreateViewFile( w );
  1021. X
  1022. X    /* finish up */
  1023. X    w->posTopline = 0;
  1024. X    selBegin = 0;
  1025. X    selEnd = 0;
  1026. X    AssertSelectionOwnership();
  1027. X
  1028. X    /* set up the last row cache */
  1029. X    w->posCurLast = 0;
  1030. X    w->lastPosTop = 0;
  1031. X    w->rowCurLast = 0;
  1032. X}
  1033. X
  1034. int
  1035. InsertBlock( n )
  1036. X    unsigned int n;
  1037. X{
  1038. X    extern Offset selBegin, selEnd;
  1039. X    extern struct window *selWindow;
  1040. X    extern unsigned char beginMarkerChar;
  1041. X    extern unsigned char endMarkerChar;
  1042. X    extern struct openFile *files;
  1043. X    extern char msgBuffer[];
  1044. X    extern int hypertextOn;
  1045. X
  1046. X    Offset saveSelBegin = selBegin;
  1047. X    int i;
  1048. X    int saveHypertextOn = hypertextOn;
  1049. X
  1050. X    hypertextOn = 0;
  1051. X    
  1052. X    /* insert the end marker */
  1053. X    /* move one character past the selection for the insertion */
  1054. X    selBegin = ++selEnd;
  1055. X
  1056. X    insertChar( beginMarkerChar );
  1057. X    sprintf( msgBuffer, "%06d", n );
  1058. X    for( i = 0; i < 6; ++i )
  1059. X        insertChar( msgBuffer[i] );
  1060. X    insertChar( ',' );
  1061. X    insertChar( EndBlockFlag );
  1062. X    insertChar( endMarkerChar );
  1063. X
  1064. X    /* insert the begin marker */
  1065. X    selEnd = selBegin = saveSelBegin;
  1066. X    insertChar( beginMarkerChar );
  1067. X    for( i = 0; i < 6; ++i )
  1068. X        insertChar( msgBuffer[i] );
  1069. X    insertChar( ',' );
  1070. X    insertChar( BeginBlockFlag );
  1071. X    insertChar( endMarkerChar );
  1072. X
  1073. X    hypertextOn = saveHypertextOn;
  1074. X    
  1075. X    return 1;
  1076. X}
  1077. X#endif
  1078. X
  1079. END_OF_FILE
  1080. if test 26116 -ne `wc -c <'anaSources.c'`; then
  1081.     echo shar: \"'anaSources.c'\" unpacked with wrong size!
  1082. fi
  1083. # end of 'anaSources.c'
  1084. fi
  1085. if test -f 'doc/point.n' -a "${1}" != "-c" ; then 
  1086.   echo shar: Will not clobber existing file \"'doc/point.n'\"
  1087. else
  1088. echo shar: Extracting \"'doc/point.n'\" \(23608 characters\)
  1089. sed "s/^X//" >'doc/point.n' <<'END_OF_FILE'
  1090. X.TH PT 1 "7 February 1992"
  1091. X.SH NAME
  1092. Point \- an X-based text editor
  1093. X.SH SYNOPSIS
  1094. X.B point
  1095. X[-nobrowser] [-nb]
  1096. X[
  1097. X.IR filename \.\|\.\|\.\|]
  1098. X.SH DESCRIPTION
  1099. This document gives an overview of Point so you can
  1100. get started using it quickly to determine whether you like it or not.
  1101. There is a longer manual that describes Point in detail.
  1102. Point is highly configurable but in this document will describe
  1103. the configuration specified in files \fItclLib/*.tcl\fR.
  1104. X
  1105. X
  1106. X
  1107. X.SH USAGE
  1108. X
  1109. X
  1110. X.SS Starting Point
  1111. You just have to make sure that
  1112. X.I point
  1113. is in your
  1114. X.IR path .
  1115. Point uses a startup file to specify menus, key bindings and options.
  1116. Point will look for a startup file
  1117. X.I ~/.ptrc
  1118. first.
  1119. Typically this will just source the real startup file but by doing it
  1120. this way, the startup file is found no matter which directory you
  1121. start point in.
  1122. If it cannot find that it will look for 
  1123. X.IR ./ptsetup.tcl .
  1124. If it cannot find either of those it will use an installation
  1125. default which is the configuration described in this manual page.
  1126. The default startup file will print out its pathname so you can
  1127. copy and modify it to configure Point the way you would like.
  1128. X.LP
  1129. When Point starts a thin
  1130. X.I file browser
  1131. appears in the upper, central part
  1132. of your screen and a text window for each file name on the command line
  1133. will appear on the upper left, all stacked on top of each other
  1134. X(thus you will only see one text window).
  1135. X(The reference manual describes a way for Point to find its
  1136. configuration file from any directory.)
  1137. X
  1138. X
  1139. X.SS Selecting text
  1140. The
  1141. X.I selection
  1142. is a central concept in Point.
  1143. The selection is the implied object of many Point commands
  1144. X(e.g., delete, move, copy, search).
  1145. The
  1146. X.I insertion point
  1147. is the position just in front
  1148. of the first character of the selection and is the destination
  1149. of all insert operation in Point (e.g., typed characters, insert scrap,
  1150. move and copy)
  1151. The selection is one or more characters of text in one of the
  1152. open text windows.
  1153. There is only one selection among all the text windows at any one time.
  1154. X.LP
  1155. You select text in the usual way, that is,
  1156. you move the sprite to the first character of the intended
  1157. selection, press the left mouse button, move the sprite to
  1158. the last character of the selection and release the left mouse button.
  1159. Alternatively you can click the left mouse button on the
  1160. first character of the intended selection and click the right
  1161. mouse button on the last character of the selection.
  1162. XFinally you can double (triple) click on a word (line) to select it.
  1163. By holding down the second (third) click and moving the mouse
  1164. you can extend the selection by words (lines).
  1165. X
  1166. X
  1167. X.SS X selections
  1168. When you select text in Point it becomes the X selection
  1169. and can be inserted in \fIxterm\fR windows (for example) by clicking
  1170. the middle mouse button.
  1171. The ``Insert X selection'' command (on the EDIT menu) inserts the X selection
  1172. into a Point text window at the insertion point. 
  1173. This X selection must be made after any Point selections to ensure
  1174. that it is the current X selection.
  1175. X
  1176. X
  1177. X.SS Editing text
  1178. Typed characters are inserted at the insertion point
  1179. X(just in front of the first character of the selection).
  1180. The delete (to the scrap buffer) command
  1181. deletes the selected text into the scrap buffer.
  1182. The delete command is on the \fIScrap =>\fR submenu of the EDIT menu
  1183. and is also attached to the F1 key.
  1184. The insert (from the scrap buffer) command inserts the text
  1185. in the scrap buffer at the insertion point.
  1186. The insert command is on the \fIScrap =>\fR submenu of the EDIT menu
  1187. and is also attached to the F2 key.
  1188. X.LP
  1189. Point keeps a history list of all commands executed.
  1190. The \fIagain\fR command repeats the last command using the current selection.
  1191. The \fIundo\fR command undoes the last command.
  1192. Additional \fIundo\fR commands undo earlier and earlier commands.
  1193. If you undo too many commands the \fIredo\fR command will
  1194. redo an undone command.
  1195. These are all on the \fIUndo/Again/Redo =>\fR submenu of the EDIT menu.
  1196. X
  1197. X
  1198. X.SS Scrolling the text
  1199. Point has vertical and horizontal scroll bars.
  1200. The size and position of the slider in the scroll bar indicate how
  1201. much of and what part of the file is being displayed in the window.
  1202. The right mouse button scrolls down (towards the end of the file)
  1203. and the left mouse button scrolls up (towards the beginning of the file)
  1204. when they are clicked in the scroll bar.
  1205. The line of text beside the sprite (mouse cursor) is moved to the top
  1206. of the window when you scroll down and is replaced by the top
  1207. line when you scroll up.
  1208. This allows you to control exactly the number of lines scrolls.
  1209. It is common to use this feature to move the beginning of the text
  1210. of interest (say a procedure definition) to the top of the window.
  1211. If you hold down the left or right mouse button the window
  1212. will scroll continuously (after a short initial delay).
  1213. When the middle mouse button is clicked in the scroll bar the window
  1214. jumps so that the top of the slider is located at the location of
  1215. the mouse sprite.
  1216. The middle mouse button can also be dragged to scroll the text.
  1217. X
  1218. X
  1219. X.SS Searching for text
  1220. The \fISearch for string =>\fR submenu of the GOTO menu contains
  1221. several commands
  1222. which search for a string and reposition the window
  1223. so that the string is displayed in the window.
  1224. You can search forward (backward) for the next (previous) instance of the
  1225. selected text.
  1226. You can also repeat the last search (forward or backwards),
  1227. that is, search again for the last string searched for or
  1228. you can bring up a dialogue box that allows you to enter a search string.
  1229. Also there is a regular expression search command that uses the same
  1230. types of regular expressions as the Unix commands grep/sed/ed/ex/vi.
  1231. X
  1232. X
  1233. X.SS Moving around the file
  1234. The GOTO menu contains several other functions that move the window
  1235. around the text.
  1236. The \fIMove in file to =>\fR submenu has specific commands to move
  1237. to the beginning and end of the
  1238. file although this can also be done using the scroll bar.
  1239. When you jump around the file (that is, any movement not a scroll)
  1240. Point remembers the last place you jumped from
  1241. and there is a command to go back to that place.
  1242. This command is convenient for alternating between two places
  1243. in the file.
  1244. The GOTO menu also has commands to go to specified line
  1245. numbers and to show the selection.
  1246. X
  1247. X
  1248. X.SS Moving and resizing windows
  1249. The FILE menu has a submenu (\fIMove Window =>\fR) with four commands
  1250. X(\fIMove to (NW,NE,SE,SW)\fR)
  1251. which will move windows to one of the predefined
  1252. locations for windows and a \fIZoom vertical\fR command that
  1253. zooms the window vertically to (almost) the whole height of the screen.
  1254. You can also move and resize the windows using the usual
  1255. window manager commands.
  1256. X
  1257. X
  1258. X.SS Raising and lowering windows
  1259. Click on a window name in the list of windows at the top of the
  1260. file browser to top that window (and move it to
  1261. the first predefined window stack location).
  1262. Clicking with the middle or right mouse buttons tops the window and
  1263. moves it to the second or third window stack locations.
  1264. You can also raise and lower windows using the window manager.
  1265. X
  1266. X
  1267. X.SS Opening windows and changing directories
  1268. To open a window, double click on the name of the desired
  1269. file in the file browser.
  1270. To change to a directory, double click on its name in the file browser.
  1271. The DIRS menu (on the file browser menu bar)
  1272. also allows direct jumps to some directories.
  1273. Double clicking with the middle or right mouse buttons
  1274. also opens a window but at the second (SE)
  1275. and third (NE) window stack locations.
  1276. X
  1277. X
  1278. X.SS Closing windows
  1279. To close a window, click on the \fIClose\fR item on its menu bar.
  1280. If the file in the window has been edited and not saved it will be
  1281. saved automatically (click with the right mouse button to prevent
  1282. this saving).
  1283. The \fIClose =>\fR submenu of the FILE menu has commands
  1284. to close and automatically save and close and automatically not save.
  1285. You can also save the file or write it to a new name
  1286. using commands from the FILE menu.
  1287. X
  1288. X
  1289. X.SS Redrawing the screen
  1290. Point occasionally fails to update the display correctly.
  1291. Clicking the right mouse button on \fISv\fR and selecting
  1292. the \fIRedraw window\fR command
  1293. on the EDIT menu) fixes it up and ensures that the
  1294. display reflects the actual state of the text.
  1295. X
  1296. X
  1297. X.SS Changing fonts
  1298. The FILE menu (submenu \fISet text fonts =>\fR)
  1299. allows you to change the font used to display the
  1300. text in the window.
  1301. This allows you to see more text or see it the text more easily
  1302. X(but not both).
  1303. You can change the font size at any time.
  1304. It is often useful to change to a smaller font for a short time
  1305. in order to see more text.
  1306. X
  1307. X
  1308. X.SS The text window menu bar
  1309. The FILE menu contains file and window related commands.
  1310. The EDIT menu contains commands that change text.
  1311. The GOTO window contains commands that move the window around the text
  1312. X(including the search commands).
  1313. X
  1314. Most of the menu bar items do different things depending
  1315. on which mouse button you click on them.
  1316. I have tried to group the functions logically with related
  1317. functions grouped together.
  1318. Here are the overloaded functions (where LMB represents
  1319. clicking the left mouse
  1320. button and MMB and RMB clicking the middle and right mouse buttons):
  1321. X.LP
  1322. X.IP \fB<<\fR
  1323. LMB: search backward for selection, MMB: pop up search dialogue box,
  1324. RMB: search backward for the last string searched for
  1325. X.IP \fB>>\fR
  1326. LMB: search forward for selection, MMB: pop up search dialogue box,
  1327. RMB: search forward for the last string searched for
  1328. X.IP \fBClose\fR
  1329. LMB: close and save, MMB: close and ask about saving changes,
  1330. RMB: close and do not save changes
  1331. X.IP \fBSv\fR
  1332. LMB: save, MMB: save as (write with new name), RMB: redraw the window
  1333. X(This combination is not logical but I wanted redraw somewhere.)
  1334. X.IP \fBJump\fR
  1335. LMB: beginning of file, MMB: last place jumped from, RMB: end of file
  1336. X.IP \fBTag\fR
  1337. LMB: find selected tag,
  1338. MMB: bring up tag dialogue box
  1339. RMB: find selected keyword
  1340. X.IP \fB++X--\fR
  1341. LMB: insert (at the insertion point) the scrap, MMB: insert the X selection,
  1342. RMB: delete the selection to the scrap
  1343. X.IP \fB+Do-\fR
  1344. LMB: redo, MMB: repeat last edit (again), RMB: undo
  1345. X.IP \fBZz\fR
  1346. LMB: make selection upper case, MMB: toggle case of selection,
  1347. RMB: make selection lower case
  1348. X.IP \fBMoveW\fR Move this window to:
  1349. LMB: NW position, MMB: SE position, RMB: NE position
  1350. X.IP \fBLine#\fR
  1351. LMB: got selected line number, MMB: pop up goto line number dialogue box,
  1352. RMB: zoom window vertically
  1353. X(This combination is not logical but I wanted zoom vertical somewhere.)
  1354. X
  1355. X
  1356. X.SS Typing in a line number
  1357. It can be inconvenient to wait for the dialogue box to come up to type
  1358. in a line number.
  1359. One solution is to select it and goto the selected line number.
  1360. This function works with the X selection as well as the Point selection
  1361. X(whichever one was made more recently)
  1362. so the line number can be compiler output in an \fIxterm\fR window.
  1363. Another solution is to just type digits into the \fILine#\fR menu bar
  1364. item, that is, move the mouse cursor into \fILine#\fR and type
  1365. X(no mouse button press or click is required).
  1366. XEnd the number with any non-digit character (I usually use a function
  1367. key since it is close to the digits on my keyboard).
  1368. X
  1369. X
  1370. X.SS Typing in incremental search strings
  1371. You can search for the X selection in a window to avoid retyping
  1372. the search string.
  1373. That is, you can select a string in any X window that support
  1374. XX selections and then search for it in any Point window with the
  1375. X\fI<<\fR or \fI>>\fR buttons or using a mouse menu to invoke the search for
  1376. selection command.
  1377. You can also type the search string directly into
  1378. the \fI<<\fR or \fI>>\fR menu bar buttons,
  1379. that is, (as above) move the sprite inside \fI<<\fR or \fI>>\fR and type.
  1380. This form of search is incremental, that is, Point searches after each
  1381. character is added to the search string.
  1382. Any non-ASCII character restarts the search string (I use a function key).
  1383. X(It is useful to get in the habit of hitting a function key first to
  1384. clear the search string since it keeps accumulating otherwise.
  1385. The ``\fIyourString\fR not found'' error message will remind you
  1386. if you forget.)
  1387. The incremental search is convenient since you only have to type
  1388. a unique prefix of the desired string.
  1389. X
  1390. X
  1391. X.SS C tags
  1392. Point supports the ``tags'' facility like vi and emacs.
  1393. Just create a tags file in the normal way with ctags.
  1394. You can find a selected tag or type the tag in a dialogue box.
  1395. Both commands are on GOTO menu.
  1396. The file the tag is in is loaded into a new window
  1397. X(unless it is already in a window in which case the window is raised)
  1398. and jumped to the location of the tag.
  1399. X
  1400. X
  1401. X.SS Keyword search 
  1402. I commonly want to see all the places a variable name is used in
  1403. my program.
  1404. Grep can be used for this and Point's keyword search facility
  1405. will call grep for you.
  1406. The keyword can be the selection or can be typed into a dialogue box
  1407. X(both commands are on the GOTO menu).
  1408. They both bring up a dialogue box with a list of the
  1409. files that contain that keyword.
  1410. If you click (once) on a file name in the list a window
  1411. is opened on the file (or the window is topped if the file is already
  1412. in an open window),
  1413. the window is jumped to the first instance of the keyword,
  1414. the keyword is selected and an asterisk is placed before the
  1415. file name on the list so you can easily tell which files
  1416. you have already examined and which you haven't.
  1417. X
  1418. X
  1419. X.SS Function keys
  1420. X.IP
  1421. X.B Arrow keys
  1422. move the selection up, down, left and right
  1423. X.IP
  1424. X.B F1
  1425. delete the selection to the scrap buffer
  1426. X.IP
  1427. X.B F2
  1428. insert text in the scrap buffer at the insertion point
  1429. X.IP
  1430. X.B F3
  1431. search backwards from the selection for the last string searched for
  1432. X.IP
  1433. X.B F4
  1434. search forwards from the selection for the last string searched for
  1435. X.IP
  1436. X.B F5
  1437. repeat the last edit (using the current selection and insertion point)
  1438. X.IP
  1439. X.B F6
  1440. redo the last undone edit
  1441. X.IP
  1442. X.B F7
  1443. scroll up one page
  1444. X.IP
  1445. X.B F8
  1446. scroll down one page
  1447. X.IP
  1448. X.B F9
  1449. undo the last edit (this is undoable with redo)
  1450. X.LP
  1451. The best use of function keys is to combine with mouse command to
  1452. get maximum editing bandwidth.
  1453. XFor example I usually select things with the mouse and execute
  1454. delete (F1), insert (F2) or again (F5) commands with function keys.
  1455. I also often use repeat search (F4) and repeat edit (F5) alternatively
  1456. to do an interactive search and replace.
  1457. X
  1458. X
  1459. X.SS The browser window
  1460. The browser window contains:
  1461. X.HP
  1462. X\(bu A list of open text windows \(em click on a name to top and
  1463. relocate the window \- the mouse button clicked determines the
  1464. new location: left button for NorthWest, middle button for SouthEast
  1465. and right button for NorthEast
  1466. X.HP
  1467. X\(bu A short menu bar of commands (see below),
  1468. X.HP
  1469. X\(bu A display of file and directory names.
  1470. Directories are shown with a ``/'' appended to their name.
  1471. If you double click on a directory name with the left mouse button
  1472. the browser switches to that directory.
  1473. If you double click on a directory name with the middle (right)
  1474. mouse button, a new browser is created in the second (third)
  1475. standard position and the new browser will display the named directory.
  1476. It is handy to have two or three file browsers on different
  1477. directories available at one time.
  1478. If you double click on a file name point will open a window on that file.
  1479. The button used determines the location of the new window:
  1480. left button for NorthWest, middle button for SouthEast
  1481. and right button for NorthEast.
  1482. X.HP
  1483. X\(bu A message line.
  1484. X.LP
  1485. The ``DIRS'' menu allows you to jump directly to one of
  1486. a list of preselected directories.
  1487. It also includes a command to change to the dirertory named by the
  1488. XX selection.
  1489. X.LP
  1490. The ``New'' button creates new browsers.
  1491. The button determines which of three predefined browser positions
  1492. is used.
  1493. The initial browser is in the position  used when you click
  1494. on ``New'' with the left mouse button.
  1495. The other two positions are to the right of that.
  1496. X.LP
  1497. The ``MENU'' menu contains most of the commands in submenus.
  1498. The ``PREFS'' menu allows you to change most Point options.
  1499. It has several submenus and many check boxes and radio buttons.
  1500. The ``New'' button creates a new window and loads it with
  1501. the file name that is selected
  1502. X(this can be either the Point selection or the X selection \(em whichever
  1503. one was made most recently).
  1504. The ``DIRS'' menu allows you to jump directly to one of
  1505. a list of preselected directories.
  1506. X
  1507. The MISC menu contain a number of occasionally useful commands.
  1508. It allows you to change the font used to display file names
  1509. in the browser.
  1510. X
  1511. The ``  *  '' button rereads and redisplays the directory contents.
  1512. The ``New Browser'' button create another file browser.
  1513. The ``Del File'' button deletes the  file whose name is selected.
  1514. The ``Close'' button closes this file browser.
  1515. The ``Quit'' menu exits Point and gives you three options for
  1516. disposing of unsaved edits.
  1517. X
  1518. X
  1519. X.SS Mouse menus
  1520. Pressing the middle or right mouse button enters a mode where you select
  1521. a command from a ``circular menu''.
  1522. When you press the middle or right mouse button, after a delay of 0.6 seconds,
  1523. the menu comes up showing the commands in each of five positions.
  1524. As you move the mouse around the circle you select the nearest command.
  1525. Release the button to execute the command.
  1526. To cancel the command click the left mouse button
  1527. and then release the mouse button.
  1528. The purpose of the delay is to allow you to give these
  1529. command without the overhead of displaying the menu.
  1530. If you select the direction and release the middle mouse button before
  1531. X0.6 seconds is up the menu is not displayed.
  1532. X.LP
  1533. The commands are for the \fBMiddle mouse button\fR:
  1534. X.HP
  1535. X\fBClose to it:\fR duplicate (copy-to-from)
  1536. X.HP
  1537. X\fBNorth (or up) of it:\fR delete the selection to the scrap buffer
  1538. X.HP
  1539. X\fBSouth (or down) of it:\fR insert the scrap buffer
  1540. X.HP
  1541. X\fBEast (or right) of it:\fR copy the selection to the location where
  1542. you first pressed the middle mouse button
  1543. X.HP
  1544. X\fBWest (or left) of it:\fR move the selection to the location where
  1545. you first pressed the middle mouse button
  1546. X.LP
  1547. The commands are for the \fBRight mouse button\fR:
  1548. X.HP
  1549. X\fBClose to it:\fR extend the selection to this point
  1550. X.HP
  1551. X\fBNorth (or up) of it:\fR search towards the beginning of the file
  1552. X.HP
  1553. X\fBSouth (or down) of it:\fR search towards the end of the file
  1554. X.HP
  1555. X\fBEast (or right) of it:\fR undo the last edit
  1556. X.HP
  1557. X\fBWest (or left) of it:\fR repeat the last edit with the current selection
  1558. X
  1559. X
  1560. X.SS Using mouse menus
  1561. The mouse menu commands are close at hand and are used for the
  1562. most common actions.
  1563. X(Since this changes from user to user you will probably want to
  1564. change some of these commands on the mouse menus after you get used
  1565. to using Point.
  1566. The next section discusses customizing Point to your own tastes.)
  1567. The forward and backward searches are obviously useful to find
  1568. the previous and next use of a variable name in a program.
  1569. The duplicate command is for duplicating text.
  1570. Duplicating a line is the most common case:
  1571. X.IP
  1572. X1. Select the line (triple click) or lines (triple click and drag
  1573. before releasing the third click).
  1574. X.IP
  1575. X2. Duplicate the line(s) (double click the middle mouse button).
  1576. X(Duplicate is the ``close to'' command so a fast click executes duplicate.
  1577. The first click sets the destination of the duplicate at the beginning
  1578. of the selected line and the second click copies the selected text to that
  1579. point.)
  1580. X.LP
  1581. Another common use of duplicate is to copy a nearby word to the insertion
  1582. point as you are typing a line.
  1583. Suppose you are typing a line and you want to use a word that is
  1584. on a nearby line:
  1585. X.IP
  1586. X1. Stop typing where the word is to go and click the middle mouse button.
  1587. This executes duplicate which remembers the current insertion point.
  1588. X.IP
  1589. X2. Move the sprite to the word to be copied and select it
  1590. X(with a double click).
  1591. X.IP
  1592. X3. Click the middle mouse button to execute duplicate a second time
  1593. which copies the selected word back to the line you were typing and
  1594. leaves the insertion point just after the copied word so you can
  1595. immediately resume typing the rest of the line.
  1596. X.LP
  1597. I have found that any word longer that seven or eight characters is
  1598. worth copying rather than typing, especially in programs where misspelled
  1599. identifiers cause you to have to recompile.
  1600. Similarly to replace a word with a nearby word:
  1601. X.IP
  1602. X1. Select the word (double click)
  1603. X.IP
  1604. X2. Delete it (F1 or EDIT menu)
  1605. X.IP
  1606. X3. Duplicate (click middle button)
  1607. X.IP
  1608. X4. Select word to copy in (double click)
  1609. X.IP
  1610. X5. Duplicate (click middle button)
  1611. X.LP
  1612. These techniques can be used repeatedly to build up or modify
  1613. lines from pieces of nearby lines.
  1614. Also the text to be copied need not be nearby text.
  1615. It can be in another window or in a different place in the same window.
  1616. Between the first and second duplicate commands you can invoke any other
  1617. Point commands.
  1618. XFor example, you can scroll windows, you can open new windows,
  1619. you can search in windows, etc.
  1620. X.LP
  1621. The duplicate command mentioned above is a ``copy-to-from'' command
  1622. because first you give the location to copy to and then you select
  1623. the text to be copied there.
  1624. The East (left) mouse motion command is a ``copy-from-to'' command.
  1625. Here is how you would use it:
  1626. X.IP
  1627. X1. Select the text to be copied (the `from' text))
  1628. X.IP
  1629. X2. Move the mouse to the `to' point.
  1630. If you are copying a whole word (that is, if it was selected in
  1631. word mode \(em with a double click) then you can point anywhere
  1632. within the word and the text will be copied in front of that word.
  1633. Similarly, to copy text selected in line mode (triple click) you
  1634. can point anywhere in the line you want it copied in front of.
  1635. X.IP
  1636. X3. Press the middle mouse button and move to the left 
  1637. and then release the middle mouse button.
  1638. X.LP
  1639. The Move scenario is nearly identical \- just move right in step 3.
  1640. X
  1641. X
  1642. X.SS Moving windows
  1643. The ``MoveW'' menu item is useful for positioning windows quickly.
  1644. If I want to see two windows at the same time I usually put them in the
  1645. NW (left mouse button) and NE (right mouse button) window positions.
  1646. You can click the left (right) mouse button on either the ``MoveW''
  1647. menu item or on the window's file name in the main browser window.
  1648. A third document goes to the SE (middle mouse button) window position.
  1649. I find that I spend a lot of time looking at several files
  1650. at the same time during program development.
  1651. X
  1652. X
  1653. X.SS Backups
  1654. Most UNIX users (except emacs users) are not used to backup files.
  1655. I got to like them using PCs even though at first I hated them
  1656. because they cluttered up my directory.
  1657. There are two options that control backups.
  1658. The first is ``backupDepth'' which determines how many versions
  1659. of each file are kept.
  1660. It can vary for 0 (no backups are kept) to 9
  1661. X(the default is 1 but I use 6).
  1662. The backup files are often named with the file name appended with a period
  1663. and a digit (``.1'' to ``.9'' with ``.1'' being the most recent).
  1664. The option \fIbackupNameFormat\fR determines the form of
  1665. the name of the backup file and hence where the backup files are stored.
  1666. The default is the current directory (\fIbackupNameFormat=%n.%v\fR).
  1667. I use
  1668. X.I backupNameFormat=bak/%n.%v
  1669. so the backup files are out of the way but there when I need them.
  1670. The backup file name can be a relative or absolute pathname.
  1671. X
  1672. X
  1673. X.SS Hints for using Point
  1674. Section 7 of the Point Reference Manual has a number of hints on
  1675. how to use Point's features.
  1676. All of the command bindings described in this document are configurable
  1677. in by editing
  1678. X.I ptsetup.tcl
  1679. X(the Point configuration file).
  1680. You can look in this file but to change very much you should read the
  1681. relevant sections in the user's manual
  1682. X.LP
  1683. You can change almost all of Point's options dynamically the
  1684. X.I PREFS
  1685. menu.
  1686. X
  1687. X
  1688. X.SH BUGS
  1689. See the file KnownBugs.
  1690. X
  1691. X
  1692. X.SH AUTHOR
  1693. Charles Crowley
  1694. X.br
  1695. Computer Science Department
  1696. X.br
  1697. University of New Mexico
  1698. X.br
  1699. Albuquerque, New Mexico 87131
  1700. X.br
  1701. X505-277-5446 (office) or 505-277-3112 (messages)
  1702. X.br
  1703. crowley@unmvax.cs.unm.edu
  1704. X
  1705. X
  1706. X
  1707. END_OF_FILE
  1708. if test 23608 -ne `wc -c <'doc/point.n'`; then
  1709.     echo shar: \"'doc/point.n'\" unpacked with wrong size!
  1710. fi
  1711. # end of 'doc/point.n'
  1712. fi
  1713. echo shar: End of archive 9 \(of 15\).
  1714. cp /dev/null ark9isdone
  1715. MISSING=""
  1716. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ; do
  1717.     if test ! -f ark${I}isdone ; then
  1718.     MISSING="${MISSING} ${I}"
  1719.     fi
  1720. done
  1721. if test "${MISSING}" = "" ; then
  1722.     echo You have unpacked all 15 archives.
  1723.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1724. else
  1725.     echo You still need to unpack the following archives:
  1726.     echo "        " ${MISSING}
  1727. fi
  1728. ##  End of shell archive.
  1729. exit 0
  1730. -- 
  1731. --
  1732. Molecular Simulations, Inc.            mail: dcmartin@msi.com
  1733. 796 N. Pastoria Avenue                uucp: uunet!dcmartin
  1734. Sunnyvale, California 94086            at&t: 408/522-9236
  1735.