home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / alt / sources / 2596 < prev    next >
Encoding:
Text File  |  1992-11-20  |  54.8 KB  |  2,361 lines

  1. Newsgroups: alt.sources
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!eff!world!jhallen
  3. From: jhallen@world.std.com (Joseph H Allen)
  4. Subject: JOE 1.0.5 Part 10 of 10
  5. Message-ID: <By2Mpu.L8L@world.std.com>
  6. Organization: The World Public Access UNIX, Brookline, MA
  7. Date: Sat, 21 Nov 1992 14:53:53 GMT
  8. Lines: 2351
  9.  
  10. Submitted-by: jhallen@world.std.com
  11. Archive-name: joe1.0.5part10
  12.  
  13. #define sLEN(a) ((a)?*((int *)(a)-1):0)
  14. #define sLen(a) (*((int *)(a)-1))
  15. X
  16. /* int slen(sELEMENT(*ary));
  17. X * Compute length of char or variable length array by searching for termination
  18. X * element.  Returns 0 if 'vary' is 0.
  19. X */
  20. int slen();
  21. X
  22. /* sELEMENT(*vsensure(sELEMENT(*vary),int len));
  23. X * Make sure there's enough space in the array for 'len' elements.  Whenever
  24. X * vsensure reallocs the array, it allocates 25% more than the necessary
  25. X * minimum space in anticipation of future expansion.  If 'vary' is 0,
  26. X * it creates a new array.
  27. X */
  28. sELEMENT(*vsensure());
  29. X
  30. /* sELEMENT(*vszap(sELEMENT(*vary),int pos,int n));
  31. X * Destroy n elements from an array beginning at pos.  Is ok if pos/n go
  32. X * past end of array.  This does not change the sLEN() value of the array.
  33. X * This does nothing and returns 0 if 'vary' is 0.  Note that this
  34. X * function does not actually write to the array.  This does not stop if
  35. X * a sterm is encountered.
  36. X */
  37. sELEMENT(*vszap());
  38. X
  39. /* sELEMENT(*vstrunc(sELEMENT(*vary),int len));
  40. X * Truncate array to indicated size.  This zaps or expands with blank elements
  41. X * and sets the LEN() of the array.  A new array is created if 'vary' is 0.
  42. X */
  43. sELEMENT(*vstrunc());
  44. X
  45. /************************************/
  46. /* Function which write to an array */
  47. /************************************/
  48. X
  49. /* sELEMENT(*vsfill(sELEMENT(*vary),int pos,sELEMENT(el),int len));
  50. X * Set 'len' element of 'vary' beginning at 'pos' to duplications of 'el'.
  51. X * Ok, if pos/len are past end of array.  If 'vary' is 0, a new array is
  52. X * created.
  53. X *
  54. X * This does not zap previous values.  If you need that to happen, call
  55. X * vszap first.  It does move the terminator around properly though.
  56. X */
  57. sELEMENT(*vsfill());
  58. X
  59. /* sELEMENT(*vsncpy(sELEMENT(*vary),int pos,sELEMENT(*array),int len));
  60. X * Copy 'len' elements from 'array' onto 'vary' beginning at position 'pos'.
  61. X * 'array' can be a normal char array since the length is passed seperately.  The
  62. X * elements are copied, not duplicated.  A new array is created if 'vary' is
  63. X * 0.  This does not zap previous elements.
  64. X */
  65. sELEMENT(*vsncpy());
  66. X
  67. /* sELEMENT(*vsndup(sELEMENT(*vary),int pos,sELEMENT(*array),int len));
  68. X * Duplicate 'len' elements from 'array' onto 'vary' beginning at position
  69. X * 'pos'.  'array' can be a char array since its length is passed seperately.  A
  70. X * new array is created if 'vary' is 0.
  71. X */
  72. sELEMENT(*vsndup());
  73. X
  74. /* sELEMENT(*vsfield(sELEMENT(*vary),int pos,int len));
  75. X * Make sure a field exists at 'pos' of length 'len'.  If there isn't one,
  76. X * 'vary' is extended with blank elements.  This does not eliminate elements
  77. X * which already exist in the field.  Use vszap for that.
  78. X */
  79. sELEMENT(*vsfield());
  80. X
  81. /* sELEMENT(*vsdup(sELEMENT(*vary)));
  82. X * Duplicate array.  This is just a functionalized version of:
  83. X *
  84. X *   vsndup(NULL,0,vary,sLEN(vary));
  85. X *
  86. X * but since you need to be able to refer to this particular function by
  87. X * address often it's given here.
  88. X *
  89. X * (actually, there's bazillions of these simple combinations of the above
  90. X * functions and the macros of the next section.  You'll probably want to make
  91. X * functionalized instances of the ones you use most often - especially since
  92. X * the macros aren't safe).
  93. X */ 
  94. sELEMENT(*vsdup());
  95. X
  96. /* sELEMENT(*vsset(sELEMENT(*vary),int pos,sELEMENT(element)));
  97. X * Set an element in an array.  Any value of 'pos' is valid.  A new array
  98. X * is created if 'vary' is 0.  The previous contents of the position is
  99. X * deleted.    This does not duplicate 'element'.  If you need 'element'
  100. X * duplicated, call: vsset(vary,pos,sdup(element));
  101. X */
  102. sELEMENT(*_vsset());
  103. X
  104. #define vsset(v,p,el)  \
  105. X (!(v) || (p)>sLen(v) || (p)>=sSiz(v) ?  \
  106. X  _vsset((v),(p),(el)) \
  107. X : \
  108. X  ((p)==sLen(v) ? \
  109. X   ((v)[(p)+1]=0, sLen(v)=(p)+1, (v)[p]=(el), (v)) \
  110. X  : \
  111. X   ((v)[p]=(el), (v)) \
  112. X  ) \
  113. X )   
  114. X
  115. /* sELEMENT(*vsadd(sELEMENT(*vary),sELEMENT(element)));
  116. X * Concatenate a single element to the end of 'vary'.  A new array is created
  117. X * if 'vary' is 0.  This does not duplicate element: call
  118. X * vsadd(vary,sdup(element));  If you need it duplicated.
  119. X */
  120. #define vsadd(v,el) \
  121. X (!(v) || sLen(v)==sSiz(v) ? \
  122. X  _vsset((v),sLEN(v),(el)) \
  123. X : \
  124. X  ((v)[sLen(v)+1]=0, (v)[sLen(v)]=(el), sLen(v)=sLen(v)+1, (v)) \
  125. X )
  126. X
  127. /**************************************/
  128. /* Functions which read from an array */
  129. /**************************************/
  130. X
  131. /* These macros are used to generate the address/size pairs which get
  132. X * passed to the functions of the previous section.
  133. X */
  134. X
  135. /* { sELEMENT(*),int } sv(sELEMENT(*array));
  136. X * Return array,size pair.  Uses sLEN to get size.
  137. X */
  138. #define sv(a) (a),sLEN(a)
  139. X
  140. /* { sELEMENT(*),int } sz(sELEMENT(*array));
  141. X * Return array,size pair.  Uses slen to get size.
  142. X */
  143. #define sz(a) (a),slen(a)
  144. X
  145. /* { sELEMENT(*),int } sc(sELEMENT(*array));
  146. X * Return array,size pair.  Uses 'sizeof' to get size.
  147. X */
  148. #define sc(a) (a),(sizeof(a)/sizeof(sCAST)-1)
  149. X
  150. /* { sELEMENT(*),int } srest(sELEMENT(*vary),int pos);
  151. X * Return array,size pair of rest of array beginning at pos.  If
  152. X * pos is past end of array, gives size of 0.
  153. X */
  154. #define srest(a,p) ((a)+(p)),(((p)>sLEN(a))?0:sLen(a)-(p))
  155. X
  156. /* { sELEMENT(*),int } spart(sELEMENT(*vary),int pos,int len);
  157. X * Return array,size pair of 'len' elements of array beginning with pos.  If
  158. X * pos is past end of array, gives size of 0.  If pos+len is past end of array,
  159. X * returns number of elements to end of array.
  160. X */
  161. #define spart(a,p,l) \
  162. X ((a)+(p)),((p)>=sLEN(a)?0:((p)+(l)>sLen(a)?sLen(a)-(p):(l)))
  163. X
  164. /* sELEMENT(vsget(sELEMENT(*vary),int pos));
  165. X * Get an element from an array.  Any value of pos is valid; if it's past the
  166. X * end of the array or if 'vary' is 0, the terminator is returned.  This
  167. X * does not make a duplicate of the returned element.  If you want that, pass
  168. X * the return value of this to sdup.
  169. X */
  170. #define vsget(a,p) ((p)>=sLEN(a)?sterm:(a)[p])
  171. X
  172. /**********************/
  173. /* Insertion/Deletion */
  174. /**********************/
  175. X
  176. /* sELEMENT(*vsins(sELEMENT(*vary),int pos,int n));
  177. X * Insert n empty slots into the array.  If 'pos' >= the length of the array,
  178. X * the array is simply extended.  The new slots are not set to anything.
  179. X * This does not set the elements in the created hole to any particular
  180. X * value: use vsfill if you need that to occur.
  181. X */
  182. sELEMENT(*vsins());
  183. X
  184. /* sELEMENT(*vsdel(sELEMENT(*vary),int pos,int n));
  185. X * Delete n slots from the array.  This does not zap the elements first; call
  186. X * vszap first if you need this to happen.
  187. X */
  188. sELEMENT(*vsdel());
  189. X
  190. /*************************/
  191. /* Searching and Sorting */
  192. /*************************/
  193. X
  194. /* sELEMENT(*vssort(sELEMENT(*ary),int len))
  195. X * Sort the elements of an array (char or variable length) using qsort().
  196. X */
  197. sELEMENT(*vssort());
  198. X
  199. /* int vsbsearch(sELEMENT(*ary),int len,sELEMENT(element));
  200. X * Do a binary search on a sorted variable length or char array.  Returns position
  201. X * of matching element or the position where the element should be if it was
  202. X * not found.  (You should test with scmp to find out which).
  203. X *
  204. X * Hmm... this should really indicate whether or not the element was found.
  205. X */
  206. int vsbsearch();
  207. X
  208. /* int vsfirst(sELEMENT(*ary),int len,sELEMENT(element));
  209. X * Find offset to first matching element in 'vary' or return ~0 if not found.
  210. X */
  211. int vsfirst();
  212. X
  213. /* int vslast(sELEMENT(*ary),int len,sELEMENT(element));
  214. X * Find offset to last matching element in 'vary' or return ~0 if none found.
  215. X */
  216. int vslast();
  217. X
  218. /* int vss(sELEMENT(*a),int alen,sELEMENT(*b),int blen);
  219. X * Do a substring search on 'a'.  Return offset from 'a' to first matching
  220. X * occurance of 'b' in 'a' or return ~0 if none found.
  221. X */
  222. int vss();
  223. X
  224. /* int vscmpn(sELEMENT(*a),int alen,sELEMENT(*b),int blen);
  225. X *
  226. X * Compare two arrays using scmp.  If 'a' > 'b', return 1.  If 'a' == 'b',
  227. X * return 0.  If 'a' < 'b', return -1.  Longer strings are > shorter ones if
  228. X * their beginning match.
  229. X */
  230. int vscmpn();
  231. X
  232. /* int vscmp(sELEMENT(*a),sELEMENT(*b));
  233. X *
  234. X * Functionalized version of: vscmpn(sv(a),sv(b));
  235. X */
  236. int vscmp();
  237. X
  238. /* int vsicmpn(sELEMENT(*a),int alen,sELEMENT(*b),int blen);
  239. X *
  240. X * Compare two arrays using sicmp.  If 'a' > 'b', return 1.  If 'a' == 'b',
  241. X * return 0.  If 'a' < 'b', return -1.  Longer strings are > shorter ones if
  242. X * their beginning match.
  243. X *
  244. X * This is same as vscmpn except that it is case insensitive.
  245. X */
  246. int vsicmpn();
  247. X
  248. /* int vsicmp(sELEMENT(*a),sELEMENT(*b));
  249. X *
  250. X * Functionalized version of: vsicmpn(sv(a),sv(b));
  251. X */
  252. int vsicmp();
  253. X
  254. /* int vsscan(sELEMENT(*a),int alen,sELEMENT(*b),int blen);
  255. X * Find offset of first matching element in 'a' which matches any
  256. X * of the elements passed in 'b'.  Array 'b' must be sorted.
  257. X *
  258. X * Hmm... this really needs to return what the found element is.
  259. X */
  260. int vsscan();
  261. X
  262. /* int vsspan(sELEMENT(*a),int alen,sELEMENT(*b),int blen);
  263. X * Find offset of first matching element in 'a' which does not match any
  264. X * of the elements passed in 'b'.  Array 'b' must be sorted.
  265. X */
  266. int vsspan();
  267. X
  268. /***************/
  269. /* Other stuff */
  270. /***************/
  271. X
  272. /* char *vsread(char *d,int p,int (*getC)(void *ptr),void *ptr);
  273. X * Replace 'd' with next line read from read-character function 'getC'.  If 
  274. X * 'd' is 0, a new string is allocated.  If there is no more input, the string
  275. X * is freed and 0 is returned.  The \n is deleted from the entered line.
  276. X *
  277. X * 'ptr' is passed as the first arg to 'getC'.  'getC' should return -1 if
  278. X * there is no more input.
  279. X */
  280. char *vsread();
  281. X
  282. /* char *vwords(char *s,char **a,int len,char t);
  283. X *
  284. X * Generate a 't'-seperated word list from the words in the zero-terminated
  285. X * array of zero-terminated strings 'a'.  For example a simple 'echo.c':
  286. X *
  287. X * main(argc,argv)
  288. X * char *argv[];
  289. X * {
  290. X * printf("%s\n",vwords(NULL,argv,argc,' ')):
  291. X * }
  292. X *
  293. X */
  294. char *vswords();
  295. X
  296. /* char *vsfmt(char *s,char *fmt,...);
  297. X *
  298. X * (Yeah, yeah.. I really need to make this printf compatible, I know.)
  299. X *
  300. X * Printf (almost) to a variable length string.  If 's' is zero, a string is
  301. X * created.  All chars from 'fmt' are copied to string except for these '%'
  302. X * sequences:
  303. X *
  304. X *    % [' '|'+'|'-'] Base _ FieldWidth . Precision [l] {d|D|u|U|c|s}
  305. X *    %% generates %
  306. X *
  307. X *    '+' means leading + needed for zero and positive numbers
  308. X *    ' ' means leading space needed for zero and positive numbers
  309. X *    '-' means left justified within field instead of right justified
  310. X *    FieldWidth is minimum field width
  311. X *
  312. X *    s     Means insert next zero-terminated string from argument list
  313. X *          Precision means maximum string size
  314. X *
  315. X *    c     Means insert next character from argument list.  The character is
  316. X *          normally passed as an int.  If 'l' is given, the character is
  317. X *          passed as a long.
  318. X *
  319. X *    d signed integer, use lower case letters for digits above 9
  320. X *    D signed integer, use upper case letters for digits above 9
  321. X *    u unsigned integer, use lower case letters for digits above 9
  322. X *    U unsigned integer, use upper case letters for digits above 9
  323. X *          If 'l' is give, a long or unsigned long is requested instead.
  324. X *          Precision is minimum number of digits to generate in number.
  325. X *          Default base is decimal.
  326. X */
  327. char *vsfmt();
  328. X
  329. X
  330. #endif
  331. SHAR_EOF
  332. chmod 0600 vs.h ||
  333. echo 'restore of vs.h failed'
  334. Wc_c="`wc -c < 'vs.h'`"
  335. test 13819 -eq "$Wc_c" ||
  336.     echo 'vs.h: original size 13819, current size' "$Wc_c"
  337. fi
  338. # ============= w.c ==============
  339. if test -f 'w.c' -a X"$1" != X"-c"; then
  340.     echo 'x - skipping w.c (File already exists)'
  341. else
  342. echo 'x - extracting w.c (Text)'
  343. sed 's/^X//' << 'SHAR_EOF' > 'w.c' &&
  344. /* Window system
  345. X   Copyright (C) 1992 Joseph H. Allen
  346. X
  347. This file is part of JOE (Joe's Own Editor)
  348. X
  349. JOE is free software; you can redistribute it and/or modify it under the 
  350. terms of the GNU General Public License as published by the Free Software 
  351. Foundation; either version 1, or (at your option) any later version.  
  352. X
  353. JOE is distributed in the hope that it will be useful, but WITHOUT ANY 
  354. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
  355. FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
  356. details.  
  357. X
  358. You should have received a copy of the GNU General Public License along with 
  359. JOE; see the file COPYING.  If not, write to the Free Software Foundation, 
  360. 675 Mass Ave, Cambridge, MA 02139, USA.  */ 
  361. X
  362. #include "config.h"
  363. #include "heap.h"
  364. #include "vfile.h"
  365. #include "toomany.h"
  366. #include "b.h"
  367. #include "termcap.h"
  368. #include "scrn.h"
  369. #include "tty.h"
  370. #include "queue.h"
  371. #include "kbd.h"
  372. #include "main.h"
  373. #include "poshist.h"
  374. #include "w.h"
  375. X
  376. /* Redraw a window */
  377. X
  378. void wredraw(w)
  379. W *w;
  380. {
  381. msetI(w->t->t->updtab+w->y,1,w->h);
  382. }
  383. X
  384. /* Scroll an update array */
  385. X
  386. void scrldn(ary,top,bot,amnt)
  387. int *ary,top,bot,amnt;
  388. {
  389. if(!amnt || top>=bot || amnt>bot-top) return;
  390. if(bot>25)
  391. X {
  392. X signal(0,5);
  393. X }
  394. /* mbkwd(ary+top+amnt,ary+top,(bot-top-amnt)*sizeof(int)); */
  395. msetI(ary+top,1,amnt);
  396. }
  397. X
  398. void scrlup(ary,top,bot,amnt)
  399. int *ary,top,bot,amnt;
  400. {
  401. if(!amnt || top>=bot || amnt>bot-top) return;
  402. if(bot>25)
  403. X {
  404. X signal(0,5);
  405. X }
  406. /* mfwrd(ary+top,ary+top+amnt,(bot-top-amnt)*sizeof(int)); */
  407. msetI(ary+bot-amnt,1,amnt);
  408. }
  409. X
  410. /* Find first window in a group */
  411. X
  412. W *findtopw(w)
  413. W *w;
  414. {
  415. W *x;
  416. for(x=w;x->link.prev->main==w->main && x->link.prev!=w;x=x->link.prev);
  417. return x;
  418. }
  419. X
  420. /* Determine height of a family of windows */
  421. X
  422. int getgrouph(w)
  423. W *w;
  424. {
  425. W *x;
  426. int h;
  427. X
  428. /* Find first window in family */
  429. x=findtopw(w);
  430. X
  431. /* Add heights of all windows in family */
  432. for(w=x, h=(w->reqh?w->reqh:w->hh);
  433. X    w->link.next!=x && w->link.next->main==x->main;
  434. X    w=w->link.next, h+=(w->reqh?w->reqh:w->hh));
  435. X
  436. return h;
  437. }
  438. X
  439. /* Determine minimum height of a family */
  440. X
  441. int getminh(w)
  442. W *w;
  443. {
  444. W *x;
  445. int h;
  446. x=findtopw(w);
  447. for(w=x, h=(w->win?1:2);
  448. X    w->link.next!=x && w->link.next->main==x->main;
  449. X    w=w->link.next, h+=(w->win?1:2));
  450. X
  451. return h;
  452. }
  453. X
  454. /* Find last window in a group */
  455. X
  456. W *findbotw(w)
  457. W *w;
  458. {
  459. W *x;
  460. for(x=w;x->link.next->main==w->main && x->link.next!=w;x=x->link.next);
  461. return x;
  462. }
  463. X
  464. /* Find last window on the screen */
  465. X
  466. W *lastw(t)
  467. SCREEN *t;
  468. {
  469. W *x;
  470. for(x=t->topwin;x->link.next!=t->topwin && x->link.next->y>=0;x=x->link.next);
  471. return x;
  472. }
  473. X
  474. /* Create a screen object */
  475. X
  476. SCREEN *scr;
  477. X
  478. SCREEN *screate(scrn)
  479. SCRN *scrn;
  480. {
  481. SCREEN *t=(SCREEN *)malloc(sizeof(SCREEN));
  482. t->pattern=0;
  483. t->replace=0;
  484. t->t=scrn;
  485. t->w=scrn->co;
  486. t->h=scrn->li;
  487. t->topwin=0;
  488. t->curwin=0;
  489. t->wind=0;
  490. t->markb=0;
  491. t->markk=0;
  492. t->arg=0;
  493. scr=t;
  494. return t;
  495. }
  496. X
  497. void chsize(t,mul,div)
  498. SCREEN *t;
  499. {
  500. W *w;
  501. w=t->topwin; do
  502. X if(!w->win)
  503. X  {
  504. X  w->reqh=getgrouph(w)*mul;
  505. X  w->reqh=w->reqh/div+(w->reqh%div>=div/2?1:0);
  506. X  if(w->reqh<FITHEIGHT) w->reqh=FITHEIGHT;
  507. X  w->reqh-=getminh(w)-2;
  508. X  if(w->reqh<2) w->reqh=2;
  509. X  if(w->reqh>t->h-t->wind) w->reqh=t->h-t->wind;
  510. X  }
  511. X while(w=w->link.next, w!=t->topwin);
  512. wfit(t);
  513. }
  514. X
  515. void sresize(t)
  516. SCREEN *t;
  517. {
  518. SCRN *scrn=t->t;
  519. W *w;
  520. int osize=t->h-t->wind;
  521. t->w=scrn->co;
  522. t->h=scrn->li;
  523. if(t->h-t->wind<FITHEIGHT) t->wind=t->h-FITHEIGHT;
  524. if(t->wind<0) t->wind=0;
  525. w=t->topwin; do
  526. X w->y= -1, w->w=t->w-1;
  527. X while(w=w->link.next, w!=t->topwin);
  528. chsize(t,t->h-t->wind,osize);
  529. updall();
  530. }
  531. X
  532. void updall()
  533. {
  534. int y;
  535. for(y=0;y!=scr->h;++y) scr->t->updtab[y]=1;
  536. }
  537. X
  538. void scrins(b,l,n,flg)
  539. B *b;
  540. long l,n;
  541. int flg;
  542. {
  543. W *w;
  544. if(w=scr->topwin) do
  545. X if(w->y>=0) w->watom->ins(w,b,l,n,flg);
  546. X while(w=w->link.next, w!=scr->topwin);
  547. }
  548. X
  549. void scrdel(b,l,n,flg)
  550. B *b;
  551. long l,n;
  552. int flg;
  553. {
  554. W *w;
  555. if(w=scr->topwin) do
  556. X if(w->y>=0) w->watom->del(w,b,l,n,flg);
  557. X while(w=w->link.next, w!=scr->topwin);
  558. }
  559. X
  560. /* Fit as many windows on the screen as is possible beginning with the window
  561. X * at topwin.  Give any extra space which couldn't be used to fit in another
  562. X * window to the last text window on the screen.  This function guarentees
  563. X * to fit on the window with the cursor in it (moves topwin to next group
  564. X * of windows until window with cursor fits on screen).
  565. X */
  566. X
  567. static int doabort();
  568. X
  569. void wfit(t)
  570. SCREEN *t;
  571. {
  572. int y;        /* Where next window goes */
  573. int left;    /* Lines left on screen */
  574. W *w;        /* Current window we're fitting */
  575. W *pw;        /* Main window of previous family */
  576. int req;    /* Amount this family needs */
  577. int adj;    /* Amount family needs to be adjusted */
  578. int flg=0;    /* Set if cursor window was placed on screen */
  579. X
  580. tryagain:
  581. y=t->wind; left=t->h-y; pw=0;
  582. X
  583. w=t->topwin; do
  584. X w->ny= -1, w->hh=w->nh=(w->reqh?w->reqh:w->hh);
  585. X while((w=w->link.next)!=t->topwin);
  586. X
  587. /* Fit a group of windows on the screen */
  588. w=t->topwin; do
  589. X {
  590. X req=getgrouph(w);
  591. X if(req>left)        /* If group is taller than lines left */
  592. X  adj=req-left;        /* then family gets shorter */
  593. X else adj=0;
  594. X /* Fit a family of windows on the screen */
  595. X do
  596. X  {
  597. X  w->ny=y;            /* Set window's y position */
  598. X  if(!w->win) pw=w, w->nh-=adj;    /* Adjust main window of the group */
  599. X  if(!w->win && w->nh<2) while(w->nh<2) w->nh+=doabort(w->link.next);
  600. X  if(w==t->curwin) flg=1;    /* Set if we got window with cursor */
  601. X  y+=w->nh; left-=w->nh;    /* Increment y value by height of window */
  602. X  w=w->link.next;        /* Next window */
  603. X  } while(w!=t->topwin && w->main==w->link.prev->main);
  604. X } while(w!=t->topwin && left>=FITHEIGHT);
  605. X
  606. /* We can't use extra space to fit a new family on, so give space to parent of
  607. X * previous family */
  608. pw->nh+=left;
  609. X
  610. /* Adjust that family's children which are below the parent */
  611. while((pw=pw->link.next)!=w) pw->ny+=left;
  612. X
  613. /* Make sure the cursor window got on the screen */
  614. if(!flg)
  615. X {
  616. X t->topwin=findbotw(t->topwin)->link.next;
  617. X goto tryagain;
  618. X }
  619. X
  620. /* All of the windows are now on the screen.  Scroll the screen to reflect what
  621. X * happened
  622. X */
  623. w=t->topwin; do
  624. X if(w->y>=0 && w->ny>=0)
  625. X  if(w->ny>w->y)
  626. X   {
  627. X   W *l=pw=w;
  628. X   while(pw->link.next!=t->topwin &&
  629. X         (pw->link.next->y<0 || pw->link.next->ny<0 ||
  630. X         pw->link.next->ny>pw->link.next->y))
  631. X    {
  632. X    pw=pw->link.next;
  633. X    if(pw->ny>=0 && pw->y>=0) l=pw;
  634. X    }
  635. X   /* Scroll windows between l and w */
  636. X   loop1:
  637. X   if(l->ny>=0 && l->y>=0)
  638. X    {
  639. X    nscrldn(t->t,l->y,l->ny+Umin(l->h,l->nh),l->ny-l->y);
  640. X    scrldn(t->t->updtab,l->y,l->ny+Umin(l->h,l->nh),l->ny-l->y);
  641. X    }
  642. X   if(w!=l)
  643. X    {
  644. X    l=l->link.prev;
  645. X    goto loop1;
  646. X    }
  647. X   w=pw->link.next;
  648. X   }
  649. X  else if(w->ny<w->y)
  650. X   {
  651. X   W *l=pw=w;
  652. X   while(pw->link.next!=t->topwin &&
  653. X         (pw->link.next->y<0 || 
  654. X         pw->link.next->ny<0 || 
  655. X         pw->link.next->ny<pw->link.next->y))
  656. X    {
  657. X    pw=pw->link.next;
  658. X    if(pw->ny>=0 && pw->y>=0) l=pw;
  659. X    }
  660. X   /* Scroll windows between l and w */
  661. X   loop0:
  662. X   if(w->ny>=0 && w->y>=0)
  663. X    {
  664. X    nscrlup(t->t,w->ny,w->y+Umin(w->h,w->nh),w->y-w->ny);
  665. X    scrlup(t->t->updtab,w->ny,w->y+Umin(w->h,w->nh),w->y-w->ny);
  666. X    }
  667. X   if(w!=l)
  668. X    {
  669. X    w=w->link.next;
  670. X    goto loop0;
  671. X    }
  672. X   w=pw->link.next;
  673. X   }
  674. X  else w=w->link.next;
  675. X else w=w->link.next;
  676. X while(w!=t->topwin);
  677. X
  678. /* Update current height and position values */
  679. w=t->topwin; do
  680. X {
  681. X if(w->ny>=0)
  682. X  {
  683. X  if(w->object) w->watom->move(w,w->x,w->ny),
  684. X                w->watom->resize(w,w->w,w->nh);
  685. X  if(w->y== -1) msetI(t->t->updtab+w->ny,1,w->nh);
  686. X  w->y=w->ny;
  687. X  }
  688. X else w->y= -1;
  689. X w->h=w->nh;
  690. X w->reqh=0;
  691. X }
  692. X while(w=w->link.next, w!=t->topwin);
  693. }
  694. X
  695. /* Goto next window */
  696. X
  697. int wnext(t)
  698. SCREEN *t;
  699. {
  700. if(t->curwin->link.next!=t->curwin)
  701. X {
  702. X t->curwin=t->curwin->link.next;
  703. X if(t->curwin->y== -1) wfit(t);
  704. X return 0;
  705. X }
  706. else return -1;
  707. }
  708. X
  709. /* Goto previous window */
  710. X
  711. int wprev(t)
  712. SCREEN *t;
  713. {
  714. if(t->curwin->link.prev!=t->curwin)
  715. X {
  716. X t->curwin=t->curwin->link.prev;
  717. X if(t->curwin->y== -1)
  718. X  {
  719. X  t->topwin=findtopw(t->curwin);
  720. X  wfit(t);
  721. X  }
  722. X return 0;
  723. X }
  724. else return -1;
  725. }
  726. X
  727. /* Grow window */
  728. X
  729. int wgrow(w)
  730. W *w;
  731. {
  732. W *nextw, *z;
  733. /* Is there enough space to grow window? */
  734. for(nextw=w->link.next;
  735. X    nextw->win && nextw!=w->t->topwin;
  736. X    nextw=nextw->link.next);
  737. if(nextw==w->t->topwin) return -1;
  738. if(nextw->y== -1 || nextw->hh<=FITHEIGHT) return -1;
  739. X
  740. w->reqh=w->hh+1;    /* Increase this window's height */
  741. nextw->reqh=nextw->hh-1;/* Decrease this window's height and move it down */
  742. X
  743. wfit(w->t);
  744. X
  745. return 0;
  746. }
  747. X
  748. /* Shrink window */
  749. X
  750. int wshrink(w)
  751. W *w;
  752. {
  753. W *nextw, *z;
  754. /* Is this window too small already? */
  755. if(w->hh<=FITHEIGHT) return -1;
  756. X
  757. /* Is there a window we can grow with this window's space? */
  758. for(nextw=w->link.next;
  759. X    nextw!=w->t->topwin && nextw->win;
  760. X    nextw=nextw->link.next);
  761. if(nextw==w->t->topwin) return -1;
  762. X
  763. w->reqh=w->hh-1;        /* Decrease window size */
  764. nextw->reqh=nextw->hh+1;    /* Give space to this window */
  765. X
  766. wfit(w->t);
  767. return 0;
  768. }
  769. X
  770. /* Show all windows */
  771. X
  772. void wshowall(t)
  773. SCREEN *t;
  774. {
  775. int n=0;
  776. int set;
  777. W *w=t->topwin; do
  778. X if(!w->win) ++n;
  779. X while(w=w->link.next, w!=t->topwin);
  780. if((t->h-t->wind)/n>=FITHEIGHT) set=(t->h-t->wind)/n;
  781. else set=FITHEIGHT;
  782. w=t->topwin; do
  783. X if(!w->win)
  784. X  {
  785. X  int h=getminh(w);
  786. X  if(h>=set) w->reqh=2;
  787. X  else w->reqh=set-(h-2);
  788. X  w->orgwin=0;
  789. X  }
  790. X while(w=w->link.next, w!=t->topwin);
  791. wfit(t);
  792. }
  793. X
  794. void wspread(t)
  795. SCREEN *t;
  796. {
  797. int n=0;
  798. W *w=t->topwin; do
  799. X if(w->y>=0 && !w->win) ++n;
  800. X while(w=w->link.next, w!=t->topwin);
  801. if(!n)
  802. X {
  803. X wfit(t);
  804. X return;
  805. X }
  806. if((t->h-t->wind)/n>=FITHEIGHT) n=(t->h-t->wind)/n;
  807. else n=FITHEIGHT;
  808. w=t->topwin; do
  809. X if(!w->win)
  810. X  {
  811. X  int h=getminh(w);
  812. X  if(h>=n) w->reqh=2;
  813. X  else w->reqh=n-(h-2);
  814. X  w->orgwin=0;
  815. X  }
  816. X while(w=w->link.next, w!=t->topwin);
  817. wfit(t);
  818. }
  819. X
  820. /* Show just one family of windows */
  821. X
  822. void wshowone(w)
  823. W *w;
  824. {
  825. W *q=w->t->topwin; do
  826. X if(!q->win)
  827. X  q->reqh=w->t->h-(getgrouph(q)-q->hh), q->orgwin=0;
  828. X while(q=q->link.next, q!=w->t->topwin);
  829. wfit(w->t);
  830. }
  831. X
  832. /* Create a window */
  833. X
  834. W *wcreate(t,watom,where,target,original,height,huh)
  835. SCREEN *t;
  836. WATOM *watom;
  837. W *where, *target, *original;
  838. int height;
  839. char *huh;
  840. {
  841. W *new;
  842. X
  843. if(height<1) return 0;
  844. X
  845. /* Create the window */
  846. new=(W *)malloc(sizeof(W));
  847. new->t=t;
  848. new->w=t->w-1;
  849. new->hh=new->h=height;
  850. new->y= -1;
  851. new->ny=0; new->nh=0; new->reqh=0;
  852. new->x=0;
  853. new->huh=huh;
  854. new->orgwin=original;
  855. new->watom=watom;
  856. new->object=0;
  857. new->msgb=0;
  858. new->msgt=0;
  859. X
  860. /* Set window's target and family */
  861. if(new->win=target) new->main=target->main;
  862. else new->main=new;
  863. X
  864. /* Get space for window */
  865. if(original)
  866. X if(original->hh-height<=2)
  867. X  {
  868. X  /* Not enough space for window */
  869. X  free(new);
  870. X  return 0;
  871. X  }
  872. X else original->hh-=height;
  873. X
  874. /* Create new keyboard handler for window */
  875. if(watom->context) new->kbd=mkkbd(watom->context,new);
  876. else new->kbd=0;
  877. X
  878. /* Put window on the screen */
  879. if(where) enquef(W,link,where,new);
  880. else
  881. X {
  882. X if(t->topwin) enqueb(W,link,t->topwin,new);
  883. X else izque(W,link,new), t->curwin=t->topwin=new;
  884. X }
  885. X
  886. wfit(t);
  887. return new;
  888. }
  889. X
  890. /* Abort group of windows */
  891. X
  892. static int doabort(w)
  893. W *w;
  894. {
  895. int amnt=w->hh;
  896. W *z, *zn;
  897. w->y= -2;
  898. if(w->t->topwin==w) w->t->topwin=w->link.next;
  899. loop:
  900. z=w->t->topwin; do
  901. X {
  902. X if(z->orgwin==w) z->orgwin=0;
  903. X if((z->win==w || z->main==w) && z->y!= -2)
  904. X  {
  905. X  amnt+=doabort(z);
  906. X  goto loop;
  907. X  }
  908. X }
  909. X while(z=z->link.next, z!=w->t->topwin);
  910. if(w->orgwin)
  911. X {
  912. X if(w->orgwin->reqh) w->orgwin->reqh+=(w->reqh?w->reqh:w->hh);
  913. X else w->orgwin->reqh=w->orgwin->hh+(w->reqh?w->reqh:w->hh);
  914. X }
  915. if(w->t->curwin==w)
  916. X if(w->t->curwin->win) w->t->curwin=w->t->curwin->win;
  917. X else
  918. X  if(w->orgwin) w->t->curwin=w->orgwin;
  919. X  else w->t->curwin=w->link.next;
  920. if(qempty(W,link,w))
  921. X {
  922. X leave=1;
  923. X amnt=0;
  924. X }
  925. deque(W,link,w);
  926. w->watom->kill(w);
  927. rmkbd(w->kbd);
  928. free(w);
  929. windie(w);
  930. return amnt;
  931. }
  932. X
  933. /* Abort a window and its children */
  934. X
  935. void wabort(w)
  936. W *w;
  937. {
  938. SCREEN *t=w->t;
  939. if(w!=w->main)
  940. X {
  941. X doabort(w);
  942. X if(!leave) wfit(t);
  943. X }
  944. else
  945. X {
  946. X doabort(w);
  947. X if(!leave)
  948. X  {
  949. X  if(lastw(t)->link.next!=t->topwin) wfit(t);
  950. X  else wspread(t);
  951. X  }
  952. X }
  953. }
  954. X
  955. /* Generate text with formatting escape sequences */
  956. X
  957. void genfmt(t,x,y,ofst,s,flg)
  958. SCRN *t;
  959. char *s;
  960. {
  961. int *scrn=t->scrn+y*t->co+x;
  962. int atr=0;
  963. int col=0;
  964. while(*s)
  965. X {
  966. X int c;
  967. X if(*s=='\\')
  968. X  {
  969. X  ++s;
  970. X  if(!*s) break;
  971. X  if(*s=='\\') if(col++>=ofst) c= (unsigned char)*s++ + atr; else { ++s; continue; }
  972. X  else if(*s=='u' || *s=='U') { atr^=UNDERLINE; ++s; continue; }
  973. X  else if(*s=='i' || *s=='I') { atr^=INVERSE; ++s; continue; }
  974. X  else { ++s; continue; }
  975. X  }
  976. X else if(col++>=ofst) c= (unsigned char)*s++ + atr; else { ++s; continue; }
  977. X if(c!=*scrn) *scrn=c, outatr(t,col-ofst+x-1,y,c);
  978. X ++scrn;
  979. X }
  980. if(flg) eraeol(t,col-ofst+x,y);
  981. }
  982. X
  983. /* Determine column width of string with format codes */
  984. X
  985. int fmtlen(s)
  986. char *s;
  987. {
  988. int col=0;
  989. while(*s)
  990. X {
  991. X if(*s=='\\')
  992. X  {
  993. X  ++s;
  994. X  if(!*s) break;
  995. X  if(*s=='\\') { ++col; ++s; continue; }
  996. X  if(*s=='u' || *s=='U') { ++s; continue; }
  997. X  if(*s=='i' || *s=='I') { ++s; continue; }
  998. X  ++s; continue;
  999. X  }
  1000. X ++col; ++s;
  1001. X }
  1002. return col;
  1003. }
  1004. X
  1005. /* Display a message and skip the next key */
  1006. X
  1007. int msgout(t,y,s)
  1008. SCRN *t;
  1009. char *s;
  1010. {
  1011. int ofst;
  1012. int len;
  1013. len=fmtlen(s);
  1014. if(len<=(t->co-1)) ofst=0;
  1015. else ofst=len-(t->co-1);
  1016. genfmt(t,0,y,ofst,s,1);
  1017. return len-ofst;
  1018. }
  1019. X
  1020. void msg(w,s)
  1021. W *w;
  1022. char *s;
  1023. {
  1024. cpos(w->t->t,msgout(w->t->t,w->y+w->h-1,s),w->y+w->h-1);
  1025. w->t->t->updtab[w->y+w->h-1]=1;
  1026. engetc(w->t->t);
  1027. }
  1028. X
  1029. /* Set temporary message */
  1030. X
  1031. void msgnw(w,s)
  1032. W *w;
  1033. char *s;
  1034. {
  1035. w->msgb=s;
  1036. }
  1037. X
  1038. void msgnwt(w,s)
  1039. W *w;
  1040. char *s;
  1041. {
  1042. w->msgt=s;
  1043. }
  1044. X
  1045. /* Single key query */
  1046. X
  1047. int query(w,s)
  1048. W *w;
  1049. char *s;
  1050. {
  1051. int ofst;
  1052. int c;
  1053. int len;
  1054. len=fmtlen(s);
  1055. if(len<=w->w-2) ofst=0;
  1056. else ofst=len-(w->w-2);
  1057. genfmt(w->t->t,w->x,w->y+w->h-1,ofst,s,1);
  1058. cpos(w->t->t,w->x+len-ofst,w->y+w->h-1);
  1059. c=engetc(w->t->t);
  1060. w->t->t->updtab[w->y+w->h-1]=1;
  1061. return c;
  1062. }
  1063. X
  1064. /* Single key query - leave cursor in curwin */
  1065. X
  1066. static void dumb()
  1067. {
  1068. }
  1069. X
  1070. static WATOM dummy=
  1071. {
  1072. 0,dumb,dumb,dumb,dumb,dumb,dumb,dumb
  1073. };
  1074. X
  1075. int queryn(w,s)
  1076. W *w;
  1077. char *s;
  1078. {
  1079. int ofst;
  1080. int len;
  1081. int c;
  1082. W *new=wcreate(w->t,&dummy,w,w,w,1,NULL);
  1083. if(!new) return MAXINT;
  1084. len=fmtlen(s);
  1085. if(len<=w->w-1) ofst=0;
  1086. else ofst=len-(w->w-1);
  1087. genfmt(w->t->t,w->x,new->y,ofst,s,1);
  1088. c=edgetc();
  1089. wabort(new);
  1090. return c;
  1091. }
  1092. SHAR_EOF
  1093. chmod 0600 w.c ||
  1094. echo 'restore of w.c failed'
  1095. Wc_c="`wc -c < 'w.c'`"
  1096. test 13930 -eq "$Wc_c" ||
  1097.     echo 'w.c: original size 13930, current size' "$Wc_c"
  1098. fi
  1099. # ============= w.h ==============
  1100. if test -f 'w.h' -a X"$1" != X"-c"; then
  1101.     echo 'x - skipping w.h (File already exists)'
  1102. else
  1103. echo 'x - extracting w.h (Text)'
  1104. sed 's/^X//' << 'SHAR_EOF' > 'w.h' &&
  1105. /* Window management
  1106. X   Copyright (C) 1992 Joseph H. Allen
  1107. X
  1108. This file is part of JOE (Joe's Own Editor)
  1109. X
  1110. JOE is free software; you can redistribute it and/or modify it under the 
  1111. terms of the GNU General Public License as published by the Free Software 
  1112. Foundation; either version 1, or (at your option) any later version.  
  1113. X
  1114. JOE is distributed in the hope that it will be useful, but WITHOUT ANY 
  1115. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
  1116. FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
  1117. details.  
  1118. X
  1119. You should have received a copy of the GNU General Public License along with 
  1120. JOE; see the file COPYING.  If not, write to the Free Software Foundation, 
  1121. 675 Mass Ave, Cambridge, MA 02139, USA.  */ 
  1122. X
  1123. #ifndef _Iw
  1124. #define _Iw 1
  1125. X
  1126. #include "config.h"
  1127. #include "queue.h"
  1128. #include "kbd.h"
  1129. #include "scrn.h"
  1130. #include "b.h"
  1131. X
  1132. typedef struct watom WATOM;
  1133. typedef struct screen SCREEN;
  1134. typedef struct window W;
  1135. X
  1136. struct watom
  1137. X {
  1138. X CONTEXT *context;
  1139. X void (*disp)();
  1140. X void (*follow)();
  1141. X void (*kill)();
  1142. X void (*resize)();
  1143. X void (*move)();
  1144. X void (*ins)();
  1145. X void (*del)();
  1146. X int what;        /* Type of this thing */
  1147. X };
  1148. X
  1149. struct screen
  1150. X {
  1151. X SCRN *t;            /* Screen data on this screen is output to */
  1152. X
  1153. X int wind;            /* Number of help lines on this screen */
  1154. X W *topwin;            /* Top-most window showing on screen */
  1155. X W *curwin;            /* Window cursor is in */
  1156. X
  1157. X int w,h;            /* Width and height of this screen */
  1158. X char *pattern;            /* pattern being searched for */
  1159. X char *replace;            /* what to replace with */
  1160. X int options;            /* Search/Replace options */
  1161. X int repeat;
  1162. X int foundlen;
  1163. X P *markb;            /* Beginning and end of marked block */
  1164. X P *markk;
  1165. X
  1166. X int arg;
  1167. X };
  1168. X
  1169. struct window
  1170. X {
  1171. X LINK(W) link;            /* Linked list of windows in order they
  1172. X                    appear on the screen */
  1173. X SCREEN *t;            /* Screen this thing is on */
  1174. X int x,y,w,h;            /* Position and size of window */
  1175. X                                /* Currently, x=0, w=width or screen. */
  1176. X                                /* y== -1 if window is not on screen */
  1177. X int ny,nh;            /* Temporary values for wfit */
  1178. X int reqh;            /* Requested new height or 0 for same */
  1179. X                 /* This is an argument for wfit */
  1180. X int hh;            /* Natural height */
  1181. X W *win;            /* Window this one operates on */
  1182. X W *main;            /* Main window of this family */
  1183. X W *orgwin;            /* Window where space from this window came */
  1184. X int curx, cury;        /* Cursor position within window */
  1185. X KBD *kbd;            /* Keyboard handler for this window */
  1186. X WATOM *watom;            /* The type of this window */
  1187. X void *object;            /* Object which inherits this */
  1188. X
  1189. X char *msgt;            /* Message at top of window */
  1190. X
  1191. X char *msgb;            /* Message at bottom of window */
  1192. X
  1193. X char *huh;            /* Name of window for context sensitive hlp */
  1194. X };
  1195. X
  1196. /* Minimum text window height */
  1197. #define FITHEIGHT 4
  1198. X
  1199. /***************/
  1200. /* Subroutines */
  1201. /***************/
  1202. X
  1203. void scrlup();
  1204. void scrldn();
  1205. void prming();
  1206. void updall();
  1207. X
  1208. /* int getgrouph(W *);
  1209. X * Get height of a family of windows
  1210. X */
  1211. int getgrouph();
  1212. X
  1213. /* W *findtopw(W *);
  1214. X * Find first (top-most) window of a family
  1215. X */
  1216. W *findtopw();
  1217. X
  1218. /* W *findbotw(W *);
  1219. X * Find last (bottom-most) window a family
  1220. X */
  1221. W *findbotw();
  1222. X
  1223. W *lastw();
  1224. X
  1225. /* void wfit(SCREEN *);
  1226. X *
  1227. X * Fit all of the windows onto the screen
  1228. X */
  1229. void wfit();
  1230. X
  1231. /*****************/
  1232. /* Main routines */
  1233. /*****************/
  1234. X
  1235. /* SCREEN *screate(SCRN *);
  1236. X *
  1237. X * Create a screen
  1238. X */
  1239. SCREEN *screate();
  1240. X
  1241. /* void sresize(SCREEN *t);
  1242. X * Screen size changed
  1243. X */
  1244. void sresize();
  1245. X
  1246. void chsize();
  1247. X
  1248. /* W *wcreate(SCREEN *t,WATOM *watom,W *where,W *target,W *original,int height);
  1249. X *
  1250. X * Try to create a window
  1251. X *
  1252. X * 't'        Is the screen the window is placed on
  1253. X * 'watom'    Type of new window
  1254. X * 'where'    The window placed after this window, or if 'where'==0, the
  1255. X *        window is placed on the end of the screen
  1256. X * 'target'    The window operates on this window.  The window becomes a
  1257. X *        member of 'target's family or starts a new family if
  1258. X *        'target'==0.
  1259. X * 'original'    Attempt to get 'height' from this window.  When the window is
  1260. X *              aborted, the space gets returned to 'original' if it still
  1261. X *        exists.  If 'original'==0, the window will force other
  1262. X *        windows to go off of the screen.
  1263. X * 'height'    The height of the window
  1264. X *
  1265. X * Returns the new window or returns 0 if there was not enough space to
  1266. X * create the window and maintain family integrity.
  1267. X */
  1268. W *wcreate();
  1269. X
  1270. /* void wabort(W *w);
  1271. X *
  1272. X * Kill a window and it's children
  1273. X */
  1274. void wabort();
  1275. X
  1276. /* int wnext(SCREEN *);
  1277. X *
  1278. X * Switch to next window
  1279. X */
  1280. int wnext();
  1281. X
  1282. /* int wprev(SCREEN *);
  1283. X *
  1284. X * Switch to previous window
  1285. X */
  1286. int wprev();
  1287. X
  1288. /* int wgrow(W *);
  1289. X *
  1290. X * increase size of window.  Return 0 for success, -1 for fail.
  1291. X */
  1292. int wgrow();
  1293. X
  1294. /* int wshrink(W *);
  1295. X *
  1296. X * Decrease size of window.  Returns 0 for success, -1 for fail.
  1297. X */
  1298. int wshrink();
  1299. X
  1300. /* void wshowone(W *);
  1301. X *
  1302. X * Show only one window on the screen
  1303. X */
  1304. void wshowone();
  1305. X
  1306. /* void wshowall(SCREEN *);
  1307. X *
  1308. X * Show all windows on the screen, including the given one
  1309. X */
  1310. void wshowall();
  1311. X
  1312. /* void wredraw(W *);
  1313. X *
  1314. X * Force complete redraw of window
  1315. X */
  1316. void wredraw();
  1317. X
  1318. /* void wsquish(SCREEN *,int h);
  1319. X *
  1320. X * Squish all of the windows on the screen so that h lines can fit
  1321. X */
  1322. void wsquish();
  1323. X
  1324. /* void wrestore(SCREEN *);
  1325. X *
  1326. X * Restore windows to their original heights
  1327. X */
  1328. void wrestore();
  1329. X
  1330. /* void msg(W *w,char *text);
  1331. X * Display a message and then continue editing after the next keypress.
  1332. X * The message is placed in the last line of 'w'
  1333. X */
  1334. int msgout();
  1335. void msg();
  1336. X
  1337. void msgnw();
  1338. void msgnwt();
  1339. X
  1340. /* int query(W *w,char *text);
  1341. X * Single-key query.  'func' gets the key as it's first arg.  The message is
  1342. X * displayed on the last line of 'w'.
  1343. X */
  1344. int query();
  1345. X
  1346. /* int queryn(W *w,char *text);
  1347. X * As above, but leave cursor in current window
  1348. X */
  1349. int queryn();
  1350. X
  1351. #endif
  1352. SHAR_EOF
  1353. chmod 0600 w.h ||
  1354. echo 'restore of w.h failed'
  1355. Wc_c="`wc -c < 'w.h'`"
  1356. test 5765 -eq "$Wc_c" ||
  1357.     echo 'w.h: original size 5765, current size' "$Wc_c"
  1358. fi
  1359. # ============= zstr.c ==============
  1360. if test -f 'zstr.c' -a X"$1" != X"-c"; then
  1361.     echo 'x - skipping zstr.c (File already exists)'
  1362. else
  1363. echo 'x - extracting zstr.c (Text)'
  1364. sed 's/^X//' << 'SHAR_EOF' > 'zstr.c' &&
  1365. /* Zero terminated strings
  1366. X   Copyright (C) 1992 Joseph H. Allen
  1367. X
  1368. This file is part of JOE (Joe's Own Editor)
  1369. X
  1370. JOE is free software; you can redistribute it and/or modify it under the 
  1371. terms of the GNU General Public License as published by the Free Software 
  1372. Foundation; either version 1, or (at your option) any later version.  
  1373. X
  1374. JOE is distributed in the hope that it will be useful, but WITHOUT ANY 
  1375. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
  1376. FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
  1377. details.  
  1378. X
  1379. You should have received a copy of the GNU General Public License along with 
  1380. JOE; see the file COPYING.  If not, write to the Free Software Foundation, 
  1381. 675 Mass Ave, Cambridge, MA 02139, USA.  */ 
  1382. X
  1383. #include "heap.h"
  1384. #include "zstr.h"
  1385. X
  1386. int toup(a) { return (a>='a' && a<='z')?a+'A'-'a':a; }
  1387. unsigned Umin(a,b) unsigned a,b; { return a<b?a:b; }
  1388. unsigned Umax(a,b) unsigned a,b; { return a>b?a:b; }
  1389. int Imin(a,b) { return a<b?a:b; }
  1390. int Imax(a,b) { return a>b?a:b; }
  1391. int Iabs(a) { return a>=0?a:-a; }
  1392. X
  1393. int cword(c)
  1394. {
  1395. return c>='A' && c<='Z' || c>='a' && c<='z' || c>='0' && c<='9' || c=='_';
  1396. }
  1397. X
  1398. int cwhitel(c)
  1399. {
  1400. return c==' ' || c=='\t' || c=='\n';
  1401. }
  1402. X
  1403. int cwhite(c)
  1404. {
  1405. return c==' ' || c=='\t';
  1406. }
  1407. X
  1408. int zlen(s)
  1409. char *s;
  1410. {
  1411. char *os=s;
  1412. while(*s) ++s;
  1413. return s-os;
  1414. }
  1415. X
  1416. char *zcpy(d,s)
  1417. char *d,*s;
  1418. {
  1419. char *od=d;
  1420. while(*d++= *s++);
  1421. return od;
  1422. }
  1423. X
  1424. char *zcat(d,s)
  1425. char *d,*s;
  1426. {
  1427. char *od=d;
  1428. while(*d) ++d;
  1429. while(*d++= *s++);
  1430. return od;
  1431. }
  1432. X
  1433. char *zdup(s)
  1434. char *s;
  1435. {
  1436. return zcpy((char *)malloc(zlen(s)+1),s);
  1437. }
  1438. X
  1439. int zcmp(l,r)
  1440. char *l, *r;
  1441. {
  1442. while(*l && *l==*r) ++l, ++r;
  1443. if(*l>*r) return 1;
  1444. if(*l<*r) return -1;
  1445. return 0;
  1446. }
  1447. X
  1448. int fields(s,fields,sep)
  1449. char *s, **fields, sep;
  1450. {
  1451. int y=1;
  1452. fields[0]=s;
  1453. while(*s)
  1454. X {
  1455. X if(*s==sep) fields[y++]=s+1, *s=0;
  1456. X ++s;
  1457. X }
  1458. return y;
  1459. }
  1460. X
  1461. int nfields(s,sep)
  1462. char *s, sep;
  1463. {
  1464. int y=1;
  1465. while(*s) if(*s++==sep) ++y;
  1466. return y;
  1467. }
  1468. SHAR_EOF
  1469. chmod 0600 zstr.c ||
  1470. echo 'restore of zstr.c failed'
  1471. Wc_c="`wc -c < 'zstr.c'`"
  1472. test 1902 -eq "$Wc_c" ||
  1473.     echo 'zstr.c: original size 1902, current size' "$Wc_c"
  1474. fi
  1475. # ============= zstr.h ==============
  1476. if test -f 'zstr.h' -a X"$1" != X"-c"; then
  1477.     echo 'x - skipping zstr.h (File already exists)'
  1478. else
  1479. echo 'x - extracting zstr.h (Text)'
  1480. sed 's/^X//' << 'SHAR_EOF' > 'zstr.h' &&
  1481. /* Zero terminated strings
  1482. X   Copyright (C) 1992 Joseph H. Allen
  1483. X
  1484. This file is part of JOE (Joe's Own Editor)
  1485. X
  1486. JOE is free software; you can redistribute it and/or modify it under the 
  1487. terms of the GNU General Public License as published by the Free Software 
  1488. Foundation; either version 1, or (at your option) any later version.  
  1489. X
  1490. JOE is distributed in the hope that it will be useful, but WITHOUT ANY 
  1491. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
  1492. FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
  1493. details.  
  1494. X
  1495. You should have received a copy of the GNU General Public License along with 
  1496. JOE; see the file COPYING.  If not, write to the Free Software Foundation, 
  1497. 675 Mass Ave, Cambridge, MA 02139, USA.  */ 
  1498. X
  1499. #ifndef _Izstr
  1500. #define _Izstr 1
  1501. X
  1502. #include "config.h"
  1503. X
  1504. int cword();
  1505. int cwhite();
  1506. int cwhitel();
  1507. int Iabs();
  1508. int toup();
  1509. unsigned Umin();
  1510. unsigned Umax();
  1511. int Imin();
  1512. int Imax();
  1513. char *zcpy();
  1514. char *zdup();
  1515. char *zcat();
  1516. int zcmp();
  1517. int zlen();
  1518. int fields();
  1519. int nfields();
  1520. X
  1521. #endif
  1522. SHAR_EOF
  1523. chmod 0600 zstr.h ||
  1524. echo 'restore of zstr.h failed'
  1525. Wc_c="`wc -c < 'zstr.h'`"
  1526. test 1044 -eq "$Wc_c" ||
  1527.     echo 'zstr.h: original size 1044, current size' "$Wc_c"
  1528. fi
  1529. # ============= .joerc ==============
  1530. if test -f '.joerc' -a X"$1" != X"-c"; then
  1531.     echo 'x - skipping .joerc (File already exists)'
  1532. else
  1533. echo 'x - extracting .joerc (Text)'
  1534. sed 's/^X//' << 'SHAR_EOF' > '.joerc' &&
  1535. X                         Initialization file for JOE
  1536. X
  1537. X JOE looks for this file in:
  1538. X    1 - .joerc
  1539. X    2 - $HOME/.joerc
  1540. X    3 - /usr/local/lib/joerc
  1541. X
  1542. X FIRST SECTION: Default global options:
  1543. X
  1544. X Put each option you want set in the first column:
  1545. X
  1546. X -mid        Cursor is recentered when scrolling is necessary
  1547. X -asis        Characters 160 - 254 shown as-is
  1548. X -stacol    Column number in status line
  1549. X -starow    Row number in status line
  1550. X -force        Force final newline when files are saved
  1551. X -help        Start with help on
  1552. X -pg nnn    No. lines to keep for PgUp/PgDn
  1553. X -gtab nnn    Default tab width for prompt windows
  1554. X
  1555. X SECOND SECTION: File name dependant local option settings:
  1556. X
  1557. X Each line with '*' in the first column indicates the modes which should be
  1558. X files which match the regular expression.  If more than one regular
  1559. X expression matches the file name, than the last matching one is chosen.
  1560. X
  1561. X Here is a list of modes which can be set:
  1562. X
  1563. X    -wordwrap        Wordwrap
  1564. X    -autoindent        Auto indent
  1565. X    -overwrite        Overtype mode
  1566. X    -lmargin nnn        Left margin
  1567. X    -rmargin nnn        Right margin
  1568. X    -tab nnn        Tab width
  1569. X    -indentc nnn        Indentation character (32 for space, 9 for tab)
  1570. X    -istep nnn        Number of indentation columns
  1571. *
  1572. -wordwrap
  1573. X
  1574. *.c
  1575. -autoindent
  1576. X
  1577. *.h
  1578. -autoindent
  1579. X
  1580. *akefile
  1581. *AKEFILE
  1582. *joerc
  1583. X
  1584. *.p
  1585. -autoindent
  1586. X
  1587. X THIRD SECTION: Named help screens:
  1588. X
  1589. X Use \i to turn on/off inverse video
  1590. X Use \u to turn on/off underline
  1591. X
  1592. {Basic
  1593. \i   Help Screen    turn off with ^KH                                            \i
  1594. \i \i\uCURSOR\u           \uGO TO\u            \uBLOCK\u      \uDELETE\u   \uMISC\u         \uEXIT\u      \i \i
  1595. \i \i^B left ^F right ^U  prev. screen ^KB begin  ^D char. ^KJ reformat ^KX save  \i \i
  1596. \i \i^P up   ^N down  ^V  next screen  ^KK end    ^Y line  ^TT overtype ^C  abort \i \i
  1597. \i \i^Z previous word ^A  beg. of line ^KM move   ^W >word `   Ctrl-    ^KZ shell \i \i
  1598. \i \i^X next word     ^E  end of line  ^KC copy   ^O word< ^\\  Meta-    \uFILE\u      \i \i
  1599. \i \i\uSEARCH\u           ^KU top of file  ^KW file   ^J >line ^R  retype   ^KE new   \i \i
  1600. \i \i^KF find text    ^KV end of file  ^KY delete ^_ undo  ^@  insert   ^KR insert\i \i
  1601. \i \i^L  find next    ^KL to line No.  ^K/ filter ^^ redo               ^KD save  \i \i
  1602. }
  1603. X
  1604. {Windows
  1605. \i   Help Screen    turn off with ^KH                                            \i
  1606. \i \i^KO Split the window into two.  You can then use ^KE to load a file into the \i \i
  1607. \i \i    new window.                                                              \i \i
  1608. \i \i^KG Make current window bigger         ^KT Make current window smaller       \i \i
  1609. \i \i^KN Go to the window below             ^KP Go to the window above            \i \i
  1610. \i \i^C  Eliminate the current window       ^KI Show all windows / Show one window\i \i
  1611. }
  1612. X
  1613. {Advanced
  1614. \i   Help Screen    turn off with ^KH                                            \i
  1615. \i \i ESC nn   repeat next command nn times     ^G   goto matching ( [ {          \i \i
  1616. \i \i ^K SPACE show position status             ^K-  goto prevous place in        \i \i
  1617. \i \i ^K [ 0-9 begin recording macro n               position history             \i \i
  1618. \i \i ^K ]     stop recording                   ^K=  goto next place              \i \i
  1619. \i \i ^K 0-9   play macro n                     ^K,  indent marked block less     \i \i
  1620. \i \i ^K A     center line                      ^K.  indent marked block more     \i \i
  1621. \i \i ^T X     rectangle mode                   ^K;  tag search                   \i \i
  1622. }
  1623. X
  1624. {Options
  1625. \i   Help Screen    turn off with ^KH                                            \i
  1626. \i \i                                Mode Settings                                \i \i
  1627. \i \i                                                                             \i \i
  1628. \i \i ^TT Insert/Overtype             ^TM Recenter cursor when it goes off window \i \i
  1629. \i \i ^TA Autoindent on/off           ^TF Force final NL when files are written   \i \i
  1630. \i \i ^TW Wordwrap on/off             ^TH Display characters above 127 as-is      \i \i
  1631. \i \i ^TL Left margin                 ^TN Show line number on status line         \i \i
  1632. \i \i ^TR Right margin                ^TC Show column number on status line       \i \i
  1633. \i \i ^TP No. PgUp/PgDn Lines         ^TD Tab width                               \i \i
  1634. \i \i ^TK Indent character            ^TI Indent step column width                \i \i
  1635. \i \i ^TX Rectangle mode                                                          \i \i
  1636. }
  1637. X
  1638. {Search
  1639. \i   Help Screen    turn off with ^KH                                            \i
  1640. \i \iSpecial search sequences:                                                    \i \i
  1641. \i \i    \\^     matches beginning of line     \\$     matches end of line          \i \i
  1642. \i \i    \\<     matches beginning of word     \\>     matches end of word          \i \i
  1643. \i \i    \\?     matches any single character  \\*     matches 0 or more characters \i \i
  1644. \i \i    \\c     matches balanced C expression \\\\     matches a \\                  \i \i
  1645. \i \i    \\[..]  matches one of a set          \\n     matches a newline            \i \i
  1646. \i \i    \\+     matches 0 or more of the character which follows the \\+           \i \i
  1647. \i \iSpecial replace sequences:                                                   \i \i
  1648. \i \i    \\&     replaced with text which matched search string                    \i \i
  1649. \i \i    \\0 - 9 replaced with text which matched Nth \\*, \\?, \\c, \\+, or \\[..]     \i \i
  1650. \i \i    \\\\     replaced with \\               \\n     replaced with newline        \i \i
  1651. }
  1652. X
  1653. {Names
  1654. \i   Help Screen    turn off with ^KH                                            \i
  1655. \i \i Hit TAB at file name prompts to generate menu of file names                 \i \i
  1656. \i \i Or use up/down keys to access history of previously entered names           \i \i
  1657. \i \i Special file names:                                                         \i \i
  1658. \i \i      !command                 Pipe in/out of a shell command                \i \i
  1659. \i \i      >>filename               Append to a file                              \i \i
  1660. \i \i      -                        Read/Write to/from standard I/O               \i \i
  1661. \i \i      filename,START,SIZE      Read/Write a part of a file/device            \i \i
  1662. \i \i          Give START/SIZE in decimal (255), octal (0377) or hex (0xFF)       \i \i
  1663. }
  1664. X
  1665. {Joe
  1666. \i   Help Screen    turn off with ^KH                                            \i
  1667. \i \i Joe Allen's email address:  'jhallen@world.std.com' or                      \i \i
  1668. \i \i 'rcarter' on the VWIS Linux BBS (508)793-9568                               \i \i
  1669. }
  1670. X
  1671. X FOURTH SECTION: Key bindings:
  1672. X
  1673. X :main are the main editing bindings
  1674. X :fprompt are file name prompt bindings
  1675. X :prompt are other prompt bindings
  1676. X :tab are file menu bindings
  1677. X :help are help menu bindings
  1678. X
  1679. X Use ^@ through ^_ and ^? for Ctrl chars
  1680. X Use SP for space
  1681. X Use a TO b to generate a range of characters
  1682. X Use UP DOWN RIGHT LEFT HOME END INS DEL PGUP PGDN
  1683. X     F1 F2 F3 F4 F5 F6 F7 F8 F9 F0
  1684. X     for the corresponding termcap key sequence definitions
  1685. X
  1686. X Simple macros can be made by comma seperating 2 or more command names.  For
  1687. X example:
  1688. X
  1689. X bof,bol    ^T Z        Goto beginning of last line
  1690. X
  1691. X Also quoted matter is typed in literally:
  1692. X
  1693. X bol,">",dnarw    F1        Quote news article line
  1694. X
  1695. :main
  1696. X
  1697. type        ^I        Tab
  1698. quote8        ^\        Quote Meta chars
  1699. type        SP TO ~        Typeable characters
  1700. quote        `        Quote Ctrl chars
  1701. X
  1702. abort        ^C        Abort window
  1703. arg        ^[ 1 TO 9    Repeat count
  1704. backs        ^?        Backspace
  1705. backs        ^H
  1706. backw        ^O        Backspace word
  1707. blkcpy        ^K C        Copy marked block
  1708. blkcpy        ^K ^C
  1709. blkcpy        ^K c
  1710. blkdel        ^K Y        Delete marked block
  1711. blkdel        ^K ^Y
  1712. blkdel        ^K y
  1713. blkmove        ^K M        Move marked block
  1714. blkmove        ^K ^M
  1715. blkmove        ^K m
  1716. blksave        ^K W        Save marked block
  1717. blksave        ^K ^W
  1718. blksave        ^K w
  1719. bof        ^K U        Goto beginning of file
  1720. bof        ^K ^U
  1721. bof        ^K u
  1722. bol        HOME        Goto beginning of line
  1723. bol        ^A
  1724. center        ^K A        Center line
  1725. center        ^K ^A
  1726. center        ^K a
  1727. delch        DEL        Delete character
  1728. delch        ^D
  1729. deleol        ^J        Delete to end of line
  1730. dellin        ^Y        Delete entire line
  1731. delw        ^W        Delete word to right
  1732. dnarw        DOWN        Go down
  1733. dnarw        ^N
  1734. dnarw        ^[ O B
  1735. dnarw        ^[ [ B
  1736. edit        ^K E        Edit a file
  1737. edit        ^K ^E
  1738. edit        ^K e
  1739. eof        ^K V        Go to end of file
  1740. eof        ^K ^V
  1741. eof        ^K v
  1742. eol        END        Go to end of line
  1743. eol        ^E
  1744. explode        ^K I        Show one window / Show all windows
  1745. explode        ^K ^I
  1746. explode        ^K i
  1747. exsave        ^K X        Save and exit
  1748. exsave        ^K ^X
  1749. exsave        ^K x
  1750. ffirst        ^K F        Find first
  1751. ffirst        ^K ^F
  1752. ffirst        ^K f
  1753. filt        ^K /        Filter block
  1754. fnext        ^L        Find next
  1755. format        ^K J        Format paragraph
  1756. format        ^K ^J
  1757. format        ^K j
  1758. groww        ^K G        Grow window
  1759. groww        ^K ^G
  1760. groww        ^K g
  1761. help        ^K H        Help
  1762. help        ^K ^H
  1763. help        ^K h
  1764. iasis        ^T H        Characters 160-254 shown as-is
  1765. iasis        ^T ^H
  1766. iasis        ^T h
  1767. iforce        ^T F        Force final newline
  1768. iforce        ^T ^F
  1769. iforce        ^T f
  1770. iindent        ^T A        Autoindent on/off
  1771. iindent        ^T ^A
  1772. iindent        ^T a
  1773. iindentc    ^T k
  1774. iindentc    ^T K
  1775. iindentc    ^T ^K
  1776. ilmargin    ^T L        Set left margin
  1777. ilmargin    ^T ^L
  1778. ilmargin    ^T l
  1779. imid        ^T M        Center cursor when scrolling
  1780. imid        ^T ^M
  1781. imid        ^T m
  1782. insc        INS        Insert a space
  1783. insc        ^@
  1784. insf        ^K R        Insert a file
  1785. insf        ^K ^R
  1786. insf        ^K r
  1787. ipgamnt        ^T P        No. lines to keep for PGUP/PGDN
  1788. ipgamnt        ^T ^P
  1789. ipgamnt        ^T p
  1790. irmargin    ^T R        Set right margin
  1791. irmargin    ^T ^R
  1792. irmargin    ^T r
  1793. istacol        ^T C        Column number on status line
  1794. istacol        ^T ^C
  1795. istacol        ^T c
  1796. istarow        ^T N        Row number on status line
  1797. istarow        ^T ^N
  1798. istarow        ^T n
  1799. iistep        ^T i
  1800. iistep        ^T I
  1801. iistep        ^T ^I
  1802. isquare        ^T x
  1803. isquare        ^T X
  1804. isquare        ^T ^X
  1805. itab        ^T D
  1806. itab        ^T ^D
  1807. itab        ^T d
  1808. itype        ^T T        Insert/Overtype
  1809. itype        ^T ^T
  1810. itype        ^T t
  1811. iwrap        ^T W        Word wrap
  1812. iwrap        ^T ^W
  1813. iwrap        ^T w
  1814. lindent        ^K ,        Indent to left
  1815. line        ^K L        Goto line no.
  1816. line        ^K ^L
  1817. line        ^K l
  1818. ltarw        LEFT        Go left
  1819. ltarw        ^B
  1820. ltarw        ^[ O D
  1821. ltarw        ^[ [ D
  1822. markb        ^K B        Set beginning of marked block
  1823. markb        ^K ^B
  1824. markb        ^K b
  1825. markk        ^K K        Set end of marked block
  1826. markk        ^K ^K
  1827. markk        ^K k
  1828. nextpos        ^K =        Goto next position in position history
  1829. nextw        ^K N        Goto window below
  1830. nextw        ^K ^N
  1831. nextw        ^K n
  1832. nextword    ^X        Goto next word
  1833. open        ^]        Split line
  1834. pgdn        PGDN        Screen down
  1835. pgdn        ^V
  1836. pgup        PGUP        Screen up
  1837. pgup        ^U
  1838. play        ^K 0 TO 9    Execute macro
  1839. prevpos        ^K -
  1840. prevw        ^K P        Window above
  1841. prevw        ^K ^P
  1842. prevw        ^K p
  1843. prevword    ^Z        Previous word
  1844. record        ^K [        Record macro
  1845. redo        ^^        Redo changes
  1846. retype        ^R        Refresh screen
  1847. rindent        ^K .        Indent to right
  1848. rtarw        RIGHT        Go right
  1849. rtarw        ^F
  1850. rtarw        ^[ O C
  1851. rtarw        ^[ [ C
  1852. rtn        ^M        Return
  1853. save        ^K D        Save file
  1854. save        ^K S
  1855. save        ^K ^D
  1856. save        ^K ^S
  1857. save        ^K d
  1858. save        ^K s
  1859. shell        ^K Z        Shell escape/Suspend
  1860. shell        ^K ^Z
  1861. shell        ^K z
  1862. shrinkw        ^K T        Shrink window
  1863. shrinkw        ^K ^T
  1864. shrinkw        ^K t
  1865. splitw        ^K O        Split window
  1866. splitw        ^K ^O
  1867. splitw        ^K o
  1868. stat        ^K SP        Show status
  1869. stop        ^K ]        Stop recording macro
  1870. tag        ^K ;
  1871. tomatch        ^G        Goto matching parenthasis
  1872. undo        ^_        Undo changes
  1873. uparw        UP        Go up
  1874. uparw        ^P
  1875. uparw        ^[ O A
  1876. uparw        ^[ [ A
  1877. X
  1878. :prompt
  1879. X
  1880. type        ^I        Tab
  1881. quote8        ^\        Quote Meta chars
  1882. type        SP TO ~        Typeable characters
  1883. quote        `        Quote Ctrl chars
  1884. X
  1885. abortpw        ^C        Abort window
  1886. arg        ^[ 1 TO 9    Repeat count
  1887. backs        ^?        Backspace
  1888. backs        ^H
  1889. backw        ^O        Backspace word
  1890. blkcpy        ^K C        Copy marked block
  1891. blkcpy        ^K ^C
  1892. blkcpy        ^K c
  1893. blkdel        ^K Y        Delete marked block
  1894. blkdel        ^K ^Y
  1895. blkdel        ^K y
  1896. blkmove        ^K M        Move marked block
  1897. blkmove        ^K ^M
  1898. blkmove        ^K m
  1899. blksave        ^K W        Save marked block
  1900. blksave        ^K ^W
  1901. blksave        ^K w
  1902. bof        ^K U        Goto beginning of file
  1903. bof        ^K ^U
  1904. bof        ^K u
  1905. bol        HOME        Goto beginning of line
  1906. bol        ^A
  1907. center        ^K A        Center line
  1908. center        ^K ^A
  1909. center        ^K a
  1910. delch        DEL        Delete character
  1911. delch        ^D
  1912. deleol        ^J        Delete to end of line
  1913. dellin        ^Y        Delete entire line
  1914. delw        ^W        Delete word to right
  1915. dnarw        DOWN        Go down
  1916. dnarw        ^N
  1917. dnarw        ^[ O B
  1918. dnarw        ^[ [ B
  1919. edit        ^K E        Edit a file
  1920. edit        ^K ^E
  1921. edit        ^K e
  1922. eof        ^K V        Go to end of file
  1923. eof        ^K ^V
  1924. eof        ^K v
  1925. eol        END        Go to end of line
  1926. eol        ^E
  1927. explode        ^K I        Show one window / Show all windows
  1928. explode        ^K ^I
  1929. explode        ^K i
  1930. exsave        ^K X        Save and exit
  1931. exsave        ^K ^X
  1932. exsave        ^K x
  1933. ffirst        ^K F        Find first
  1934. ffirst        ^K ^F
  1935. ffirst        ^K f
  1936. filt        ^K /        Filter block
  1937. fnext        ^L        Find next
  1938. format        ^K J        Format paragraph
  1939. format        ^K ^J
  1940. format        ^K j
  1941. groww        ^K G        Grow window
  1942. groww        ^K ^G
  1943. groww        ^K g
  1944. help        ^K H        Help
  1945. help        ^K ^H
  1946. help        ^K h
  1947. iasis        ^T H        Characters 160-254 shown as-is
  1948. iasis        ^T ^H
  1949. iasis        ^T h
  1950. iforce        ^T F        Force final newline
  1951. iforce        ^T ^F
  1952. iforce        ^T f
  1953. iindent        ^T A        Autoindent on/off
  1954. iindent        ^T ^A
  1955. iindent        ^T a
  1956. iindentc    ^T k
  1957. iindentc    ^T K
  1958. iindentc    ^T ^K
  1959. ilmargin    ^T L        Set left margin
  1960. ilmargin    ^T ^L
  1961. ilmargin    ^T l
  1962. imid        ^T M        Center cursor when scrolling
  1963. imid        ^T ^M
  1964. imid        ^T m
  1965. insc        INS        Insert a space
  1966. insc        ^@
  1967. insf        ^K R        Insert a file
  1968. insf        ^K ^R
  1969. insf        ^K r
  1970. ipgamnt        ^T P        No. lines to keep for PGUP/PGDN
  1971. ipgamnt        ^T ^P
  1972. ipgamnt        ^T p
  1973. irmargin    ^T R        Set right margin
  1974. irmargin    ^T ^R
  1975. irmargin    ^T r
  1976. istacol        ^T C        Column number on status line
  1977. istacol        ^T ^C
  1978. istacol        ^T c
  1979. istarow        ^T N        Row number on status line
  1980. istarow        ^T ^N
  1981. istarow        ^T n
  1982. iistep        ^T i
  1983. iistep        ^T I
  1984. iistep        ^T ^I
  1985. isquare        ^T x
  1986. isquare        ^T X
  1987. isquare        ^T ^X
  1988. itab        ^T D
  1989. itab        ^T ^D
  1990. itab        ^T d
  1991. itype        ^T T        Insert/Overtype
  1992. itype        ^T ^T
  1993. itype        ^T t
  1994. iwrap        ^T W        Word wrap
  1995. iwrap        ^T ^W
  1996. iwrap        ^T w
  1997. lindent        ^K ,        Indent to left
  1998. line        ^K L        Goto line no.
  1999. line        ^K ^L
  2000. line        ^K l
  2001. ltarw        LEFT        Go left
  2002. ltarw        ^B
  2003. ltarw        ^[ O D
  2004. ltarw        ^[ [ D
  2005. markb        ^K B        Set beginning of marked block
  2006. markb        ^K ^B
  2007. markb        ^K b
  2008. markk        ^K K        Set end of marked block
  2009. markk        ^K ^K
  2010. markk        ^K k
  2011. nextpos        ^K =        Goto next position in position history
  2012. nextw        ^K N        Goto window below
  2013. nextw        ^K ^N
  2014. nextw        ^K n
  2015. nextword    ^X        Goto next word
  2016. open        ^]        Split line
  2017. pgdn        PGDN        Screen down
  2018. pgdn        ^V
  2019. pgup        PGUP        Screen up
  2020. pgup        ^U
  2021. play        ^K 0 TO 9    Execute macro
  2022. prevpos        ^K -
  2023. prevw        ^K P        Window above
  2024. prevw        ^K ^P
  2025. prevw        ^K p
  2026. prevword    ^Z        Previous word
  2027. record        ^K [        Record macro
  2028. redo        ^^        Redo changes
  2029. retype        ^R        Refresh screen
  2030. rindent        ^K .        Indent to right
  2031. rtarw        RIGHT        Go right
  2032. rtarw        ^F
  2033. rtarw        ^[ O C
  2034. rtarw        ^[ [ C
  2035. rtnpw        ^M        Return
  2036. save        ^K D        Save file
  2037. save        ^K S
  2038. save        ^K ^D
  2039. save        ^K ^S
  2040. save        ^K d
  2041. save        ^K s
  2042. shell        ^K Z        Shell escape/Suspend
  2043. shell        ^K ^Z
  2044. shell        ^K z
  2045. shrinkw        ^K T        Shrink window
  2046. shrinkw        ^K ^T
  2047. shrinkw        ^K t
  2048. splitw        ^K O        Split window
  2049. splitw        ^K ^O
  2050. splitw        ^K o
  2051. stat        ^K SP        Show status
  2052. stop        ^K ]        Stop recording macro
  2053. tag        ^K ;
  2054. tomatch        ^G        Goto matching parenthasis
  2055. undo        ^_        Undo changes
  2056. uparw        UP        Go up
  2057. uparw        ^P
  2058. uparw        ^[ O A
  2059. uparw        ^[ [ A
  2060. X
  2061. :fprompt
  2062. X
  2063. complete    ^I        Complete file name
  2064. quote8        ^\        Quote Meta chars
  2065. type        SP TO ~        Typeable characters
  2066. quote        `        Quote Ctrl chars
  2067. X
  2068. abortpw        ^C        Abort window
  2069. arg        ^[ 1 TO 9    Repeat count
  2070. backs        ^?        Backspace
  2071. backs        ^H
  2072. backw        ^O        Backspace word
  2073. blkcpy        ^K C        Copy marked block
  2074. blkcpy        ^K ^C
  2075. blkcpy        ^K c
  2076. blkdel        ^K Y        Delete marked block
  2077. blkdel        ^K ^Y
  2078. blkdel        ^K y
  2079. blkmove        ^K M        Move marked block
  2080. blkmove        ^K ^M
  2081. blkmove        ^K m
  2082. blksave        ^K W        Save marked block
  2083. blksave        ^K ^W
  2084. blksave        ^K w
  2085. bof        ^K U        Goto beginning of file
  2086. bof        ^K ^U
  2087. bof        ^K u
  2088. bol        HOME        Goto beginning of line
  2089. bol        ^A
  2090. center        ^K A        Center line
  2091. center        ^K ^A
  2092. center        ^K a
  2093. delch        DEL        Delete character
  2094. delch        ^D
  2095. deleol        ^J        Delete to end of line
  2096. dellin        ^Y        Delete entire line
  2097. delw        ^W        Delete word to right
  2098. dnarw        DOWN        Go down
  2099. dnarw        ^N
  2100. dnarw        ^[ O B
  2101. dnarw        ^[ [ B
  2102. edit        ^K E        Edit a file
  2103. edit        ^K ^E
  2104. edit        ^K e
  2105. eof        ^K V        Go to end of file
  2106. eof        ^K ^V
  2107. eof        ^K v
  2108. eol        END        Go to end of line
  2109. eol        ^E
  2110. explode        ^K I        Show one window / Show all windows
  2111. explode        ^K ^I
  2112. explode        ^K i
  2113. exsave        ^K X        Save and exit
  2114. exsave        ^K ^X
  2115. exsave        ^K x
  2116. ffirst        ^K F        Find first
  2117. ffirst        ^K ^F
  2118. ffirst        ^K f
  2119. filt        ^K /        Filter block
  2120. fnext        ^L        Find next
  2121. format        ^K J        Format paragraph
  2122. format        ^K ^J
  2123. format        ^K j
  2124. groww        ^K G        Grow window
  2125. groww        ^K ^G
  2126. groww        ^K g
  2127. help        ^K H        Help
  2128. help        ^K ^H
  2129. help        ^K h
  2130. iasis        ^T H        Characters 160-254 shown as-is
  2131. iasis        ^T ^H
  2132. iasis        ^T h
  2133. iforce        ^T F        Force final newline
  2134. iforce        ^T ^F
  2135. iforce        ^T f
  2136. iindent        ^T A        Autoindent on/off
  2137. iindent        ^T ^A
  2138. iindent        ^T a
  2139. iindentc    ^T k
  2140. iindentc    ^T K
  2141. iindentc    ^T ^K
  2142. ilmargin    ^T L        Set left margin
  2143. ilmargin    ^T ^L
  2144. ilmargin    ^T l
  2145. imid        ^T M        Center cursor when scrolling
  2146. imid        ^T ^M
  2147. imid        ^T m
  2148. insc        INS        Insert a space
  2149. insc        ^@
  2150. insf        ^K R        Insert a file
  2151. insf        ^K ^R
  2152. insf        ^K r
  2153. ipgamnt        ^T P        No. lines to keep for PGUP/PGDN
  2154. ipgamnt        ^T ^P
  2155. ipgamnt        ^T p
  2156. irmargin    ^T R        Set right margin
  2157. irmargin    ^T ^R
  2158. irmargin    ^T r
  2159. istacol        ^T C        Column number on status line
  2160. istacol        ^T ^C
  2161. istacol        ^T c
  2162. istarow        ^T N        Row number on status line
  2163. istarow        ^T ^N
  2164. istarow        ^T n
  2165. iistep        ^T i
  2166. iistep        ^T I
  2167. iistep        ^T ^I
  2168. isquare        ^T x
  2169. isquare        ^T X
  2170. isquare        ^T ^X
  2171. itab        ^T D
  2172. itab        ^T ^D
  2173. itab        ^T d
  2174. itype        ^T T        Insert/Overtype
  2175. itype        ^T ^T
  2176. itype        ^T t
  2177. iwrap        ^T W        Word wrap
  2178. iwrap        ^T ^W
  2179. iwrap        ^T w
  2180. lindent        ^K ,        Indent to left
  2181. line        ^K L        Goto line no.
  2182. line        ^K ^L
  2183. line        ^K l
  2184. ltarw        LEFT        Go left
  2185. ltarw        ^B
  2186. ltarw        ^[ O D
  2187. ltarw        ^[ [ D
  2188. markb        ^K B        Set beginning of marked block
  2189. markb        ^K ^B
  2190. markb        ^K b
  2191. markk        ^K K        Set end of marked block
  2192. markk        ^K ^K
  2193. markk        ^K k
  2194. nextpos        ^K =        Goto next position in position history
  2195. nextw        ^K N        Goto window below
  2196. nextw        ^K ^N
  2197. nextw        ^K n
  2198. nextword    ^X        Goto next word
  2199. open        ^]        Split line
  2200. pgdn        PGDN        Screen down
  2201. pgdn        ^V
  2202. pgup        PGUP        Screen up
  2203. pgup        ^U
  2204. play        ^K 0 TO 9    Execute macro
  2205. prevpos        ^K -
  2206. prevw        ^K P        Window above
  2207. prevw        ^K ^P
  2208. prevw        ^K p
  2209. prevword    ^Z        Previous word
  2210. record        ^K [        Record macro
  2211. redo        ^^        Redo changes
  2212. retype        ^R        Refresh screen
  2213. rindent        ^K .        Indent to right
  2214. rtarw        RIGHT        Go right
  2215. rtarw        ^F
  2216. rtarw        ^[ O C
  2217. rtarw        ^[ [ C
  2218. rtnpw        ^M        Return
  2219. save        ^K D        Save file
  2220. save        ^K S
  2221. save        ^K ^D
  2222. save        ^K ^S
  2223. save        ^K d
  2224. save        ^K s
  2225. shell        ^K Z        Shell escape/Suspend
  2226. shell        ^K ^Z
  2227. shell        ^K z
  2228. shrinkw        ^K T        Shrink window
  2229. shrinkw        ^K ^T
  2230. shrinkw        ^K t
  2231. splitw        ^K O        Split window
  2232. splitw        ^K ^O
  2233. splitw        ^K o
  2234. stat        ^K SP        Show status
  2235. stop        ^K ]        Stop recording macro
  2236. tag        ^K ;
  2237. tomatch        ^G        Goto matching parenthasis
  2238. undo        ^_        Undo changes
  2239. uparw        UP        Go up
  2240. uparw        ^P
  2241. uparw        ^[ O A
  2242. uparw        ^[ [ A
  2243. X
  2244. :tab
  2245. X
  2246. aborttab    ^C
  2247. arg        ^[ 1 TO 9
  2248. backstab    ^?
  2249. backstab    ^H
  2250. boftab        ^K U
  2251. boftab        ^K ^U
  2252. boftab        ^K u
  2253. boltab        HOME
  2254. boltab        ^A
  2255. dnarwtab    DOWN
  2256. dnarwtab    ^N
  2257. dnarwtab    ^[ [ B
  2258. dnarwtab    ^[ O B
  2259. eoftab        ^K V
  2260. eoftab        ^K ^V
  2261. eoftab        ^K v
  2262. eoltab        END
  2263. eoltab        ^E
  2264. explode        ^K I
  2265. explode        ^K ^I
  2266. explode        ^K i
  2267. help        ^K H
  2268. help        ^K ^H
  2269. help        ^K h
  2270. ltarwtab    LEFT
  2271. ltarwtab    ^B
  2272. ltarwtab    ^[ [ D
  2273. ltarwtab    ^[ O D
  2274. nextw        ^K N
  2275. nextw        ^K ^N
  2276. nextw        ^K n
  2277. play        ^K 0 TO 9
  2278. prevw        ^K P
  2279. prevw        ^K ^P
  2280. prevw        ^K p
  2281. record        ^K [
  2282. retype        ^R
  2283. rtarwtab    RIGHT
  2284. rtarwtab    ^F
  2285. rtarwtab    ^[ [ C
  2286. rtarwtab    ^[ O C
  2287. rtntab        SP
  2288. rtntab        ^M
  2289. shell        ^K Z
  2290. shell        ^K ^Z
  2291. shell        ^K z
  2292. stop        ^K ]
  2293. uparwtab    UP
  2294. uparwtab    ^P
  2295. uparwtab    ^[ [ A
  2296. uparwtab    ^[ O A
  2297. X
  2298. :help
  2299. X
  2300. aborthelp    ^C
  2301. arg        ^[ 1 TO 9
  2302. bofhelp        ^K U
  2303. bofhelp        ^K ^U
  2304. bofhelp        ^K u
  2305. bolhelp        HOME
  2306. bolhelp        ^A
  2307. dnarwhelp    DOWN
  2308. dnarwhelp    ^N
  2309. dnarwhelp    ^[ [ B
  2310. dnarwhelp    ^[ O B
  2311. eofhelp        ^K V
  2312. eofhelp        ^K ^V
  2313. eofhelp        ^K v
  2314. eolhelp        END
  2315. eolhelp        ^E
  2316. explode        ^K I
  2317. explode        ^K ^I
  2318. explode        ^K i
  2319. ltarwhelp    LEFT
  2320. ltarwhelp    ^B
  2321. ltarwhelp    ^[ [ D
  2322. ltarwhelp    ^[ O D
  2323. nextw        ^K N
  2324. nextw        ^K ^N
  2325. nextw        ^K n
  2326. play        ^K 0 TO 9
  2327. prevw        ^K P
  2328. prevw        ^K ^P
  2329. prevw        ^K p
  2330. record        ^K [
  2331. retype        ^R
  2332. rtarwhelp    RIGHT
  2333. rtarwhelp    ^F
  2334. rtarwhelp    ^[ [ C
  2335. rtarwhelp    ^[ O C
  2336. rtnhelp        SP
  2337. rtnhelp        ^M
  2338. rtnhelp        ^K H
  2339. rtnhelp        ^K ^H
  2340. rtnhelp        ^K h
  2341. shell        ^K Z
  2342. shell        ^K ^Z
  2343. shell        ^K z
  2344. stop        ^K ]
  2345. uparwhelp    UP
  2346. uparwhelp    ^P
  2347. uparwhelp    ^[ [ A
  2348. uparwhelp    ^[ O A
  2349. SHAR_EOF
  2350. chmod 0600 .joerc ||
  2351. echo 'restore of .joerc failed'
  2352. Wc_c="`wc -c < '.joerc'`"
  2353. test 19130 -eq "$Wc_c" ||
  2354.     echo '.joerc: original size 19130, current size' "$Wc_c"
  2355. fi
  2356. exit 0
  2357.