home *** CD-ROM | disk | FTP | other *** search
- Path: wupost!decwrl!amdcad!pyramid!oliveb!olivea!samsung!crackers!m2c!wpi.WPI.EDU!rcarter
- From: rcarter@wpi.WPI.EDU (Randolph Carter (nee. Joseph H. Allen))
- Newsgroups: alt.sources
- Subject: J (Joe's Editor) - Part 1 of 3
- Message-ID: <1991Aug22.043241.4493@wpi.WPI.EDU>
- Date: 22 Aug 91 04:32:41 GMT
- Sender: rcarter@wpi.WPI.EDU (Randolph Carter (nee. Joseph H. Allen))
- Organization: Kadath Tours, Inc.
- Lines: 2011
-
-
- Concatenate the indicated parts of these 3 posts into a file called 'parts'
- Make a directory called 'j' and go into it
- Type sh ../parts to unpack the archive
-
- -- Cut here; take text between this line and the last 'cut' line
- # This is a shell archive. Remove anything before this line,
- # then unpack it by saving it in a file and typing "sh file".
- #
- # Wrapped by Joseph Allen <jallen@libserv1> on Thu Aug 22 00:17:52 1991
- #
- # This archive contains:
- # COPYING Makefile NEWS README
- # async.h asyncbsd.c asynchpux.c asyncxenix.c
- # blocks.c blocks.h cruddy.c j.1
- # j.c j.h keymapbsd keymapxenix
- #
-
- LANG=""; export LANG
- PATH=/bin:/usr/bin:$PATH; export PATH
-
- echo x - COPYING
- cat >COPYING <<'@EOF'
-
- GNU GENERAL PUBLIC LICENSE
- Version 1, February 1989
-
- Copyright (C) 1989 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The license agreements of most software companies try to keep users
- at the mercy of those companies. By contrast, our General Public
- License is intended to guarantee your freedom to share and change free
- software--to make sure the software is free for all its users. The
- General Public License applies to the Free Software Foundation's
- software and to any other program whose authors commit to using it.
- You can use it for your programs, too.
-
- When we speak of free software, we are referring to freedom, not
- price. Specifically, the General Public License is designed to make
- sure that you have the freedom to give away or sell copies of free
- software, that you receive source code or can get it if you want it,
- that you can change the software or use pieces of it in new free
- programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
- anyone to deny you these rights or to ask you to surrender the rights.
- These restrictions translate to certain responsibilities for you if you
- distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of a such a program, whether
- gratis or for a fee, you must give the recipients all the rights that
- you have. You must make sure that they, too, receive or can get the
- source code. And you must tell them their rights.
-
- We protect your rights with two steps: (1) copyright the software, and
- (2) offer you this license which gives you legal permission to copy,
- distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
- that everyone understands that there is no warranty for this free
- software. If the software is modified by someone else and passed on, we
- want its recipients to know that what they have is not the original, so
- that any problems introduced by others will not reflect on the original
- authors' reputations.
-
- The precise terms and conditions for copying, distribution and
- modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any program or other work which
- contains a notice placed by the copyright holder saying it may be
- distributed under the terms of this General Public License. The
- "Program", below, refers to any such program or work, and a "work based
- on the Program" means either the Program or any work containing the
- Program or a portion of it, either verbatim or with modifications. Each
- licensee is addressed as "you".
-
- 1. You may copy and distribute verbatim copies of the Program's source
- code as you receive it, in any medium, provided that you conspicuously and
- appropriately publish on each copy an appropriate copyright notice and
- disclaimer of warranty; keep intact all the notices that refer to this
- General Public License and to the absence of any warranty; and give any
- other recipients of the Program a copy of this General Public License
- along with the Program. You may charge a fee for the physical act of
- transferring a copy.
-
- 2. You may modify your copy or copies of the Program or any portion of
- it, and copy and distribute such modifications under the terms of Paragraph
- 1 above, provided that you also do the following:
-
- a) cause the modified files to carry prominent notices stating that
- you changed the files and the date of any change; and
-
- b) cause the whole of any work that you distribute or publish, that
- in whole or in part contains the Program or any part thereof, either
- with or without modifications, to be licensed at no charge to all
- third parties under the terms of this General Public License (except
- that you may choose to grant warranty protection to some or all
- third parties, at your option).
-
- c) If the modified program normally reads commands interactively when
- run, you must cause it, when started running for such interactive use
- in the simplest and most usual way, to print or display an
- announcement including an appropriate copyright notice and a notice
- that there is no warranty (or else, saying that you provide a
- warranty) and that users may redistribute the program under these
- conditions, and telling the user how to view a copy of this General
- Public License.
-
- d) You may charge a fee for the physical act of transferring a
- copy, and you may at your option offer warranty protection in
- exchange for a fee.
-
- Mere aggregation of another independent work with the Program (or its
- derivative) on a volume of a storage or distribution medium does not bring
- the other work under the scope of these terms.
-
- 3. You may copy and distribute the Program (or a portion or derivative of
- it, under Paragraph 2) in object code or executable form under the terms of
- Paragraphs 1 and 2 above provided that you also do one of the following:
-
- a) accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of
- Paragraphs 1 and 2 above; or,
-
- b) accompany it with a written offer, valid for at least three
- years, to give any third party free (except for a nominal charge
- for the cost of distribution) a complete machine-readable copy of the
- corresponding source code, to be distributed under the terms of
- Paragraphs 1 and 2 above; or,
-
- c) accompany it with the information you received as to where the
- corresponding source code may be obtained. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form alone.)
-
- Source code for a work means the preferred form of the work for making
- modifications to it. For an executable file, complete source code means
- all the source code for all modules it contains; but, as a special
- exception, it need not include source code for modules which are standard
- libraries that accompany the operating system on which the executable
- file runs, or for standard header files or definitions files that
- accompany that operating system.
-
- 4. You may not copy, modify, sublicense, distribute or transfer the
- Program except as expressly provided under this General Public License.
- Any attempt otherwise to copy, modify, sublicense, distribute or transfer
- the Program is void, and will automatically terminate your rights to use
- the Program under this License. However, parties who have received
- copies, or rights to use copies, from you under this General Public
- License will not have their licenses terminated so long as such parties
- remain in full compliance.
-
- 5. By copying, distributing or modifying the Program (or any work based
- on the Program) you indicate your acceptance of this license to do so,
- and all its terms and conditions.
-
- 6. Each time you redistribute the Program (or any work based on the
- Program), the recipient automatically receives a license from the original
- licensor to copy, distribute or modify the Program subject to these
- terms and conditions. You may not impose any further restrictions on the
- recipients' exercise of the rights granted herein.
-
- 7. The Free Software Foundation may publish revised and/or new versions
- of the General Public License from time to time. Such new versions will
- be similar in spirit to the present version, but may differ in detail to
- address new problems or concerns.
-
- Each version is given a distinguishing version number. If the Program
- specifies a version number of the license which applies to it and "any
- later version", you have the option of following the terms and conditions
- either of that version or of any later version published by the Free
- Software Foundation. If the Program does not specify a version number of
- the license, you may choose any version ever published by the Free Software
- Foundation.
-
- 8. If you wish to incorporate parts of the Program into other free
- programs whose distribution conditions are different, write to the author
- to ask for permission. For software which is copyrighted by the Free
- Software Foundation, write to the Free Software Foundation; we sometimes
- make exceptions for this. Our decision will be guided by the two goals
- of preserving the free status of all derivatives of our free software and
- of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
- FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
- OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
- PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
- OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
- TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
- PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
- REPAIR OR CORRECTION.
-
- 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
- WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
- REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
- INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
- OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
- TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
- YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
- PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- Appendix: How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
- possible use to humanity, the best way to achieve this is to make it
- free software which everyone can redistribute and change under these
- terms.
-
- To do so, attach the following notices to the program. It is safest to
- attach them to the start of each source file to most effectively convey
- the exclusion of warranty; and each file should have at least the
- "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) 19yy <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- Also add information on how to contact you by electronic and paper mail.
-
- If the program is interactive, make it output a short notice like this
- when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) 19xx name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
- The hypothetical commands `show w' and `show c' should show the
- appropriate parts of the General Public License. Of course, the
- commands you use may be called something other than `show w' and `show
- c'; they could even be mouse-clicks or menu items--whatever suits your
- program.
-
- You should also get your employer (if you work as a programmer) or your
- school, if any, to sign a "copyright disclaimer" for the program, if
- necessary. Here a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- program `Gnomovision' (a program to direct compilers to make passes
- at assemblers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
- That's all there is to it!
- @EOF
-
- chmod 600 COPYING
-
- echo x - Makefile
- cat >Makefile <<'@EOF'
- # Makefile for Joe's Editor
-
- # Directory to install j into
- WHERE = /usr/bin
-
- # Use these two for 'cc'
- CC = cc
- CFLAGS = -DKEYDEF=\"$(WHERE)/keymap.j\" -O
-
- # Use these two for 'gcc'
- #CC = gcc
- #CFLAGS = -DKEYDEF=\"$(WHERE)/keymap.j\" -traditional -O
-
- foo:
- @echo Type make followed by one of the following
- @echo
- @echo bsd hpux xenix cruddy install clean
-
- bsd: j.o asyncbsd.o blocks.o
- $(CC) $(CFLAGS) j.o asyncbsd.o blocks.o -ltermcap -o j
- cp keymapbsd keymap.j
-
- xenix: j.o asyncxenix.o blocks.o
- $(CC) $(CFLAGS) j.o asyncxenix.o blocks.o -lx -ltermcap -o j
- cp keymapxenix keymap.j
-
- hpux: j.o asynchpux.o blocks.o
- $(CC) $(CFLAGS) j.o asynchpux.o blocks.o -ltermcap -o j
- cp keymapbsd keymap.j
-
- cruddy: j.o cruddy.o blocks.o
- $(CC) $(CFLAGS) j.o cruddy.o blocks.o -o j
- cp keymapbsd keymap.j
-
- install:
- strip j
- mv j $(WHERE)
- mv keymap.j $(WHERE)
- chmod a+x $(WHERE)/j
- chmod a+r $(WHERE)/keymap.j
-
- clean:
- rm asyncbsd.o asyncxenix.o asynchpux.o cruddy.o blocks.o j.o keymap.j
-
- asyncbsd.o cruddy.o asyncxenix.o asynxhpux.o : async.h
-
- blocks.o : blocks.h
-
- j.o : blocks.h j.h async.h
- @EOF
-
- chmod 600 Makefile
-
- echo x - NEWS
- cat >NEWS <<'@EOF'
-
- Release 0.0.0 of 'J' (Joe's Editor): This release supersedes all previous
- versions which lack a release number. Note that this program was previously
- called 'E' but the name has been changed ('E' turns out to be one of the
- synonyms for 'vi'). See below for list of bug fixes and new features. The
- 2 following posts contain the source.
-
- Introduction
-
- 'J' is a small screen editor which was designed to be easy to use for
- novice users but also to be powerful and complete enough for experienced
- users. Several elements of its design are unique innovations. Here is a
- copy of the on-line help text to give you a feel for this editor:
-
- GO TO DELETE MISC BLOCK FIND QUOTE WINDOW
- ^B left ^F right ^D single ^T mode ^KB mark ^KF text ` Ctrl ^KO split
- ^Z word ^X word ^W >word ^R retype ^KK end ^L next ^\ bit-7 ^KI 1 / all
- ^A edge ^E edge ^O word< ^KA center ^KC copy ^KL line FILE ^KP up
- ^P up ^N down ^J >line ^KJ format ^KM move EXIT ^KD save ^KN down
- ^U page ^V page ^Y line ^KZ shell ^KW save ^KX save ^KR read ^KG grow
- ^KU top ^KV end ^K- undo ^K, indnt< ^KY kill ^C abort/ ^KT shrink
- ^G matching ([<{` ^K+ redo ^K. indnt> close window ^KE get file
-
- Other relevent features:
-
- * Extremely small - the XENIX version is only 58K
-
- * Help text can be left on while editing
-
- * Key layout designed to eliminate headaches: ^Q and ^S are not used,
- both ^H and DEL are backspace. Also, each user may customize
- his key layout by modifying a simple initialization file
-
- * Versions for BSD, HPUX and XENIX 386 are included. A simple tty
- driver is also provided to ease porting to other systems
-
- * Currently only VT100/ANSI terminals are supported. If the terminal
- has scrolling regions, J uses them. Has well-tuned interruptable
- screen update algorithm
-
- * Has: autoindent, word-wrap, overtype/insert, picture mode (right-
- arrow makes space past ends of lines), right margin (for paragraph
- formatting and center), and magic tabs (the column number of text
- after tab stops is preserved when inserting and deleting)
-
- * The cursor column doesn't 'jump' when you move between long and
- short lines. Instead the cursor column only jumps when you try to
- edit in an invalid place or if picture mode is set, the invalid
- place is made real by space filling
-
- * Editor modes can be set depending on file extension
-
- * No line length restrictions. Binary files can be edited without
- difficulty
-
- * Long lines are truncated, not wrapped (I.E., the screen scrolls to
- the right to get to the truncated parts)
-
- FIXES FOR THIS VERSION
-
- * Shell escape lock-ups are fixed
-
- * Paragraph reformat glitch is fixed
-
- * Cursor update screwynesses fixed for picture mode
-
- * Goto next word/Goto previous word/Delete word left and Delete word
- right were made more consistant
-
- NEW FEATURES FOR THIS VERSION
-
- * ~ can be used at file name prompts to expand user home directories
-
- * J now has undelete and redelete (you can go backwards and forewards
- through the delete buffer to select which text you want to undelete)
-
- * J now has indent functions. A marked block can be indented more
- or less. If you use an indent function outside a marked block, the
- lines with the same or greater indent level surrounding the cursor
- are marked
-
- * Right margin was added for paragraph format and center line
-
- * Goto matching parenthasis (or [ { ` < )
-
- * ` was made the quote control character key because ^_ is not easy
- generate on many keyboard. `` gets `
-
- * tty drivers were rewritten. This made the screen update faster
- (now the screen update is instantaneous on 20MHz 386s). Screen
- update preempting also works better
-
- THE PLAN
-
- Version 1.0.0 will be a complete rewrite. It should be done sometime
- before january. These are my goals for it:
-
- * Block oriented software virtual memory support (for less thrashing
- and elimination of file size limits caused by the system's process
- size limit)
-
- * MS-DOS support
-
- * X windows support
-
- * Better integration with UNIX: J will be able to process text
- through pipes (like vi), will have standard unix regular expressions,
- and will be usable as a 'more' program.
-
- * Will be terminal independant and use termcap and terminfo
-
- * Will have a ASCII/HEX dump display mode
-
- * Will have complete program developement support (save&make, next
- error/previous error, tags file support)
-
- * Will have a much more powerful scrolling algorithm. I have a
- methode which is simpler and faster than even GNU-EMACS' Gosling
- algorithm
-
- * All of this will require no changes to the basic keyboard layout-
- maybe one more added line of help text for new things
-
- * It will probably have keyboard macros but it won't have much of
- an extension language. Maybe in version 2.0.0
-
- * I expect all of this not to add more than 30 or 40% to the size
-
- Joseph H. Allen
- 28 Dale Lane
- Smithtown, N.Y. 11787
-
- /* rcarter@wpi.wpi.edu */ /* Amazing */ /* Joseph H. Allen */
- int a[1817];main(z,p,q,r){for(p=80;q+p-80;p-=2*a[p])for(z=9;z--;)q=3&(r=time(0)
- +r*57)/7,q=q?q-1?q-2?1-p%79?-1:0:p%79-77?1:0:p<1659?79:0:p>158?-79:0,q?!a[p+q*2
- ]?a[p+=a[p+=q]=q]=q:0:0;for(;q++-1817;)printf(q%79?"%c":"%c\n"," #"[!a[q-1]]);}
- @EOF
-
- chmod 600 NEWS
-
- echo x - README
- cat >README <<'@EOF'
- If you don't know what this is, read the NEWS file.
-
- To compile:
-
- (1) Determine where you want to install the editor program and the
- system default keymap file. Put this path in the Makefile. If
- you're a mere user, don't worry about this. Instead, place a copy
- of the 'keymap.j' file (created after you make) in your home
- directory.
-
- (2) type 'make xenix' for xenix systems, 'make hpux' for hpux systems
- or 'make bsd' for BSD systems. If none of these work, type
- 'make cruddy' to make a version with an inferior terminal driver.
-
- (3) To install it in the system, log in as superuser and do
- 'make install'
- @EOF
-
- chmod 600 README
-
- echo x - async.h
- cat >async.h <<'@EOF'
- /* Terminal interface header file
- Copyright (C) 1991 Joseph H. Allen
-
- This file is part of J (Joe's Editor)
-
- J is free software; you can redistribute it and/or modify it under the terms
- of the GNU General Public License as published by the Free Software
- Foundation; either version 1, or (at your option) any later version.
-
- J is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNU Emacs; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
- aopen(); /* Set terminal to raw (character at a time) mode */
- aclose(); /* Restore terminal to cooked (line at a time) mode */
- aflush(); /* Flush the output */
- anext(); /* Get next key */
-
- extern int have; /* Set if there is typeahead */
-
- /* All of the above functions do a fflush(stdout) before doing anything else */
-
- eputs(); /* Write string to terminal */
- eputc(); /* Write character to terminal */
-
- shell(); /* Shell escape */
- tsignal(); /* E's signal handler. This function saves the current
- edit file in .cut.e and then exists some signals
- might be set up to call this */
-
- termtype(); /* Determine the following terminal parameters */
-
- extern int width; /* Screen width */
- extern int height; /* Screen height */
- extern int scroll; /* Set=use scrolling regions, Clr=don't use them */
-
- /* If termtype does nothing, these value defualt to: width=80, height=24,
- scroll=1 (true).
-
- Note that the only terminal type supported is ANSI/VT100
- */
-
-
- /* For Best operation:
- *
- * acheck returns true if the user typed ahead
- *
- * acheck should sleep (nap) for number*(10000/baud) milliseconds
- * immediately after its fflush(stdout) call. Number is
- * the number of characters the call to fflush(stdout)
- * wrote.
- *
- * aopen & aclose should not loose any typeahead when they change modes
- *
- * For example: see the async*.c files
- */
-
- /* For O.K. operation:
- *
- * acheck always returns 0 (false). If acheck is going to do this, don't
- * even have it fflush(stdout).
- *
- * aopen & aclose do system("/bin/stty ...."); so they invariably loose
- * any typeahead
- *
- * For example: see the cruddy.c file
- */
- @EOF
-
- chmod 600 async.h
-
- echo x - asyncbsd.c
- cat >asyncbsd.c <<'@EOF'
- /* Terminal interface for BSD
- Copyright (C) 1991 Joseph H. Allen
-
- This file is part of J (Joe's Editor)
-
- J is free software; you can redistribute it and/or modify it under the terms
- of the GNU General Public License as published by the Free Software
- Foundation; either version 1, or (at your option) any later version.
-
- J is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNU Emacs; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
- #include <sgtty.h>
- #include <fcntl.h>
- #include <stdio.h>
- #include <signal.h>
- #include <sys/time.h>
- #include "async.h"
-
- #define HZ 10 /* Clock ticks/second */
-
- #define DIVISOR 11000000 /* The baud rate divided into this should
- give the number of microseconds per
- character. It should attempt to
- reflect the true throughput, which is
- usually slower than the best possible
- for a given baud rate */
-
- #define TIMES 3 /* Times per second that we check for
- typeahead */
-
- static struct sgttyb oarg;
- static struct tchars otarg;
- static struct ltchars oltarg;
-
- static unsigned char *obuf=0;
- static unsigned obufp=0;
- static unsigned obufsiz;
- static unsigned long ccc;
-
- static unsigned speeds[]=
- {
- B50,50,B75,75,B110,110,B134,134,B150,150,B200,200,B300,300,B600,600,B1200,1200,
- B1800,1800,B2400,2400,B4800,4800,B9600,9600,EXTA,19200,EXTB,38400
- };
-
- aopen()
- {
- int x;
- struct sgttyb arg;
- struct tchars targ;
- struct ltchars ltarg;
- fflush(stdout);
- signal(SIGHUP,tsignal);
- signal(SIGINT,SIG_IGN);
- signal(SIGQUIT,SIG_IGN);
- signal(SIGPIPE,SIG_IGN);
- signal(SIGALRM,SIG_IGN);
- signal(SIGTERM,tsignal);
- signal(SIGUSR1,SIG_IGN);
- signal(SIGUSR2,SIG_IGN);
- ioctl(fileno(stdin),TIOCGETP,&arg);
- ioctl(fileno(stdin),TIOCGETC,&targ);
- ioctl(fileno(stdin),TIOCGLTC,<arg);
- oarg=arg; otarg=targ; oltarg=ltarg;
- arg.sg_flags=( (arg.sg_flags&~(ECHO|CRMOD) ) | CBREAK) ;
- targ.t_intrc= -1;
- targ.t_quitc= -1;
- targ.t_eofc= -1;
- targ.t_brkc= -1;
- ltarg.t_suspc= -1;
- ltarg.t_dsuspc= -1;
- ltarg.t_rprntc= -1;
- ltarg.t_flushc= -1;
- ltarg.t_werasc= -1;
- ltarg.t_lnextc= -1;
- ioctl(fileno(stdin),TIOCSETN,&arg);
- ioctl(fileno(stdin),TIOCSETC,&targ);
- ioctl(fileno(stdin),TIOCSLTC,<arg);
- ccc=0;
- for(x=0;x!=30;x+=2)
- if(arg.sg_ospeed==speeds[x])
- {
- ccc=DIVISOR/speeds[x+1];
- break;
- }
- if(!obuf)
- {
- if(!(TIMES*ccc)) obufsiz=4096;
- else
- {
- obufsiz=1000000/(TIMES*ccc);
- if(obufsiz>4096) obufsiz=4096;
- }
- if(!obufsiz) obufsiz=1;
- obuf=(unsigned char *)malloc(obufsiz);
- }
- }
-
- aclose()
- {
- aflush();
- ioctl(fileno(stdin),TIOCSETN,&oarg);
- ioctl(fileno(stdin),TIOCSETC,&otarg);
- ioctl(fileno(stdin),TIOCSLTC,&oltarg);
- signal(SIGHUP,SIG_DFL);
- signal(SIGINT,SIG_DFL);
- signal(SIGQUIT,SIG_DFL);
- signal(SIGPIPE,SIG_DFL);
- signal(SIGALRM,SIG_DFL);
- signal(SIGTERM,SIG_DFL);
- signal(SIGUSR1,SIG_DFL);
- signal(SIGUSR2,SIG_DFL);
- }
-
- int have=0;
- static unsigned char havec;
- static int yep;
-
- static dosig()
- {
- yep=1;
- }
-
- aflush()
- {
- if(obufp)
- {
- struct itimerval a,b;
- unsigned long usec=obufp*ccc;
- if(usec>=500000/HZ)
- {
- a.it_value.tv_sec=usec/1000000;
- a.it_value.tv_usec=usec%1000000;
- a.it_interval.tv_usec=0;
- a.it_interval.tv_sec=0;
- signal(SIGALRM,dosig);
- yep=0;
- sigsetmask(sigmask(SIGALRM));
- setitimer(ITIMER_REAL,&a,&b);
- write(fileno(stdout),obuf,obufp);
- while(!yep) sigpause(0);
- signal(SIGALRM,SIG_DFL);
- }
- else write(fileno(stdout),obuf,obufp);
- obufp=0;
- }
- if(!have)
- {
- fcntl(fileno(stdin),F_SETFL,FNDELAY);
- if(read(fileno(stdin),&havec,1)==1) have=1;
- fcntl(fileno(stdin),F_SETFL,0);
- }
- }
-
- anext()
- {
- aflush();
- if(have) have=0;
- else if(read(fileno(stdin),&havec,1)<1) tsignal();
- return havec;
- }
-
- eputc(c)
- unsigned char c;
- {
- obuf[obufp++]=c;
- if(obufp==obufsiz) aflush();
- }
-
- eputs(s)
- char *s;
- {
- while(*s)
- {
- obuf[obufp++]= *(s++);
- if(obufp==obufsiz) aflush();
- }
- }
-
- termtype()
- {
- unsigned char entry[1024];
- unsigned char area[1024];
- unsigned char *foo=area;
- unsigned char *x=(unsigned char *)getenv("TERM");
- if(!x) return;
- if(tgetent(entry,x)!=1) return;
- height=tgetnum("li");
- if(height<2) height=24;
- width=tgetnum("co");
- if(width<2) width=80;
- if(!tgetstr("cs",&foo)) scroll=0;
- }
-
- shell(s)
- char *s;
- {
- aclose();
- if(fork()) wait(0);
- else
- {
- execl(s,s,0);
- _exit(0);
- }
- aopen();
- }
- @EOF
-
- chmod 600 asyncbsd.c
-
- echo x - asynchpux.c
- cat >asynchpux.c <<'@EOF'
- /* Terminal interface for HPUX
- Copyright (C) 1991 Joseph H. Allen
-
- This file is part of J (Joe's Editor)
-
- J is free software; you can redistribute it and/or modify it under the terms
- of the GNU General Public License as published by the Free Software
- Foundation; either version 1, or (at your option) any later version.
-
- J is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNU Emacs; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
- #include <stdio.h>
- #include <signal.h>
- #include <fcntl.h>
- #include <time.h>
- #include <sys/param.h>
- #include <termio.h>
- #include "async.h"
-
- #define DIVISOR 12000000
- #define TIMES 2
-
- static struct termio oldterm;
-
- static unsigned char *obuf=0;
- static unsigned obufp=0;
- static unsigned obufsiz;
- static unsigned long ccc;
-
- static unsigned speeds[]=
- {
- B50,50,B75,75,B110,110,B134,134,B150,150,B200,200,B300,300,B600,600,B1200,1200,
- B1800,1800,B2400,2400,B4800,4800,B9600,9600,EXTA,19200,EXTB,38400
- };
-
- aopen()
- {
- int x;
- struct termio newterm;
- fflush(stdout);
- signal(SIGHUP,tsignal);
- signal(SIGINT,SIG_IGN);
- signal(SIGQUIT,SIG_IGN);
- signal(SIGPIPE,SIG_IGN);
- signal(SIGALRM,SIG_IGN);
- signal(SIGTERM,tsignal);
- signal(SIGUSR1,SIG_IGN);
- signal(SIGUSR2,SIG_IGN);
- signal(SIGPWR,tsignal);
- ioctl(fileno(stdin),TCGETA,&oldterm);
- newterm=oldterm;
- newterm.c_lflag=0;
- newterm.c_iflag=IXON|IXOFF|IGNBRK;
- newterm.c_oflag=0;
- newterm.c_cc[VINTR]= -1;
- newterm.c_cc[VQUIT]= -1;
- newterm.c_cc[VMIN]=1;
- newterm.c_cc[VTIME]=0;
- ioctl(fileno(stdin),TCSETAW,&newterm);
- ccc=0;
- for(x=0;x!=30;x+=2)
- if((newterm.c_cflag&CBAUD)==speeds[x])
- {
- ccc=DIVISOR/speeds[x+1];
- break;
- }
- if(!obuf)
- {
- if(!(TIMES*ccc)) obufsiz=4096;
- else
- {
- obufsiz=1000000/(TIMES*ccc);
- if(obufsiz>4096) obufsiz=4096;
- }
- if(!obufsiz) obufsiz=1;
- obuf=(unsigned char *)malloc(obufsiz);
- }
- }
-
- aclose()
- {
- aflush();
- ioctl(fileno(stdin),TCSETAW,&oldterm);
- signal(SIGHUP,SIG_DFL);
- signal(SIGINT,SIG_DFL);
- signal(SIGQUIT,SIG_DFL);
- signal(SIGPIPE,SIG_DFL);
- signal(SIGALRM,SIG_DFL);
- signal(SIGTERM,SIG_DFL);
- signal(SIGUSR1,SIG_DFL);
- signal(SIGUSR2,SIG_DFL);
- signal(SIGPWR,SIG_DFL);
- }
-
- int have=0;
- static unsigned char havec;
- static int yep;
-
- static dosig()
- {
- yep=1;
- }
-
- aflush()
- {
- if(obufp)
- {
- struct itimerval a,b;
- unsigned long usec=obufp*ccc;
- if(usec>=500000/HZ)
- {
- a.it_value.tv_sec=usec/1000000;
- a.it_value.tv_usec=usec%1000000;
- a.it_interval.tv_usec=0;
- a.it_interval.tv_sec=0;
- signal(SIGALRM,dosig);
- yep=0;
- sigsetmask(sigmask(SIGALRM));
- setitimer(ITIMER_REAL,&a,&b);
- write(fileno(stdout),obuf,obufp);
- while(!yep) sigpause(0);
- signal(SIGALRM,SIG_DFL);
- }
- else write(fileno(stdout),obuf,obufp);
- obufp=0;
- }
- if(!have)
- {
- fcntl(fileno(stdin),F_SETFL,O_NDELAY);
- if(read(fileno(stdin),&havec,1)==1) have=1;
- fcntl(fileno(stdin),F_SETFL,0);
- }
- }
-
- anext()
- {
- aflush();
- if(have) have=0;
- else if(read(fileno(stdin),&havec,1)<1) tsignal();
- return havec;
- }
-
- eputc(c)
- unsigned char c;
- {
- obuf[obufp++]=c;
- if(obufp==obufsiz) aflush();
- }
-
- eputs(s)
- char *s;
- {
- while(*s)
- {
- obuf[obufp++]= *(s++);
- if(obufp==obufsiz) aflush();
- }
- }
-
- termtype()
- {
- unsigned char entry[1024];
- unsigned char area[1024];
- unsigned char *foo=area;
- unsigned char *x=(unsigned char *)getenv("TERM");
- if(!x) return;
- if(tgetent(entry,x)!=1) return;
- height=tgetnum("li");
- if(height<2) height=24;
- width=tgetnum("co");
- if(width<2) width=80;
- if(!tgetstr("cs",&foo)) scroll=0;
- }
-
- shell(s)
- char *s;
- {
- aclose();
- if(fork()) wait(0);
- else
- {
- execl(s,s,0);
- _exit(0);
- }
- aopen();
- }
- @EOF
-
- chmod 600 asynchpux.c
-
- echo x - asyncxenix.c
- cat >asyncxenix.c <<'@EOF'
- /* Terminal interface for XENIX
- Copyright (C) 1991 Joseph H. Allen
-
- This file is part of J (Joe's Editor)
-
- J is free software; you can redistribute it and/or modify it under the terms
- of the GNU General Public License as published by the Free Software
- Foundation; either version 1, or (at your option) any later version.
-
- J is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNU Emacs; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
- #include <stdio.h>
- #include <signal.h>
- #include <termio.h>
- #include "async.h"
-
- #define DIVISOR 12000
- #define TIMES 2
-
- static struct termio oldterm;
-
- static unsigned char *obuf=0;
- static unsigned obufp=0;
- static unsigned obufsiz;
- static unsigned long ccc;
-
- static unsigned speeds[]=
- {
- B50,50,B75,75,B110,110,B134,134,B150,150,B200,200,B300,300,B600,600,B1200,1200,
- B1800,1800,B2400,2400,B4800,4800,B9600,9600,EXTA,19200,EXTB,38400
- };
-
- aopen()
- {
- int x;
- struct termio newterm;
- fflush(stdout);
- signal(SIGHUP,tsignal);
- signal(SIGINT,SIG_IGN);
- signal(SIGQUIT,SIG_IGN);
- signal(SIGPIPE,SIG_IGN);
- signal(SIGALRM,SIG_IGN);
- signal(SIGTERM,tsignal);
- signal(SIGUSR1,SIG_IGN);
- signal(SIGUSR2,SIG_IGN);
- signal(SIGPWR,tsignal);
- ioctl(fileno(stdin),TCGETA,&oldterm);
- newterm=oldterm;
- newterm.c_lflag=0;
- newterm.c_iflag=IXON|IXOFF|IGNBRK;
- newterm.c_oflag=0;
- newterm.c_cc[VINTR]= -1;
- newterm.c_cc[VQUIT]= -1;
- newterm.c_cc[VMIN]=1;
- newterm.c_cc[VTIME]=0;
- ioctl(fileno(stdin),TCSETAW,&newterm);
- ccc=0;
- for(x=0;x!=30;x+=2)
- if((newterm.c_cflag&CBAUD)==speeds[x])
- {
- ccc=DIVISOR/speeds[x+1];
- break;
- }
- if(!obuf)
- {
- if(!(TIMES*ccc)) obufsiz=4096;
- else
- {
- obufsiz=1000/(TIMES*ccc);
- if(obufsiz>4096) obufsiz=4096;
- }
- if(!obufsiz) obufsiz=1;
- obuf=(unsigned char *)malloc(obufsiz);
- }
- }
-
- aclose()
- {
- aflush();
- ioctl(fileno(stdin),TCSETAW,&oldterm);
- signal(SIGHUP,SIG_DFL);
- signal(SIGINT,SIG_DFL);
- signal(SIGQUIT,SIG_DFL);
- signal(SIGPIPE,SIG_DFL);
- signal(SIGALRM,SIG_DFL);
- signal(SIGTERM,SIG_DFL);
- signal(SIGUSR1,SIG_DFL);
- signal(SIGUSR2,SIG_DFL);
- signal(SIGPWR,SIG_DFL);
- }
-
- int have=0;
-
- aflush()
- {
- if(obufp)
- {
- write(fileno(stdout),obuf,obufp);
- nap(obufp*ccc);
- obufp=0;
- }
- if(!have) if(rdchk(fileno(stdin))>0) have=1;
- }
-
- anext()
- {
- unsigned char c;
- aflush();
- if(read(fileno(stdin),&c,1)<1) tsignal();
- have=0;
- return c;
- }
-
- eputc(c)
- unsigned char c;
- {
- obuf[obufp++]=c;
- if(obufp==obufsiz) aflush();
- }
-
- eputs(s)
- char *s;
- {
- while(*s)
- {
- obuf[obufp++]= *(s++);
- if(obufp==obufsiz) aflush();
- }
- }
-
- termtype()
- {
- unsigned char entry[1024];
- unsigned char area[1024];
- unsigned char *foo=area;
- unsigned char *x=(unsigned char *)getenv("TERM");
- if(!x) return;
- if(tgetent(entry,x)!=1) return;
- height=tgetnum("li");
- if(height<2) height=24;
- width=tgetnum("co");
- if(width<2) width=2;
- if(!tgetstr("cs",&foo)) scroll=0;
- }
-
- shell(s)
- char *s;
- {
- aclose();
- if(fork()) wait(0);
- else
- {
- execl(s,s,0);
- _exit(0);
- }
- aopen();
- }
- @EOF
-
- chmod 600 asyncxenix.c
-
- echo x - blocks.c
- cat >blocks.c <<'@EOF'
- /* Various memory block functions
- Copyright (C) 1991 Joseph H. Allen
-
- This file is part of J (Joe's Editor)
-
- J is free software; you can redistribute it and/or modify it under the terms
- of the GNU General Public License as published by the Free Software
- Foundation; either version 1, or (at your option) any later version.
-
- J is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNU Emacs; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-
- #include "blocks.h"
-
- /* Set block to zero */
-
- unsigned char *bzero(bk,sz)
- unsigned char *bk;
- {
- unsigned char *b=bk-1;
- if(sz) do b[sz]=0; while(--sz);
- return bk;
- }
-
- /* Set block to unsigned character */
-
- unsigned char *bset(bk,sz,c)
- unsigned char *bk;
- unsigned char c;
- {
- unsigned char *b=bk-1;
- if(sz) do b[sz]=c; while(--sz);
- return bk;
- }
-
- /* Move a possibly overlapping block of memory without loosing any data */
-
- unsigned char *bmove(dst,src,sz)
- unsigned char *dst;
- unsigned char *src;
- {
- if(src==dst || !sz) return dst;
- if(src>dst)
- {
- unsigned x=0;
- do dst[x]=src[x]; while(++x, --sz);
- }
- else
- {
- unsigned char *d=dst-1;
- --src;
- do d[sz]=src[sz]; while(--sz);
- }
- return dst;
- }
-
- /* Move a block in the forward direction */
-
- unsigned char *bfwrd(dst,src,sz)
- unsigned char *dst;
- unsigned char *src;
- {
- if(src!=dst && sz)
- {
- unsigned x=0;
- do dst[x]=src[x]; while(++x,--sz);
- }
- return dst;
- }
-
- /* Move a block in the backward direction */
-
- unsigned char *bbkwd(dst,src,sz)
- unsigned char *dst;
- unsigned char *src;
- {
- unsigned char *s=src-1, *d=dst-1;
- if(s!=d && sz) do d[sz]=s[sz]; while(--sz);
- return dst;
- }
-
- unsigned umin(a,b)
- unsigned a,b;
- {
- return (a>b)?b:a;
- }
-
- unsigned umax(a,b)
- unsigned a,b;
- {
- return (a>b)?a:b;
- }
-
- int min(a,b)
- {
- return (a>b)?b:a;
- }
-
- int max(a,b)
- {
- return (a>b)?a:b;
- }
-
- /* Compare blocks for equality */
-
- int beq(dst,src,sz)
- unsigned char *dst;
- unsigned char *src;
- {
- unsigned char *d=dst-1, *s=src-1;
- if(!sz) return 1;
- do
- if(d[sz]!=s[sz]) return 0;
- while(--sz);
- return 1;
- }
-
- /* Compare blocks for equality case insensitive */
-
- int bieq(dst,src,sz)
- unsigned char *dst;
- unsigned char *src;
- {
- unsigned char *d=dst, *s=src; int cnt=sz;
- if(!cnt) return 1;
- do
- if(*s>='a' && *s<='z')
- {
- if(*d>='a' && *d<='z') { if(*(d++)!=*(s++)) return 0; }
- else if(*(d++)!=(0x5f&*(s++))) return 0;
- }
- else if(*d>='a' && *d<='z')
- {
- if(*s>='a' && *s<='z') { if(*(d++)!=*(s++)) return 0; }
- else if(*(s++)!=(0x5f&*(d++))) return 0;
- }
- else if(*(d++)!=*(s++)) return 0;
- while(--cnt);
- return 1;
- }
-
- unsigned char *bchr(bk,sz,c)
- unsigned char *bk;
- unsigned char c;
- {
- unsigned char *s=bk;
- int cnt=sz;
- if(cnt)
- do if(*s==c) return s;
- while(++s, --cnt);
- return 0;
- }
-
- unsigned char *brchr(bk,sz,c)
- unsigned char *bk, c;
- {
- unsigned char *s=bk+sz;
- int cnt=sz;
- if(cnt)
- do if(*(--s)==c) return s;
- while(--cnt);
- return 0;
- }
- @EOF
-
- chmod 600 blocks.c
-
- echo x - blocks.h
- cat >blocks.h <<'@EOF'
- /* Memory block functions header file
- Copyright (C) 1991 Joseph H. Allen
-
- This file is part of J (Joe's Editor)
-
- J is free software; you can redistribute it and/or modify it under the terms
- of the GNU General Public License as published by the Free Software
- Foundation; either version 1, or (at your option) any later version.
-
- J is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNU Emacs; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
- unsigned char *bzero();
- unsigned char *bset();
- unsigned char *bmove();
- unsigned char *bfwrd();
- unsigned char *bbkwd();
- unsigned umin();
- unsigned umax();
- int min();
- int max();
- int beq();
- int bieq();
- unsigned char *bchr();
- unsigned char *brchr();
- @EOF
-
- chmod 600 blocks.h
-
- echo x - cruddy.c
- cat >cruddy.c <<'@EOF'
- /* Cruddy terminal interface - should be very portable though
- Copyright (C) 1991 Joseph H. Allen
-
- This file is part of J (Joe's Editor)
-
- J is free software; you can redistribute it and/or modify it under the terms
- of the GNU General Public License as published by the Free Software
- Foundation; either version 1, or (at your option) any later version.
-
- J is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNU Emacs; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-
- #include <stdio.h>
- #include <signal.h>
- #include "async.h"
-
- int have=0;
-
- eputs(s)
- char *s;
- {
- fputs(s,stdout);
- }
-
- eputc(c)
- {
- putchar(c);
- }
-
- aopen()
- {
- fflush(stdout);
- system("/bin/stty raw -echo ixon ixoff");
- signal(SIGHUP,tsignal);
- signal(SIGINT,SIG_IGN);
- signal(SIGQUIT,SIG_IGN);
- signal(SIGPIPE,SIG_IGN);
- signal(SIGALRM,SIG_IGN);
- signal(SIGTERM,tsignal);
- signal(SIGUSR1,SIG_IGN);
- signal(SIGUSR2,SIG_IGN);
- }
-
- aclose()
- {
- fflush(stdout);
- signal(SIGHUP,SIG_DFL);
- signal(SIGINT,SIG_DFL);
- signal(SIGQUIT,SIG_DFL);
- signal(SIGPIPE,SIG_DFL);
- signal(SIGALRM,SIG_DFL);
- signal(SIGTERM,SIG_DFL);
- signal(SIGUSR1,SIG_DFL);
- signal(SIGUSR2,SIG_DFL);
- system("/bin/stty cooked echo");
- }
-
- aflush()
- {
- }
-
- anext()
- {
- unsigned char c;
- fflush(stdout);
- while(read(fileno(stdin),&c,1)!=1);
- return c;
- }
-
- termtype()
- {
- /*
- char entry[1024];
- char area[1024];
- char *foo=area;
- char *x=(char *)getenv("TERM");
- if(!x) return;
- if(tgetent(entry,x)<1) return;
- height=tgetnum("li");
- if(height<1) height=24;
- width=tgetnum("co");
- if(width<2) width=80;
- if(!tgetstr("cs",&foo)) scroll=0;
- */
- }
-
- shell(s)
- char *s;
- {
- aclose();
- if(fork()) wait(0);
- else
- {
- execl(s,s,0);
- _exit(0);
- }
- aopen();
- }
- @EOF
-
- chmod 600 cruddy.c
-
- echo x - j.1
- cat >j.1 <<'@EOF'
- ..TH J 1
- ..SH NAME
- j \- Joe's Screen Editor
- ..SH SYNOPSIS
- ..B j file
- ..br
- ..BR j
- ..SH DESCRIPTION
- J is a screen editor designed to be easy to learn for novice users and
- powerfull enough for experienced users. After you invoke the editor, you can
- hit ^K H ('^' mean hold the Ctrl key down while pressing the following key) to
- turn on the help text. From this you should be able to figure out how to use
- the editor. A few things need further explanation however:
-
- J uses the "TERM" environment entry and termcap to determine the height and
- width of the screen and to determine if the terminal uses scrolling regions.
- Except for these differences the terminal must be ANSI/VT100 compatible.
-
- ^K J reformats the current paragraph. ^T R can be used to change the right
- margin. The default is the width of the screen. If auto-indent mode is set,
- indented paragraphs are formated.
-
- Use ^K B to set the beginning of a block and ^K K to set the end of a block.
- You can then copy, move save or delete the marked blocsk. To turn the
- highlighting off, hit ^K B ^K K (make the beginning and ending the same or
- move the beginning past the ending or move the ending before the beginning).
-
- ^K O splits a window into two. You can then use ^K E to load a file into the
- new window. ^K I shows either one window or it shows all of the windows. Use
- ^C to eliminate a window.
-
- Control characters (0-31, 127) are shown underlined. Characters above 127 are
- shown in inverse. You can use ` and ^\ to enter control characters
- orcharacters with the 7th bit set.
-
- Hit ^K F to find text. You will be prompted to enter the search string.
- After hitting Return, you will be prompted for options- you can type 1 or more
- of:
-
- ..br
- i Ignore case
- ..br
- b Backwards
- ..br
- r Replace
- ..br
- nnn Find the nth occurance or do nnn replacements
- ..br
-
- If you hit r, you will also be prompted to enter the
- replacement string.
-
- Hit ^L to find the next occurance of the previous search
- string (with all the same options).
-
- If for some reason J gets a signal (that it's going to crash or that the
- system is messing up), it attempts to save the last file edited in a file
- "aborted.j" in the current directory.
-
- ..SH FILES
- ..DT
- ..ta 25n
- keymap.j Keymap file. J looks for this in the current
- directory, the user's home directory and in
- the directory containing J
- ..SH RESTRICTIONS
- The file size is limited to the system process size limit
-
- ..SH BUGS
- Send bug reports to rcarter@wpi.wpi.edu (Joseph H. Allen). This should be
- valid to at least January, 1991. You can also contact me through snail mail:
-
- ..br
- Joseph H. Allen
- ..br
- 28 Dale Lane
- ..br
- Smithtown, N.Y. 11787
- @EOF
-
- chmod 600 j.1
-
- echo x - j.c
- cat >j.c <<'@EOF'
- /* J - Joe's Editor - the bulk of the code is here
- Copyright (C) 1991 Joseph H. Allen
-
- This file is part of J (Joe's Editor)
-
- J is free software; you can redistribute it and/or modify it under the terms
- of the GNU General Public License as published by the Free Software
- Foundation; either version 1, or (at your option) any later version.
-
- J is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNU Emacs; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
- #include <stdio.h>
- /* #include <stdlib.h> */
- #include <string.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <errno.h>
- #include <pwd.h>
- extern errno;
- #include "async.h"
- #include "blocks.h"
- #include "j.h"
- int width=80;
- int height=24;
- int scroll=1;
-
- unsigned char stalin[PATHSIZE];
-
- int smode=0;
- int tops=0;
- int bots;
- int oxpos=0; /* Current cursor position */
- int oypos=0;
- int *scrn; /* Screen buffer address */
-
- unsigned char *omsg=0; /* Pointer to opening message */
-
- dopen()
- {
- int x;
- unsigned char buf[30];
- scrn=(int *)malloc(width*height*sizeof(int));
- for(x=0;x<width*height;x++) scrn[x]= ' ';
- if(scroll)
- {
- sprintf(buf,"\033[0m\033[1;%dr\033[H\033[J",height), eputs(buf);
- bots=height-1;
- }
- else eputs("\033[0m\033[H\033[J");
- }
-
- dclose(ms)
- unsigned char *ms;
- {
- setregn(0,height-1);
- cpos(height-1,0);
- tputss(ms);
- eputs("\033[K");
- oxpos=strlen(ms);
- cpos(height-1,0);
- eputc(10);
- }
-
- cposs(y,x)
- {
- unsigned char s[9];
- if(y>bots || y<tops) setregn(0,height-1);
- if(y==oypos)
- {
- if(x==oxpos) return;
- if(x==0)
- {
- eputc(13);
- return;
- }
- if(oxpos>=x+1 && oxpos<=x+4)
- {
- while(oxpos!=x) eputc(8), x++;
- return;
- }
- if(x>=oxpos+1 && x<=oxpos+4)
- {
- while(x!=oxpos) tputcc(scrn[oypos*width+oxpos++]);
- return;
- }
- if(x>oxpos)
- sprintf(s,"\033[%dC",x-oxpos);
- else
- sprintf(s,"\033[%dD",oxpos-x);
- eputs(s);
- return;
- }
- if(x==oxpos)
- {
- if(y>=oypos+1 && y<=oypos+4)
- {
- while(y!=oypos) /* acheck(), */ eputc(10), oypos++;
- return;
- }
- if(y==0 && x==0)
- {
- eputs("\033[H");
- }
- if(y>oypos)
- sprintf(s,"\033[%dB",y-oypos);
- else
- sprintf(s,"\033[%dA",oypos-y);
- eputs(s);
- return;
- }
- if(x<3 && y>oypos && y<oypos+5)
- {
- while(oypos!=y) ++oypos, eputc('\012');
- eputc('\015'); oxpos=0;
- while(x!=oxpos) tputcc(scrn[oypos*width+oxpos++]);
- return;
- }
- if(x==0 && y==0)
- {
- eputs("\033[H");
- return;
- }
- if(x==0)
- {
- sprintf(s,"\033[%dH",y+1);
- eputs(s);
- return;
- }
- sprintf(s,"\033[%d;%dH",y+1,x+1);
- eputs(s);
- return;
- }
-
- cpos(y,x)
- {
- cposs(y,x);
- oxpos=x;
- oypos=y;
- }
-
- setregn(top,bot)
- {
- unsigned char sst[16];
- if(top!=tops || bots!=bot)
- {
- tops=top;
- bots=bot;
- if(scroll)
- {
- oxpos=0;
- oypos=0;
- sprintf(sst,"\033[%d;%dr",top+1,bot+1);
- eputs(sst);
- }
- }
- }
-
- attrib(x)
- {
- if(smode== -1) goto clr;
- if(!(x&INVERSE) && (smode&INVERSE)) goto clr;
- if(!(x&BLINK) && (smode&BLINK)) goto clr;
- if(!(x&UNDERLINE) && (smode&UNDERLINE)) goto clr;
- if(!(x&BOLD) && (smode&BOLD)) goto clr;
- goto ovr;
- clr:
- smode=0;
- eputs("\033[m");
- ovr:
- if(x&INVERSE && !(smode&INVERSE)) eputs("\033[7m");
- if(x&BLINK && !(smode&BLINK)) eputs("\033[5m");
- if(x&UNDERLINE && !(smode&UNDERLINE)) eputs("\033[4m");
- if(x&BOLD && !(smode&BOLD)) eputs("\033[1m");
- smode=x;
- }
-
- int uuu=0;
- int cntr=0;
- int upd=1;
- int hupd=0;
- int newy=1;
- int helpon=0;
- int wind=0;
- int xpos=0;
- int ypos=0;
- TXTSIZ saddr=0;
- TXTSIZ xoffset=0;
-
- unsigned char help[]=
- "\
- \240\240\240\310\345\354\360\240\323\343\362\345\345\356\240\240\240\364\365\
- \362\356\240\357\346\346\240\367\351\364\350\240\336\313\310\240\240\
- \240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\
- \240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\
- \240\240\240\240\240\240\240\
- \240\
- \7\017 \024\017 \4\5\014\5\024\5 \015\011\023\03 \02\
- \014\017\03\013 \06\011\016\04 \021\025\017\024\05 \027\011\016\04\017\
- \027 \
- \240\
- \240\
- ^B left ^F right ^D single ^T mode ^KB mark ^KF text ` Ctrl ^KO split \
- \240\
- \240\
- ^Z word ^X word ^W >word ^R retype ^KK end ^L next ^\\ bit-7 ^KI 1 / all\
- \240\
- \240\
- ^A edge ^E edge ^O word< ^KA center ^KC copy ^KL line \06\011\014\
- \05 ^KP up \
- \240\
- \240\
- ^P up ^N down ^J >line ^KJ format ^KM move \05\
- \030\011\024 ^KD save ^KN down \
- \240\
- \240\
- ^U page ^V page ^Y line ^KZ shell ^KW save ^KX save ^KR read ^KG grow \
- \240\
- \240\
- ^KU top ^KV end ^K- undo ^K, indnt< ^KY kill ^C abort/ ^KT shrink \
- \240\
- \240\
- ^G matching ([<{` ^K+ redo ^K. indnt> close window ^KE get file\
- \240";
-
- /* Clear end of line if needed. i is row number and j is column number */
-
- clreolchk(i,j)
- TXTSIZ j;
- {
- int *k=scrn+i*width;
- int t, jj;
- if(j<xoffset) jj=0;
- else
- if(j>=xoffset+width-1) return;
- else jj=j-xoffset;
- for(t=width-1;t>=jj;--t) if(k[t]!=' ') goto ohoh;
- return;
- ohoh:
- if(t==jj)
- {
- cpos(i,jj);
- tputcc(' ');
- k[jj]=' ';
- oxpos++;
- return;
- }
- while(t>=jj) k[t--]=' ';
- cpos(i,jj);
- tattrib(' ');
- eputs("\033[K");
- }
-
- int udline(i)
- {
- int q=i*width;
- TXTSIZ j;
- int t;
- int u;
- unsigned char ch;
- for(j=0;1;j++)
- {
- if(have) return -1;
- if(fmeof())
- {
- clreolchk(i++,j);
- j=0;
- while(i<curwin->wind+curwin->height) clreolchk(i++,j);
- return 1;
- }
- ch=fmgetc();
- if(ch==NL)
- {
- clreolchk(i,j);
- return 0;
- }
- if(ch==TAB)
- {
- ch=' ';
- if(fmnote()-1>=markb && fmnote()<=marke && curbuf==markbuf) ch^=128;
- t=i*width+j-xoffset;
- do
- {
- if(j>=xoffset && j<xoffset+width-1)
- {
- u=scrn[t];
- if(ch!=u || u==-1)
- {
- cpos(i,(int)(j-xoffset));
- scrn[t]=ch;
- tputcc(ch);
- oxpos++;
- }
- }
- t++;
- j++;
- } while(j&7);
- j--;
- }
- else
- {
- if(fmnote()-1>=markb && fmnote()<=marke && curbuf==markbuf) ch^=128;
- t=q+j-xoffset;
- if(j>=xoffset && j<xoffset+width-1)
- {
- u=scrn[t];
- if(ch!=u || u==-1)
- {
- cpos(i,(int)(j-xoffset));
- scrn[t]=ch;
- tputcc(ch);
- oxpos++;
- }
- }
- }
- }
- }
-
- int udscrn()
- {
- int i;
- int v;
- for(i=ypos;i<curwin->height+curwin->wind;i++)
- if(v=udline(i)) break;
- if(v== -1) return 0;
- fmpoint(saddr);
- for(i=curwin->wind+1;i<ypos;i++)
- if(udline(i)) return 0;
- return 1;
- }
-
- dupdate1(fgf)
- {
- int y;
- TXTSIZ x;
- TXTSIZ sve=fmnote();
-
- TXTSIZ sve1;
-
- /* Status line */
- bset(stalin,width-1,' ');
- bfwrd(stalin,"File:",5);
- if(changed)
- if(gfnam[0]) bfwrd(bfwrd(stalin+6,gfnam,strlen(gfnam))+strlen(gfnam),
- " (Modified)",11);
- else bfwrd(bfwrd(stalin+6,"(Unnamed)",9)+9," (Modified)",11);
- else
- if(gfnam[0]) bfwrd(stalin+6,gfnam,strlen(gfnam));
- else bfwrd(stalin+6,"(Unnamed)",9);
- if(!helpon) bfwrd(stalin+width-22,"Hit Ctrl-K H for help",21);
-
- for(y=0;y<width-1;y++)
- if(scrn[y+curwin->wind*width]!=stalin[y]+128)
- {
- if(have) break;
- cpos(curwin->wind,y);
- tputcc(stalin[y]+128);
- scrn[y+curwin->wind*width]=stalin[y]+128;
- oxpos++;
- }
-
- x=getcol();
- if(fmnrnl()) fmpoint(fmnote()+1);
- sve1=fmnote();
-
- /* calculate what screen cursor position should be */
-
- if(x>xoffset+width-2)
- xpos=width-2, xoffset=x-width+2;
- else
- if(x<xoffset)
- xpos=0, xoffset=x;
- else
- xpos=x-xoffset;
-
- /* calculate new y cursor position and point to beginning of screen */
-
- if(newy)
- {
- if(fmnote()<=saddr)
- {
- ypos=curwin->wind+1;
- saddr=fmnote();
- }
- else
- {
- /* is cursor within 24 lines of old beginning of screen */
-
- for(y=0;y!=curwin->height-2;y++)
- {
- if(fmnote()==saddr) goto over;
- fmrgetc();
- if(fmnrnl()) fmpoint(fmnote()+1);
- }
- if(cntr)
- {
- for(x=0;x<(curwin->height-1)/2;x++)
- {
- fmfnl();
- y--;
- fmgetc();
- }
- }
- over:
- cntr=0;
- saddr=fmnote();
- ypos=y+curwin->wind+1;
- }
- newy=0;
- }
-
- /* Now update screen */
- if(have)
- { if(fgf) cpos(ypos,xpos); }
- else
- {
- fmpoint(sve1);
- if(udscrn()) upd=0;
- if(fgf) cpos(ypos,xpos);
- }
- fmpoint(sve);
- }
-
- dupdatehelp()
- {
- int i,j;
- unsigned char *from=help;
- int *too=scrn;
- wind=helplines;
- for(i=0;i!=helplines;i++)
- {
- for(j=0;j!=helpwidth;j++)
- {
- if(have) return;
- if(j>=width-1)
- {
- -- Cut here
- --
- /* rcarter@wpi.wpi.edu */ /* Amazing */ /* Joseph H. Allen */
- int a[1817];main(z,p,q,r){for(p=80;q+p-80;p-=2*a[p])for(z=9;z--;)q=3&(r=time(0)
- +r*57)/7,q=q?q-1?q-2?1-p%79?-1:0:p%79-77?1:0:p<1659?79:0:p>158?-79:0,q?!a[p+q*2
- ]?a[p+=a[p+=q]=q]=q:0:0;for(;q++-1817;)printf(q%79?"%c":"%c\n"," #"[!a[q-1]]);}
-