Initial commit
This commit is contained in:
commit
30e61fe409
|
@ -0,0 +1,2 @@
|
|||
/target
|
||||
**/*.rs.bk
|
|
@ -0,0 +1,9 @@
|
|||
[package]
|
||||
name = "rust-most"
|
||||
version = "0.1.0"
|
||||
authors = ["greg <greg.shuflin@protonmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
|
@ -0,0 +1,339 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 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 licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU 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. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), 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 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 show them these terms so they know 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.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
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 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 derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
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 License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
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.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary 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
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 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 Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing 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 for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
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.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. 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 this 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
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. 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
|
||||
|
||||
11. 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.
|
||||
|
||||
12. 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
|
||||
|
||||
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 the public, 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 2 of the License, 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) 19yy 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 is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
|
@ -0,0 +1,17 @@
|
|||
This file is part of MOST.
|
||||
|
||||
Copyright (c) 1991, 1999, 2002, 2005-2018,2019 John E. Davis
|
||||
|
||||
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 2 of the License, 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.
|
|
@ -0,0 +1,43 @@
|
|||
# -*- sh -*-
|
||||
|
||||
#This is a UNIX-only makefile.
|
||||
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
all: makefiles
|
||||
cd src; $(MAKE) all
|
||||
Makefile: configure autoconf/Makefile.in
|
||||
@echo "Makefile is older than the configure script".
|
||||
@echo "Please re-run the configure script."
|
||||
@exit 1
|
||||
src/Makefile: configure src/Makefile.in src/config.hin
|
||||
@echo "src/Makefile is older than its dependencies".
|
||||
@echo "Please re-run the configure script."
|
||||
@exit 1
|
||||
makefiles: Makefile src/Makefile
|
||||
clean:
|
||||
/bin/rm -f *~
|
||||
cd src; $(MAKE) clean
|
||||
#
|
||||
distclean:
|
||||
/bin/rm -f *~ Makefile config.status config.log config.cache files.pck
|
||||
cd src; $(MAKE) distclean
|
||||
#
|
||||
install: all
|
||||
cd src; $(MAKE) install
|
||||
#
|
||||
|
||||
# The symlinks target is for my own private use. It simply creates the object
|
||||
# directory as a symbolic link to a local disk instead of an NFS mounted one.
|
||||
symlinks:
|
||||
cd src; $(MAKE) symlinks
|
||||
configure: autoconf/aclocal.m4 autoconf/configure.ac
|
||||
cd autoconf && autoconf && mv ./configure ..
|
||||
update: autoconf/config.sub autoconf/config.guess
|
||||
autoconf/config.guess: /usr/share/misc/config.guess
|
||||
/bin/cp -f /usr/share/misc/config.guess autoconf/config.guess
|
||||
autoconf/config.sub: /usr/share/misc/config.sub
|
||||
/bin/cp -f /usr/share/misc/config.sub autoconf/config.sub
|
||||
|
||||
.PHONY: all clean distclean install symlinks update makefiles
|
|
@ -0,0 +1,12 @@
|
|||
NEWS for v5.1.0
|
||||
|
||||
This is primarily a maintenance release.
|
||||
|
||||
The most notable update is that regular expression (RE) searches are
|
||||
supported again. In ancient times, most supported RE searches, but
|
||||
was RE support was dropped was dropped when UTF-8 support was added.
|
||||
The default is still to use a non-RE search. The -r command line
|
||||
switch may be used to make the default a RE-based search. Within
|
||||
most, ":r" may be used to toggle the search type between RE and
|
||||
non-RE.
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
Compiling MOST requires an ANSI C compiler. In addition you MUST have
|
||||
a copy of the S-Lang library version 2.X. Version 1 is no longer
|
||||
supported. This library is available from
|
||||
<http://www.jedsoft.org/slang/>.
|
||||
|
||||
INSTALLATION INSTRUCTIONS
|
||||
|
||||
On Unix, you should be able to simply type:
|
||||
|
||||
./configure; make
|
||||
|
||||
at the Unix prompt. If you are using CYGWIN, you will need to ensure
|
||||
that libslang.dll is on your PATH; otherwise the chkslang program will
|
||||
not run.
|
||||
|
||||
If using DJGPP or MINGW32, do:
|
||||
|
||||
<edit src/makefile.w32, setting ARCH to either dgj or gw32>
|
||||
cd src
|
||||
make -f makefile.w32
|
||||
|
||||
For VMS, edit the file `vmsmake.com'. When finished, either type `@vmsmake'
|
||||
or `@vmsmake gcc' at the VMS prompt. Once MOST has been created, it must be
|
||||
installed as a foreign command. This means that you must first type:
|
||||
|
||||
$ most :== $device:[dir.containing.most]most.exe
|
||||
|
||||
I suggest that you first build MOST then view the doc file using MOST (`most
|
||||
most.doc'). If you need help, hit the `h' key from within MOST.
|
||||
|
||||
MOST understands the following environment variables:
|
||||
|
||||
MOST_SWITCHES
|
||||
MOST_EDITOR, SLANG_EDITOR, EDITOR
|
||||
MOST_INITFILE
|
||||
MOST_HELP
|
||||
|
||||
1. MOST_SWITCHES is a list of commonly used switches.
|
||||
|
||||
2. MOST_EDITOR and SLANG_EDITOR are formatted strings describing what
|
||||
editor to use. The string can contain %s and %d formatting descriptors
|
||||
that represent the file name and line number, respectively. For
|
||||
example, if JED is your editor, then set MOST_EDITOR to 'jed %s -g %d'.
|
||||
Since MOST is just one of several programs that use the S-Lang library,
|
||||
I suggest that you use SLANG_EDITOR instead of MOST_EDITOR.
|
||||
|
||||
3. MOST_INITFILE specifies a configuration file for MOST. One can specify
|
||||
keymaps, colors, etc. via this file. In the absence of
|
||||
MOST_INITFILE, the program will look for a file call .mostrc in
|
||||
the home directory (most.rc on non-Unix systems).
|
||||
|
||||
See `lesskeys.rc' for an example of a key definition file that
|
||||
causes MOST to emulate the `less' pager. See also most-fun.txt
|
||||
for a list of functions that can be used for key definitions. The
|
||||
file `most.rc' list the bindings that are built-in to the
|
||||
viewer.
|
||||
|
||||
4. If MOST_HELP is defined to point to an existing file, MOST will load a
|
||||
file as a help file. This is useful for describing custom keymaps.
|
||||
|
||||
Any problems with MOST should be reported to jed@jedsoft.org.
|
||||
|
||||
[Note also that this is really the first non-trivial C program that
|
||||
I ever wrote. Because of this, much of the code appears very
|
||||
amateurish. For example, I tried very hard to avoid C constructs
|
||||
that some authors strongly discourage, e.g., goto, continue,
|
||||
break. Of course this made some of the code convoluted, e.g.,
|
||||
contrast
|
||||
|
||||
int test = 1;
|
||||
while (test)
|
||||
{
|
||||
function ();
|
||||
|
||||
if (-1 == some_function ())
|
||||
test = 0;
|
||||
|
||||
if (test)
|
||||
some_other_function ();
|
||||
}
|
||||
|
||||
with:
|
||||
|
||||
while (1)
|
||||
{
|
||||
function ();
|
||||
if (-1 == some_function ()) break;
|
||||
some_other_function ();
|
||||
}
|
||||
|
||||
I have since concluded that many text-book authors never actually
|
||||
wrote anything non-trivial. Whenever I work on MOST, I try to make
|
||||
some changes in an effort to clean it up. ]
|
||||
|
||||
--John Davis
|
|
@ -0,0 +1,8 @@
|
|||
../configure: aclocal.m4 configure.ac
|
||||
/bin/rm -rf autom4te.cache
|
||||
autoconf && mv ./configure ..
|
||||
update: config.sub config.guess
|
||||
config.guess: /usr/share/misc/config.guess
|
||||
/bin/cp -f /usr/share/misc/config.guess config.guess
|
||||
config.sub: /usr/share/misc/config.sub
|
||||
/bin/cp -f /usr/share/misc/config.sub config.sub
|
|
@ -0,0 +1,43 @@
|
|||
# -*- sh -*-
|
||||
|
||||
#This is a UNIX-only makefile.
|
||||
|
||||
@SET_MAKE@
|
||||
SHELL = /bin/sh
|
||||
|
||||
all: makefiles
|
||||
cd src; $(MAKE) all
|
||||
Makefile: configure autoconf/Makefile.in
|
||||
@echo "Makefile is older than the configure script".
|
||||
@echo "Please re-run the configure script."
|
||||
@exit 1
|
||||
src/Makefile: configure src/Makefile.in src/config.hin
|
||||
@echo "src/Makefile is older than its dependencies".
|
||||
@echo "Please re-run the configure script."
|
||||
@exit 1
|
||||
makefiles: Makefile src/Makefile
|
||||
clean:
|
||||
/bin/rm -f *~
|
||||
cd src; $(MAKE) clean
|
||||
#
|
||||
distclean:
|
||||
/bin/rm -f *~ Makefile config.status config.log config.cache files.pck
|
||||
cd src; $(MAKE) distclean
|
||||
#
|
||||
install: all
|
||||
cd src; $(MAKE) install
|
||||
#
|
||||
|
||||
# The symlinks target is for my own private use. It simply creates the object
|
||||
# directory as a symbolic link to a local disk instead of an NFS mounted one.
|
||||
symlinks:
|
||||
cd src; $(MAKE) symlinks
|
||||
configure: autoconf/aclocal.m4 autoconf/configure.ac
|
||||
cd autoconf && autoconf && mv ./configure ..
|
||||
update: autoconf/config.sub autoconf/config.guess
|
||||
autoconf/config.guess: /usr/share/misc/config.guess
|
||||
/bin/cp -f /usr/share/misc/config.guess autoconf/config.guess
|
||||
autoconf/config.sub: /usr/share/misc/config.sub
|
||||
/bin/cp -f /usr/share/misc/config.sub autoconf/config.sub
|
||||
|
||||
.PHONY: all clean distclean install symlinks update makefiles
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,76 @@
|
|||
dnl -*- sh -*-
|
||||
AC_INIT(src/most.c)
|
||||
JD_INIT
|
||||
JD_ANSI_CC
|
||||
|
||||
AC_CONFIG_AUX_DIR(autoconf)
|
||||
AC_PROG_MAKE_SET
|
||||
AC_PROG_INSTALL
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
JD_ELF_COMPILER
|
||||
|
||||
# determine X include and needed libs
|
||||
AC_PATH_XTRA
|
||||
|
||||
# Implementation of the --disable-dev-random switch.
|
||||
AC_MSG_CHECKING([if you want to use mmap if available])
|
||||
AC_ARG_ENABLE(mmap,
|
||||
AC_HELP_STRING([--disable-mmap],[disable the use of mmap]),
|
||||
jd_use_mmap=$enableval, jd_use_mmap=yes)
|
||||
AC_MSG_RESULT($jd_use_mmap)
|
||||
case "x$jd_use_mmap" in
|
||||
xyes )
|
||||
AC_DEFINE(USE_MMAP)
|
||||
;;
|
||||
esac
|
||||
|
||||
#Check these header since they cause trouble
|
||||
AC_CHECK_HEADERS( \
|
||||
stdlib.h \
|
||||
unistd.h \
|
||||
memory.h \
|
||||
malloc.h \
|
||||
termios.h \
|
||||
sys/mman.h \
|
||||
)
|
||||
|
||||
AC_HEADER_DIRENT
|
||||
|
||||
AC_TYPE_MODE_T
|
||||
AC_TYPE_PID_T
|
||||
AC_TYPE_UID_T
|
||||
AC_TYPE_SIZE_T
|
||||
|
||||
AC_CHECK_SIZEOF(short, 2)
|
||||
AC_CHECK_SIZEOF(int, 4)
|
||||
AC_CHECK_SIZEOF(long, 4)
|
||||
AC_CHECK_SIZEOF(float, 4)
|
||||
AC_CHECK_SIZEOF(double, 8)
|
||||
|
||||
JD_CHECK_LONG_LONG
|
||||
JD_LARGE_FILE_SUPPORT
|
||||
|
||||
AC_CHECK_FUNCS(\
|
||||
memset \
|
||||
memcpy \
|
||||
putenv \
|
||||
getcwd \
|
||||
mmap \
|
||||
snprintf \
|
||||
getpgrp tcgetpgrp \
|
||||
)
|
||||
|
||||
JD_SET_OBJ_SRC_DIR
|
||||
JD_TERMCAP
|
||||
JD_WITH_LIBRARY(slang)
|
||||
JD_GCC_WARNINGS
|
||||
JD_GET_MODULES(src/modules.lis)
|
||||
JD_CREATE_MODULE_ORULES
|
||||
|
||||
AC_CONFIG_HEADER(src/sysconf.h:src/config.hin)
|
||||
AC_OUTPUT(Makefile:autoconf/Makefile.in src/Makefile)
|
||||
|
||||
JD_CREATE_ORULE(chkslang)
|
||||
JD_APPEND_RULES(src/Makefile)
|
||||
|
|
@ -0,0 +1,251 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
# This comes from X11R5 (mit/util/scripts/install.sh).
|
||||
#
|
||||
# Copyright 1991 by the Massachusetts Institute of Technology
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and its
|
||||
# documentation for any purpose is hereby granted without fee, provided that
|
||||
# the above copyright notice appear in all copies and that both that
|
||||
# copyright notice and this permission notice appear in supporting
|
||||
# documentation, and that the name of M.I.T. not be used in advertising or
|
||||
# publicity pertaining to distribution of the software without specific,
|
||||
# written prior permission. M.I.T. makes no representations about the
|
||||
# suitability of this software for any purpose. It is provided "as is"
|
||||
# without express or implied warranty.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch. It can only install one file at a time, a restriction
|
||||
# shared with many OS's install programs.
|
||||
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
transformbasename=""
|
||||
transform_arg=""
|
||||
instcmd="$mvprog"
|
||||
chmodcmd="$chmodprog 0755"
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=""
|
||||
dst=""
|
||||
dir_arg=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) instcmd="$cpprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-d) dir_arg=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd="$stripprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
# this colon is to work around a 386BSD /bin/sh bug
|
||||
:
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "install: no input file specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]; then
|
||||
dst=$src
|
||||
src=""
|
||||
|
||||
if [ -d $dst ]; then
|
||||
instcmd=:
|
||||
chmodcmd=""
|
||||
else
|
||||
instcmd=mkdir
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
|
||||
if [ -f $src -o -d $src ]
|
||||
then
|
||||
true
|
||||
else
|
||||
echo "install: $src does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "install: no destination specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# If destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d $dst ]
|
||||
then
|
||||
dst="$dst"/`basename $src`
|
||||
else
|
||||
true
|
||||
fi
|
||||
fi
|
||||
|
||||
## this sed command emulates the dirname command
|
||||
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if [ ! -d "$dstdir" ]; then
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-${defaultIFS}}"
|
||||
|
||||
oIFS="${IFS}"
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
IFS="${oIFS}"
|
||||
|
||||
pathcomp=''
|
||||
|
||||
while [ $# -ne 0 ] ; do
|
||||
pathcomp="${pathcomp}${1}"
|
||||
shift
|
||||
|
||||
if [ ! -d "${pathcomp}" ] ;
|
||||
then
|
||||
$mkdirprog "${pathcomp}"
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
pathcomp="${pathcomp}/"
|
||||
done
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]
|
||||
then
|
||||
$doit $instcmd $dst &&
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
||||
else
|
||||
|
||||
# If we're going to rename the final executable, determine the name now.
|
||||
|
||||
if [ x"$transformarg" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
dstfile=`basename $dst $transformbasename |
|
||||
sed $transformarg`$transformbasename
|
||||
fi
|
||||
|
||||
# don't allow the sed command to completely eliminate the filename
|
||||
|
||||
if [ x"$dstfile" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# Make a temp file name in the proper directory.
|
||||
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
|
||||
$doit $instcmd $src $dsttmp &&
|
||||
|
||||
trap "rm -f ${dsttmp}" 0 &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits
|
||||
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
|
||||
$doit $rmcmd -f $dstdir/$dstfile &&
|
||||
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
||||
|
||||
fi &&
|
||||
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,32 @@
|
|||
#! /bin/sh
|
||||
# mkinstalldirs --- make directory hierarchy
|
||||
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
|
||||
# Created: 1993-05-16
|
||||
# Public domain
|
||||
|
||||
errstatus=0
|
||||
|
||||
for file
|
||||
do
|
||||
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
|
||||
shift
|
||||
|
||||
pathcomp=
|
||||
for d in ${1+"$@"} ; do
|
||||
pathcomp="$pathcomp$d"
|
||||
case "$pathcomp" in
|
||||
-* ) pathcomp=./$pathcomp ;;
|
||||
esac
|
||||
|
||||
if test ! -d "$pathcomp"; then
|
||||
echo "mkdir $pathcomp" 1>&2
|
||||
mkdir "$pathcomp" || errstatus=$?
|
||||
fi
|
||||
|
||||
pathcomp="$pathcomp/"
|
||||
done
|
||||
done
|
||||
|
||||
exit $errstatus
|
||||
|
||||
# mkinstalldirs ends here
|
|
@ -0,0 +1,77 @@
|
|||
#!/bin/sh
|
||||
|
||||
# This script parses /etc/ld.so.conf and returns lib and include directories
|
||||
# in a form that JD_CHECK_FOR_LIBRARY can grok.
|
||||
|
||||
SH_TRUE=0
|
||||
SH_FALSE=1
|
||||
|
||||
# Usage: sh_substr string a b ==> string[a:b] (1s-based)
|
||||
sh_substr()
|
||||
{
|
||||
echo "$1" | cut "-c" "$2-$3"
|
||||
}
|
||||
|
||||
# if sh_is_comment line; then ...
|
||||
sh_is_comment()
|
||||
{
|
||||
ch=`sh_substr "$1" 1 1`
|
||||
if test "X$ch" = "X#" -o "X$ch" = "X"
|
||||
then
|
||||
return $SH_TRUE;
|
||||
fi
|
||||
return $SH_FALSE;
|
||||
}
|
||||
|
||||
sh_read_ldsoconf ()
|
||||
{
|
||||
file="$1"
|
||||
dirlist=""
|
||||
if test ! -f "$file"
|
||||
then
|
||||
return $SH_FALSE;
|
||||
fi
|
||||
|
||||
while read line
|
||||
do
|
||||
if sh_is_comment "$line"; then continue; fi
|
||||
read p1 p2 pn << EOF
|
||||
${line}
|
||||
EOF
|
||||
if test "$p1" = "include"
|
||||
then
|
||||
for file in $p2
|
||||
do
|
||||
dirs=`sh_read_ldsoconf "$file"`
|
||||
dirlist="$dirlist $dirs"
|
||||
done
|
||||
else
|
||||
dirlist="$dirlist $p1"
|
||||
fi
|
||||
done < "$file"
|
||||
echo "$dirlist"
|
||||
}
|
||||
|
||||
dirs=`sh_read_ldsoconf "/etc/ld.so.conf"`
|
||||
XY=""
|
||||
for Y in $dirs
|
||||
do
|
||||
if test "/usr/lib" = `sh_substr $Y 1 8`
|
||||
then
|
||||
X="/usr/include"
|
||||
else
|
||||
if test "/lib" = `sh_substr $Y 1 4`
|
||||
then
|
||||
X="/usr/include"
|
||||
else
|
||||
X=`dirname $Y`"/include"
|
||||
fi
|
||||
fi
|
||||
if test -d "$Y"
|
||||
then
|
||||
XY="$XY $X,$Y"
|
||||
fi
|
||||
done
|
||||
|
||||
echo $XY
|
||||
|
|
@ -0,0 +1,201 @@
|
|||
-*- mode: text; mode: fold -*-
|
||||
Changes since 5.0.0
|
||||
1. src/Makefile.in: Install docs in $prefix/share/doc
|
||||
2. src/most.h,sysdep.c: win32-specific patches (Andrew Wu)
|
||||
3. most.1: Typo corrected (Stephane Blondon)
|
||||
4. src/line.c: removed redundant switch in the most_forward_columns
|
||||
function.
|
||||
5. src/buffer.c: avoid call to SLutf8_skip_char if the character is
|
||||
ascii.
|
||||
6. src/file.c: Added an option to most_read_file_dsc to skip the line
|
||||
count and made use of it in search.c to speed up the searches a bit.
|
||||
7. src/display.c: When wrapping a line, the color was not "wrapping".
|
||||
8. src/line.c: When moving forward n columns, skip over trailing 0
|
||||
length color escape sequences.
|
||||
9. src/buffer.c: If a color escape sequence occurs at the end of a
|
||||
line line whose display width is equal to the terminal width, do
|
||||
not wrap the line.
|
||||
10. src/keym.c: Limit the amount of loops when going to the end of the
|
||||
buffer. It is possible for a run-away process to write to a
|
||||
logfile that most is viewing causing it to loop forever seeking the
|
||||
end of the file, which may never come.
|
||||
11. src/help.c: Change DELETE to BACKSPACE. file.c: Indicate that
|
||||
chdir return value is being ignored.
|
||||
12. configure,autoconf/*: Updated configure script and related files.
|
||||
13. src/most.c: when acting as `cat`, a file pointer was not being
|
||||
closed (George Danchev).
|
||||
14. src/*.c: Removed some unused variables.
|
||||
15. configure: Use /etc/ld.so.conf to located system lib paths.
|
||||
16. autoconf/*: updates
|
||||
17. src/line.c, buffer.c: Fixed an issue with the display of
|
||||
double-width characters to address
|
||||
<https://bugs.launchpad.net/ubuntu/+source/most/+bug/312454>.
|
||||
18. src/*.[ch]: Updated copyright year
|
||||
19. src/search.c: Rewrote the search functions from scratch. Both
|
||||
ordinary and regexp searches are now supported. Use -r to startup
|
||||
with regular-expression searches.
|
||||
20. src/keym.c: Added support for Home/End keys (top/bottom of buffer).
|
||||
21. src/line.c: Added a work-around for programs that try colorize the
|
||||
output using the clear-to-end-of-line escape sequence (ESC[K)
|
||||
without regard for the value of isatty(fileno(sdout)). Most will
|
||||
ignore ESC[K unless invoked with -v.
|
||||
22. configure: Updated to use aclocal.m4 v0.3.3-1
|
||||
23. src/Makefile.in: Added LDFLAGS to chkslang linker line (Denis Pronin)
|
||||
24. *: Converted the man page source most.1 to text-macro, and
|
||||
regenerated it. Updated copyrights for upcoming release.
|
||||
25. Updated manifest and copyrights updated for 2019 release.
|
||||
|
||||
{{{ Previous Versions
|
||||
Changes since 4.10.2
|
||||
0. src/most.c: version bumped to 5.0.0-x
|
||||
1. src/line.c: Added support for embedded ANSI escape sequences that
|
||||
seem to be more common in man pages.
|
||||
2. When switching searching directions, and no search string was
|
||||
entered at the search prompt, use the previous string.
|
||||
3. Added patches for UTF-8 support kindly provided by Javier Kohen.
|
||||
4. src/most.c: Removed references to Kanji from the usage message.
|
||||
Kanji is not supported by slang-2. Use Unicode.
|
||||
5. src/file.c: Most will automatically start up in binary mode if the
|
||||
file contains a nul-byte in the first 512 characters. Previously,
|
||||
it would switch into binary mode when the file contained any
|
||||
characters with the most significant bit set.
|
||||
6. autoconf/config.sub,config.guess: Updated to more recent versions.
|
||||
7. src/most.c: Add +u/-u switches to force UTF-8 on/off. The default
|
||||
behavior depends upon the locale.
|
||||
8. src/sysdep.c: In most_getkey, if SLang_getkey returns an error,
|
||||
then just exit.
|
||||
9. src/search.c: Added `#undef SLANG_REGEXP' and `#undef
|
||||
HAVE_V8_REGCOMP' until the regexp searches are rewritten.
|
||||
10. src/edit.c: Filenames are quoted before being passed to the shell
|
||||
for editing.
|
||||
11. src/file.c: Filenames are quoted before being passed to the unzip
|
||||
program.
|
||||
12. src/sysdep.c: Check the process group id of the terminal and
|
||||
if it does not match that of most, then exit.
|
||||
13. src/keym.c: Added "find_next_other_dir" function and bound it to N.
|
||||
14. src/most.c: New commandline switch: "-d". This switch disables
|
||||
the display of the \ character used to denote a wrapped line.
|
||||
15. src/line.c: Added support for embedded ansi-color escape
|
||||
sequences, e.g., `ls --color | most`
|
||||
16. src/window.c: Added an error hook to prevent slang from writing to
|
||||
stderr.
|
||||
17. src/line.c: An ascii character+combining character was not being
|
||||
handled.
|
||||
|
||||
Changes since 4.10.1
|
||||
1. src/window.c:most_read_from_minibuffer: An variable was not being
|
||||
initialized. (Kevin Oberman, oberman at es, net).
|
||||
2. configure: mmap is enabled by default. Use the --disable-mmap
|
||||
configure option of you do not want it.
|
||||
|
||||
Changes since 4.10.0
|
||||
1. src/most.h: Prototype for SLang_set_error inconsistent with the
|
||||
function in most.c.
|
||||
2. src/most.h: If compiled against slang2 without an snprintf
|
||||
function, use _pSLsnprintf.
|
||||
|
||||
Changes since 4.9.5
|
||||
0. src/*.c: Various changes to support slang 2. Version bumped to
|
||||
4.10.0. UTF-8 support not yet available.
|
||||
1. src/keym.c: Ignore mouse events under DOS/Windows (Gisle Vanem,
|
||||
giva at bgnett, no).
|
||||
|
||||
Changes since 4.9.4
|
||||
1. src/line.c: A "length" variable was declared as unsigned char
|
||||
instead of unsigned int, causing a SEGV for columns larger than 255.
|
||||
2. src/file.c: fixed a buffer overflow caused by a long file name on
|
||||
the command line.
|
||||
|
||||
Changes since 4.9.3
|
||||
|
||||
1. src/buffer.c: SLtt_Screen_Rows and SLtt_Screen_Cols were swapped
|
||||
causing a file to be improperly displayed in wrap mode. Adrian P.
|
||||
van Bloois (adrian at accu.uu.nlhas) has my thanks for find this bug.
|
||||
2. src/most.c: when run without arguments, S-Lang library version also
|
||||
printed.
|
||||
|
||||
Changes since 4.9.2
|
||||
|
||||
1. src/keym.c: added support for \xE0 type arrow keys (Win9X).
|
||||
2. src/file.c: When resyncing mmaped buffer, make sure to preserve the
|
||||
current line number.
|
||||
3. src/sysdep.c: SLang_getkey_intr_hook is unix
|
||||
specific and should not be used on VMS.
|
||||
4. src/file.c: Make arrow-keys for next_file_cmd work on win32 systems.
|
||||
5. src/file.h: be sure to quote filename argument (Mako Hill
|
||||
<mako@debian.org>)
|
||||
6. src/file.c: added support for bzip2 files
|
||||
7. src/*.c: replace calls to sprintf with _SLsnprintf (Steve Kemp
|
||||
<skx@tardis.ed.ac.uk>).
|
||||
|
||||
Changes since 4.9.1
|
||||
0. Added support for using mmap to read files. Use configure
|
||||
--enable-mmap to enable this experimental feature.
|
||||
1. Wrapping bug fixed. Also some optimizations were made to speed up
|
||||
the display of wrapped files.
|
||||
2. File default.rc renamed to most.rc.
|
||||
3. A^H_ interpreted as underline. Previously, _^HA was recognized.
|
||||
4. Jerome Lauret <JLAURET@mail.chem.sunysb.edu> provided most.hlp, as
|
||||
well as a few VMS patches.
|
||||
5. src/Makefile.in: patch to make most's Makefile respect DESTDIR as
|
||||
well as removing the hardcoded use of $(prefix)/etc for the
|
||||
location of most's config file. <brad@comstyle.com>
|
||||
6. src/line.c: some simplifications and cleanups designed to avoid
|
||||
nasty problems with extremely long lines.
|
||||
|
||||
Changes since 4.9.0
|
||||
1. MOST_SWITCHES env variable can now contain extended switches.
|
||||
2. If most is reading from stdin, it will reinit the terminal when it
|
||||
encounters an EOF on stdin. This is to work around a problem under
|
||||
linux where for some reason, some other process resets the terminal.
|
||||
Changes since 4.8.1
|
||||
1. Apparantly, the binary flag +b is not valid with POSIX popen.
|
||||
2. Screen resize code modified so that most works in a SunOS cmdtool.
|
||||
3. Color support added. Use `most -C' to disable.
|
||||
4. Ported to Mingw32 (GNU C)
|
||||
|
||||
Changes since 4.7
|
||||
1. Added tail -f type mode. Use F to activate.
|
||||
2. OS/2 port provided by j.burnell@irl.cri.nz (John Burnell).
|
||||
3. Left/Right arrow scroll 1 column. Use <, > to scroll in larger
|
||||
chunks.
|
||||
|
||||
Changes since 4.6
|
||||
0. Various cleanups and other improvements
|
||||
1. Binary mode displays byte offset
|
||||
2. Ported to DJGPP
|
||||
|
||||
Changes since 4.5
|
||||
1. Many changes to enable MOST use the S-Lang screen management routines.
|
||||
|
||||
Features in 4.5
|
||||
1. More cleanup/bug fixes
|
||||
2. Regular expression searches
|
||||
3. Automatic detection of compressed files.
|
||||
|
||||
Features in 4.41:
|
||||
1. Modified to read raw directry file in BINARY mode.
|
||||
|
||||
New features in MOST 4.4:
|
||||
|
||||
1. User definable keymaps
|
||||
2. ISO Latin1 8 bit clean
|
||||
3. Edit and recall previous search strings
|
||||
4. Much friendlier, lots of messages and help
|
||||
5. VMS ``Gopher ready''
|
||||
6. Cleaned up alot and small bugs fixed
|
||||
7. Most now re-reads the file after editing.
|
||||
|
||||
New Features since MOST version 3.x (Sept 25, 1994)
|
||||
|
||||
1. Terminfo/termcap under Unix supported
|
||||
2. -1 flag specifies terminal is a VT100 and not anything better, e.g.,
|
||||
VT102. (VMS only)
|
||||
3. MOST will only read in what it has to. This means it starts up alot
|
||||
faster on large files.
|
||||
4. Cleaned up alot.
|
||||
|
||||
John E. Davis
|
||||
davis@space.mit.edu
|
||||
|
||||
}}}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,59 @@
|
|||
% This is an example configuration file that provides a `less' emulation
|
||||
% for MOST.
|
||||
%
|
||||
% The format is simple:
|
||||
% setkey <function-name> <key-name>
|
||||
% unsetkey <key-name>
|
||||
% color <object-name> <fg> <bg>
|
||||
%
|
||||
% Here <key-name> must be enclosed in double quotes. '^' represents Ctrl.
|
||||
% The function name is not in double quotes.
|
||||
%
|
||||
%
|
||||
% When MOST starts up, it looks for a keymap file given by the environment
|
||||
% variable MOST_INITFILE. If that environment variable does not exist,
|
||||
% MOST will look in the users HOME directory for .mostrc on Unix systems
|
||||
% and MOST.RC on VMS systems.
|
||||
%
|
||||
% The file `most.rc' contains a listing of the default MOST keybindings.
|
||||
|
||||
% Color settings
|
||||
|
||||
color normal lightgray black
|
||||
color status yellow blue
|
||||
color underline brightgreen black
|
||||
color overstrike brightred black
|
||||
|
||||
% Keybindings
|
||||
|
||||
unsetkey "^K"
|
||||
setkey up "^K"
|
||||
|
||||
unsetkey ":"
|
||||
setkey next_file ":n"
|
||||
setkey find_file ":e"
|
||||
setkey next_file ":p"
|
||||
setkey toggle_options ":o"
|
||||
setkey toggle_case ":c"
|
||||
setkey delete_file ":d"
|
||||
setkey exit ":q"
|
||||
|
||||
setkey down "e"
|
||||
setkey down "E"
|
||||
setkey down "j"
|
||||
setkey down "^N"
|
||||
setkey up "y"
|
||||
setkey up "^Y"
|
||||
setkey up "k"
|
||||
setkey up "^P"
|
||||
setkey page_down "f"
|
||||
setkey page_down "^F"
|
||||
setkey page_up "b"
|
||||
setkey page_up "^B"
|
||||
setkey other_window "z"
|
||||
setkey other_window "w"
|
||||
setkey search_backward "?"
|
||||
setkey bob "p"
|
||||
setkey goto_mark "'"
|
||||
setkey find_file "E"
|
||||
setkey edit "v"
|
|
@ -0,0 +1,45 @@
|
|||
The following functions may be used in custom keymaps:
|
||||
|
||||
edit
|
||||
suspend
|
||||
toggle_lock
|
||||
next_file
|
||||
toggle_options
|
||||
extended_key
|
||||
toggle_case
|
||||
delete_file
|
||||
bob
|
||||
delete_window
|
||||
digit_arg
|
||||
down
|
||||
edt_backward
|
||||
edt_find
|
||||
edt_find_next
|
||||
edt_forward
|
||||
edt_line
|
||||
edt_page
|
||||
eob
|
||||
exit
|
||||
find_file
|
||||
find_next
|
||||
goto_line
|
||||
goto_mark
|
||||
goto_percent
|
||||
help
|
||||
one_window
|
||||
other_window
|
||||
page_down
|
||||
page_left
|
||||
page_right
|
||||
column_right
|
||||
column_left
|
||||
page_up
|
||||
redraw
|
||||
search_backward
|
||||
search_forward
|
||||
set_mark
|
||||
show_time
|
||||
tail_mode
|
||||
toggle_width
|
||||
two_windows
|
||||
up
|
|
@ -0,0 +1,432 @@
|
|||
.\" This manpage has been automatically generated by docbook2man
|
||||
.\" from a DocBook document. This tool can be found at:
|
||||
.\" <http://shell.ipoline.com/~elmert/comp/docbook2X/>
|
||||
.\" Please send any bug reports, improvements, comments, patches,
|
||||
.\" etc. to Steve Cheng <steve@ggi-project.org>.
|
||||
.TH "MOST" "1" "17 February 2019" "" ""
|
||||
|
||||
.SH NAME
|
||||
most \- browse or page through a text file
|
||||
.SH SYNOPSIS
|
||||
|
||||
\fBmost\fR [ \fB-1\fR ] [ \fB-b\fR ] [ \fB-C\fR ] [ \fB-c\fR ] [ \fB-d\fR ] [ \fB-M\fR ] [ \fB-r\fR ] [ \fB-s\fR ] [ \fB-t\fR ] [ \fB-u\fR ] [ \fB-v\fR ] [ \fB-w\fR ] [ \fB-z\fR ] [ \fB+/\fIstring\fB\fR ] [ \fB+\fIline-number\fB\fR ] [ \fB+d\fR ] [ \fB+s\fR ] [ \fB+u\fR ] [ \fB\fIfile...\fB\fR ]
|
||||
|
||||
.SH "DESCRIPTION"
|
||||
.PP
|
||||
\fBmost\fR is a paging program that displays, one windowful at a time,
|
||||
the contents of a file on a terminal. It pauses after each
|
||||
windowful and prints on the window status line the screen the file
|
||||
name, current line number, and the percentage of the file so far
|
||||
displayed.
|
||||
.PP
|
||||
Unlike other paging programs, \fBmost\fR is capable of displaying an
|
||||
arbitrary number of windows as long as each window occupies at least
|
||||
two screen lines. Each window may contain the same file or a
|
||||
different file. In addition, each window has its own mode. For
|
||||
example, one window may display a file with its lines wrapped while
|
||||
another may be truncating the lines. Windows may be `locked'
|
||||
together in the sense that if one of the locked windows scrolls, all
|
||||
locked windows will scroll. \fBmost\fR is also capable of ignoring lines
|
||||
that are indented beyond a user specified value. This is useful
|
||||
when viewing computer programs to pick out gross features of the
|
||||
code. See the `:o' command for a description of this feature.
|
||||
.PP
|
||||
In addition to displaying ordinary text files, \fBmost\fR can also
|
||||
display binary files as well as files with arbitrary ascii
|
||||
characters. When a file is read into a buffer, \fBmost\fR examines the
|
||||
first 32 bytes of the file to determine if the file is a binary file
|
||||
and then switches to the appropriate mode. However, this feature
|
||||
may be disabled with the -k option. See the description of the -b,
|
||||
-k, -v, and -t options for further details.
|
||||
.PP
|
||||
Text files may contain combinations of underscore and backspace
|
||||
characters causing a printer to underline or overstrike. When \fBmost\fR
|
||||
recognizes this, it inserts the appropriate escape sequences to
|
||||
achieve the desired effect. In addition, some files cause the
|
||||
printer to overstrike some characters by embedding carriage return
|
||||
characters in the middle of a line. When this occurs, \fBmost\fR displays
|
||||
the overstruck character with a bold attribute. This feature
|
||||
facilitates the reading of UNIX man pages or a document produced by
|
||||
runoff. In particular, viewing this document with \fBmost\fR should
|
||||
illustrate this behavior provided that the underline characters
|
||||
have not been stripped. This may be turned off with the -v option.
|
||||
.PP
|
||||
By default, lines with more characters than the terminal width are
|
||||
not wrapped but are instead truncated. When truncation occurs, this
|
||||
is indicated by a `$' in the far right column of the terminal
|
||||
screen. The RIGHT and LEFT arrow keys may be used to view lines
|
||||
which extend past the margins of the screen. The -w option may be
|
||||
used to override this feature. When a window is wrapped, the
|
||||
character `\\' will appear at the right edge of the window.
|
||||
.PP
|
||||
Commands are listed below.
|
||||
.SH "OPTIONS"
|
||||
.TP
|
||||
\fB-1\fR
|
||||
VT100 mode. This is meaningful only
|
||||
on VMS systems. This option should be used if the terminal is
|
||||
strictly a VT100. This implies that the terminal does not have the
|
||||
ability to delete and insert multiple lines. VT102s and above have
|
||||
this ability.
|
||||
.TP
|
||||
\fB-b\fR
|
||||
Binary mode. Use this switch when
|
||||
you want to view files containing 8 bit characters. \fBmost\fR will
|
||||
display the file 16 bytes per line in hexadecimal notation. A
|
||||
typical line looks like:
|
||||
|
||||
.nf
|
||||
01000000 40001575 9C23A020 4000168D ....@..u.#. @...
|
||||
.fi
|
||||
|
||||
When used with the -v option, the same line looks like:
|
||||
|
||||
.nf
|
||||
^A^@^@^@ @^@^U u 9C #A0 @^@^V8D ....@..u.#. @...
|
||||
.fi
|
||||
.TP
|
||||
\fB-C\fR
|
||||
Disable color support.
|
||||
.TP
|
||||
\fB-c\fR
|
||||
Make searches case-sensitive
|
||||
.TP
|
||||
\fB-d\fR
|
||||
Omit the backslash mark used to denote a wrapped line.
|
||||
.TP
|
||||
\fB-M\fR
|
||||
Disable the use of mmap.
|
||||
.TP
|
||||
\fB-r\fR
|
||||
Default to using regexp searches
|
||||
.TP
|
||||
\fB-s\fR
|
||||
Squeeze-mode. Replace multiple blank
|
||||
lines with a single blank line.
|
||||
.TP
|
||||
\fB-t\fR
|
||||
Display tabs as ^I. If this option
|
||||
is immediately followed by an integer, the integer sets the tab
|
||||
width, e.g., -t4
|
||||
.TP
|
||||
\fB-u\fR
|
||||
Disable UTF-8 mode even if the
|
||||
locale dictates it
|
||||
.TP
|
||||
\fB+u\fR
|
||||
Force UTF-8 mode. By default \fBmost\fR
|
||||
will use the current locale to determine if UTF-8 mode should be
|
||||
used. The +u and -u switches allow the behavior to be overridden
|
||||
.TP
|
||||
\fB-v\fR
|
||||
Display control characters as in
|
||||
`^A' for control A. Normally \fBmost\fR does not interpret control
|
||||
characters.
|
||||
.TP
|
||||
\fB-w\fR
|
||||
Wrap lines
|
||||
.TP
|
||||
\fB-z\fR
|
||||
Disable gunzip-on-the-fly
|
||||
.TP
|
||||
\fB+/\fIstring\fB\fR
|
||||
Start up at the
|
||||
line containing the first occurrence of string
|
||||
.TP
|
||||
\fB+\fIlineno\fB\fR
|
||||
Start up at the
|
||||
specified line-number
|
||||
.TP
|
||||
\fB+d\fR
|
||||
This switch should only be used if
|
||||
you want the option to delete a file while viewing it. This makes
|
||||
it easier to clean unwanted files out of a directory. The file is
|
||||
deleted with the interactive key sequence `:D' and then confirming
|
||||
with `y'.
|
||||
.TP
|
||||
\fB+s\fR
|
||||
Secure Mode-- no edit, cd, shell,
|
||||
and reading files not already listed on the command line.
|
||||
.SH "COMMAND USAGE"
|
||||
.PP
|
||||
The commands take effect immediately; it is not necessary to type a
|
||||
carriage return. In the following commands, \fBi\fR is a numerical
|
||||
argument (1 by default).
|
||||
.TP
|
||||
\fBSPACE, CTRL-D, NEXT_SCREEN\fR
|
||||
Display another windowful, or jump \fBi\fR windowfuls if \fBi\fR is specified.
|
||||
.TP
|
||||
\fBRETURN, DOWN_ARROW, V, CTRL-N\fR
|
||||
Display another line, or \fBi\fR more lines, if specified.
|
||||
.TP
|
||||
\fBUP_ARROW, ^, CTRL-P\fR
|
||||
Display previous line, or \fBi\fR previous
|
||||
lines, if specified.
|
||||
.TP
|
||||
\fBT, ESCAPE<\fR
|
||||
Move to top of buffer.
|
||||
.TP
|
||||
\fBB, ESCAPE>\fR
|
||||
Move to bottom of buffer.
|
||||
.TP
|
||||
\fBRIGHT_ARROW, TAB, >\fR
|
||||
Scroll window left 60\fBi\fR columns to view
|
||||
lines that are beyond the right margin of the window.
|
||||
.TP
|
||||
\fBLEFT_ARROW, CTRL-B, <\fR
|
||||
Scroll window right 60\fBi\fR columns to
|
||||
view lines that are beyond the left margin of the window.
|
||||
.TP
|
||||
\fBU, CTRL-U, DELETE, PREV_SCREEN\fR
|
||||
Skip back \fBi\fR windowfuls and
|
||||
then print a windowful.
|
||||
.TP
|
||||
\fBR, CTRL-R\fR
|
||||
Redraw the window.
|
||||
.TP
|
||||
\fBJ, G\fR
|
||||
If \fBi\fR is not specified, then prompt for a line
|
||||
number then jump to that line otherwise just jump to line i.
|
||||
.TP
|
||||
\fB%\fR
|
||||
If \fBi\fR is not specified, then prompt for a percent number
|
||||
then jump to that percent of the file otherwise just jump to \fBi\fR percent
|
||||
of the file.
|
||||
.TP
|
||||
\fBW, w\fR
|
||||
If the current screen width is 80, make it 132 and
|
||||
vice-versa. For other values, this command is ignored.
|
||||
.TP
|
||||
\fBQ, CTRL-X CTRL-C, CTRL-K E\fR
|
||||
Exit from \fBmost\fR\&. On VMS, ^Z also
|
||||
exits.
|
||||
.TP
|
||||
\fBh, CTRL-H, HELP, PF2\fR
|
||||
Help. Give a description of all the
|
||||
\fBmost\fR commands. The \fBmost\fR environment variable MOST_HELP must be set
|
||||
for this to be meaningful.
|
||||
.TP
|
||||
\fBf, /, CTRL-F, FIND, GOLD PF3\fR
|
||||
Prompt for a string and
|
||||
search forward from the current line for ith distinct line containing
|
||||
the string. CTRL-G aborts.
|
||||
.TP
|
||||
\fB?\fR
|
||||
Prompt for a string and search backward for the ith
|
||||
distinct line containing the string. CTRL-G aborts.
|
||||
.TP
|
||||
\fBn\fR
|
||||
Search for the next \fBi\fR lines containing an occurrence of
|
||||
the last search string in the direction of the previous search.
|
||||
.TP
|
||||
\fBm, SELECT, CTRL-@, CTRL-K M, PERIOD\fR
|
||||
Set a mark on the
|
||||
current line for later reference.
|
||||
.TP
|
||||
\fBINSERT_HERE, CTRL-X CTRL-X, COMMA, CTRL-K RETURN, GOLD PERIOD\fR
|
||||
Set a mark on the current line but return to previous mark.
|
||||
This allows the user to toggle back and forth between two positions in
|
||||
the file.
|
||||
.TP
|
||||
\fBl, L\fR
|
||||
Toggle locking for this window. The window is locked
|
||||
if there is a `*' at the left edge of the status line. Windows locked
|
||||
together, scroll together.
|
||||
.TP
|
||||
\fBCTRL-X 2, CTRL-W 2, GOLD X\fR
|
||||
Split this window in half.
|
||||
.TP
|
||||
\fBCTRL-X o, CTRL-W o, o, GOLDUP, GOLDDOWN\fR
|
||||
Move to other window.
|
||||
.TP
|
||||
\fBCTRL-X 0, CTRL-W 0, GOLD V\fR
|
||||
Delete this window.
|
||||
.TP
|
||||
\fBCTRL-X 1, CTRL-W 1, GOLD O\fR
|
||||
Delete all other windows, leaving
|
||||
only one window.
|
||||
.TP
|
||||
\fBE, e\fR
|
||||
Edit this file.
|
||||
.TP
|
||||
\fB$, ESC $\fR
|
||||
This is system dependent. On VMS, this causes \fBmost\fR
|
||||
to spawn a subprocess. When the user exits the process, \fBmost\fR is
|
||||
resumed. On UNIX systems, \fBmost\fR simply suspends itself.
|
||||
.TP
|
||||
\fB:n\fR
|
||||
Skip to the next filename given in the command line. Use
|
||||
the arrow keys to scroll forward or backward through the file list.
|
||||
`Q' quits \fBmost\fR and any other key selects the given file.
|
||||
.TP
|
||||
\fB:c\fR
|
||||
Toggle case sensitive search.
|
||||
.TP
|
||||
\fB:D\fR
|
||||
Delete current file. This command is only meaningful
|
||||
with the +d switch.
|
||||
.TP
|
||||
\fB:o, :O\fR
|
||||
Toggle various options. With this key sequence, \fBmost\fR
|
||||
displays a prompt asking the user to hit one of: bdtvw. The `b', `t',
|
||||
`v', and `w' options have the same meaning as the command line
|
||||
switches. For example, the `w' option will toggle wrapping on and off
|
||||
for the current window.
|
||||
|
||||
The `d' option must be used with a prefix integer i. All lines
|
||||
indented beyond \fBi\fR columns will not be displayed. For example,
|
||||
consider the fragment:
|
||||
.TP
|
||||
\fB\fR
|
||||
|
||||
.nf
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < argc, i++)
|
||||
{
|
||||
fprintf(stdout,"%i: %s\\n",i,argv[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
.fi
|
||||
The key sequence `1:od' will cause \fBmost\fR to display the file ignoring
|
||||
all lines indented beyond the first column. So for the example above,
|
||||
\fBmost\fR would display:
|
||||
|
||||
.nf
|
||||
int main(int argc, char **argv)...
|
||||
}
|
||||
.fi
|
||||
where the `...' indicates lines that follow are not displayed.
|
||||
.SH "HINTS"
|
||||
.PP
|
||||
CTRL-G aborts the commands requiring the user to type something in
|
||||
at a prompt. The back-quote key has a special meaning here. It is
|
||||
used to quote certain characters. This is useful when search for
|
||||
the occurrence of a string with a control character or a string at
|
||||
the beginning of a line. In the latter case, to find the occurrence
|
||||
of `The' at the beginning of a line, enter `^JThe where ` quotes the
|
||||
CTRL-J.
|
||||
.SH "ENVIRONMENT"
|
||||
.PP
|
||||
\fBmost\fR uses the following environment variables:
|
||||
.TP
|
||||
\fBMOST_SWITCHES\fR
|
||||
This variable sets commonly used switches.
|
||||
For example, some people prefer to use \fBmost\fR with the -s option so that
|
||||
excess blank lines are not displayed. On VMS this is normally done
|
||||
done in the login.com through the line:
|
||||
.TP
|
||||
\fB\fR
|
||||
|
||||
.nf
|
||||
$ define MOST_SWITCHES "-s"
|
||||
.fi
|
||||
.TP
|
||||
\fBMOST_EDITOR, SLANG_EDITOR\fR
|
||||
Either of these environment
|
||||
variables specify an editor for \fBmost\fR to invoke to edit a file. The
|
||||
value can contain %s and %d formatting descriptors that represent the
|
||||
file name and line number, respectively. For example, if JED is
|
||||
your editor, then set MOST_EDITOR to 'jed %s -g %d'.
|
||||
.TP
|
||||
\fBMOST_HELP\fR
|
||||
This variable may be used to specify an alternate
|
||||
help file.
|
||||
.TP
|
||||
\fBMOST_INITFILE\fR
|
||||
Set this variable to specify the
|
||||
initialization file to load during startup. The default action is to
|
||||
load the system configuration file and then a personal configuration
|
||||
file called .mostrc on Unix, and most.rc on other systems.
|
||||
.SH "CONFIGURATION FILE SYNTAX"
|
||||
.PP
|
||||
When \fBmost\fR starts up, it tries to read a system configuration file and
|
||||
then a personal configuration file. These files may be used to specify
|
||||
key-bindings and colors.
|
||||
.PP
|
||||
To bind a key to a particular function use the syntax:
|
||||
|
||||
.nf
|
||||
setkey function-name key-sequence
|
||||
.fi
|
||||
.PP
|
||||
The setkey command requires two arguments. The function-name argument
|
||||
specifies the function that is to be executed as a response to the
|
||||
keys specified by the key-sequence argument are pressed. For example,
|
||||
|
||||
.nf
|
||||
setkey "up" "^P"
|
||||
.fi
|
||||
.PP
|
||||
indicates that when Ctrl-P is pressed then the function up is to be executed.
|
||||
.PP
|
||||
Sometimes, it is necessary to first unbind a key-sequence before
|
||||
rebinding it in order via the unsetkey function:
|
||||
|
||||
.nf
|
||||
unsetkey "^F"
|
||||
.fi
|
||||
.PP
|
||||
Colors may be defined through the use of the color keyword in the the
|
||||
configuration file using the syntax:
|
||||
|
||||
.nf
|
||||
color OBJECT-NAME FOREGROUND-COLOR BACKGROUND-COLOR
|
||||
.fi
|
||||
.PP
|
||||
Here, OBJECT-NAME can be any one of the following items:
|
||||
|
||||
.nf
|
||||
status -- the status line
|
||||
underline -- underlined text
|
||||
overstrike -- overstruck text
|
||||
normal -- anything else
|
||||
.fi
|
||||
.PP
|
||||
See the sample configuration files for more information.
|
||||
.SH "BUGS"
|
||||
.PP
|
||||
Almost all of the known bugs or limitations of \fBmost\fR are due to a
|
||||
desire to read and interpret control characters in files. One
|
||||
problem concerns the use of backspace characters to underscore or
|
||||
overstrike other characters. \fBmost\fR makes an attempt to use terminal
|
||||
escape sequences to simulate this behavior. One side effect is the
|
||||
one does not always get what one expects when scrolling right and left
|
||||
through a file. When in doubt, use the -v and -b options of \fBmost\fR\&.
|
||||
.PP
|
||||
The regular-expression searches may fail to find strings that involve
|
||||
backspace/underscore used for highlighting. The regular-expression
|
||||
syntax is described in the S-Lang Library documentation.
|
||||
.SH "AUTHOR"
|
||||
.PP
|
||||
John E. Davis <jed@jedsoft.org>
|
||||
.SH "ACKNOWLEDGEMENTS"
|
||||
.PP
|
||||
Over the years, many people have contributed to \fBmost\fR in one way or
|
||||
another, e.g., via code patches, bug-fixes, comments, or criticisms.
|
||||
I am particularly grateful to the very early adopters of the program
|
||||
who took a chance with a fledgling software project headed by someone
|
||||
learning the underlying language. These include:
|
||||
.PP
|
||||
Mats Akerberg, Henk D. Davids, Rex O. Livingston, and Mark Pizzolato
|
||||
contributed to the early VMS versions of \fBmost\fR\&. In particular, Mark
|
||||
worked on it to get it ready for DECUS.
|
||||
.PP
|
||||
Foteos Macrides adapted \fBmost\fR for use in cswing and gopher. A few
|
||||
features of the present version of \fBmost\fR was inspired from his work.
|
||||
.PP
|
||||
I am grateful to Robert Mills for re-writing the search routines to
|
||||
use regular expressions.
|
||||
.PP
|
||||
Sven Oliver Moll came up with the idea of automatic detection of
|
||||
zipped files.
|
||||
.PP
|
||||
I would also like to thank Shinichi Hama for his valuable criticisms
|
||||
of \fBmost\fR\&.
|
||||
.PP
|
||||
Javier Kohen was instrumental in the support for UTF-8.
|
||||
.PP
|
||||
Thanks to David W. Sanderson for adapting the early documentation to
|
||||
nroff man page source format.
|
|
@ -0,0 +1,347 @@
|
|||
1 MOST
|
||||
browse or page through a text file
|
||||
|
||||
2 Synopsis
|
||||
most [-Cbstvwz] [+lineno] [+c] [+d] [+/string] [filename...]
|
||||
|
||||
2 Description
|
||||
most is a paging program that displays, one windowful at a time, the
|
||||
contents of a file on a terminal. It pauses after each windowful and
|
||||
prints on the window status line the screen the file name, current
|
||||
line number, and the percentage of the file so far displayed.
|
||||
|
||||
Unlike other paging programs, most is capable of displaying an
|
||||
arbitrary number of windows as long as each window occupies at least
|
||||
two screen lines. Each window may contain the same file or a
|
||||
different file. In addition, each window has its own mode. For
|
||||
example, one window may display a file with its lines wrapped while
|
||||
another may be truncating the lines. Windows may be `locked' together
|
||||
in the sense that if one of the locked windows scrolls, all locked
|
||||
windows will scroll. most is also capable of ignoring lines that are
|
||||
indented beyond a user specified value. This is useful when viewing
|
||||
computer programs to pick out gross features of the code. See the
|
||||
`:o' command for a description of this feature.
|
||||
|
||||
In addition to displaying ordinary text files, most can also display
|
||||
binary files as well as files with arbitrary ascii characters. When a
|
||||
file is read into a buffer, most examines the first 32 bytes of the
|
||||
file to determine if the file is a binary file and then switches to
|
||||
the appropriate mode. However, this feature may be disabled with the
|
||||
-k option. See the description of the -b, -k, -v, and -t options for
|
||||
further details.
|
||||
|
||||
Text files may contain combinations of underscore and backspace
|
||||
characters causing a printer to underline or overstrike. When most
|
||||
recognizes this, it inserts the appropriate escape sequences to
|
||||
achieve the desired effect. In addition, some files cause the printer
|
||||
to overstrike some characters by embedding carriage return characters
|
||||
in the middle of a line. When this occurs, most displays the
|
||||
overstruck character with a bold attribute. This feature facilitates
|
||||
the reading of UNIX man pages or a document produced by runoff. In
|
||||
particular, viewing this document with most should illustrate this
|
||||
behavior provided that the underline characters have not been
|
||||
stripped. This may be turned off with the -v option.
|
||||
|
||||
By default, lines with more characters than the terminal width are not
|
||||
wrapped but are instead truncated. When truncation occurs, this is
|
||||
indicated by a `$' in the far right column of the terminal screen.
|
||||
The RIGHT and LEFT arrow keys may be used to view lines which extend
|
||||
past the margins of the screen. The -w option may be used to override
|
||||
this feature. When a window is wrapped, the character `\' will appear
|
||||
at the right edge of the window.
|
||||
|
||||
Commands are listed below.
|
||||
|
||||
2 Options
|
||||
|
||||
-1 VT100 mode. This is meaningful only on VMS systems. This option
|
||||
should be used if the terminal is strictly a VT100. This implies
|
||||
that the terminal does not have the ability to delete and insert
|
||||
multiple lines. VT102s and above have this ability.
|
||||
|
||||
-b Binary mode. Use this switch when you want to view files
|
||||
containing 8 bit characters. most will display the file 16 bytes
|
||||
per line in hexidecimal notation. A typical line looks like:
|
||||
|
||||
|
||||
01000000 40001575 9C23A020 4000168D ....@..u.#. @...
|
||||
|
||||
When used with the -v option, the same line looks like:
|
||||
|
||||
|
||||
^A^@^@^@ @^@^U u 9C #A0 @^@^V8D ....@..u.#. @...
|
||||
|
||||
-k `Kanji' option. Ordinarily, most will go into binary mode if the
|
||||
file consists of non-ascii characters. Sometimes this feature is
|
||||
not desirable since some terminals have a special interpretation
|
||||
for eight bit characters. The -k option turns off the automatic
|
||||
sensing.
|
||||
|
||||
-C Disable color support.
|
||||
|
||||
-s Squeeze. Replace multiple blank lines with a single blank line.
|
||||
|
||||
-z option turns off gunzip-on-the-fly.
|
||||
|
||||
-v Display control characters as in `^A' for control A. Normally
|
||||
most does not interpret control characters.
|
||||
|
||||
-t Display tabs as `^I'. This option is meaningful only when used
|
||||
with the -v option. +lineno Start up at lineno.
|
||||
|
||||
+c Make search case sensitive. By default, they are not.
|
||||
|
||||
+d This switch should only be used if you want the option to delete
|
||||
a file while viewing it. This makes it easier to clean unwanted
|
||||
files out of a directory. The file is deleted with the
|
||||
interactive key sequence `:D' and then confirming with `y'.
|
||||
|
||||
+/string
|
||||
Start up at the line containing the first occurrence of string.
|
||||
|
||||
2 Command_usage
|
||||
The commands take effect immediately; it is not necessary to type a
|
||||
carriage return.
|
||||
|
||||
In the following commands, i is a numerical argument (1 by default).
|
||||
|
||||
SPACE, CTRL-D, NEXT_SCREEN
|
||||
Display another windowful, or jump i windowfuls if i is specified.
|
||||
|
||||
RETURN, DOWN_ARROW, V, CTRL-N
|
||||
Display another line, or i more lines, if specified.
|
||||
|
||||
UP_ARROW, ^, CTRL-P
|
||||
Display previous line, or i previous lines, if specified.
|
||||
|
||||
T, ESCAPE<
|
||||
Move to top of buffer.
|
||||
|
||||
B, ESCAPE>
|
||||
Move to bottom of buffer.
|
||||
|
||||
RIGHT_ARROW, TAB, >
|
||||
Scroll window left 60i columns to view lines that are beyond the
|
||||
right margin of the window.
|
||||
|
||||
LEFT_ARROW, CTRL-B, <
|
||||
Scroll window right 60i columns to view lines that are beyond the
|
||||
left margin of the window.
|
||||
|
||||
U, CTRL-U, DELETE, PREV_SCREEN
|
||||
Skip back i windowfuls and then print a windowful.
|
||||
|
||||
R, CTRL-R
|
||||
Redraw the window.
|
||||
|
||||
J, G If i is not specified, then prompt for a line number then jump to
|
||||
that line otherwise just jump to line i.
|
||||
|
||||
% If i is not specified, then prompt for a percent number then jump
|
||||
to that percent of the file otherwise just jump to i percent of
|
||||
the file.
|
||||
|
||||
W, w If the current screen width is 80, make it 132 and vice-versa.
|
||||
For other values, this command is ignored.
|
||||
|
||||
Q, CTRL-X CTRL-C, CTRL-K E
|
||||
Exit from most. On VMS, ^Z also exits.
|
||||
|
||||
h, CTRL-H, HELP,
|
||||
Help. Give a description of all the most commands. The most
|
||||
environment variable MOST_HELP must be set for this to be
|
||||
meaningful.
|
||||
|
||||
f, /, CTRL-F, FIND, GOLD PF3
|
||||
Prompt for a string and search forward from the current line for
|
||||
ith distinct line containing the string. CTRL-G aborts.
|
||||
|
||||
? Prompt for a string and search backward for the ith distinct line
|
||||
containing the string. CTRL-G aborts.
|
||||
|
||||
n Search for the next i lines containing an occurrence of the last
|
||||
search string in the direction of the previous search.
|
||||
|
||||
m, SELECT, CTRL-@, CTRL-K M, PERIOD
|
||||
Set a mark on the current line for later reference.
|
||||
|
||||
INSERT_HERE, CTRL-X CTRL-X, COMMA, CTRL-K RETURN, GOLD PERIOD
|
||||
Set a mark on the current line but return to previous mark. This
|
||||
allows the user to toggle back and forth between two positions in
|
||||
the file.
|
||||
|
||||
l, L Toggle locking for this window. The window is locked if there is
|
||||
a `*' at the left edge of the status line. Windows locked
|
||||
together, scroll together.
|
||||
|
||||
CTRL-X 2, CTRL-W 2, GOLD X
|
||||
Split this window in half.
|
||||
|
||||
CTRL-X o, CTRL-W o, o,
|
||||
Move to other window.
|
||||
|
||||
CTRL-X 0, CTRL-W 0, GOLD V
|
||||
Delete this window.
|
||||
|
||||
CTRL-X 1, CTRL-W 1, GOLD O
|
||||
Delete all other windows, leaving only one window.
|
||||
|
||||
E, e Edit this file.
|
||||
|
||||
$, ESC $
|
||||
This is system dependent. On VMS, this causes most to spawn a
|
||||
subprocess. When the user exits the process, most is resumed.
|
||||
On UNIX systems, most simply suspends itself.
|
||||
|
||||
:n Skip to the next filename given in the command line. Use the
|
||||
arrow keys to scroll forward or backward through the file list.
|
||||
`Q' quits most and any other key selects the given file.
|
||||
|
||||
:c Toggle case sensitive search.
|
||||
|
||||
:D Delete current file. This command is only meaningful with the +d
|
||||
switch.
|
||||
|
||||
:o, :O
|
||||
Toggle various options. With this key sequence, most displays a
|
||||
prompt asking the user to hit one of: bdtvw. The `b', `t', `v',
|
||||
and `w' options have the same meaning as the command line
|
||||
switches. For example, the `w' option will toggle wrapping on
|
||||
and off for the current window.
|
||||
|
||||
The `d' option must be used with a prefix integer i. All lines
|
||||
indented beyond i columns will not be displayed. For example,
|
||||
consider the fragment:
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < argc, i++)
|
||||
{
|
||||
fprintf(stdout,"%i: %s\n",i,argv[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
The key sequence `1:od' will cause most to display the file
|
||||
ignoring all lines indented beyond the first column. So for the
|
||||
example above, most would display:
|
||||
|
||||
|
||||
int main(int argc, char **argv)...
|
||||
}
|
||||
|
||||
where the `...' indicates lines follow are not displayed.
|
||||
|
||||
2 Hints
|
||||
CTRL-G aborts the commands requiring the user to type something in at
|
||||
a prompt. The backquote key has a special meaning here. It is used
|
||||
to quote certain characters. This is useful when search for the
|
||||
occurrence of a string with a control character or a string at the
|
||||
beginning of a line. In the latter case, to find the occurrence of
|
||||
`The' at the beginning of a line, enter `^JThe where ` quotes the
|
||||
CTRL-J.
|
||||
|
||||
2 Environment
|
||||
most uses the following environment variables:
|
||||
|
||||
MOST_SWITCHES
|
||||
This variable sets commonly used switches. For example, some
|
||||
people prefer to use most with the -s option so that excess blank
|
||||
lines are not displayed. On VMS this is normally done done in
|
||||
the login.com through the line:
|
||||
|
||||
$ define MOST_SWITCHES "-s"
|
||||
|
||||
MOST_EDITOR, SLANG_EDITOR
|
||||
Either of these environment variables specify an editor for most
|
||||
to invoke to edit a file. The value can contain %s and %d
|
||||
formatting descriptors that represent the file name and line
|
||||
number, respectively. For example, if JED is your editor, then
|
||||
set MOST_EDITOR to 'jed %s -g %d'.
|
||||
|
||||
MOST_HELP
|
||||
This variable may be used to specify an alternate help file.
|
||||
|
||||
MOST_INITFILE
|
||||
Set this variable to specify the initialization file to load
|
||||
during startup. The default action is to load the system
|
||||
configuration file and then a personal configuration file called
|
||||
.mostrc on Unix, and most.rc on other systems.
|
||||
|
||||
2 Configuration_file_syntax
|
||||
When most starts up, it tries to read a system confiuration file and
|
||||
then a personal configuration file. These files may be used to
|
||||
specify keybind ings and colors.
|
||||
|
||||
To bind a key to a particular function use the syntax:
|
||||
|
||||
setkey function-name key-sequence
|
||||
|
||||
The setkey command requires two arguments. The function-name argument
|
||||
specifies the function that is to be executed as a response to the
|
||||
keys specified by the key-sequence argument are pressed. For example,
|
||||
|
||||
setkey "up" "^P"
|
||||
|
||||
indicates that when Ctrl-P is pressed then the function up is to be
|
||||
executed.
|
||||
|
||||
Sometimes, it is necessary to first unbind a key-sequence before
|
||||
rebinding it in order via the unsetkey function:
|
||||
|
||||
unsetkey "^F"
|
||||
|
||||
Colors may be defined through the use of the color keyword in the the
|
||||
configuration file using the syntax:
|
||||
|
||||
color OBJECT-NAME FOREGROUND-COLOR BACKGROUND-COLOR
|
||||
|
||||
Here, OBJECT-NAME can be any one of the following items:
|
||||
|
||||
status -- the status line
|
||||
underline -- underlined text
|
||||
overstrike -- overstriked text
|
||||
normal -- anything else
|
||||
|
||||
See the sample configuration files for more information.
|
||||
|
||||
2 Bugs
|
||||
Almost all of the known bugs or limitations of most are due to a
|
||||
desire to read and interpret control characters in files. One problem
|
||||
concerns the use of backspace characters to underscore or overstrike
|
||||
other characters. most makes an attempt to use terminal escape
|
||||
sequences to simulate this behavior. One side effect is the one does
|
||||
not always get what one expects when scrolling right and left through
|
||||
a file. When in doubt, use the -v and -b options of most.
|
||||
|
||||
2 Author
|
||||
John E. Davis
|
||||
davis@space.mit.edu
|
||||
|
||||
2 Acknowledgements
|
||||
I would like to thank the users of most for valuable comments and
|
||||
criticisms. I would especially like to thank those individuals who
|
||||
have contributed code to most.
|
||||
|
||||
Mats Akerberg, Henk D. Davids, Rex O. Livingston, and Mark Pizzolato
|
||||
contributed to the early VMS versions of most. In particular, Mark
|
||||
worked on it to get it ready for DECUS.
|
||||
|
||||
Foteos Macrides <MACRIDES@SCI.WFEB.EDU> adapted most for use in cswing
|
||||
and gopher. A few features of the present version of most was
|
||||
inspired from his work.
|
||||
|
||||
I am grateful to Robert Mills <robert@jna.com.au> for re-writing the
|
||||
search routines to use regular expressions.
|
||||
|
||||
Sven Oliver Moll <smol0075@rz.uni-hildesheim.de> came up with the idea
|
||||
of automatic detection of zipped files.
|
||||
|
||||
I would also like to thank Shinichi Hama for his valuable criticisms
|
||||
of most.
|
||||
|
||||
Thanks to David W. Sanderson (dws@cs.wisc.edu) for adapting the
|
||||
documentation to nroff man page source format.
|
|
@ -0,0 +1,129 @@
|
|||
% Color settings
|
||||
|
||||
color normal lightgray black
|
||||
color status yellow blue
|
||||
color underline brightgreen black
|
||||
color overstrike brightred black
|
||||
|
||||
% Keybindings
|
||||
|
||||
%setkey digit_arg dig
|
||||
%setkey digit_arg esc dig
|
||||
%setkey digit_arg gold dig
|
||||
%setkey column_left < Not Set >
|
||||
%setkey column_right < Not Set >
|
||||
setkey page_down " "
|
||||
setkey suspend "$"
|
||||
setkey goto_percent "%"
|
||||
setkey goto_mark ","
|
||||
setkey search_forward "/"
|
||||
setkey extended_key ":"
|
||||
setkey page_left "<"
|
||||
setkey page_right ">"
|
||||
setkey search_backward "?"
|
||||
setkey eob "B"
|
||||
setkey page_down "D"
|
||||
setkey edit "E"
|
||||
setkey search_forward "F"
|
||||
setkey goto_line "G"
|
||||
setkey help "H"
|
||||
setkey goto_line "J"
|
||||
setkey toggle_lock "L"
|
||||
setkey set_mark "M"
|
||||
setkey find_next "N"
|
||||
setkey other_window "O"
|
||||
setkey exit "Q"
|
||||
setkey redraw "R"
|
||||
setkey search_forward "S"
|
||||
setkey bob "T"
|
||||
setkey page_up "U"
|
||||
setkey down "V"
|
||||
setkey toggle_width "W"
|
||||
setkey exit "X"
|
||||
setkey suspend "\033$"
|
||||
setkey bob "\033<"
|
||||
setkey eob "\033>"
|
||||
setkey up "\033OA"
|
||||
setkey down "\033OB"
|
||||
setkey page_right "\033OC"
|
||||
setkey page_left "\033OD"
|
||||
setkey exit "\033OPE"
|
||||
setkey one_window "\033OPO"
|
||||
setkey exit "\033OPQ"
|
||||
setkey suspend "\033OPS"
|
||||
setkey delete_window "\033OPV"
|
||||
setkey two_windows "\033OPX"
|
||||
setkey edt_find "\033OP\033OR"
|
||||
setkey goto_mark "\033OP\033On"
|
||||
setkey eob "\033OP\033Ot"
|
||||
setkey bob "\033OP\033Ou"
|
||||
setkey other_window "\033OP\033[A"
|
||||
setkey other_window "\033OP\033[B"
|
||||
setkey page_right "\033OP\033[C"
|
||||
setkey page_left "\033OP\033[D"
|
||||
setkey help "\033OQ"
|
||||
setkey edt_find_next "\033OR"
|
||||
setkey set_mark "\033On"
|
||||
setkey edt_line "\033Op"
|
||||
setkey edt_forward "\033Ot"
|
||||
setkey edt_backward "\033Ou"
|
||||
setkey edt_page "\033Ox"
|
||||
setkey page_up "\033V"
|
||||
setkey search_forward "\033[1~"
|
||||
setkey goto_mark "\033[2~"
|
||||
setkey help "\033[28~"
|
||||
setkey set_mark "\033[4~"
|
||||
setkey page_up "\033[5~"
|
||||
setkey page_down "\033[6~"
|
||||
setkey up "\033[A"
|
||||
setkey down "\033[B"
|
||||
setkey page_right "\033[C"
|
||||
setkey page_left "\033[D"
|
||||
setkey page_right "\t"
|
||||
setkey up "^"
|
||||
setkey page_up "^?"
|
||||
setkey set_mark "^@"
|
||||
setkey page_down "^D"
|
||||
setkey search_forward "^F"
|
||||
setkey help "^H"
|
||||
setkey exit "^KE"
|
||||
setkey find_file "^KG"
|
||||
setkey set_mark "^K^B"
|
||||
setkey goto_mark "^K^J"
|
||||
setkey goto_mark "^K^M"
|
||||
setkey redraw "^L"
|
||||
setkey down "^M"
|
||||
setkey down "^N"
|
||||
setkey up "^P"
|
||||
setkey redraw "^R"
|
||||
setkey show_time "^T"
|
||||
setkey page_up "^U"
|
||||
setkey page_down "^V"
|
||||
setkey delete_window "^W0"
|
||||
setkey one_window "^W1"
|
||||
setkey two_windows "^W2"
|
||||
setkey other_window "^WO"
|
||||
setkey delete_window "^X0"
|
||||
setkey one_window "^X1"
|
||||
setkey two_windows "^X2"
|
||||
setkey other_window "^XO"
|
||||
setkey exit "^X^C"
|
||||
setkey find_file "^X^F"
|
||||
setkey suspend "^Z"
|
||||
setkey eob "b"
|
||||
setkey page_down "d"
|
||||
setkey edit "e"
|
||||
setkey search_forward "f"
|
||||
setkey goto_line "g"
|
||||
setkey goto_line "j"
|
||||
setkey toggle_lock "l"
|
||||
setkey set_mark "m"
|
||||
setkey find_next "n"
|
||||
setkey other_window "o"
|
||||
setkey exit "q"
|
||||
setkey redraw "r"
|
||||
setkey search_forward "s"
|
||||
setkey bob "t"
|
||||
setkey down "v"
|
||||
setkey toggle_width "w"
|
||||
setkey exit "x"
|
|
@ -0,0 +1,421 @@
|
|||
most
|
||||
|
||||
Name
|
||||
|
||||
most -- browse or page through a text file
|
||||
|
||||
Synopsis
|
||||
|
||||
most [-1] [-b] [-C] [-c] [-d] [-M] [-r] [-s] [-t] [-u] [-v]
|
||||
[-w] [-z] [+/string] [+line-number] [+d] [+s] [+u] [file...]
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
most is a paging program that displays, one windowful at a
|
||||
time, the contents of a file on a terminal. It pauses after
|
||||
each windowful and prints on the window status line the screen
|
||||
the file name, current line number, and the percentage of the
|
||||
file so far displayed.
|
||||
|
||||
Unlike other paging programs, most is capable of displaying an
|
||||
arbitrary number of windows as long as each window occupies at
|
||||
least two screen lines. Each window may contain the same file
|
||||
or a different file. In addition, each window has its own mode.
|
||||
For example, one window may display a file with its lines
|
||||
wrapped while another may be truncating the lines. Windows may
|
||||
be `locked' together in the sense that if one of the locked
|
||||
windows scrolls, all locked windows will scroll. most is also
|
||||
capable of ignoring lines that are indented beyond a user
|
||||
specified value. This is useful when viewing computer programs
|
||||
to pick out gross features of the code. See the `:o' command
|
||||
for a description of this feature.
|
||||
|
||||
In addition to displaying ordinary text files, most can also
|
||||
display binary files as well as files with arbitrary ascii
|
||||
characters. When a file is read into a buffer, most examines
|
||||
the first 32 bytes of the file to determine if the file is a
|
||||
binary file and then switches to the appropriate mode. However,
|
||||
this feature may be disabled with the -k option. See the
|
||||
description of the -b, -k, -v, and -t options for further
|
||||
details.
|
||||
|
||||
Text files may contain combinations of underscore and backspace
|
||||
characters causing a printer to underline or overstrike. When
|
||||
most recognizes this, it inserts the appropriate escape
|
||||
sequences to achieve the desired effect. In addition, some
|
||||
files cause the printer to overstrike some characters by
|
||||
embedding carriage return characters in the middle of a line.
|
||||
When this occurs, most displays the overstruck character with a
|
||||
bold attribute. This feature facilitates the reading of UNIX
|
||||
man pages or a document produced by runoff. In particular,
|
||||
viewing this document with most should illustrate this behavior
|
||||
provided that the underline characters have not been stripped.
|
||||
This may be turned off with the -v option.
|
||||
|
||||
By default, lines with more characters than the terminal width
|
||||
are not wrapped but are instead truncated. When truncation
|
||||
occurs, this is indicated by a `$' in the far right column of
|
||||
the terminal screen. The RIGHT and LEFT arrow keys may be used
|
||||
to view lines which extend past the margins of the screen. The
|
||||
-w option may be used to override this feature. When a window
|
||||
is wrapped, the character `\' will appear at the right edge of
|
||||
the window.
|
||||
|
||||
Commands are listed below.
|
||||
|
||||
OPTIONS
|
||||
|
||||
-1
|
||||
VT100 mode. This is meaningful only on VMS systems. This
|
||||
option should be used if the terminal is strictly a
|
||||
VT100. This implies that the terminal does not have the
|
||||
ability to delete and insert multiple lines. VT102s and
|
||||
above have this ability.
|
||||
|
||||
-b
|
||||
Binary mode. Use this switch when you want to view files
|
||||
containing 8 bit characters. most will display the file
|
||||
16 bytes per line in hexadecimal notation. A typical
|
||||
line looks like:
|
||||
|
||||
01000000 40001575 9C23A020 4000168D ....@..u.#. @...
|
||||
|
||||
When used with the -v option, the same line looks like:
|
||||
|
||||
^A^@^@^@ @^@^U u 9C #A0 @^@^V8D ....@..u.#. @...
|
||||
|
||||
-C
|
||||
Disable color support.
|
||||
|
||||
-c
|
||||
Make searches case-sensitive
|
||||
|
||||
-d
|
||||
Omit the backslash mark used to denote a wrapped line.
|
||||
|
||||
-M
|
||||
Disable the use of mmap.
|
||||
|
||||
-r
|
||||
Default to using regexp searches
|
||||
|
||||
-s
|
||||
Squeeze-mode. Replace multiple blank lines with a single
|
||||
blank line.
|
||||
|
||||
-t
|
||||
Display tabs as ^I. If this option is immediately
|
||||
followed by an integer, the integer sets the tab width,
|
||||
e.g., -t4
|
||||
|
||||
-u
|
||||
Disable UTF-8 mode even if the locale dictates it
|
||||
|
||||
+u
|
||||
Force UTF-8 mode. By default most will use the current
|
||||
locale to determine if UTF-8 mode should be used. The +u
|
||||
and -u switches allow the behavior to be overridden
|
||||
|
||||
-v
|
||||
Display control characters as in `^A' for control A.
|
||||
Normally most does not interpret control characters.
|
||||
|
||||
-w
|
||||
Wrap lines
|
||||
|
||||
-z
|
||||
Disable gunzip-on-the-fly
|
||||
|
||||
+/string
|
||||
Start up at the line containing the first occurrence of
|
||||
string
|
||||
|
||||
+lineno
|
||||
Start up at the specified line-number
|
||||
|
||||
+d
|
||||
This switch should only be used if you want the option
|
||||
to delete a file while viewing it. This makes it easier
|
||||
to clean unwanted files out of a directory. The file is
|
||||
deleted with the interactive key sequence `:D' and then
|
||||
confirming with `y'.
|
||||
|
||||
+s
|
||||
Secure Mode-- no edit, cd, shell, and reading files not
|
||||
already listed on the command line.
|
||||
|
||||
COMMAND USAGE
|
||||
|
||||
The commands take effect immediately; it is not necessary to
|
||||
type a carriage return. In the following commands, i is a
|
||||
numerical argument (1 by default).
|
||||
|
||||
SPACE, CTRL-D, NEXT_SCREEN
|
||||
Display another windowful, or jump i windowfuls if i is
|
||||
specified.
|
||||
|
||||
RETURN, DOWN_ARROW, V, CTRL-N
|
||||
Display another line, or i more lines, if specified.
|
||||
|
||||
UP_ARROW, ^, CTRL-P
|
||||
Display previous line, or i previous lines, if
|
||||
specified.
|
||||
|
||||
T, ESCAPE<
|
||||
Move to top of buffer.
|
||||
|
||||
B, ESCAPE>
|
||||
Move to bottom of buffer.
|
||||
|
||||
RIGHT_ARROW, TAB, >
|
||||
Scroll window left 60i columns to view lines that are
|
||||
beyond the right margin of the window.
|
||||
|
||||
LEFT_ARROW, CTRL-B, <
|
||||
Scroll window right 60i columns to view lines that are
|
||||
beyond the left margin of the window.
|
||||
|
||||
U, CTRL-U, DELETE, PREV_SCREEN
|
||||
Skip back i windowfuls and then print a windowful.
|
||||
|
||||
R, CTRL-R
|
||||
Redraw the window.
|
||||
|
||||
J, G
|
||||
If i is not specified, then prompt for a line number
|
||||
then jump to that line otherwise just jump to line i.
|
||||
|
||||
%
|
||||
If i is not specified, then prompt for a percent number
|
||||
then jump to that percent of the file otherwise just
|
||||
jump to i percent of the file.
|
||||
|
||||
W, w
|
||||
If the current screen width is 80, make it 132 and
|
||||
vice-versa. For other values, this command is ignored.
|
||||
|
||||
Q, CTRL-X CTRL-C, CTRL-K E
|
||||
Exit from most. On VMS, ^Z also exits.
|
||||
|
||||
h, CTRL-H, HELP, PF2
|
||||
Help. Give a description of all the most commands. The
|
||||
most environment variable MOST_HELP must be set for this
|
||||
to be meaningful.
|
||||
|
||||
f, /, CTRL-F, FIND, GOLD PF3
|
||||
Prompt for a string and search forward from the current
|
||||
line for ith distinct line containing the string. CTRL-G
|
||||
aborts.
|
||||
|
||||
?
|
||||
Prompt for a string and search backward for the ith
|
||||
distinct line containing the string. CTRL-G aborts.
|
||||
|
||||
n
|
||||
Search for the next i lines containing an occurrence of
|
||||
the last search string in the direction of the previous
|
||||
search.
|
||||
|
||||
m, SELECT, CTRL-@, CTRL-K M, PERIOD
|
||||
Set a mark on the current line for later reference.
|
||||
|
||||
INSERT_HERE, CTRL-X CTRL-X, COMMA, CTRL-K RETURN, GOLD PERIOD
|
||||
Set a mark on the current line but return to previous
|
||||
mark. This allows the user to toggle back and forth
|
||||
between two positions in the file.
|
||||
|
||||
l, L
|
||||
Toggle locking for this window. The window is locked if
|
||||
there is a `*' at the left edge of the status line.
|
||||
Windows locked together, scroll together.
|
||||
|
||||
CTRL-X 2, CTRL-W 2, GOLD X
|
||||
Split this window in half.
|
||||
|
||||
CTRL-X o, CTRL-W o, o, GOLDUP, GOLDDOWN
|
||||
Move to other window.
|
||||
|
||||
CTRL-X 0, CTRL-W 0, GOLD V
|
||||
Delete this window.
|
||||
|
||||
CTRL-X 1, CTRL-W 1, GOLD O
|
||||
Delete all other windows, leaving only one window.
|
||||
|
||||
E, e
|
||||
Edit this file.
|
||||
|
||||
$, ESC $
|
||||
This is system dependent. On VMS, this causes most to
|
||||
spawn a subprocess. When the user exits the process,
|
||||
most is resumed. On UNIX systems, most simply suspends
|
||||
itself.
|
||||
|
||||
:n
|
||||
Skip to the next filename given in the command line. Use
|
||||
the arrow keys to scroll forward or backward through the
|
||||
file list. `Q' quits most and any other key selects the
|
||||
given file.
|
||||
|
||||
:c
|
||||
Toggle case sensitive search.
|
||||
|
||||
:D
|
||||
Delete current file. This command is only meaningful
|
||||
with the +d switch.
|
||||
|
||||
:o, :O
|
||||
Toggle various options. With this key sequence, most
|
||||
displays a prompt asking the user to hit one of: bdtvw.
|
||||
The `b', `t', `v', and `w' options have the same meaning
|
||||
as the command line switches. For example, the `w'
|
||||
option will toggle wrapping on and off for the current
|
||||
window.
|
||||
|
||||
The `d' option must be used with a prefix integer i. All
|
||||
lines indented beyond i columns will not be displayed.
|
||||
For example, consider the fragment:
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < argc, i++)
|
||||
{
|
||||
fprintf(stdout,"%i: %s\n",i,argv[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
The key sequence `1:od' will cause most to display the
|
||||
file ignoring all lines indented beyond the first
|
||||
column. So for the example above, most would display:
|
||||
|
||||
int main(int argc, char **argv)...
|
||||
}
|
||||
|
||||
where the `...' indicates lines that follow are not
|
||||
displayed.
|
||||
|
||||
HINTS
|
||||
|
||||
CTRL-G aborts the commands requiring the user to type something
|
||||
in at a prompt. The back-quote key has a special meaning here.
|
||||
It is used to quote certain characters. This is useful when
|
||||
search for the occurrence of a string with a control character
|
||||
or a string at the beginning of a line. In the latter case, to
|
||||
find the occurrence of `The' at the beginning of a line, enter
|
||||
`^JThe where ` quotes the CTRL-J.
|
||||
|
||||
ENVIRONMENT
|
||||
|
||||
most uses the following environment variables:
|
||||
|
||||
MOST_SWITCHES
|
||||
This variable sets commonly used switches. For example,
|
||||
some people prefer to use most with the -s option so
|
||||
that excess blank lines are not displayed. On VMS this
|
||||
is normally done done in the login.com through the line:
|
||||
|
||||
$ define MOST_SWITCHES "-s"
|
||||
|
||||
MOST_EDITOR, SLANG_EDITOR
|
||||
Either of these environment variables specify an editor
|
||||
for most to invoke to edit a file. The value can contain
|
||||
%s and %d formatting descriptors that represent the file
|
||||
name and line number, respectively. For example, if JED
|
||||
is your editor, then set MOST_EDITOR to 'jed %s -g %d'.
|
||||
|
||||
MOST_HELP
|
||||
This variable may be used to specify an alternate help
|
||||
file.
|
||||
|
||||
MOST_INITFILE
|
||||
Set this variable to specify the initialization file to
|
||||
load during startup. The default action is to load the
|
||||
system configuration file and then a personal
|
||||
configuration file called .mostrc on Unix, and most.rc
|
||||
on other systems.
|
||||
|
||||
CONFIGURATION FILE SYNTAX
|
||||
|
||||
When most starts up, it tries to read a system configuration
|
||||
file and then a personal configuration file. These files may be
|
||||
used to specify key-bindings and colors.
|
||||
|
||||
To bind a key to a particular function use the syntax:
|
||||
setkey function-name key-sequence
|
||||
|
||||
The setkey command requires two arguments. The function-name
|
||||
argument specifies the function that is to be executed as a
|
||||
response to the keys specified by the key-sequence argument are
|
||||
pressed. For example,
|
||||
setkey "up" "^P"
|
||||
|
||||
indicates that when Ctrl-P is pressed then the function up is
|
||||
to be executed.
|
||||
|
||||
Sometimes, it is necessary to first unbind a key-sequence
|
||||
before rebinding it in order via the unsetkey function:
|
||||
unsetkey "^F"
|
||||
|
||||
Colors may be defined through the use of the color keyword in
|
||||
the the configuration file using the syntax:
|
||||
color OBJECT-NAME FOREGROUND-COLOR BACKGROUND-COLOR
|
||||
|
||||
Here, OBJECT-NAME can be any one of the following items:
|
||||
status -- the status line
|
||||
underline -- underlined text
|
||||
overstrike -- overstruck text
|
||||
normal -- anything else
|
||||
|
||||
See the sample configuration files for more information.
|
||||
|
||||
BUGS
|
||||
|
||||
Almost all of the known bugs or limitations of most are due to
|
||||
a desire to read and interpret control characters in files. One
|
||||
problem concerns the use of backspace characters to underscore
|
||||
or overstrike other characters. most makes an attempt to use
|
||||
terminal escape sequences to simulate this behavior. One side
|
||||
effect is the one does not always get what one expects when
|
||||
scrolling right and left through a file. When in doubt, use the
|
||||
-v and -b options of most.
|
||||
|
||||
The regular-expression searches may fail to find strings that
|
||||
involve backspace/underscore used for highlighting. The
|
||||
regular-expression syntax is described in the S-Lang Library
|
||||
documentation.
|
||||
|
||||
AUTHOR
|
||||
|
||||
John E. Davis <jed@jedsoft.org>
|
||||
|
||||
ACKNOWLEDGEMENTS
|
||||
|
||||
Over the years, many people have contributed to most in one way
|
||||
or another, e.g., via code patches, bug-fixes, comments, or
|
||||
criticisms. I am particularly grateful to the very early
|
||||
adopters of the program who took a chance with a fledgling
|
||||
software project headed by someone learning the underlying
|
||||
language. These include:
|
||||
|
||||
Mats Akerberg, Henk D. Davids, Rex O. Livingston, and Mark
|
||||
Pizzolato contributed to the early VMS versions of most. In
|
||||
particular, Mark worked on it to get it ready for DECUS.
|
||||
|
||||
Foteos Macrides adapted most for use in cswing and gopher. A
|
||||
few features of the present version of most was inspired from
|
||||
his work.
|
||||
|
||||
I am grateful to Robert Mills for re-writing the search
|
||||
routines to use regular expressions.
|
||||
|
||||
Sven Oliver Moll came up with the idea of automatic detection
|
||||
of zipped files.
|
||||
|
||||
I would also like to thank Shinichi Hama for his valuable
|
||||
criticisms of most.
|
||||
|
||||
Javier Kohen was instrumental in the support for UTF-8.
|
||||
|
||||
Thanks to David W. Sanderson for adapting the early
|
||||
documentation to nroff man page source format.
|
|
@ -0,0 +1,27 @@
|
|||
# -*- sh -*-
|
||||
#
|
||||
# To create the SGML files, you will need to install the tmexpand
|
||||
# package. See http://www.jedsoft.org/ for more information.
|
||||
#
|
||||
TM2SGML = tmexpand
|
||||
SGML2HTML = sgml2html
|
||||
DOCBOOK2MAN = docbook2man
|
||||
DOCBOOK2TXT = docbook2txt
|
||||
|
||||
all: most.1 most.txt
|
||||
|
||||
most.1: most.sgml
|
||||
$(DOCBOOK2MAN) most.sgml
|
||||
most.sgml: most.tm
|
||||
$(TM2SGML) most.tm most.sgml
|
||||
most.txt: most.sgml
|
||||
$(DOCBOOK2TXT) most.sgml
|
||||
view: most.1
|
||||
nroff -man most.1 | most
|
||||
#----------------------------------------------------------------------------
|
||||
clean:
|
||||
-rm -f *~ *-error manpage.refs manpage.links
|
||||
distclean: clean
|
||||
-rm -f most.1 most.sgml
|
||||
install: most.1 most.txt
|
||||
mv most.1 most.txt ..
|
|
@ -0,0 +1,427 @@
|
|||
#i docbook_man.tm
|
||||
|
||||
#d man_options_entry#2 \varlistentry{\term{$1}}{\p $2 \p-end}\__newline__
|
||||
|
||||
#d arg#1 <arg>$1</arg>\__newline__
|
||||
#d desc-list \variablelist
|
||||
#d desc-item#2 \varlistentry{\term{$1}}{\p $2 \p-end}\__newline__
|
||||
#d desc-item-continue <varlistentry><term></term><listitem>\p
|
||||
#d desc-item-continue-end </listitem></varlistentry>
|
||||
#d desc-list-end \variablelist-end
|
||||
|
||||
#d envdesc#2 \varlistentry{\term{$1}}{\p $2 \p-end}\__newline__
|
||||
#d envdesc-begin \variablelist
|
||||
#d envdesc-end \variablelist-end
|
||||
#d envdesc-verb-begin <varlistentry><term></term><listitem>
|
||||
#d envdesc-verb-end </listitem></varlistentry>
|
||||
|
||||
#d most \command{most}
|
||||
#d slang \literal{S-Lang}
|
||||
#d lit#1 \literal{$1}
|
||||
#d underline#1 <emphasis role="underline">$1</emphasis>
|
||||
#d i \underline{i}
|
||||
|
||||
\manpage{most}{1}{browse or page through a text file}
|
||||
\mansynopsis{most}{
|
||||
\arg{\option{-1}}
|
||||
\arg{\option{-b}}
|
||||
\arg{\option{-C}}
|
||||
\arg{\option{-c}}
|
||||
\arg{\option{-d}}
|
||||
\arg{\option{-M}}
|
||||
\arg{\option{-r}}
|
||||
\arg{\option{-s}}
|
||||
\arg{\option{-t}}
|
||||
\arg{\option{-u}}
|
||||
\arg{\option{-v}}
|
||||
\arg{\option{-w}}
|
||||
\arg{\option{-z}}
|
||||
\arg{\option{+/\replaceable{string}}}
|
||||
\arg{\option{+\replaceable{line-number}}}
|
||||
\arg{\option{+d}}
|
||||
\arg{\option{+s}}
|
||||
\arg{\option{+u}}
|
||||
\arg{\option{\replaceable{file...}}}
|
||||
}
|
||||
|
||||
\refsect1{DESCRIPTION}
|
||||
\p
|
||||
\most is a paging program that displays, one windowful at a time,
|
||||
the contents of a file on a terminal. It pauses after each
|
||||
windowful and prints on the window status line the screen the file
|
||||
name, current line number, and the percentage of the file so far
|
||||
displayed.
|
||||
\pp
|
||||
Unlike other paging programs, \most is capable of displaying an
|
||||
arbitrary number of windows as long as each window occupies at least
|
||||
two screen lines. Each window may contain the same file or a
|
||||
different file. In addition, each window has its own mode. For
|
||||
example, one window may display a file with its lines wrapped while
|
||||
another may be truncating the lines. Windows may be `locked'
|
||||
together in the sense that if one of the locked windows scrolls, all
|
||||
locked windows will scroll. \most is also capable of ignoring lines
|
||||
that are indented beyond a user specified value. This is useful
|
||||
when viewing computer programs to pick out gross features of the
|
||||
code. See the `:o' command for a description of this feature.
|
||||
\pp
|
||||
In addition to displaying ordinary text files, \most can also
|
||||
display binary files as well as files with arbitrary ascii
|
||||
characters. When a file is read into a buffer, \most examines the
|
||||
first 32 bytes of the file to determine if the file is a binary file
|
||||
and then switches to the appropriate mode. However, this feature
|
||||
may be disabled with the -k option. See the description of the -b,
|
||||
-k, -v, and -t options for further details.
|
||||
\pp
|
||||
Text files may contain combinations of underscore and backspace
|
||||
characters causing a printer to underline or overstrike. When \most
|
||||
recognizes this, it inserts the appropriate escape sequences to
|
||||
achieve the desired effect. In addition, some files cause the
|
||||
printer to overstrike some characters by embedding carriage return
|
||||
characters in the middle of a line. When this occurs, \most displays
|
||||
the overstruck character with a bold attribute. This feature
|
||||
facilitates the reading of UNIX man pages or a document produced by
|
||||
runoff. In particular, viewing this document with \most should
|
||||
illustrate this behavior provided that the underline characters
|
||||
have not been stripped. This may be turned off with the -v option.
|
||||
\pp
|
||||
By default, lines with more characters than the terminal width are
|
||||
not wrapped but are instead truncated. When truncation occurs, this
|
||||
is indicated by a `$' in the far right column of the terminal
|
||||
screen. The RIGHT and LEFT arrow keys may be used to view lines
|
||||
which extend past the margins of the screen. The -w option may be
|
||||
used to override this feature. When a window is wrapped, the
|
||||
character `\\' will appear at the right edge of the window.
|
||||
\pp
|
||||
Commands are listed below.
|
||||
\p-end
|
||||
\refsect1-end
|
||||
|
||||
\refsect1{OPTIONS}
|
||||
\variablelist
|
||||
|
||||
\man_options_entry{\option{-1}}{VT100 mode. This is meaningful only
|
||||
on VMS systems. This option should be used if the terminal is
|
||||
strictly a VT100. This implies that the terminal does not have the
|
||||
ability to delete and insert multiple lines. VT102s and above have
|
||||
this ability.}
|
||||
|
||||
\man_options_entry{\option{-b}}{ Binary mode. Use this switch when
|
||||
you want to view files containing 8 bit characters. \most will
|
||||
display the file 16 bytes per line in hexadecimal notation. A
|
||||
typical line looks like:
|
||||
#v+
|
||||
01000000 40001575 9C23A020 4000168D ....@..u.#. @...
|
||||
#v-
|
||||
\pp
|
||||
When used with the -v option, the same line looks like:
|
||||
#v+
|
||||
^A^@^@^@ @^@^U u 9C #A0 @^@^V8D ....@..u.#. @...
|
||||
#v-
|
||||
}
|
||||
|
||||
\man_options_entry{\option{-C}}{Disable color support.}
|
||||
\man_options_entry{\option{-c}}{Make searches case-sensitive}
|
||||
\man_options_entry{\option{-d}}{Omit the backslash mark used to denote a wrapped line.}
|
||||
\man_options_entry{\option{-M}}{Disable the use of mmap.}
|
||||
\man_options_entry{\option{-r}}{Default to using regexp searches}
|
||||
\man_options_entry{\option{-s}}{Squeeze-mode. Replace multiple blank
|
||||
lines with a single blank line.}
|
||||
|
||||
\man_options_entry{\option{-t}}{Display tabs as ^I. If this option
|
||||
is immediately followed by an integer, the integer sets the tab
|
||||
width, e.g., -t4}
|
||||
|
||||
\man_options_entry{\option{-u}}{Disable UTF-8 mode even if the
|
||||
locale dictates it}
|
||||
|
||||
\man_options_entry{\option{+u}}{Force UTF-8 mode. By default \most
|
||||
will use the current locale to determine if UTF-8 mode should be
|
||||
used. The +u and -u switches allow the behavior to be overridden}
|
||||
|
||||
\man_options_entry{\option{-v}}{Display control characters as in
|
||||
`^A' for control A. Normally \most does not interpret control
|
||||
characters.}
|
||||
\man_options_entry{\option{-w}}{Wrap lines}
|
||||
\man_options_entry{\option{-z}}{Disable gunzip-on-the-fly}
|
||||
|
||||
\man_options_entry{\option{+/\replaceable{string}}}{Start up at the
|
||||
line containing the first occurrence of string}
|
||||
|
||||
\man_options_entry{\option{+\replaceable{lineno}}}{Start up at the
|
||||
specified line-number}
|
||||
|
||||
\man_options_entry{\option{+d}}{This switch should only be used if
|
||||
you want the option to delete a file while viewing it. This makes
|
||||
it easier to clean unwanted files out of a directory. The file is
|
||||
deleted with the interactive key sequence `:D' and then confirming
|
||||
with `y'.}
|
||||
|
||||
\man_options_entry{\option{+s}}{Secure Mode-- no edit, cd, shell,
|
||||
and reading files not already listed on the command line.}
|
||||
|
||||
\variablelist-end
|
||||
\refsect1-end
|
||||
|
||||
\refsect1{COMMAND USAGE}
|
||||
\p
|
||||
The commands take effect immediately; it is not necessary to type a
|
||||
carriage return. In the following commands, \i is a numerical
|
||||
argument (1 by default).
|
||||
\desc-list
|
||||
\desc-item{SPACE, CTRL-D, NEXT_SCREEN}{
|
||||
Display another windowful, or jump \i windowfuls if \i is specified.}
|
||||
\desc-item{RETURN, DOWN_ARROW, V, CTRL-N}{
|
||||
Display another line, or \i more lines, if specified.}
|
||||
|
||||
\desc-item{UP_ARROW, ^, CTRL-P}{Display previous line, or \i previous
|
||||
lines, if specified.}
|
||||
|
||||
\desc-item{T, ESCAPE<}{Move to top of buffer.}
|
||||
|
||||
\desc-item{B, ESCAPE>}{Move to bottom of buffer.}
|
||||
|
||||
\desc-item{RIGHT_ARROW, TAB, >}{Scroll window left 60\i columns to view
|
||||
lines that are beyond the right margin of the window.}
|
||||
|
||||
\desc-item{LEFT_ARROW, CTRL-B, <}{Scroll window right 60\i columns to
|
||||
view lines that are beyond the left margin of the window.}
|
||||
|
||||
\desc-item{U, CTRL-U, DELETE, PREV_SCREEN}{Skip back \i windowfuls and
|
||||
then print a windowful.}
|
||||
|
||||
\desc-item{R, CTRL-R}{Redraw the window.}
|
||||
|
||||
\desc-item{J, G}{If \i is not specified, then prompt for a line
|
||||
number then jump to that line otherwise just jump to line i.}
|
||||
|
||||
\desc-item{%}{If \i is not specified, then prompt for a percent number
|
||||
then jump to that percent of the file otherwise just jump to \i percent
|
||||
of the file.}
|
||||
|
||||
\desc-item{W, w}{If the current screen width is 80, make it 132 and
|
||||
vice-versa. For other values, this command is ignored.}
|
||||
|
||||
\desc-item{Q, CTRL-X CTRL-C, CTRL-K E}{Exit from \most. On VMS, ^Z also
|
||||
exits.}
|
||||
|
||||
\desc-item{h, CTRL-H, HELP, PF2}{Help. Give a description of all the
|
||||
\most commands. The \most environment variable MOST_HELP must be set
|
||||
for this to be meaningful.}
|
||||
|
||||
\desc-item{f, /, CTRL-F, FIND, GOLD PF3}{Prompt for a string and
|
||||
search forward from the current line for ith distinct line containing
|
||||
the string. CTRL-G aborts.}
|
||||
|
||||
\desc-item{?}{Prompt for a string and search backward for the ith
|
||||
distinct line containing the string. CTRL-G aborts.}
|
||||
|
||||
\desc-item{n}{Search for the next \i lines containing an occurrence of
|
||||
the last search string in the direction of the previous search.}
|
||||
|
||||
\desc-item{m, SELECT, CTRL-@, CTRL-K M, PERIOD}{Set a mark on the
|
||||
current line for later reference.}
|
||||
|
||||
\desc-item{INSERT_HERE, CTRL-X CTRL-X, COMMA, CTRL-K RETURN, GOLD
|
||||
PERIOD}{Set a mark on the current line but return to previous mark.
|
||||
This allows the user to toggle back and forth between two positions in
|
||||
the file.}
|
||||
|
||||
\desc-item{l, L}{Toggle locking for this window. The window is locked
|
||||
if there is a `*' at the left edge of the status line. Windows locked
|
||||
together, scroll together.}
|
||||
|
||||
\desc-item{CTRL-X 2, CTRL-W 2, GOLD X}{Split this window in half.}
|
||||
|
||||
\desc-item{CTRL-X o, CTRL-W o, o, GOLDUP, GOLDDOWN}{Move to other window.}
|
||||
|
||||
\desc-item{CTRL-X 0, CTRL-W 0, GOLD V}{Delete this window.}
|
||||
|
||||
\desc-item{CTRL-X 1, CTRL-W 1, GOLD O}{Delete all other windows, leaving
|
||||
only one window.}
|
||||
|
||||
\desc-item{E, e}{Edit this file.}
|
||||
|
||||
\desc-item{$, ESC $}{This is system dependent. On VMS, this causes \most
|
||||
to spawn a subprocess. When the user exits the process, \most is
|
||||
resumed. On UNIX systems, \most simply suspends itself.}
|
||||
|
||||
\desc-item{:n}{Skip to the next filename given in the command line. Use
|
||||
the arrow keys to scroll forward or backward through the file list.
|
||||
`Q' quits \most and any other key selects the given file.}
|
||||
|
||||
\desc-item{:c}{Toggle case sensitive search.}
|
||||
|
||||
\desc-item{:D}{Delete current file. This command is only meaningful
|
||||
with the +d switch.}
|
||||
|
||||
\desc-item{:o, :O}{Toggle various options. With this key sequence, \most
|
||||
displays a prompt asking the user to hit one of: bdtvw. The `b', `t',
|
||||
`v', and `w' options have the same meaning as the command line
|
||||
switches. For example, the `w' option will toggle wrapping on and off
|
||||
for the current window.
|
||||
\p
|
||||
The `d' option must be used with a prefix integer i. All lines
|
||||
indented beyond \i columns will not be displayed. For example,
|
||||
consider the fragment:}
|
||||
\desc-item-continue
|
||||
#v+
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < argc, i++)
|
||||
{
|
||||
fprintf(stdout,"%i: %s\n",i,argv[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#v-
|
||||
The key sequence `1:od' will cause \most to display the file ignoring
|
||||
all lines indented beyond the first column. So for the example above,
|
||||
\most would display:
|
||||
#v+
|
||||
int main(int argc, char **argv)...
|
||||
}
|
||||
#v-
|
||||
where the `...' indicates lines that follow are not displayed.
|
||||
\desc-item-continue-end
|
||||
\desc-list-end
|
||||
\p-end
|
||||
\refsect1-end
|
||||
|
||||
\refsect1{HINTS}
|
||||
\p
|
||||
CTRL-G aborts the commands requiring the user to type something in
|
||||
at a prompt. The back-quote key has a special meaning here. It is
|
||||
used to quote certain characters. This is useful when search for
|
||||
the occurrence of a string with a control character or a string at
|
||||
the beginning of a line. In the latter case, to find the occurrence
|
||||
of `The' at the beginning of a line, enter `^JThe where ` quotes the
|
||||
CTRL-J.
|
||||
\p-end
|
||||
\refsect1-end
|
||||
|
||||
\refsect1{ENVIRONMENT}
|
||||
\p
|
||||
\most uses the following environment variables:
|
||||
\desc-list
|
||||
\desc-item{MOST_SWITCHES}{This variable sets commonly used switches.
|
||||
For example, some people prefer to use \most with the -s option so that
|
||||
excess blank lines are not displayed. On VMS this is normally done
|
||||
done in the login.com through the line:}
|
||||
\desc-item-continue
|
||||
#v+
|
||||
$ define MOST_SWITCHES "-s"
|
||||
#v-
|
||||
\desc-item-continue-end
|
||||
|
||||
\desc-item{MOST_EDITOR, SLANG_EDITOR}{Either of these environment
|
||||
variables specify an editor for \most to invoke to edit a file. The
|
||||
value can contain %s and %d formatting descriptors that represent the
|
||||
file name and line number, respectively. For example, if JED is
|
||||
your editor, then set MOST_EDITOR to 'jed %s -g %d'.}
|
||||
|
||||
\desc-item{MOST_HELP}{This variable may be used to specify an alternate
|
||||
help file.}
|
||||
|
||||
\desc-item{MOST_INITFILE}{Set this variable to specify the
|
||||
initialization file to load during startup. The default action is to
|
||||
load the system configuration file and then a personal configuration
|
||||
file called .mostrc on Unix, and most.rc on other systems.}
|
||||
\desc-list-end
|
||||
\refsect1-end
|
||||
|
||||
\refsect1{CONFIGURATION FILE SYNTAX}
|
||||
\p
|
||||
When \most starts up, it tries to read a system configuration file and
|
||||
then a personal configuration file. These files may be used to specify
|
||||
key-bindings and colors.
|
||||
\pp
|
||||
To bind a key to a particular function use the syntax:
|
||||
#v+
|
||||
setkey function-name key-sequence
|
||||
#v-
|
||||
\pp
|
||||
The setkey command requires two arguments. The function-name argument
|
||||
specifies the function that is to be executed as a response to the
|
||||
keys specified by the key-sequence argument are pressed. For example,
|
||||
#v+
|
||||
setkey "up" "^P"
|
||||
#v-
|
||||
\pp
|
||||
indicates that when Ctrl-P is pressed then the function up is to be executed.
|
||||
\pp
|
||||
Sometimes, it is necessary to first unbind a key-sequence before
|
||||
rebinding it in order via the unsetkey function:
|
||||
#v+
|
||||
unsetkey "^F"
|
||||
#v-
|
||||
\pp
|
||||
Colors may be defined through the use of the color keyword in the the
|
||||
configuration file using the syntax:
|
||||
#v+
|
||||
color OBJECT-NAME FOREGROUND-COLOR BACKGROUND-COLOR
|
||||
#v-
|
||||
\pp
|
||||
Here, OBJECT-NAME can be any one of the following items:
|
||||
#v+
|
||||
status -- the status line
|
||||
underline -- underlined text
|
||||
overstrike -- overstruck text
|
||||
normal -- anything else
|
||||
#v-
|
||||
\pp
|
||||
See the sample configuration files for more information.
|
||||
\p-end
|
||||
\refsect1-end
|
||||
|
||||
\refsect1{BUGS}
|
||||
\p
|
||||
Almost all of the known bugs or limitations of \most are due to a
|
||||
desire to read and interpret control characters in files. One
|
||||
problem concerns the use of backspace characters to underscore or
|
||||
overstrike other characters. \most makes an attempt to use terminal
|
||||
escape sequences to simulate this behavior. One side effect is the
|
||||
one does not always get what one expects when scrolling right and left
|
||||
through a file. When in doubt, use the -v and -b options of \most.
|
||||
\pp
|
||||
The regular-expression searches may fail to find strings that involve
|
||||
backspace/underscore used for highlighting. The regular-expression
|
||||
syntax is described in the S-Lang Library documentation.
|
||||
\p-end
|
||||
\refsect1-end
|
||||
|
||||
\refsect1{AUTHOR}
|
||||
\p
|
||||
John E. Davis \email{jed@jedsoft.org}
|
||||
\p-end
|
||||
\refsect1{ACKNOWLEDGEMENTS}
|
||||
\p
|
||||
Over the years, many people have contributed to \most in one way or
|
||||
another, e.g., via code patches, bug-fixes, comments, or criticisms.
|
||||
I am particularly grateful to the very early adopters of the program
|
||||
who took a chance with a fledgling software project headed by someone
|
||||
learning the underlying language. These include:
|
||||
\pp
|
||||
Mats Akerberg, Henk D. Davids, Rex O. Livingston, and Mark Pizzolato
|
||||
contributed to the early VMS versions of \most. In particular, Mark
|
||||
worked on it to get it ready for DECUS.
|
||||
\pp
|
||||
Foteos Macrides adapted \most for use in cswing and gopher. A few
|
||||
features of the present version of \most was inspired from his work.
|
||||
\pp
|
||||
I am grateful to Robert Mills for re-writing the search routines to
|
||||
use regular expressions.
|
||||
\pp
|
||||
Sven Oliver Moll came up with the idea of automatic detection of
|
||||
zipped files.
|
||||
\pp
|
||||
I would also like to thank Shinichi Hama for his valuable criticisms
|
||||
of \most.
|
||||
\pp
|
||||
Javier Kohen was instrumental in the support for UTF-8.
|
||||
\pp
|
||||
Thanks to David W. Sanderson for adapting the early documentation to
|
||||
nroff man page source format.
|
||||
\p-end
|
||||
\refsect1-end
|
||||
\manpage-end
|
|
@ -0,0 +1,63 @@
|
|||
@configure 0755
|
||||
@most.lis
|
||||
@README
|
||||
@COPYRIGHT
|
||||
@COPYING
|
||||
@NEWS
|
||||
@changes.txt
|
||||
|
||||
@doc/lesskeys.rc
|
||||
@doc/most.rc
|
||||
@doc/most-fun.txt
|
||||
@doc/most.1
|
||||
@doc/most.txt
|
||||
@doc/most.hlp
|
||||
@doc/tm/most.tm
|
||||
@doc/tm/Makefile
|
||||
|
||||
@autoconf/Makefile.in
|
||||
@autoconf/aclocal.m4
|
||||
@autoconf/configure.ac
|
||||
@autoconf/mkinsdir.sh 0755
|
||||
@autoconf/install.sh 0755
|
||||
@autoconf/config.guess 0755
|
||||
@autoconf/config.sub 0755
|
||||
|
||||
@src/DESCRIP.MMS
|
||||
@src/VMSMAKE.COM
|
||||
@src/RTL.OPT
|
||||
@src/Makefile.in
|
||||
@src/Makefile.w32
|
||||
@src/sysconf.h
|
||||
@src/config.hin
|
||||
@src/mostconf.h
|
||||
@src/modules.lis
|
||||
@src/w32conf.h
|
||||
@src/jdmacros.h
|
||||
@src/main.c
|
||||
@src/buffer.c
|
||||
@src/file.c
|
||||
@src/window.c
|
||||
@src/line.c
|
||||
@src/display.c
|
||||
@src/sysdep.c
|
||||
@src/keym.c
|
||||
@src/most.c
|
||||
@src/search.c
|
||||
@src/help.c
|
||||
@src/cmd.c
|
||||
@src/edit.c
|
||||
@src/edit.h
|
||||
@src/buffer.h
|
||||
@src/file.h
|
||||
@src/window.h
|
||||
@src/line.h
|
||||
@src/display.h
|
||||
@src/sysdep.h
|
||||
@src/keym.h
|
||||
@src/most.h
|
||||
@src/search.h
|
||||
@src/keyparse.c
|
||||
@src/keyparse.h
|
||||
@src/chkslang.c
|
||||
@src/version.h
|
|
@ -0,0 +1,68 @@
|
|||
#
|
||||
# MMS file to build MOST.
|
||||
#
|
||||
# Written by Hunter Goatley <goathunter@WKUVX1.BITNET> ( 4-OCT-1993 15:41)
|
||||
# Removed reference to DIR.C, Michael Lemke <ai26@alf001.sternwarte.uni-erlangen.de> ( 3-NOV-1995 17:25:44.05)
|
||||
# Moved CC =.. into if clause. New MMS doesn't like redefinition of macros.
|
||||
# 6-AUG-1997 14:43:25.04 Michael Lemke <ai26@alf001.sternwarte.uni-erlangen.de> ( 3-NOV-1995 17:25:44.05)
|
||||
#
|
||||
.IFDEF __MATTS_MMS__
|
||||
.ELSE
|
||||
EXE = .EXE
|
||||
OBJ = .OBJ
|
||||
.ENDIF
|
||||
|
||||
|
||||
.IFDEF __ALPHA__
|
||||
CC = CC/STANDARD=VAXC
|
||||
OPTFILE =
|
||||
OPTIONS =
|
||||
NATIVE = /NONATIVE_ONLY
|
||||
.ELSE
|
||||
CC = CC/STANDARD/VAXC
|
||||
OPTFILE = ,VAXCRTL.OPT
|
||||
OPTIONS = $(OPTFILE)/OPTIONS
|
||||
NATIVE =
|
||||
.ENDIF
|
||||
|
||||
.IFDEF SLANG_OLB
|
||||
.ELSE
|
||||
SLANG_DIR = [-.SLANG.SRC]
|
||||
SLANG_OLB = $(SLANG_DIR)SLANG$(OLB)
|
||||
.ENDIF
|
||||
|
||||
CFLAGS = $(CFLAGS)/DEFINE=(USE_SLANG)/INCLUDE=$(SLANG_DIR)
|
||||
LINKFLAGS = $(LINKFLAGS)$(NATIVE)/NOTRACE
|
||||
|
||||
OBJS = MAIN$(OBJ),-
|
||||
BUFFER$(OBJ),-
|
||||
FILE$(OBJ),-
|
||||
WINDOW$(OBJ),-
|
||||
LINE$(OBJ),-
|
||||
DISPLAY$(OBJ),-
|
||||
SYSDEP$(OBJ),-
|
||||
KEYM$(OBJ),-
|
||||
MOST$(OBJ),-
|
||||
SEARCH$(OBJ),-
|
||||
HELP$(OBJ),-
|
||||
CMD$(OBJ),-
|
||||
EDIT$(OBJ),-
|
||||
KEYPARSE$(OBJ)
|
||||
# DIR$(OBJ),-
|
||||
|
||||
MOST$(EXE) : config.h $(OBJS)$(OPTFILE)
|
||||
$(LINK)$(LINKFLAGS) $(OBJS)$(OPTIONS),$(SLANG_OLB)/LIBRARY
|
||||
|
||||
config.h : mostconf.h
|
||||
copy mostconf.h config.h
|
||||
|
||||
#
|
||||
# Build the linker options file for OpenVMS VAX and VAX C.
|
||||
#
|
||||
VAXCRTL.OPT :
|
||||
@ open/write tmp vaxcrtl.opt
|
||||
@ write tmp "SYS$SHARE:VAXCRTL.EXE/SHARE"
|
||||
@ close tmp
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,150 @@
|
|||
CC = gcc
|
||||
CFLAGS = -g -O2
|
||||
LDFLAGS =
|
||||
SLANG_INC =
|
||||
SLANG_LIB = -lslang
|
||||
MISCLIBS =
|
||||
RPATH =
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Location where object files are placed (Absolute path)
|
||||
#-----------------------------------------------------------------------------
|
||||
SRCDIR = /home/greg/code/most-5.1.0/src
|
||||
OBJDIR = /home/greg/code/most-5.1.0/src/$(ARCH)objs
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# 5. Install location
|
||||
#----------------------------------------------------------------------------
|
||||
INSTALL = /usr/bin/install -c
|
||||
INSTALL_DATA = ${INSTALL} -m 644
|
||||
DESTDIR =
|
||||
prefix = /usr/local
|
||||
exec_prefix = ${prefix}
|
||||
datarootdir = ${prefix}/share
|
||||
BIN_DIR = $(prefix)/bin
|
||||
MAN_DIR = $(datarootdir)/man
|
||||
DOC_DIR = $(datarootdir)/doc/most
|
||||
SYS_INITFILE = ${prefix}/etc/most.conf
|
||||
MKINSDIR = ../autoconf/mkinsdir.sh
|
||||
|
||||
DOC_FILES = ../doc/most.txt ../README ../doc/most-fun.txt ../doc/lesskeys.rc ../doc/most.rc ../changes.txt
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Nothing below here should require changing.
|
||||
#----------------------------------------------------------------------------
|
||||
DEST_DOCDIR = $(DESTDIR)$(DOC_DIR)
|
||||
DEST_MANDIR = $(DESTDIR)$(MAN_DIR)
|
||||
DEST_BINDIR = $(DESTDIR)$(BIN_DIR)
|
||||
#
|
||||
SHELL = /bin/sh
|
||||
OBJS = $(OBJDIR)/buffer.o $(OBJDIR)/cmd.o $(OBJDIR)/display.o $(OBJDIR)/edit.o $(OBJDIR)/file.o $(OBJDIR)/help.o $(OBJDIR)/keym.o $(OBJDIR)/keyparse.o $(OBJDIR)/line.o $(OBJDIR)/main.o $(OBJDIR)/most.o $(OBJDIR)/search.o $(OBJDIR)/sysdep.o $(OBJDIR)/window.o
|
||||
OFILES = buffer.o cmd.o display.o edit.o file.o help.o keym.o keyparse.o line.o main.o most.o search.o sysdep.o window.o
|
||||
|
||||
EXEC = most
|
||||
CONFIG_H = config.h
|
||||
INCS = $(SLANG_INC)
|
||||
ALL_CFLAGS = $(CFLAGS) -Dunix $(INCS)
|
||||
EXECLIBS = $(RPATH) $(SLANG_LIB) $(MISCLIBS) -lm
|
||||
#
|
||||
most_O_DEP = $(SRCDIR)/version.h
|
||||
UPDATE_VERSION_SCRIPT = $(HOME)/bin/update_changes_version
|
||||
|
||||
COMPILE_CMD = $(CC) -c $(ALL_CFLAGS) -DMOST_SYSTEM_INITFILE='"$(SYS_INITFILE)"'
|
||||
#
|
||||
all: $(EXEC)
|
||||
$(EXEC): $(OBJDIR) $(CONFIG_H) slangversion $(OBJDIR)/$(EXEC)
|
||||
@echo $(EXEC) created in $(OBJDIR)
|
||||
$(OBJDIR)/$(EXEC): $(OBJS)
|
||||
cd $(OBJDIR); $(CC) $(OFILES) -o $(EXEC) $(LDFLAGS) $(EXECLIBS)
|
||||
#
|
||||
$(OBJDIR):
|
||||
-mkdir $(OBJDIR)
|
||||
#
|
||||
$(CONFIG_H) : $(SRCDIR)/sysconf.h
|
||||
/bin/cp $(SRCDIR)/sysconf.h $(CONFIG_H)
|
||||
#
|
||||
slangversion: $(OBJDIR)/chkslang
|
||||
$(OBJDIR)/chkslang $(EXEC) 20000
|
||||
#
|
||||
$(OBJDIR)/chkslang: $(OBJDIR)/chkslang.o
|
||||
$(CC) $(OBJDIR)/chkslang.o -o $(OBJDIR)/chkslang $(LDFLAGS) $(EXECLIBS)
|
||||
#
|
||||
$(SRCDIR)/version.h: $(SRCDIR)/../changes.txt
|
||||
if [ -x $(UPDATE_VERSION_SCRIPT) ]; then \
|
||||
$(UPDATE_VERSION_SCRIPT) $(SRCDIR)/../changes.txt $(SRCDIR)/version.h; \
|
||||
fi
|
||||
#
|
||||
clean:
|
||||
/bin/rm -f $(OBJDIR)/* *~
|
||||
distclean: clean
|
||||
/bin/rm -rf $(OBJDIR) Makefile sysconf.h
|
||||
installdirs:
|
||||
$(MKINSDIR) $(DEST_DOCDIR)
|
||||
$(MKINSDIR) $(DEST_MANDIR)/man1
|
||||
$(MKINSDIR) $(DEST_BINDIR)
|
||||
install: all installdirs
|
||||
$(INSTALL) -s $(OBJDIR)/most $(DEST_BINDIR)
|
||||
$(INSTALL_DATA) ../doc/most.1 $(DEST_MANDIR)/man1
|
||||
@for i in $(DOC_FILES); \
|
||||
do \
|
||||
echo $(INSTALL_DATA) $$i $(DEST_DOCDIR)/; \
|
||||
$(INSTALL_DATA) $$i $(DEST_DOCDIR)/; \
|
||||
if [ "$$?" != "0" ]; then \
|
||||
exit 1; \
|
||||
fi; \
|
||||
done
|
||||
# The symlinks target is for my own private use. It simply creates the object
|
||||
# directory as a symbolic link to a local disk instead of an NFS mounted one.
|
||||
symlinks:
|
||||
-/bin/rm -f $(ARCH)objs
|
||||
mkdir -p $(HOME)/sys/$(ARCH)/objs/most/src
|
||||
ln -s $(HOME)/sys/$(ARCH)/objs/most/src $(ARCH)objs
|
||||
#---------------------------------------------------------------------------
|
||||
# Rules (automatically generated)
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
$(OBJDIR)/buffer.o : $(SRCDIR)/buffer.c $(DOT_O_DEPS) $(OBJ_O_DEPS) $(buffer_O_DEP)
|
||||
cd $(OBJDIR) && $(COMPILE_CMD) $(buffer_C_FLAGS) $(SRCDIR)/buffer.c
|
||||
|
||||
$(OBJDIR)/cmd.o : $(SRCDIR)/cmd.c $(DOT_O_DEPS) $(OBJ_O_DEPS) $(cmd_O_DEP)
|
||||
cd $(OBJDIR) && $(COMPILE_CMD) $(cmd_C_FLAGS) $(SRCDIR)/cmd.c
|
||||
|
||||
$(OBJDIR)/display.o : $(SRCDIR)/display.c $(DOT_O_DEPS) $(OBJ_O_DEPS) $(display_O_DEP)
|
||||
cd $(OBJDIR) && $(COMPILE_CMD) $(display_C_FLAGS) $(SRCDIR)/display.c
|
||||
|
||||
$(OBJDIR)/edit.o : $(SRCDIR)/edit.c $(DOT_O_DEPS) $(OBJ_O_DEPS) $(edit_O_DEP)
|
||||
cd $(OBJDIR) && $(COMPILE_CMD) $(edit_C_FLAGS) $(SRCDIR)/edit.c
|
||||
|
||||
$(OBJDIR)/file.o : $(SRCDIR)/file.c $(DOT_O_DEPS) $(OBJ_O_DEPS) $(file_O_DEP)
|
||||
cd $(OBJDIR) && $(COMPILE_CMD) $(file_C_FLAGS) $(SRCDIR)/file.c
|
||||
|
||||
$(OBJDIR)/help.o : $(SRCDIR)/help.c $(DOT_O_DEPS) $(OBJ_O_DEPS) $(help_O_DEP)
|
||||
cd $(OBJDIR) && $(COMPILE_CMD) $(help_C_FLAGS) $(SRCDIR)/help.c
|
||||
|
||||
$(OBJDIR)/keym.o : $(SRCDIR)/keym.c $(DOT_O_DEPS) $(OBJ_O_DEPS) $(keym_O_DEP)
|
||||
cd $(OBJDIR) && $(COMPILE_CMD) $(keym_C_FLAGS) $(SRCDIR)/keym.c
|
||||
|
||||
$(OBJDIR)/keyparse.o : $(SRCDIR)/keyparse.c $(DOT_O_DEPS) $(OBJ_O_DEPS) $(keyparse_O_DEP)
|
||||
cd $(OBJDIR) && $(COMPILE_CMD) $(keyparse_C_FLAGS) $(SRCDIR)/keyparse.c
|
||||
|
||||
$(OBJDIR)/line.o : $(SRCDIR)/line.c $(DOT_O_DEPS) $(OBJ_O_DEPS) $(line_O_DEP)
|
||||
cd $(OBJDIR) && $(COMPILE_CMD) $(line_C_FLAGS) $(SRCDIR)/line.c
|
||||
|
||||
$(OBJDIR)/main.o : $(SRCDIR)/main.c $(DOT_O_DEPS) $(OBJ_O_DEPS) $(main_O_DEP)
|
||||
cd $(OBJDIR) && $(COMPILE_CMD) $(main_C_FLAGS) $(SRCDIR)/main.c
|
||||
|
||||
$(OBJDIR)/most.o : $(SRCDIR)/most.c $(DOT_O_DEPS) $(OBJ_O_DEPS) $(most_O_DEP)
|
||||
cd $(OBJDIR) && $(COMPILE_CMD) $(most_C_FLAGS) $(SRCDIR)/most.c
|
||||
|
||||
$(OBJDIR)/search.o : $(SRCDIR)/search.c $(DOT_O_DEPS) $(OBJ_O_DEPS) $(search_O_DEP)
|
||||
cd $(OBJDIR) && $(COMPILE_CMD) $(search_C_FLAGS) $(SRCDIR)/search.c
|
||||
|
||||
$(OBJDIR)/sysdep.o : $(SRCDIR)/sysdep.c $(DOT_O_DEPS) $(OBJ_O_DEPS) $(sysdep_O_DEP)
|
||||
cd $(OBJDIR) && $(COMPILE_CMD) $(sysdep_C_FLAGS) $(SRCDIR)/sysdep.c
|
||||
|
||||
$(OBJDIR)/window.o : $(SRCDIR)/window.c $(DOT_O_DEPS) $(OBJ_O_DEPS) $(window_O_DEP)
|
||||
cd $(OBJDIR) && $(COMPILE_CMD) $(window_C_FLAGS) $(SRCDIR)/window.c
|
||||
|
||||
$(OBJDIR)/chkslang.o : $(SRCDIR)/chkslang.c $(DOT_O_DEPS) $(OBJ_O_DEPS) $(chkslang_O_DEP)
|
||||
cd $(OBJDIR) && $(COMPILE_CMD) $(chkslang_C_FLAGS) $(SRCDIR)/chkslang.c
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
CC = @CC@
|
||||
CFLAGS = @CFLAGS@ @SLANG_DLL_CFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
SLANG_INC = @SLANG_INC@
|
||||
SLANG_LIB = @SLANG_LIB@ -lslang
|
||||
MISCLIBS = @TERMCAP@
|
||||
RPATH = @RPATH@
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Location where object files are placed (Absolute path)
|
||||
#-----------------------------------------------------------------------------
|
||||
SRCDIR = @CONFIG_DIR@/src
|
||||
OBJDIR = @CONFIG_DIR@/src/$(ARCH)objs
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# 5. Install location
|
||||
#----------------------------------------------------------------------------
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
DESTDIR =
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
datarootdir = @datarootdir@
|
||||
BIN_DIR = $(prefix)/bin
|
||||
MAN_DIR = $(datarootdir)/man
|
||||
DOC_DIR = $(datarootdir)/doc/most
|
||||
SYS_INITFILE = @sysconfdir@/most.conf
|
||||
MKINSDIR = ../autoconf/mkinsdir.sh
|
||||
|
||||
DOC_FILES = ../doc/most.txt ../README ../doc/most-fun.txt ../doc/lesskeys.rc ../doc/most.rc ../changes.txt
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Nothing below here should require changing.
|
||||
#----------------------------------------------------------------------------
|
||||
DEST_DOCDIR = $(DESTDIR)$(DOC_DIR)
|
||||
DEST_MANDIR = $(DESTDIR)$(MAN_DIR)
|
||||
DEST_BINDIR = $(DESTDIR)$(BIN_DIR)
|
||||
#
|
||||
SHELL = /bin/sh
|
||||
OBJS = @PROGRAM_OBJECTS@
|
||||
OFILES = @PROGRAM_OFILES@
|
||||
|
||||
EXEC = most
|
||||
CONFIG_H = config.h
|
||||
INCS = $(SLANG_INC)
|
||||
ALL_CFLAGS = $(CFLAGS) -Dunix $(INCS)
|
||||
EXECLIBS = $(RPATH) $(SLANG_LIB) $(MISCLIBS) -lm
|
||||
#
|
||||
most_O_DEP = $(SRCDIR)/version.h
|
||||
UPDATE_VERSION_SCRIPT = $(HOME)/bin/update_changes_version
|
||||
|
||||
COMPILE_CMD = $(CC) -c $(ALL_CFLAGS) -DMOST_SYSTEM_INITFILE='"$(SYS_INITFILE)"'
|
||||
#
|
||||
all: $(EXEC)
|
||||
$(EXEC): $(OBJDIR) $(CONFIG_H) slangversion $(OBJDIR)/$(EXEC)
|
||||
@echo $(EXEC) created in $(OBJDIR)
|
||||
$(OBJDIR)/$(EXEC): $(OBJS)
|
||||
cd $(OBJDIR); $(CC) $(OFILES) -o $(EXEC) $(LDFLAGS) $(EXECLIBS)
|
||||
#
|
||||
$(OBJDIR):
|
||||
-mkdir $(OBJDIR)
|
||||
#
|
||||
$(CONFIG_H) : $(SRCDIR)/sysconf.h
|
||||
/bin/cp $(SRCDIR)/sysconf.h $(CONFIG_H)
|
||||
#
|
||||
slangversion: $(OBJDIR)/chkslang
|
||||
$(OBJDIR)/chkslang $(EXEC) 20000
|
||||
#
|
||||
$(OBJDIR)/chkslang: $(OBJDIR)/chkslang.o
|
||||
$(CC) $(OBJDIR)/chkslang.o -o $(OBJDIR)/chkslang $(LDFLAGS) $(EXECLIBS)
|
||||
#
|
||||
$(SRCDIR)/version.h: $(SRCDIR)/../changes.txt
|
||||
if [ -x $(UPDATE_VERSION_SCRIPT) ]; then \
|
||||
$(UPDATE_VERSION_SCRIPT) $(SRCDIR)/../changes.txt $(SRCDIR)/version.h; \
|
||||
fi
|
||||
#
|
||||
clean:
|
||||
/bin/rm -f $(OBJDIR)/* *~
|
||||
distclean: clean
|
||||
/bin/rm -rf $(OBJDIR) Makefile sysconf.h
|
||||
installdirs:
|
||||
$(MKINSDIR) $(DEST_DOCDIR)
|
||||
$(MKINSDIR) $(DEST_MANDIR)/man1
|
||||
$(MKINSDIR) $(DEST_BINDIR)
|
||||
install: all installdirs
|
||||
$(INSTALL) -s $(OBJDIR)/most $(DEST_BINDIR)
|
||||
$(INSTALL_DATA) ../doc/most.1 $(DEST_MANDIR)/man1
|
||||
@for i in $(DOC_FILES); \
|
||||
do \
|
||||
echo $(INSTALL_DATA) $$i $(DEST_DOCDIR)/; \
|
||||
$(INSTALL_DATA) $$i $(DEST_DOCDIR)/; \
|
||||
if [ "$$?" != "0" ]; then \
|
||||
exit 1; \
|
||||
fi; \
|
||||
done
|
||||
# The symlinks target is for my own private use. It simply creates the object
|
||||
# directory as a symbolic link to a local disk instead of an NFS mounted one.
|
||||
symlinks:
|
||||
-/bin/rm -f $(ARCH)objs
|
||||
mkdir -p $(HOME)/sys/$(ARCH)/objs/most/src
|
||||
ln -s $(HOME)/sys/$(ARCH)/objs/most/src $(ARCH)objs
|
||||
#---------------------------------------------------------------------------
|
||||
# Rules (automatically generated)
|
||||
#---------------------------------------------------------------------------
|
|
@ -0,0 +1,90 @@
|
|||
# DJGPP and MINGW32 Makefile for most -*- sh -*-
|
||||
#---------------------------------------------------------------------------
|
||||
# 1. Choose a C compiler. It must understand prototypes.
|
||||
#-----------------------------------------------------------------------------
|
||||
CC = gcc
|
||||
CFLAGS = -Wall -W -O2 -fno-strength-reduce
|
||||
LDFLAGS =
|
||||
|
||||
# If using DJGPP, set ARCH to djg. Use gw32 for MINGW32
|
||||
#ARCH=djg
|
||||
ARCH=gw32
|
||||
|
||||
SLANGINC = ../../slang/src# Location of slang.h
|
||||
SLANGLIB = $(SLANGINC)/$(ARCH)objs# Location of libslang.a
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# 4. Location where object files are placed
|
||||
#-----------------------------------------------------------------------------
|
||||
OBJDIR = $(ARCH)objs
|
||||
SRCDIR = .
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Nothing below here should require changing.
|
||||
#----------------------------------------------------------------------------
|
||||
OBJS = $(OBJDIR)/buffer.o $(OBJDIR)/cmd.o $(OBJDIR)/display.o $(OBJDIR)/edit.o $(OBJDIR)/file.o $(OBJDIR)/help.o $(OBJDIR)/keym.o $(OBJDIR)/keyparse.o $(OBJDIR)/line.o $(OBJDIR)/main.o $(OBJDIR)/most.o $(OBJDIR)/search.o $(OBJDIR)/sysdep.o $(OBJDIR)/window.o
|
||||
OFILES = buffer.o cmd.o display.o edit.o file.o help.o keym.o keyparse.o line.o main.o most.o search.o sysdep.o window.o
|
||||
|
||||
EXEC = most
|
||||
CONFIG_H = config.h
|
||||
ALL_CFLAGS = $(CFLAGS) -I$(SLANGINC)
|
||||
EXECLIBS = -L../$(SLANGLIB) -lslang
|
||||
#
|
||||
COMPILE_CMD = $(CC) -c $(ALL_CFLAGS)
|
||||
#
|
||||
all: $(EXEC)
|
||||
$(EXEC): $(OBJDIR) $(CONFIG_H) $(OBJDIR)/$(EXEC)
|
||||
@echo $(EXEC) created in $(OBJDIR)
|
||||
$(OBJDIR)/$(EXEC): $(OBJS)
|
||||
cd $(OBJDIR); $(CC) *.o -o $(EXEC) $(LDFLAGS) $(EXECLIBS)
|
||||
#
|
||||
$(OBJDIR):
|
||||
-mkdir $(OBJDIR)
|
||||
#
|
||||
$(CONFIG_H) : $(SRCDIR)/w32conf.h
|
||||
cp $(SRCDIR)/w32conf.h $(CONFIG_H)
|
||||
clean:
|
||||
rm -f $(OBJDIR)/* *~
|
||||
|
||||
$(OBJDIR)/buffer.o : $(SRCDIR)/buffer.c $(DOT_O_DEPS) $(buffer_O_DEP)
|
||||
$(COMPILE_CMD) $(SRCDIR)/buffer.c -o $(OBJDIR)/buffer.o
|
||||
|
||||
$(OBJDIR)/cmd.o : $(SRCDIR)/cmd.c $(DOT_O_DEPS) $(cmd_O_DEP)
|
||||
$(COMPILE_CMD) $(SRCDIR)/cmd.c -o $(OBJDIR)/cmd.o
|
||||
|
||||
$(OBJDIR)/display.o : $(SRCDIR)/display.c $(DOT_O_DEPS) $(display_O_DEP)
|
||||
$(COMPILE_CMD) $(SRCDIR)/display.c -o $(OBJDIR)/display.o
|
||||
|
||||
$(OBJDIR)/edit.o : $(SRCDIR)/edit.c $(DOT_O_DEPS) $(edit_O_DEP)
|
||||
$(COMPILE_CMD) $(SRCDIR)/edit.c -o $(OBJDIR)/edit.o
|
||||
|
||||
$(OBJDIR)/file.o : $(SRCDIR)/file.c $(DOT_O_DEPS) $(file_O_DEP)
|
||||
$(COMPILE_CMD) $(SRCDIR)/file.c -o $(OBJDIR)/file.o
|
||||
|
||||
$(OBJDIR)/help.o : $(SRCDIR)/help.c $(DOT_O_DEPS) $(help_O_DEP)
|
||||
$(COMPILE_CMD) $(SRCDIR)/help.c -o $(OBJDIR)/help.o
|
||||
|
||||
$(OBJDIR)/keym.o : $(SRCDIR)/keym.c $(DOT_O_DEPS) $(keym_O_DEP)
|
||||
$(COMPILE_CMD) $(SRCDIR)/keym.c -o $(OBJDIR)/keym.o
|
||||
|
||||
$(OBJDIR)/keyparse.o : $(SRCDIR)/keyparse.c $(DOT_O_DEPS) $(keyparse_O_DEP)
|
||||
$(COMPILE_CMD) $(SRCDIR)/keyparse.c -o $(OBJDIR)/keyparse.o
|
||||
|
||||
$(OBJDIR)/line.o : $(SRCDIR)/line.c $(DOT_O_DEPS) $(line_O_DEP)
|
||||
$(COMPILE_CMD) $(SRCDIR)/line.c -o $(OBJDIR)/line.o
|
||||
|
||||
$(OBJDIR)/main.o : $(SRCDIR)/main.c $(DOT_O_DEPS) $(main_O_DEP)
|
||||
$(COMPILE_CMD) $(SRCDIR)/main.c -o $(OBJDIR)/main.o
|
||||
|
||||
$(OBJDIR)/most.o : $(SRCDIR)/most.c $(DOT_O_DEPS) $(most_O_DEP)
|
||||
$(COMPILE_CMD) $(SRCDIR)/most.c -o $(OBJDIR)/most.o
|
||||
|
||||
$(OBJDIR)/search.o : $(SRCDIR)/search.c $(DOT_O_DEPS) $(search_O_DEP)
|
||||
$(COMPILE_CMD) $(SRCDIR)/search.c -o $(OBJDIR)/search.o
|
||||
|
||||
$(OBJDIR)/sysdep.o : $(SRCDIR)/sysdep.c $(DOT_O_DEPS) $(sysdep_O_DEP)
|
||||
$(COMPILE_CMD) $(SRCDIR)/sysdep.c -o $(OBJDIR)/sysdep.o
|
||||
|
||||
$(OBJDIR)/window.o : $(SRCDIR)/window.c $(DOT_O_DEPS) $(window_O_DEP)
|
||||
$(COMPILE_CMD) $(SRCDIR)/window.c -o $(OBJDIR)/window.o
|
|
@ -0,0 +1,2 @@
|
|||
SYS$LIBRARY:VAXCRTL/SHARE
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
$! Most Makefile for VMS
|
||||
$!
|
||||
$! S-Lang Include directory (where slang.olb is located)
|
||||
$!
|
||||
$ Link_Flags = ""
|
||||
$ Link_Libs = ""
|
||||
$ slang_dir = "[-.-.slang.src]"
|
||||
$ slang_lib = ",''slang_dir'slang/LIBR"
|
||||
$ defs = ""
|
||||
$ include = slang_dir
|
||||
$!
|
||||
$! If compiling with GCC, uncomment next line
|
||||
$! goto has_gcc
|
||||
$ if (p1 .eqs. "GCC") then goto has_gcc
|
||||
$!
|
||||
$! There should be no need to change anything below here
|
||||
$!
|
||||
$ C_C = "cc/standard=vaxc"
|
||||
$ goto start
|
||||
$ has_gcc:
|
||||
$ C_C = "gcc/warnings/nocase_hack"
|
||||
$ link_libs = "GNU_CC:[000000]GCCLIB/LIB"
|
||||
$!
|
||||
$ start:
|
||||
$ copy mostconf.h config.h
|
||||
$ axp = 0
|
||||
$ axp = f$getsyi("HW_MODEL").ge.1024
|
||||
$ exec_name = "most.exe"
|
||||
$ files = "main,buffer,file,window,line,display,sysdep,"
|
||||
$ files = files + "keym,most,search,help,cmd,edit,keyparse"
|
||||
$!
|
||||
$ if (p1 .eqs. "LINK") then goto do_link
|
||||
$!
|
||||
$! simple make
|
||||
$!
|
||||
$ if (defs .nes. "") then defs = "/define=(" + defs + ")"
|
||||
$ if (include .nes. "") then include = "/include=(" + include + ")"
|
||||
$ count = 0
|
||||
$ next_file:
|
||||
$ f = f$element(count, ",", files)
|
||||
$ count = count + 1
|
||||
$ if (f .eqs. ",") then goto do_link
|
||||
$ objf = f$search("''f'.obj")
|
||||
$ if (objf .eqs. "") then goto compile_it
|
||||
$ tobj = f$file_attr(objf, "RDT")
|
||||
$ tc = f$file_attr("''f'.c", "RDT")
|
||||
$ if (f$cvtime(tc) .lts. f$cvtime(tobj)) then goto next_file
|
||||
$ compile_it:
|
||||
$ write sys$output "''C_C' ''defs' ''include' ''f'.c"
|
||||
$ 'C_C' 'defs' 'include' 'f'.c
|
||||
$ goto next_file
|
||||
$ do_link:
|
||||
$ if axp
|
||||
$ then
|
||||
$ set verify
|
||||
$ link/exec=most.exe 'Link_Flags' 'files', 'slang_dir'slang/LIBR 'Link_Libs'
|
||||
$ set noverify
|
||||
$ else
|
||||
$ set verify
|
||||
$ link/exec=most.exe 'Link_Flags' 'files', 'slang_dir'slang/LIB 'Link_Libs', -
|
||||
sys$input/opt
|
||||
SYS$LIBRARY:VAXCRTL/SHARE
|
||||
$ set noverify
|
||||
$ endif
|
||||
$exit
|
|
@ -0,0 +1,579 @@
|
|||
/*
|
||||
This file is part of MOST.
|
||||
|
||||
Copyright (c) 1991, 1999, 2002, 2005-2018, 2019 John E. Davis
|
||||
|
||||
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 2 of the License, 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.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <slang.h>
|
||||
#include "jdmacros.h"
|
||||
|
||||
#include "most.h"
|
||||
#include "buffer.h"
|
||||
#include "display.h"
|
||||
#include "window.h"
|
||||
#include "line.h"
|
||||
#include "file.h"
|
||||
|
||||
int Most_W_Opt = 0;
|
||||
|
||||
unsigned char *Most_Beg; /* beginning of current buffer */
|
||||
unsigned char *Most_Eob; /* end of current buffer */
|
||||
|
||||
Most_Buffer_Type *Most_Buf;
|
||||
|
||||
MOST_INT Most_Num_Lines;
|
||||
|
||||
MOST_UINT Most_C_Offset;
|
||||
MOST_INT Most_C_Line;
|
||||
|
||||
/* p>p0 assumed */
|
||||
#define BSKIP_CHAR(p,p0) \
|
||||
(((Most_UTF8_Mode == 0) || (0 == ((*(p-1)) & 0x80))) \
|
||||
? ((p)--) \
|
||||
: ((p) = SLutf8_bskip_char ((p0), (p))))
|
||||
|
||||
static unsigned char *beg_of_line1(void)
|
||||
{
|
||||
unsigned char *pos;
|
||||
unsigned char *cpos;
|
||||
|
||||
cpos = pos = Most_Beg + Most_C_Offset;
|
||||
if (pos == Most_Beg) return pos;
|
||||
|
||||
if (pos != Most_Eob)
|
||||
{
|
||||
if (*pos == '\n')
|
||||
{
|
||||
pos--;/* Skip back over the new-line. */
|
||||
while ((pos > Most_Beg)
|
||||
&& (*pos != '\n'))
|
||||
pos--;
|
||||
|
||||
if (*pos != '\n') return pos;
|
||||
if (pos + 1 != cpos)
|
||||
return pos + 1;
|
||||
}
|
||||
}
|
||||
else BSKIP_CHAR (pos, Most_Beg);
|
||||
|
||||
if (*pos != '\n')
|
||||
{
|
||||
while ((pos > Most_Beg)
|
||||
&& (*pos != '\n'))
|
||||
pos--;
|
||||
if (*pos != '\n') return Most_Beg;
|
||||
return pos + 1;
|
||||
}
|
||||
|
||||
/* from here on *pos == '\n' */
|
||||
|
||||
if (Most_S_Opt == 0) return pos + 1;
|
||||
|
||||
while ((pos > Most_Beg)
|
||||
&& (*pos == '\n')) pos--;
|
||||
pos += 2;
|
||||
if (pos > cpos) pos = cpos;
|
||||
return pos;
|
||||
}
|
||||
|
||||
/* does not move point */
|
||||
static unsigned char *end_of_line1(void)
|
||||
{
|
||||
register unsigned char *pos, *pmax;
|
||||
int n, n2;
|
||||
|
||||
pos = Most_Beg + Most_C_Offset;
|
||||
pmax = Most_Eob;
|
||||
if (pos >= pmax) return pmax;
|
||||
|
||||
/* find the first '\n'. If we are wrapping lines, then do not go more
|
||||
* than 3 times the display width.
|
||||
*/
|
||||
if (Most_W_Opt && SLtt_Screen_Cols)
|
||||
{
|
||||
pmax = pos + 3 * SLtt_Screen_Cols;
|
||||
if (pmax > Most_Eob)
|
||||
pmax = Most_Eob;
|
||||
}
|
||||
|
||||
if (*pos != '\n')
|
||||
{
|
||||
/* This block is UTF-8 safe, because it only scans the buffer
|
||||
* for a new-line, and doesn't count characters.
|
||||
*/
|
||||
n = pmax - pos;
|
||||
n2 = n % 8;
|
||||
pmax = pos + (n - 8);
|
||||
|
||||
while (pos <= pmax)
|
||||
{
|
||||
if (*pos == '\n') return pos;
|
||||
if (*(pos + 1) == '\n') return pos + 1;
|
||||
if (*(pos + 2) == '\n') return pos + 2;
|
||||
if (*(pos + 3) == '\n') return pos + 3;
|
||||
if (*(pos + 4) == '\n') return pos + 4;
|
||||
if (*(pos + 5) == '\n') return pos + 5;
|
||||
if (*(pos + 6) == '\n') return pos + 6;
|
||||
if (*(pos + 7) == '\n') return pos + 7;
|
||||
pos += 8;
|
||||
}
|
||||
pmax = pos + n2;
|
||||
while ((pos < pmax) && (*pos != '\n')) pos++;
|
||||
return(pos);
|
||||
}
|
||||
|
||||
if (!Most_S_Opt) return (pos);
|
||||
/* file */
|
||||
/* if Most_Beg = "....abc\n\n\n\n\ndef..." then we are at some first \n. We
|
||||
want to return the last '\n' unless we wre at the first '\n'. */
|
||||
|
||||
/* Here we are on a \n and NOT at the end of the buffer */
|
||||
|
||||
if ((pos > Most_Beg) && (*(pos - 1) != '\n')) return (pos);
|
||||
|
||||
while ((pos < Most_Eob) && (*pos == '\n')) pos++;
|
||||
if (pos == Most_Eob) return pos;
|
||||
if (pos != Most_Beg) pos--;
|
||||
return pos;
|
||||
/* if (pos == Most_Eob) return (pos - 1);
|
||||
return pos; */
|
||||
}
|
||||
|
||||
unsigned char *most_beg_of_line(void)
|
||||
{
|
||||
unsigned char *b;
|
||||
unsigned int ncols;
|
||||
unsigned char *e;
|
||||
|
||||
if (Most_W_Opt == 0) return beg_of_line1();
|
||||
|
||||
b = beg_of_line1 ();
|
||||
e = end_of_line1 ();
|
||||
ncols = SLtt_Screen_Cols;
|
||||
if (Most_Show_Wrap_Marker)
|
||||
ncols--;
|
||||
while (1)
|
||||
{
|
||||
unsigned char *next_b = most_forward_columns (b, e, ncols);
|
||||
if ((next_b == e) || (next_b == b))
|
||||
break;
|
||||
|
||||
if (next_b >= Most_Beg + Most_C_Offset)
|
||||
break;
|
||||
|
||||
b = next_b;
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
static unsigned char *end_of_line (unsigned char *b)
|
||||
{
|
||||
unsigned char *e, *b1;
|
||||
int ncols;
|
||||
|
||||
e = end_of_line1();
|
||||
if (Most_W_Opt == 0)
|
||||
return e;
|
||||
|
||||
if (b == NULL) b = most_beg_of_line ();
|
||||
|
||||
ncols = SLtt_Screen_Cols;
|
||||
if (Most_Show_Wrap_Marker)
|
||||
ncols--;
|
||||
|
||||
b = most_forward_columns (b, e, ncols);
|
||||
|
||||
/* Do not wrap the line if the last character falls on the last column
|
||||
* of the display.
|
||||
*/
|
||||
if (Most_Show_Wrap_Marker)
|
||||
{
|
||||
if ((Most_UTF8_Mode == 0) || ((*b & 0x80) == 0))
|
||||
b1 = b + 1;
|
||||
else
|
||||
b1 = SLutf8_skip_char (b, Most_Eob);
|
||||
|
||||
if ((b1 <= e)
|
||||
&& (b1 < Most_Eob))
|
||||
{
|
||||
if (*b1 == '\n')
|
||||
b = b1;
|
||||
else if ((*b1 == 033) && (Most_V_Opt == 0))
|
||||
{
|
||||
unsigned char ch = 033;
|
||||
b1++;
|
||||
while ((ch == 033) && (b1 < e) && (b1 < Most_Eob)
|
||||
&& (0 == most_parse_color_escape (&b1, e, NULL)))
|
||||
{
|
||||
b = b1;
|
||||
ch = *b1++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
MOST_INT most_forward_line (MOST_INT save)
|
||||
{
|
||||
MOST_INT m, n;
|
||||
unsigned char *p;
|
||||
unsigned char *pmax;
|
||||
|
||||
n = save;
|
||||
pmax = Most_Eob;
|
||||
|
||||
if (n > 0)
|
||||
{
|
||||
if (Most_B_Opt)
|
||||
{
|
||||
m = (Most_Eob - (Most_Beg + Most_C_Offset)) / 16;
|
||||
if (n > m) n = m;
|
||||
Most_C_Offset += n * 16;
|
||||
Most_C_Line += n;
|
||||
return n;
|
||||
}
|
||||
|
||||
p = NULL;
|
||||
while (n--)
|
||||
{
|
||||
p = end_of_line (p);
|
||||
Most_C_Offset = p - Most_Beg;
|
||||
if (p == Most_Eob) return (save - (n + 1));
|
||||
Most_C_Line++; Most_C_Offset++;
|
||||
|
||||
if (Most_Selective_Display)
|
||||
{
|
||||
/* Skip past lines with too much indentation to the start
|
||||
* of a valid one.
|
||||
*/
|
||||
p = Most_Beg + Most_C_Offset;
|
||||
while (p < pmax)
|
||||
{
|
||||
while ((p < pmax) && (*p <= ' ')) p++;
|
||||
if (most_apparant_distance(p) < Most_Selective_Display)
|
||||
break;
|
||||
Most_C_Offset = (p - Most_Beg);
|
||||
p = end_of_line (p);
|
||||
if (p < pmax) p++;
|
||||
}
|
||||
Most_C_Offset = (p - Most_Beg);
|
||||
}
|
||||
p = Most_Beg + Most_C_Offset;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Most_B_Opt)
|
||||
{
|
||||
m = Most_C_Offset / 16;
|
||||
if (n < m) n = m;
|
||||
Most_C_Offset += n * 16;
|
||||
Most_C_Line += n;
|
||||
return n;
|
||||
}
|
||||
else while (n++)
|
||||
{
|
||||
p = most_beg_of_line();
|
||||
Most_C_Offset = (p - Most_Beg);
|
||||
if (Most_C_Offset == 0) return (n - (save + 1));
|
||||
Most_C_Line--;
|
||||
Most_C_Offset--;
|
||||
|
||||
if (Most_Selective_Display)
|
||||
{
|
||||
/* Skip past lines with too much indentation to the start
|
||||
* of a valid one.
|
||||
*/
|
||||
p = Most_Beg + Most_C_Offset;
|
||||
while (p > Most_Beg)
|
||||
{
|
||||
/* skip all blank lines */
|
||||
while ((p > Most_Beg) && (*p <= ' ')) p--;
|
||||
pmax = p;
|
||||
Most_C_Offset = pmax - Most_Beg;
|
||||
p = most_beg_of_line ();
|
||||
Most_C_Offset = p - Most_Beg;
|
||||
while ((p < pmax) && (*p <= ' ')) p++;
|
||||
if (most_apparant_distance(p) < Most_Selective_Display)
|
||||
break;
|
||||
Most_C_Offset = p - Most_Beg;
|
||||
p = most_beg_of_line ();
|
||||
if (p > Most_Beg) p--;
|
||||
Most_C_Offset = p - Most_Beg;
|
||||
}
|
||||
Most_C_Offset = p - Most_Beg;
|
||||
}
|
||||
}
|
||||
}
|
||||
return(save);
|
||||
}
|
||||
|
||||
/* Count lines in the region. A half line counts as 1 */
|
||||
MOST_INT most_count_lines(unsigned char *beg, unsigned char *end)
|
||||
{
|
||||
MOST_INT save_line, n;
|
||||
unsigned char *save_beg, *save_eob;
|
||||
MOST_UINT save_pos;
|
||||
int dn = 1000;
|
||||
|
||||
if (Most_B_Opt) return(1 + (MOST_INT)(end - beg) / 16);
|
||||
|
||||
save_line = Most_C_Line; save_beg = Most_Beg; save_eob = Most_Eob;
|
||||
save_pos = Most_C_Offset;
|
||||
|
||||
Most_Beg = beg; Most_Eob = end;
|
||||
Most_C_Offset = 0;
|
||||
|
||||
n = 1;
|
||||
while((dn = most_forward_line(dn)) != 0) n += dn;
|
||||
|
||||
Most_C_Offset = save_pos;
|
||||
Most_Eob = save_eob;
|
||||
Most_Beg = save_beg;
|
||||
Most_C_Line = save_line;
|
||||
return(n);
|
||||
}
|
||||
|
||||
void most_goto_line (MOST_INT line)
|
||||
{
|
||||
MOST_INT dif_c, dif_b, dif_t;
|
||||
|
||||
if (line < 1) line = 1;
|
||||
most_read_to_line(line);
|
||||
if (line > Most_Num_Lines) line = Most_Num_Lines;
|
||||
|
||||
if (Most_B_Opt)
|
||||
{
|
||||
Most_C_Offset = (16 * (line - 1));
|
||||
Most_C_Line = line;
|
||||
return;
|
||||
}
|
||||
|
||||
dif_c = line - Most_C_Line;
|
||||
dif_b = line - Most_Num_Lines;
|
||||
dif_t = line - 1;
|
||||
|
||||
/* 4 possibilites */
|
||||
if (dif_c <= 0)
|
||||
{
|
||||
if (dif_t < -dif_c) /* go from top */
|
||||
{
|
||||
Most_C_Line = 1;
|
||||
Most_C_Offset = 0;
|
||||
(void) most_forward_line(dif_t);
|
||||
}
|
||||
else /* from curr back */
|
||||
{
|
||||
(void) most_forward_line(dif_c);
|
||||
}
|
||||
}
|
||||
else if (dif_c > 0)
|
||||
{
|
||||
if ((dif_c + dif_b) < 0) /* go from curr */
|
||||
{
|
||||
(void) most_forward_line(dif_c);
|
||||
}
|
||||
else
|
||||
{
|
||||
Most_C_Line = Most_Num_Lines;
|
||||
Most_C_Offset = (Most_Eob - Most_Beg);
|
||||
(void) most_forward_line(dif_b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* return line the point is on without the final '\n's */
|
||||
int most_extract_line(unsigned char **beg, unsigned char **end)
|
||||
{
|
||||
*beg = most_beg_of_line();
|
||||
*end = end_of_line (*beg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
MOST_INT most_what_line(unsigned char *pos)
|
||||
{
|
||||
unsigned int save_pos;
|
||||
MOST_INT save_line, dir;
|
||||
MOST_INT dif_c, dif_b,dif_t;
|
||||
int ret;
|
||||
|
||||
if (Most_B_Opt)
|
||||
{
|
||||
return (1 + (pos - Most_Beg)/16);
|
||||
}
|
||||
|
||||
if (Most_Selective_Display)
|
||||
{
|
||||
return most_count_lines (Most_Beg, pos);
|
||||
}
|
||||
|
||||
save_pos = Most_C_Offset;
|
||||
save_line = Most_C_Line;
|
||||
|
||||
dif_c = pos - (Most_Beg + Most_C_Offset);
|
||||
dif_b = pos - Most_Eob;
|
||||
dif_t = pos - Most_Beg;
|
||||
|
||||
/* 4 possibilites */
|
||||
if (dif_c <= 0)
|
||||
{
|
||||
if (dif_t < -dif_c) /* go from top */
|
||||
{
|
||||
Most_C_Line = 1;
|
||||
Most_C_Offset = 0;
|
||||
dir = 1;
|
||||
}
|
||||
else /* from curr back */
|
||||
{
|
||||
dir = -1;
|
||||
}
|
||||
}
|
||||
else /* (dif_c > 0) */
|
||||
{
|
||||
if ((dif_c + dif_b) < 0) /* go from curr */
|
||||
{
|
||||
dir = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
Most_C_Line = Most_Num_Lines;
|
||||
Most_C_Offset = Most_Eob - Most_Beg;
|
||||
dir = -1;
|
||||
}
|
||||
}
|
||||
if (dir == 1)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
unsigned char *cpos;
|
||||
|
||||
cpos = end_of_line (NULL);
|
||||
Most_C_Offset = cpos - Most_Beg;
|
||||
|
||||
if (cpos >= pos)
|
||||
break;
|
||||
|
||||
Most_C_Offset++;
|
||||
Most_C_Line++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
unsigned char *cpos;
|
||||
|
||||
cpos = most_beg_of_line ();
|
||||
Most_C_Offset = cpos - Most_Beg;
|
||||
if (pos >= cpos)
|
||||
break;
|
||||
Most_C_Line--;
|
||||
Most_C_Offset--;
|
||||
}
|
||||
}
|
||||
|
||||
ret = Most_C_Line;
|
||||
Most_C_Offset = save_pos;
|
||||
Most_C_Line = save_line;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/* given a buffer position, find the line and column */
|
||||
void most_find_row_column(unsigned char *pos, MOST_INT *r, MOST_INT *c)
|
||||
{
|
||||
unsigned int save_offset;
|
||||
MOST_INT save_line;
|
||||
|
||||
if (pos <= Most_Beg)
|
||||
{
|
||||
*r = 1;
|
||||
*c = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
save_line = Most_C_Line;
|
||||
save_offset = Most_C_Offset;
|
||||
*r = most_what_line(pos);
|
||||
|
||||
if (Most_B_Opt)
|
||||
{
|
||||
*c = (int) (pos - Most_Beg) - (*r - 1) * 16 + 1;
|
||||
return;
|
||||
}
|
||||
Most_C_Line = *r;
|
||||
Most_C_Offset = pos - Most_Beg;
|
||||
|
||||
/* Now we have found the line it is on so.... */
|
||||
(void) most_beg_of_line();
|
||||
*c = 1 + most_apparant_distance (pos);
|
||||
|
||||
Most_C_Line = save_line;
|
||||
Most_C_Offset = save_offset;
|
||||
}
|
||||
|
||||
Most_Buffer_Type *most_switch_to_buffer(Most_Buffer_Type *nnew)
|
||||
{
|
||||
Most_Buffer_Type *old;
|
||||
old = Most_Buf;
|
||||
Most_Buf = nnew;
|
||||
Most_Beg = Most_Buf->beg;
|
||||
Most_Eob = Most_Buf->end;
|
||||
return old;
|
||||
}
|
||||
|
||||
Most_Buffer_Type *most_create_buffer(char *file)
|
||||
{
|
||||
Most_Buffer_Type *buf;
|
||||
|
||||
buf = (Most_Buffer_Type *) MOSTMALLOC(sizeof(Most_Buffer_Type));
|
||||
memset ((char *) buf, 0, sizeof(Most_Buffer_Type));
|
||||
strcpy(buf->file,file);
|
||||
return(buf);
|
||||
}
|
||||
|
||||
unsigned char *most_malloc(unsigned int n)
|
||||
{
|
||||
unsigned char *b = (unsigned char *) SLMALLOC(n);
|
||||
if (b == NULL)
|
||||
{
|
||||
most_exit_error("malloc: Memory Allocation Error.");
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
unsigned char *most_realloc(unsigned char *p, unsigned int n)
|
||||
{
|
||||
unsigned char *b = (unsigned char *) SLREALLOC(p, n);
|
||||
if (b == NULL)
|
||||
{
|
||||
most_exit_error("malloc: Memory Allocation Error.");
|
||||
}
|
||||
return b;
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
This file is part of MOST.
|
||||
|
||||
Copyright (c) 1991, 1999, 2002, 2005-2018, 2019 John E. Davis
|
||||
|
||||
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 2 of the License, 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.
|
||||
*/
|
||||
#ifndef _DAVIS_BUFFER_H_
|
||||
# define _DAVIS_BUFFER_H_
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char file[MAX_PATHLEN]; /* filename */
|
||||
unsigned char *beg; /* beginning of buffer */
|
||||
unsigned char *end; /* end of buffer */
|
||||
int mark; /* marked line in buffer */
|
||||
unsigned int flags;
|
||||
int fd; /* file descriptor--- -1 if closed */
|
||||
FILE *fp; /* use pclose when EOF is reached */
|
||||
int size;
|
||||
# ifdef VMS
|
||||
int rec; /* record size for reads */
|
||||
# endif
|
||||
# if MOST_HAS_MMAP
|
||||
int is_mmaped;
|
||||
unsigned int mmap_size;
|
||||
# endif
|
||||
}
|
||||
Most_Buffer_Type;
|
||||
|
||||
extern Most_Buffer_Type *Most_Buf;
|
||||
extern unsigned char *Most_Beg, *Most_Eob;
|
||||
extern MOST_INT Most_Num_Lines;
|
||||
|
||||
/* Offset of current position from beginning of buffer */
|
||||
extern MOST_UINT Most_C_Offset;
|
||||
|
||||
extern MOST_INT Most_C_Line;
|
||||
/*
|
||||
* Current line number. If at the beginning of the buffer, it is 1. If
|
||||
* we are at the last point of the buffer it is the number of lines.
|
||||
*/
|
||||
|
||||
/* This routine does not move the point */
|
||||
extern unsigned char *most_beg_of_line(void);
|
||||
|
||||
extern MOST_INT most_forward_line(MOST_INT);
|
||||
/* This routine moves the point forward n lines. n can be negative.
|
||||
It returns the number moved. */
|
||||
|
||||
extern void most_goto_line (MOST_INT);
|
||||
/* Move the point somewhere on the nth line of the buffer returning
|
||||
C_POS */
|
||||
|
||||
extern MOST_INT most_what_line (unsigned char *);
|
||||
/* return the line number of position 'argument'. Does not move point */
|
||||
|
||||
/* count the number of lines in the region delimited by beg and end.
|
||||
Counts lines from beg up to end but does not count end.
|
||||
Does not move point. */
|
||||
extern MOST_INT most_count_lines(unsigned char *, unsigned char *);
|
||||
extern int most_extract_line(unsigned char **, unsigned char **);
|
||||
|
||||
extern Most_Buffer_Type *most_switch_to_buffer(Most_Buffer_Type *);
|
||||
extern Most_Buffer_Type *most_create_buffer(char *);
|
||||
extern void most_find_row_column(unsigned char *, MOST_INT *, MOST_INT *);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
This file is part of MOST.
|
||||
|
||||
Copyright (c) 1991, 1999, 2002, 2005-2018, 2019 John E. Davis
|
||||
|
||||
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 2 of the License, 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.
|
||||
*/
|
||||
/* It is too bad that this cannot be done at the preprocessor level.
|
||||
* Unfortunately, C is not completely portable yet. Basically the #error
|
||||
* directive is the problem.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef VMS
|
||||
# include <ssdef.h>
|
||||
#endif
|
||||
#include <slang.h>
|
||||
#include "jdmacros.h"
|
||||
|
||||
static char *make_version (unsigned int v)
|
||||
{
|
||||
static char v_string[16];
|
||||
unsigned int a, b, c;
|
||||
|
||||
a = v/10000;
|
||||
b = (v - a * 10000) / 100;
|
||||
c = v - (a * 10000) - (b * 100);
|
||||
sprintf (v_string, "%u.%u.%u", a, b, c);
|
||||
return v_string;
|
||||
}
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
unsigned int min_version, sl_version;
|
||||
unsigned int sug_version;
|
||||
int ret;
|
||||
|
||||
if ((argc < 3) || (argc > 4))
|
||||
{
|
||||
fprintf (stderr, "Usage: %s <PGM> <SLANG-VERSION> <SUGG VERSION>\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
#ifndef SLANG_VERSION
|
||||
sl_version = 0;
|
||||
#else
|
||||
sl_version = SLANG_VERSION;
|
||||
#endif
|
||||
|
||||
sscanf (argv[2], "%u", &min_version);
|
||||
if (argc == 4) sscanf (argv[3], "%u", &sug_version);
|
||||
else sug_version = sl_version;
|
||||
|
||||
ret = 0;
|
||||
if (sl_version < min_version)
|
||||
{
|
||||
fprintf (stderr, "This version of %s requires slang version %s.\n",
|
||||
argv[1], make_version(min_version));
|
||||
#ifdef VMS
|
||||
ret = SS$_ABORT;
|
||||
#else
|
||||
ret = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (sl_version < sug_version)
|
||||
{
|
||||
fprintf (stderr, "Your slang version is %s.\n", make_version(sl_version));
|
||||
fprintf (stderr, "To fully utilize this program, you should upgrade the slang library to\n");
|
||||
fprintf (stderr, " version %s\n", make_version(sug_version));
|
||||
fprintf (stderr, "This library is available via anonymous ftp from\n\
|
||||
space.mit.edu in pub/davis/slang.\n");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -0,0 +1,287 @@
|
|||
/*
|
||||
This file is part of MOST.
|
||||
|
||||
Copyright (c) 1991, 1999, 2002, 2005-2018, 2019 John E. Davis
|
||||
|
||||
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 2 of the License, 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.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include <slang.h>
|
||||
#include "jdmacros.h"
|
||||
|
||||
#include "most.h"
|
||||
#include "search.h"
|
||||
#include "window.h"
|
||||
#include "file.h"
|
||||
#include "keym.h"
|
||||
#include "display.h"
|
||||
#include "sysdep.h"
|
||||
|
||||
static char getkey_nocase (void)
|
||||
{
|
||||
char ch = most_getkey ();
|
||||
if ((ch >= 'a') && (ch <= 'z')) ch = ch - ' ';
|
||||
|
||||
SLang_flush_input ();
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
void most_next_file (void)
|
||||
{
|
||||
static int next = 1;
|
||||
char *msg = NULL;
|
||||
|
||||
if (!Most_Num_Files) msg = "File ring is empty.";
|
||||
else if (Most_Num_Files == 1) msg = "There is only one file!";
|
||||
else
|
||||
{
|
||||
most_do_next_file(&next);
|
||||
}
|
||||
if (msg != NULL) most_message (msg, 1);
|
||||
}
|
||||
|
||||
void most_toggle_case (void)
|
||||
{
|
||||
char *msg;
|
||||
Most_Case_Sensitive = !Most_Case_Sensitive;
|
||||
if (Most_Case_Sensitive)
|
||||
msg = "Searches now respect case.";
|
||||
else
|
||||
msg = "Searches nolonger respect case.";
|
||||
|
||||
most_message (msg, 0);
|
||||
}
|
||||
|
||||
void most_toggle_research (void)
|
||||
{
|
||||
char *msg;
|
||||
|
||||
Most_Do_Regexp_Search = !Most_Do_Regexp_Search;
|
||||
|
||||
if (Most_Do_Regexp_Search)
|
||||
msg = "Regexp search enabled";
|
||||
else
|
||||
msg = "Regexp search disabled";
|
||||
|
||||
most_message (msg, 0);
|
||||
}
|
||||
|
||||
void most_delete_file_cmd (void)
|
||||
{
|
||||
int bell = 0;
|
||||
char ch;
|
||||
char *msg;
|
||||
|
||||
if ('*' == *Most_Buf->file) return;
|
||||
|
||||
if (Most_Secure_Mode) Most_D_Opt = 0;
|
||||
if (Most_D_Opt == 0) return;
|
||||
|
||||
most_select_minibuffer ();
|
||||
SLsmg_printf ("Delete %s? [n]", Most_Buf->file);
|
||||
SLsmg_refresh ();
|
||||
|
||||
ch = getkey_nocase ();
|
||||
if (ch == 'Y')
|
||||
{
|
||||
if (!most_delete_file(Most_Buf->file))
|
||||
{
|
||||
msg = "File could not be deleted.";
|
||||
bell = 1;
|
||||
}
|
||||
else
|
||||
msg = "File deleted.";
|
||||
}
|
||||
else
|
||||
msg = "File not deleted.";
|
||||
most_exit_minibuffer ();
|
||||
most_message(msg, bell);
|
||||
}
|
||||
|
||||
void most_toggle_options (void)
|
||||
{
|
||||
char ch;
|
||||
char *msg = NULL;
|
||||
int n;
|
||||
unsigned int save;
|
||||
|
||||
most_select_minibuffer();
|
||||
SLsmg_write_string("Toggle: b(binary) t(tab) v(verbose) w(wrap) d(selective display) ");
|
||||
SLsmg_gotorc (SLtt_Screen_Rows - 1, 0);
|
||||
SLsmg_refresh ();
|
||||
|
||||
ch = getkey_nocase();
|
||||
switch (ch)
|
||||
{
|
||||
default:
|
||||
msg = "\007Invalid option!";
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
Most_B_Opt = !Most_B_Opt;
|
||||
Most_Num_Lines = most_count_lines(Most_Beg,Most_Eob);
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
if (Most_W_Opt)
|
||||
{
|
||||
msg = "\007Selective Display illegal in wrap mode.";
|
||||
break;
|
||||
}
|
||||
|
||||
if (Most_Digit_Arg == NULL)
|
||||
{
|
||||
msg = "Selective Display off. Prefix with integer to set.";
|
||||
n = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = "Selective Display is set.";
|
||||
n = abs( *Most_Digit_Arg );
|
||||
}
|
||||
|
||||
if (Most_Selective_Display != n)
|
||||
{
|
||||
Most_Selective_Display = n;
|
||||
Most_Num_Lines = most_count_lines(Most_Beg,Most_Eob);
|
||||
most_forward_line (-1);
|
||||
|
||||
/* This is duplicated below */
|
||||
/* Most_C_Line = most_count_lines (Most_Beg, Most_C_Pos); */
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
|
||||
if (Most_B_Opt) msg = "\007Squeezing not available in Binary mode.";
|
||||
else
|
||||
{
|
||||
Most_S_Opt = !Most_S_Opt;
|
||||
Most_Num_Lines = most_count_lines(Most_Beg,Most_Eob);
|
||||
if (Most_S_Opt) msg = "Lines are now squeezed.";
|
||||
else msg = "Line squeezing is turned off";
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'W':
|
||||
if (Most_Selective_Display)
|
||||
{
|
||||
msg = "\007Wrap mode cannot be enabled while selective display is on.";
|
||||
break;
|
||||
}
|
||||
Most_W_Opt = !Most_W_Opt;
|
||||
Most_Num_Lines = most_count_lines(Most_Beg, Most_Eob);
|
||||
if (Most_W_Opt) msg = "Wrap turned on.";
|
||||
else msg = "Wrap turned off.";
|
||||
break;
|
||||
|
||||
case 'V':
|
||||
Most_V_Opt = !Most_V_Opt;
|
||||
if (Most_V_Opt) msg = "Control char display is turned on.";
|
||||
else msg = "Control char display is turned off.";
|
||||
break;
|
||||
|
||||
case 'T':
|
||||
if (Most_Digit_Arg == NULL) Most_T_Opt = !Most_T_Opt;
|
||||
else
|
||||
{
|
||||
Most_Tab_Width = abs( *Most_Digit_Arg );
|
||||
if (Most_Tab_Width == 0) Most_T_Opt = 1;
|
||||
else Most_T_Opt = 0;
|
||||
}
|
||||
if (Most_T_Opt) msg = "Tabs are nolonger expanded.";
|
||||
else msg = "Tabs are now expanded.";
|
||||
break;
|
||||
}
|
||||
|
||||
SLsmg_erase_eol ();
|
||||
most_exit_minibuffer();
|
||||
|
||||
if ((msg != NULL) && (*msg == '\007'))
|
||||
{
|
||||
most_message (msg + 1, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Most_Num_Lines) Most_Num_Lines = 1;
|
||||
most_save_win_flags(Most_Win);
|
||||
|
||||
save = Most_C_Offset;
|
||||
Most_C_Offset = 0;
|
||||
Most_C_Line = 1;
|
||||
Most_C_Line = most_what_line (Most_Beg + save);
|
||||
Most_C_Offset = save;
|
||||
Most_Win->beg_line = Most_C_Line;
|
||||
most_redraw_window();
|
||||
most_update_status();
|
||||
|
||||
if (msg != NULL) most_message (msg, 0);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------*/
|
||||
|
||||
void most_extended_key_cmd (void)
|
||||
{
|
||||
char ch;
|
||||
|
||||
if (Most_Secure_Mode) Most_D_Opt = 0;
|
||||
|
||||
most_select_minibuffer();
|
||||
SLsmg_write_string ("Choose: N (next file), C(toggle case), R(toggle re-search) O(toggle options)");
|
||||
if (Most_D_Opt) SLsmg_write_string (" ,D (delete file)");
|
||||
SLsmg_gotorc (SLtt_Screen_Rows - 1, 0);
|
||||
SLsmg_refresh ();
|
||||
ch = getkey_nocase();
|
||||
SLsmg_erase_eol ();
|
||||
|
||||
most_exit_minibuffer ();
|
||||
|
||||
switch (ch)
|
||||
{
|
||||
case 'N':
|
||||
most_next_file ();
|
||||
break;
|
||||
case 'C':
|
||||
most_toggle_case ();
|
||||
break;
|
||||
case 'R':
|
||||
most_toggle_research ();
|
||||
break;
|
||||
case 'O':
|
||||
most_toggle_options ();
|
||||
break;
|
||||
case 'D':
|
||||
if (Most_D_Opt)
|
||||
{
|
||||
most_delete_file_cmd ();
|
||||
break;
|
||||
}
|
||||
/* drop */
|
||||
default:
|
||||
most_message ("Invalid option.", 1);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
/* src/sysconf.h. Generated from config.hin by configure. */
|
||||
/* -*- C -*- */
|
||||
|
||||
/* Note: this is for authentic unix systems only.
|
||||
* See mostconf.h for other systems.
|
||||
*/
|
||||
|
||||
#ifndef MOST_CONFIG_H
|
||||
#define MOST_CONFIG_H
|
||||
|
||||
/* Define if you want the MMAP support */
|
||||
#define USE_MMAP 1
|
||||
|
||||
/* define if you have long long type */
|
||||
#define HAVE_LONG_LONG 1
|
||||
|
||||
/* #undef off_t */
|
||||
/* #undef size_t */
|
||||
#define SIZEOF_OFF_T 8
|
||||
#define SIZEOF_SHORT 2
|
||||
#define SIZEOF_INT 4
|
||||
#define SIZEOF_LONG 8
|
||||
#define SIZEOF_FLOAT 4
|
||||
#define SIZEOF_DOUBLE 8
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
|
||||
/* The following set defines may be necessary to activate long file support */
|
||||
/* #undef _FILE_OFFSET_BITS */
|
||||
/* #undef _LARGE_FILES */
|
||||
/* #undef _LARGEFILE_SOURCE */
|
||||
|
||||
/* define if you have stdlib.h */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* define if you have unistd.h */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* define if you have memory.h */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* define if you have malloc.h */
|
||||
#define HAVE_MALLOC_H 1
|
||||
|
||||
/* define if you have memset */
|
||||
#define HAVE_MEMSET 1
|
||||
|
||||
/* define if you have memcpy */
|
||||
#define HAVE_MEMCPY 1
|
||||
|
||||
/* define if you have this. */
|
||||
#define HAVE_GETCWD 1
|
||||
|
||||
#define HAVE_MMAP 1
|
||||
|
||||
#define HAVE_TCGETPGRP 1
|
||||
#define HAVE_GETPGRP 1
|
||||
|
||||
#define HAVE_DIRENT_H 1
|
||||
/* #undef HAVE_SYS_NDIR_H */
|
||||
/* #undef HAVE_SYS_DIR_H */
|
||||
/* #undef HAVE_NDIR_H */
|
||||
|
||||
#define HAVE_SNPRINTF 1
|
||||
#define HAVE_SYS_MMAN_H 1
|
||||
|
||||
/* #undef mode_t */
|
||||
/* #undef pid_t */
|
||||
/* #undef uid_t */
|
||||
/* #undef pid_t */
|
||||
|
||||
|
||||
#ifdef _AIX
|
||||
# ifndef _POSIX_SOURCE
|
||||
# define _POSIX_SOURCE
|
||||
# endif
|
||||
# ifndef _ALL_SOURCE
|
||||
# define _ALL_SOURCE 1
|
||||
# endif
|
||||
/* This may generate warnings but the fact is that without it, xlc will
|
||||
* INCORRECTLY inline many str* functions. */
|
||||
/* # undef __STR__ */
|
||||
#endif
|
||||
|
||||
#define MAX_PATHLEN 1024
|
||||
#if defined(USE_MMAP) && defined(HAVE_MMAP) && defined(HAVE_SYS_MMAN_H)
|
||||
# define MOST_HAS_MMAP 1
|
||||
#else
|
||||
# define MOST_HAS_MMAP 0
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LONG_LONG) && (SIZEOF_OFF_T == SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG > SIZEOF_LONG)
|
||||
typedef long long MOST_INT;
|
||||
typedef unsigned long long MOST_UINT;
|
||||
# define MOST_INT_D_FMT "%lld"
|
||||
#else
|
||||
# if (SIZEOF_OFF_T == SIZEOF_INT)
|
||||
typedef int MOST_INT;
|
||||
typedef unsigned int MOST_UINT;
|
||||
# define MOST_INT_D_FMT "%d"
|
||||
# else
|
||||
typedef long MOST_INT;
|
||||
typedef unsigned long MOST_UINT;
|
||||
# define MOST_INT_D_FMT "%ld"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* MOST_CONFIG_H */
|
|
@ -0,0 +1,106 @@
|
|||
/* -*- C -*- */
|
||||
|
||||
/* Note: this is for authentic unix systems only.
|
||||
* See mostconf.h for other systems.
|
||||
*/
|
||||
|
||||
#ifndef MOST_CONFIG_H
|
||||
#define MOST_CONFIG_H
|
||||
|
||||
/* Define if you want the MMAP support */
|
||||
#undef USE_MMAP
|
||||
|
||||
/* define if you have long long type */
|
||||
#undef HAVE_LONG_LONG
|
||||
|
||||
#undef off_t
|
||||
#undef size_t
|
||||
#undef SIZEOF_OFF_T
|
||||
#undef SIZEOF_SHORT
|
||||
#undef SIZEOF_INT
|
||||
#undef SIZEOF_LONG
|
||||
#undef SIZEOF_FLOAT
|
||||
#undef SIZEOF_DOUBLE
|
||||
#undef SIZEOF_LONG_LONG
|
||||
|
||||
/* The following set defines may be necessary to activate long file support */
|
||||
#undef _FILE_OFFSET_BITS
|
||||
#undef _LARGE_FILES
|
||||
#undef _LARGEFILE_SOURCE
|
||||
|
||||
/* define if you have stdlib.h */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* define if you have unistd.h */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* define if you have memory.h */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* define if you have malloc.h */
|
||||
#undef HAVE_MALLOC_H
|
||||
|
||||
/* define if you have memset */
|
||||
#undef HAVE_MEMSET
|
||||
|
||||
/* define if you have memcpy */
|
||||
#undef HAVE_MEMCPY
|
||||
|
||||
/* define if you have this. */
|
||||
#undef HAVE_GETCWD
|
||||
|
||||
#undef HAVE_MMAP
|
||||
|
||||
#undef HAVE_TCGETPGRP
|
||||
#undef HAVE_GETPGRP
|
||||
|
||||
#undef HAVE_DIRENT_H
|
||||
#undef HAVE_SYS_NDIR_H
|
||||
#undef HAVE_SYS_DIR_H
|
||||
#undef HAVE_NDIR_H
|
||||
|
||||
#undef HAVE_SNPRINTF
|
||||
#undef HAVE_SYS_MMAN_H
|
||||
|
||||
#undef mode_t
|
||||
#undef pid_t
|
||||
#undef uid_t
|
||||
#undef pid_t
|
||||
|
||||
|
||||
#ifdef _AIX
|
||||
# ifndef _POSIX_SOURCE
|
||||
# define _POSIX_SOURCE
|
||||
# endif
|
||||
# ifndef _ALL_SOURCE
|
||||
# define _ALL_SOURCE
|
||||
# endif
|
||||
/* This may generate warnings but the fact is that without it, xlc will
|
||||
* INCORRECTLY inline many str* functions. */
|
||||
# undef __STR__
|
||||
#endif
|
||||
|
||||
#define MAX_PATHLEN 1024
|
||||
#if defined(USE_MMAP) && defined(HAVE_MMAP) && defined(HAVE_SYS_MMAN_H)
|
||||
# define MOST_HAS_MMAP 1
|
||||
#else
|
||||
# define MOST_HAS_MMAP 0
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LONG_LONG) && (SIZEOF_OFF_T == SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG > SIZEOF_LONG)
|
||||
typedef long long MOST_INT;
|
||||
typedef unsigned long long MOST_UINT;
|
||||
# define MOST_INT_D_FMT "%lld"
|
||||
#else
|
||||
# if (SIZEOF_OFF_T == SIZEOF_INT)
|
||||
typedef int MOST_INT;
|
||||
typedef unsigned int MOST_UINT;
|
||||
# define MOST_INT_D_FMT "%d"
|
||||
# else
|
||||
typedef long MOST_INT;
|
||||
typedef unsigned long MOST_UINT;
|
||||
# define MOST_INT_D_FMT "%ld"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* MOST_CONFIG_H */
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
This file is part of MOST.
|
||||
|
||||
Copyright (c) 1991, 1999, 2002, 2005-2018, 2019 John E. Davis
|
||||
|
||||
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 2 of the License, 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.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <slang.h>
|
||||
#include "jdmacros.h"
|
||||
|
||||
#include "display.h"
|
||||
|
||||
void most_narrow_width(void)
|
||||
{
|
||||
SLsmg_refresh ();
|
||||
SLtt_write_string ("\033[?3l");
|
||||
}
|
||||
|
||||
void most_wide_width(void)
|
||||
{
|
||||
SLsmg_refresh ();
|
||||
SLtt_write_string ("\033[?3h");
|
||||
}
|
||||
|
||||
void most_tt_set_color (int color)
|
||||
{
|
||||
SLsmg_set_color (color);
|
||||
}
|
||||
|
||||
void most_tt_bold_video (void)
|
||||
{
|
||||
SLsmg_set_color (MOST_BOLD_COLOR);
|
||||
}
|
||||
|
||||
void most_tt_normal_video (void)
|
||||
{
|
||||
SLsmg_set_color (0);
|
||||
}
|
||||
|
||||
void most_tt_underline_video (void)
|
||||
{
|
||||
SLsmg_set_color (MOST_ULINE_COLOR);
|
||||
}
|
||||
|
||||
void most_tt_reverse_video (void)
|
||||
{
|
||||
SLsmg_set_color (MOST_STATUS_COLOR);
|
||||
}
|
||||
|
||||
void most_goto_rc (int r, int c)
|
||||
{
|
||||
SLsmg_gotorc (r - 1, c - 1);
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
This file is part of MOST.
|
||||
|
||||
Copyright (c) 1991, 1999, 2002, 2005-2018, 2019 John E. Davis
|
||||
|
||||
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 2 of the License, 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.
|
||||
*/
|
||||
|
||||
/* These numbers match ANSI escape sequences of form ESC [ x m */
|
||||
#define MOST_BOLD_COLOR 1
|
||||
#define MOST_ULINE_COLOR 4
|
||||
#define MOST_STATUS_COLOR 7
|
||||
|
||||
#define MOST_EMBEDDED_COLOR_OFFSET 32
|
||||
|
||||
extern void most_tt_set_color (int color);
|
||||
extern void most_tt_reverse_video(void);
|
||||
extern void most_tt_bold_video(void);
|
||||
extern void most_tt_underline_video(void);
|
||||
extern void most_tt_normal_video(void);
|
||||
extern void most_wide_width(void);
|
||||
extern void most_narrow_width(void);
|
||||
extern void most_enable_cursor_keys(void);
|
||||
|
||||
extern void most_goto_rc (int, int);
|
||||
extern void most_setup_colors (void);
|
|
@ -0,0 +1,277 @@
|
|||
/*
|
||||
This file is part of MOST.
|
||||
|
||||
Copyright (c) 1991, 1999, 2002, 2005-2018, 2019 John E. Davis
|
||||
|
||||
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 2 of the License, 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.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
/* editor functions */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef VMS
|
||||
# include <ssdef.h>
|
||||
# include <rmsdef.h>
|
||||
# include <dvidef.h>
|
||||
# include <jpidef.h>
|
||||
/* #include <libdef.h> */
|
||||
# include <descrip.h>
|
||||
# include <iodef.h>
|
||||
# include <ttdef.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include <slang.h>
|
||||
|
||||
#include "most.h"
|
||||
#include "edit.h"
|
||||
#include "window.h"
|
||||
#include "file.h"
|
||||
#include "sysdep.h"
|
||||
|
||||
/* quote_char is one of: 0, ", or '. It represents the character
|
||||
* that will be used to quote the filename.
|
||||
*/
|
||||
char *most_escape_filename (char *file, char quote_char)
|
||||
{
|
||||
char *efile, *e;
|
||||
|
||||
if (NULL == (efile = SLmalloc (5 + 2*strlen(file))))
|
||||
return NULL;
|
||||
|
||||
e = efile;
|
||||
|
||||
#ifndef VMS
|
||||
if (quote_char == 0)
|
||||
{
|
||||
/* No quote char was used for the filename command. Add it here. */
|
||||
*e++ = '"';
|
||||
}
|
||||
else if (quote_char == '\'')
|
||||
{
|
||||
/* Suppose the file is Bob's Notes. With ' as the quote, when passed
|
||||
* to the shell, it would look like 'Bob's Notes'. Unfortunately, this
|
||||
* would produce an unmatched single quote when processed by the shell.
|
||||
* So, the following escaped form will be used:
|
||||
* ''"Bob's Notes"''
|
||||
*/
|
||||
*e++ = '\'';
|
||||
*e++ = '"';
|
||||
}
|
||||
#endif
|
||||
|
||||
while (1)
|
||||
{
|
||||
char ch = *file++;
|
||||
switch (ch)
|
||||
{
|
||||
case 0:
|
||||
#ifndef VMS
|
||||
if (quote_char == 0)
|
||||
*e++ = '"';
|
||||
else if (quote_char == '\'')
|
||||
{
|
||||
*e++ = '"';
|
||||
*e++ = '\'';
|
||||
}
|
||||
#endif
|
||||
*e = 0;
|
||||
return efile;
|
||||
#ifndef VMS
|
||||
/* For a double-quoted string, only the following characters
|
||||
* may be escaped with a backslash. Unfortunately, escaping
|
||||
* others such as &, *, |, etc will not work.
|
||||
*/
|
||||
case '\\': case '$': case '"': case '`': case '\n':
|
||||
*e++ = '\\';
|
||||
*e++ = ch;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
*e++ = ch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int create_edit_command (char *edit, char *cmd, unsigned int sizeof_cmd, char *file)
|
||||
{
|
||||
int d, s;
|
||||
char ch, *p = edit;
|
||||
char *efile;
|
||||
char quote_char = '"';
|
||||
/* Look for %d and %s */
|
||||
|
||||
d = s = 0;
|
||||
|
||||
while (0 != (ch = *p++))
|
||||
{
|
||||
char q = 0;
|
||||
|
||||
if (((ch == '\'') || (ch == '"'))
|
||||
&& (*p == '%'))
|
||||
{
|
||||
q = ch;
|
||||
ch = '%';
|
||||
p++;
|
||||
}
|
||||
if (ch != '%') continue;
|
||||
|
||||
ch = *p++;
|
||||
if (!d && (ch == 'd'))
|
||||
{
|
||||
if (s == 0) d = 1; else d = 2;
|
||||
}
|
||||
else if (!s && (ch == 's'))
|
||||
{
|
||||
if (d == 0) s = 1; else s = 2;
|
||||
if (q && (q != *p))
|
||||
{
|
||||
most_message ("Unmatched quote character in editor definition", 1);
|
||||
return -1;
|
||||
}
|
||||
quote_char = q;
|
||||
}
|
||||
else
|
||||
{
|
||||
most_message ("Invalid editor definition.", 1);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL == (efile = most_escape_filename (file, quote_char)))
|
||||
return -1;
|
||||
|
||||
if ((d == 0) && (s == 0))
|
||||
{
|
||||
/* No %d, %s */
|
||||
_pSLsnprintf (cmd, sizeof_cmd, "%s \"%s\"", edit, efile);
|
||||
SLfree (efile);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (d == 0)
|
||||
{
|
||||
(void) _pSLsnprintf (cmd, sizeof_cmd, edit, efile);
|
||||
SLfree (efile);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (d && s)
|
||||
{
|
||||
if (d == 1)
|
||||
(void) _pSLsnprintf (cmd, sizeof_cmd, edit, Most_C_Line, efile);
|
||||
else
|
||||
(void) _pSLsnprintf (cmd, sizeof_cmd, edit, efile, Most_C_Line);
|
||||
|
||||
SLfree (efile);
|
||||
return 0;
|
||||
}
|
||||
|
||||
most_message ("Unsupported Editor definition", 1);
|
||||
SLfree (efile);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef VMS
|
||||
int call_edt_tpu(int tpu, char *file)
|
||||
{
|
||||
char the_file[MAX_PATHLEN], *strp;
|
||||
extern void edt$edit();
|
||||
extern void tpu$tpu();
|
||||
struct dsc$descriptor_s file_desc;
|
||||
|
||||
if (tpu == 1) /* tpu */
|
||||
_pSLsnprintf (the_file, sizeof(the_file), "TPU /START=%d ", Most_C_Line);
|
||||
else
|
||||
the_file[0] = '\0';
|
||||
|
||||
strcat(the_file, file);
|
||||
|
||||
/* lose the version number */
|
||||
strp = the_file;
|
||||
while((*strp != '\0') && (*strp != ';')) strp++;
|
||||
*strp = '\0';
|
||||
|
||||
file_desc.dsc$w_length = strlen(the_file);
|
||||
file_desc.dsc$a_pointer = the_file;
|
||||
file_desc.dsc$b_class = DSC$K_CLASS_S; /* scalar, string type */
|
||||
file_desc.dsc$b_dtype = DSC$K_DTYPE_T; /* ascii string */
|
||||
|
||||
if (tpu == 1)
|
||||
tpu$tpu(&file_desc);
|
||||
else
|
||||
edt$edit(&file_desc);
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
void most_edit_cmd(void)
|
||||
{
|
||||
char *editor;
|
||||
char cmd[2*MAX_PATHLEN + 30];
|
||||
#ifdef VMS
|
||||
int tpu = -1;
|
||||
#endif
|
||||
char *file;
|
||||
|
||||
file = Most_Buf->file;
|
||||
|
||||
if ((0 == *file) || ('*' == *file))
|
||||
return;
|
||||
|
||||
if (Most_Secure_Mode)
|
||||
{
|
||||
most_message ("Editing not permitted in secure mode.", 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((NULL == (editor = getenv("MOST_EDITOR")))
|
||||
&& (NULL == (editor = getenv("SLANG_EDITOR")))
|
||||
&& (NULL == (editor = getenv("EDITOR"))))
|
||||
#ifdef VMS
|
||||
editor = "EDT";
|
||||
#else
|
||||
editor = "vi";
|
||||
#endif
|
||||
|
||||
#ifdef VMS
|
||||
if (!strcmp(editor,"EDT")) tpu = 0;
|
||||
else if (!strcmp(editor,"TPU")) tpu = 1;
|
||||
else
|
||||
#endif
|
||||
if (-1 == create_edit_command(editor, cmd, sizeof(cmd), file))
|
||||
return;
|
||||
|
||||
most_reset_tty ();
|
||||
most_reset_display ();
|
||||
|
||||
#ifdef VMS
|
||||
if (tpu != -1) (void) call_edt_tpu(tpu, file);
|
||||
else
|
||||
#endif
|
||||
SLsystem (cmd);
|
||||
|
||||
most_reread_file ();
|
||||
most_init_tty ();
|
||||
most_init_display ();
|
||||
most_redraw_display ();
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
This file is part of MOST.
|
||||
|
||||
Copyright (c) 1991, 1999, 2002, 2005-2018, 2019 John E. Davis
|
||||
|
||||
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 2 of the License, 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.
|
||||
*/
|
||||
extern void most_edit_cmd (void);
|
||||
extern char *most_escape_filename (char *file, char quote_char);
|
||||
|
|
@ -0,0 +1,846 @@
|
|||
/*
|
||||
This file is part of MOST.
|
||||
|
||||
Copyright (c) 1991, 1999, 2002, 2005-2018, 2019 John E. Davis
|
||||
|
||||
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 2 of the License, 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.
|
||||
*/
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#ifndef VMS
|
||||
# include <fcntl.h>
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
# ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
# endif
|
||||
#else
|
||||
# include <types.h>
|
||||
# include <stat.h>
|
||||
#endif /* NOT VMS */
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include <slang.h>
|
||||
#include "jdmacros.h"
|
||||
|
||||
#ifndef O_RDONLY
|
||||
# define O_RDONLY 0
|
||||
#endif
|
||||
|
||||
#include "window.h"
|
||||
#include "file.h"
|
||||
#include "most.h"
|
||||
#include "buffer.h"
|
||||
#include "display.h"
|
||||
#include "sysdep.h"
|
||||
#include "edit.h"
|
||||
|
||||
char *Most_File_Ring[MOST_MAX_FILES];
|
||||
char Most_C_Dir[MAX_PATHLEN]; /* current working dir */
|
||||
int Most_Num_Files;
|
||||
int Most_Tail_Mode = 1;
|
||||
|
||||
#if !defined(VMS)
|
||||
|
||||
static int create_gunzip_cmd (char *cmd, char *file, char *buf, unsigned int sizeof_buf)
|
||||
{
|
||||
char *efile;
|
||||
|
||||
if (NULL == (efile = most_escape_filename (file, '"')))
|
||||
return -1;
|
||||
|
||||
(void) _pSLsnprintf (buf, sizeof_buf, cmd, efile);
|
||||
SLfree (efile);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int open_compressed_file(char *file, int mode, int *size)
|
||||
{
|
||||
int fd;
|
||||
char buf[4], cmdbuf[2*MAX_PATHLEN];
|
||||
struct stat st;
|
||||
|
||||
# ifdef O_BINARY
|
||||
mode |= O_BINARY;
|
||||
# endif
|
||||
# ifdef IBMPC_SYSTEM
|
||||
Most_Z_Opt = 1;
|
||||
# endif
|
||||
|
||||
if (Most_Z_Opt)
|
||||
{
|
||||
if (stat(file, &st)) return(-1);
|
||||
*size = st.st_size;
|
||||
return (open(file,mode));
|
||||
}
|
||||
fd = open(file, O_RDONLY);
|
||||
|
||||
if (fd < 0) return fd;
|
||||
|
||||
if (4 == read(fd, buf, 4))
|
||||
{
|
||||
char *cmd = NULL;
|
||||
|
||||
if ((buf[0] == (char) 0x1f)
|
||||
&& (buf[1] == (char) 0x8b)
|
||||
&& (buf[2] == (char) 0x08)
|
||||
&& ((buf[3] == (char) 0x08) || (buf[3] == (char)0x00)))
|
||||
{
|
||||
cmd = MOST_GUNZIP_POPEN_FORMAT;
|
||||
}
|
||||
else if ((buf[0] == 'B') && (buf[1] == 'Z') && (buf[2] == 'h')
|
||||
&& (buf[3] > 47))
|
||||
{
|
||||
cmd = MOST_BZIP2_POPEN_FORMAT;
|
||||
}
|
||||
|
||||
if (cmd != NULL)
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
close (fd);
|
||||
most_flush_message ("Uncompressing file...");
|
||||
|
||||
if (-1 == create_gunzip_cmd (cmd, file, cmdbuf, sizeof(cmdbuf)))
|
||||
return -1;
|
||||
fp = popen (cmdbuf, "r"); /* GLIBC doe not support "rb" */
|
||||
if (fp == NULL)
|
||||
return -1;
|
||||
*size = 0;
|
||||
fd = fileno (fp);
|
||||
Most_Buf->fp = fp;
|
||||
/* pclose (fp); */
|
||||
return fd;
|
||||
}
|
||||
}
|
||||
|
||||
close (fd);
|
||||
if (stat(file, &st)) return(-1);
|
||||
*size = st.st_size;
|
||||
return (open(file,mode));
|
||||
}
|
||||
#endif /* VMS */
|
||||
|
||||
#if MOST_HAS_MMAP
|
||||
#ifdef HAVE_SYS_MMAN_H
|
||||
# include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
#ifndef MAP_FAILED
|
||||
# define MAP_FAILED -1
|
||||
#endif
|
||||
static int try_mmap_buffer (int fd)
|
||||
{
|
||||
unsigned char *addr;
|
||||
struct stat st;
|
||||
|
||||
Most_Buf->is_mmaped = 0;
|
||||
|
||||
if (Most_Disable_MMap)
|
||||
return -1;
|
||||
|
||||
if (-1 == fstat (fd, &st))
|
||||
return -1;
|
||||
|
||||
addr = (unsigned char *)mmap (NULL,st.st_size,PROT_READ,MAP_SHARED,fd,0);
|
||||
if (addr == (unsigned char *)MAP_FAILED)
|
||||
return -1;
|
||||
|
||||
Most_Buf->fd = fd;
|
||||
Most_Eob = Most_Beg = Most_Buf->end = Most_Buf->beg = addr;
|
||||
Most_Buf->size = 0;
|
||||
Most_Buf->mmap_size = st.st_size;
|
||||
Most_Buf->is_mmaped = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int unmmap_buffer (Most_Buffer_Type *b)
|
||||
{
|
||||
if (b->is_mmaped == 0)
|
||||
return 0;
|
||||
|
||||
if (b->beg != NULL)
|
||||
munmap ((char *)b->beg, b->size);
|
||||
|
||||
b->end = b->beg = NULL;
|
||||
if (b == Most_Buf)
|
||||
{
|
||||
Most_Beg = Most_Eob = NULL;
|
||||
Most_C_Line = 0;
|
||||
Most_Num_Lines = Most_C_Line = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int resync_mmap (void)
|
||||
{
|
||||
struct stat st;
|
||||
int line = Most_C_Line;
|
||||
|
||||
if (Most_Buf->fd == -1)
|
||||
return 0;
|
||||
if (-1 == fstat (Most_Buf->fd, &st))
|
||||
return -1;
|
||||
|
||||
if ((unsigned int) st.st_size == Most_Buf->mmap_size)
|
||||
return 0;
|
||||
|
||||
(void) unmmap_buffer (Most_Buf);
|
||||
if (-1 == try_mmap_buffer (Most_Buf->fd))
|
||||
return -1;
|
||||
|
||||
most_goto_line (line);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* MOST_HAS_MMAP */
|
||||
|
||||
int most_close_buffer_file (Most_Buffer_Type *b)
|
||||
{
|
||||
if (b->fd != -1)
|
||||
{
|
||||
#if !defined(VMS)
|
||||
if (b->fp != NULL) pclose (b->fp);
|
||||
else
|
||||
#endif
|
||||
close(b->fd);
|
||||
}
|
||||
#if MOST_HAS_MMAP
|
||||
unmmap_buffer (b);
|
||||
#endif
|
||||
if (b->beg != NULL)
|
||||
SLFREE(b->beg);
|
||||
b->beg = NULL;
|
||||
b->fd = -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* If file[0] == 0, the file represents stdin */
|
||||
static int insert_file(char *file)
|
||||
{
|
||||
int size = 0, fd;
|
||||
/* int mode; */
|
||||
#ifdef VMS
|
||||
struct stat st;
|
||||
unsigned recsz = 512;
|
||||
/* extern int stat(char *, struct stat *); */
|
||||
#endif
|
||||
|
||||
if (file[0] == '\0') /* assume stdin */
|
||||
{
|
||||
fd = 0;
|
||||
strcpy (Most_Buf->file, "*stdin*");
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef VMS
|
||||
if (stat(file, &st)) return(-1);
|
||||
/* mode = st.st_mode & S_IFMT; */
|
||||
size = st.st_size;
|
||||
recsz = st.st_fab_mrs;
|
||||
if (recsz <= 255) recsz = 255;
|
||||
/* VMS share options (shr=put) suggested by Henk D. Davids <hdavids@mswe.dnet.ms.philips.nl> */
|
||||
/* VMS share options (shr=upi,get,put) suggested by Mark Pizzolato <mark@infocomm.com> */
|
||||
fd = open(file,O_RDONLY,"ctx=rec","mbf=8","mbc=16","rop=RAH","shr=upi,get,put");
|
||||
/* if (fd < 0) fd = open(file,O_RDONLY); */
|
||||
#else
|
||||
fd = open_compressed_file(file, O_RDONLY, &size);
|
||||
# if MOST_HAS_MMAP
|
||||
if (0 == try_mmap_buffer (fd))
|
||||
return most_read_file_dsc (1, 1);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
if (fd < 0) return(-1);
|
||||
|
||||
if (!fd || (size <= 0)) size = 0x7FFF;
|
||||
#ifdef VMS
|
||||
Most_Buf->rec = recsz;
|
||||
#endif
|
||||
Most_Buf->fd = fd;
|
||||
|
||||
/* This will fail on really large files. */
|
||||
Most_Eob = Most_Beg = Most_Buf->beg = (unsigned char *) MOSTMALLOC(size);
|
||||
Most_Buf->size = size;
|
||||
|
||||
return most_read_file_dsc (1, 1);
|
||||
}
|
||||
|
||||
static void update_buffer_windows (Most_Buffer_Type *b)
|
||||
{
|
||||
Most_Window_Type *w;
|
||||
|
||||
if (NULL == (w = Most_Win))
|
||||
return;
|
||||
do
|
||||
{
|
||||
if (w->buf == b) w->dirty_flag = 1;
|
||||
w = w->next;
|
||||
}
|
||||
while (w != Most_Win);
|
||||
}
|
||||
|
||||
static void examine_file_contents (void)
|
||||
{
|
||||
unsigned char *pos, *pos_max;
|
||||
|
||||
if (Most_B_Opt || Most_K_Opt)
|
||||
return;
|
||||
|
||||
pos = Most_Beg;
|
||||
pos_max = pos + 512;
|
||||
if (pos_max > Most_Eob)
|
||||
pos_max = Most_Eob;
|
||||
|
||||
while (pos < pos_max)
|
||||
{
|
||||
if (0 == *pos)
|
||||
{
|
||||
Most_B_Opt = 1;
|
||||
break;
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
|
||||
/* Check for a FITS file. The header looks like ASCII. */
|
||||
if (Most_B_Opt == 0)
|
||||
{
|
||||
pos = Most_Beg;
|
||||
pos_max = Most_Eob;
|
||||
if ((pos_max > pos + 80)
|
||||
&& (0 == strncmp ((char *) pos, "SIMPLE =", 9)))
|
||||
{
|
||||
Most_V_Opt = 1;
|
||||
Most_W_Opt = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int First_Time_Hack = 0; /* true if reading file for first time */
|
||||
|
||||
#if MOST_HAS_MMAP
|
||||
static int read_mmap_file_dsc (int many, int count_lines)
|
||||
{
|
||||
unsigned int size;
|
||||
|
||||
size = Most_Buf->size;
|
||||
|
||||
if (many == -1)
|
||||
{
|
||||
if (-1 == resync_mmap ())
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (size == Most_Buf->mmap_size)
|
||||
return 0;
|
||||
|
||||
if (many < 0)
|
||||
size = Most_Buf->mmap_size;
|
||||
else
|
||||
{
|
||||
size += many * 0xFFFF;
|
||||
if (size > Most_Buf->mmap_size)
|
||||
size = Most_Buf->mmap_size;
|
||||
}
|
||||
|
||||
Most_Eob = Most_Buf->end = Most_Buf->beg + size;
|
||||
Most_Buf->size = size;
|
||||
|
||||
most_flush_message ("Mapping file...");
|
||||
|
||||
if (First_Time_Hack)
|
||||
examine_file_contents ();
|
||||
|
||||
if (count_lines)
|
||||
Most_Num_Lines = most_count_lines (Most_Beg, Most_Eob);
|
||||
|
||||
most_message(Most_Global_Msg, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* if read something, return non zero (1) */
|
||||
int most_read_file_dsc (int many, int count_lines)
|
||||
{
|
||||
int fd = Most_Buf->fd, n = 0, i;
|
||||
int dsize, size, passes = 0;
|
||||
unsigned char *pos;
|
||||
#ifdef VMS
|
||||
int recsz = Most_Buf->rec;
|
||||
#endif
|
||||
|
||||
if (fd < 0) return 0;
|
||||
|
||||
#if MOST_HAS_MMAP
|
||||
if (Most_Buf->is_mmaped)
|
||||
{
|
||||
int ret = read_mmap_file_dsc (many, count_lines);
|
||||
if (-1 != ret)
|
||||
return ret;
|
||||
|
||||
if (Most_Buf->is_mmaped)
|
||||
return -1;
|
||||
/* No longer mapped..... */
|
||||
}
|
||||
#endif
|
||||
|
||||
dsize = 0x3FFF;
|
||||
|
||||
while (many--)
|
||||
{
|
||||
passes++;
|
||||
most_flush_message ("Reading...");
|
||||
|
||||
size = (Most_Eob - Most_Beg) + dsize;
|
||||
|
||||
if (Most_Buf->size > size) pos = Most_Beg;
|
||||
else
|
||||
{
|
||||
size = Most_Buf->size + 0xFFFF;
|
||||
pos = (unsigned char *) MOSTREALLOC(Most_Beg, (unsigned) size);
|
||||
Most_Buf->size = size;
|
||||
}
|
||||
|
||||
Most_Eob = pos + (unsigned int) (Most_Eob - Most_Beg);
|
||||
Most_Beg = pos;
|
||||
|
||||
pos = Most_Eob;
|
||||
n = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
#ifdef VMS
|
||||
i = read (fd, (char *) pos, recsz);
|
||||
#else
|
||||
i = read (fd, (char *) pos, dsize - n);
|
||||
#endif
|
||||
if (i == -1)
|
||||
{
|
||||
#ifdef EINTR
|
||||
if ((errno == EINTR) && (SLKeyBoard_Quit == 0)) continue;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
/* EOF */
|
||||
/* Under linux, for some reason bash when invoked by
|
||||
* man will reset the terminal. Apparantly this is a
|
||||
* result of most being orphaned.
|
||||
*/
|
||||
#ifdef __unix__
|
||||
if (fd == 0)
|
||||
(void) most_reinit_terminal ();
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
n += i;
|
||||
pos += i;
|
||||
if (n >= dsize)
|
||||
break;
|
||||
}
|
||||
|
||||
Most_Eob = Most_Buf->end = pos;
|
||||
Most_Buf->beg = Most_Beg;
|
||||
|
||||
if (n != 0) n = 1;
|
||||
|
||||
if ((i <= 0)
|
||||
|| SLKeyBoard_Quit)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (First_Time_Hack)
|
||||
examine_file_contents ();
|
||||
|
||||
if (count_lines
|
||||
&& (n || First_Time_Hack))
|
||||
Most_Num_Lines = most_count_lines (Most_Beg, Most_Eob);
|
||||
|
||||
update_buffer_windows (Most_Buf);
|
||||
|
||||
most_message("reading...done", 0);
|
||||
most_put_message();
|
||||
most_message(Most_Global_Msg, 0);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
/* This routines makes sure line n is read in. */
|
||||
void most_read_to_line(int n)
|
||||
{
|
||||
int dn;
|
||||
long nbytes;
|
||||
|
||||
if (Most_Buf->fd == -1) return;
|
||||
|
||||
n += 2 * SLtt_Screen_Rows;
|
||||
dn = n - Most_Num_Lines;
|
||||
if (dn < 0) return;
|
||||
|
||||
nbytes = 0;
|
||||
if (Most_Num_Lines)
|
||||
nbytes = dn * ((Most_Eob - Most_Beg) / Most_Num_Lines);
|
||||
if (nbytes < 0x3FFF) nbytes = 0x3FFF;
|
||||
|
||||
while ((Most_Buf->fd != -1)
|
||||
&& (n >= Most_Num_Lines)
|
||||
&& (0 != most_read_file_dsc (nbytes / 0x3FFF, 1))
|
||||
&& (SLKeyBoard_Quit == 0))
|
||||
{
|
||||
nbytes = 0;
|
||||
if (Most_Num_Lines)
|
||||
nbytes = dn * ((Most_Eob - Most_Beg) / Most_Num_Lines);
|
||||
if (nbytes < 0x3FFF) nbytes = 0x3FFF;
|
||||
}
|
||||
}
|
||||
|
||||
int most_find_file(char *file)
|
||||
{
|
||||
Most_Buffer_Type *new_buf;
|
||||
int n;
|
||||
char msg[MAX_PATHLEN+20], *msgp;
|
||||
int ret = 0;
|
||||
|
||||
new_buf = most_create_buffer(file);
|
||||
(void) most_switch_to_buffer(new_buf);
|
||||
|
||||
First_Time_Hack = 1;
|
||||
if (insert_file(file) < 0)
|
||||
{
|
||||
sprintf (msg, "%s failed to open.", file);
|
||||
n = strlen (msg);
|
||||
msgp = (char *) MOSTMALLOC((unsigned int) (n + 1));
|
||||
strcpy (msgp, msg);
|
||||
Most_Buf->beg = (unsigned char *) msgp;
|
||||
Most_Buf->end = Most_Buf->beg + n;
|
||||
Most_Buf->fd = -1;
|
||||
Most_Num_Lines = 1;
|
||||
ret = -1;
|
||||
}
|
||||
First_Time_Hack = 0;
|
||||
|
||||
Most_Beg = Most_Buf->beg;
|
||||
Most_Eob = Most_Buf->end;
|
||||
Most_C_Offset = 0;
|
||||
Most_C_Line = 1;
|
||||
Most_Column = 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* if the file is visible in a window, move to the window and return 1
|
||||
else return 0 */
|
||||
Most_Window_Type *most_file_visible(char *file)
|
||||
{
|
||||
Most_Window_Type *w;
|
||||
w = Most_Win;
|
||||
Most_Win = Most_Top_Win;
|
||||
do
|
||||
{
|
||||
if (!strcmp(Most_Win->buf->file,file))
|
||||
{
|
||||
most_set_window(Most_Win);
|
||||
return(Most_Win);
|
||||
}
|
||||
Most_Win = Most_Win->next;
|
||||
}
|
||||
while (Most_Win != Most_Top_Win);
|
||||
Most_Win = w;
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
void most_reread_file (void)
|
||||
{
|
||||
char file[MAX_PATHLEN];
|
||||
int line = Most_C_Line;
|
||||
|
||||
if (-1 == access(Most_Buf->file, 0)) /* does it exist? */
|
||||
{
|
||||
most_message("File not found.",1);
|
||||
return;
|
||||
}
|
||||
|
||||
most_one_window ();
|
||||
|
||||
strcpy (file, Most_Buf->file);
|
||||
most_free_window_buffer ();
|
||||
(void) most_find_file (file);
|
||||
most_goto_line (line);
|
||||
most_window_buffer ();
|
||||
}
|
||||
|
||||
static int find_file_in_window(char *file)
|
||||
{
|
||||
if (NULL != most_file_visible(file))
|
||||
{
|
||||
most_message ("File is already visible.", 1);
|
||||
return -2;
|
||||
}
|
||||
|
||||
if (-1 == access(file, 0)) /* does it exist? */
|
||||
{
|
||||
most_message("File not found.",1);
|
||||
return -1;
|
||||
}
|
||||
most_free_window_buffer();
|
||||
(void) most_find_file(file);
|
||||
|
||||
most_window_buffer();
|
||||
|
||||
most_redraw_window();
|
||||
most_update_status();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void format_next_file (char *mbuf, int j, char *file)
|
||||
{
|
||||
int len, max_len;
|
||||
|
||||
len = strlen (file);
|
||||
max_len = SLtt_Screen_Cols - 25;
|
||||
if (len > max_len)
|
||||
{
|
||||
sprintf(mbuf, "Next File (%d): ...%s", j, file + (len - max_len));
|
||||
}
|
||||
else sprintf(mbuf, "Next File (%d): %s", j, file);
|
||||
}
|
||||
|
||||
void most_do_next_file(int *j)
|
||||
{
|
||||
char mbuf[256], *curr_file;
|
||||
unsigned char ch;
|
||||
|
||||
most_select_minibuffer();
|
||||
|
||||
if (*j >= Most_Num_Files) *j = 0;
|
||||
curr_file = Most_File_Ring[*j];
|
||||
|
||||
while (1)
|
||||
{
|
||||
format_next_file (mbuf, *j, curr_file);
|
||||
|
||||
SLsmg_write_string (mbuf);
|
||||
SLsmg_erase_eol ();
|
||||
SLsmg_gotorc (SLtt_Screen_Rows - 1, 0);
|
||||
|
||||
SLsmg_refresh ();
|
||||
|
||||
ch = most_getkey();
|
||||
#ifndef IBMPC_SYSTEM
|
||||
if (ch != '\033') break;
|
||||
if (ch = most_getkey(), (ch != 'O') && (ch != '[')) continue;
|
||||
if (ch = most_getkey(), (ch != 'A') && (ch != 'B')) continue;
|
||||
#else
|
||||
if ((ch != 0) && (ch != 0xE0))
|
||||
break;
|
||||
|
||||
ch = most_getkey ();
|
||||
if (ch != 'H') ch = 'B'; else ch = 'A';
|
||||
|
||||
#endif
|
||||
if (ch == 'B')
|
||||
{
|
||||
if (*j == 0) *j = Most_Num_Files;
|
||||
(*j)--;
|
||||
}
|
||||
else /* ch == 'A' */
|
||||
{
|
||||
(*j)++;
|
||||
if (*j == Most_Num_Files) *j = 0;
|
||||
}
|
||||
curr_file = Most_File_Ring[*j];
|
||||
}
|
||||
|
||||
most_exit_minibuffer();
|
||||
|
||||
(*j)++;
|
||||
if ((ch == 'Q') || (ch == 'q'))
|
||||
{
|
||||
most_exit_most ();
|
||||
}
|
||||
else find_file_in_window(curr_file);
|
||||
}
|
||||
|
||||
/* extracts directory from file string, returns false if no dir */
|
||||
int most_head(char *file, char *dir)
|
||||
{
|
||||
int n;
|
||||
|
||||
if (file == NULL) return 0;
|
||||
|
||||
(void) strcpy(dir,file);
|
||||
n = strlen(file) - 1;
|
||||
#ifdef VMS
|
||||
while((n > -1) && (file[n] != ']') && (file[n] != ':')) n--;
|
||||
#else
|
||||
while((n > -1) && file[n] != '/') n--;
|
||||
#endif
|
||||
n++;
|
||||
dir[n] = '\0';
|
||||
return(n);
|
||||
}
|
||||
|
||||
/* returns a pointer to the tail of file */
|
||||
static int tail(char *filed, char **filep)
|
||||
{
|
||||
int n;
|
||||
n = strlen(filed) - 1;
|
||||
#ifdef VMS
|
||||
while((n > -1) && ((filed[n] != ']') && (filed[n] != ':'))) n--;
|
||||
#else
|
||||
while((n > -1) && (filed[n] != '/')) n--;
|
||||
#endif
|
||||
n++;
|
||||
*filep = (filed + n);
|
||||
return(n);
|
||||
}
|
||||
|
||||
/* assume path is big enough to hold new expanded version */
|
||||
static int expand_path(char *path)
|
||||
{
|
||||
#ifndef VMS
|
||||
int n;
|
||||
#endif
|
||||
/* really cheat here-- let system do it. The path must exist!! */
|
||||
if (chdir(path))
|
||||
{
|
||||
most_message(path,1);
|
||||
return(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
most_get_cdir(path);
|
||||
(void) chdir(Most_C_Dir);
|
||||
#ifndef VMS
|
||||
n = strlen(path);
|
||||
if (path[n-1] == '/') return(1);
|
||||
path[n++] = '/'; path[n] = 0;
|
||||
#endif
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void most_cd (void)
|
||||
{
|
||||
char tmp_dir[MAX_PATHLEN];
|
||||
int n;
|
||||
|
||||
if (Most_Secure_Mode)
|
||||
{
|
||||
most_message ("CD disabled in secure mode.", 1);
|
||||
return;
|
||||
}
|
||||
|
||||
strcpy(tmp_dir,Most_C_Dir);
|
||||
if (most_read_from_minibuffer("cd ",Most_C_Dir) == -1) return;
|
||||
if (!chdir(Most_C_Dir))
|
||||
{
|
||||
most_get_cdir(Most_C_Dir); /* expands ../ etc... */
|
||||
n = strlen(Most_C_Dir);
|
||||
# ifndef VMS
|
||||
if (Most_C_Dir[n-1] == '/') return;
|
||||
Most_C_Dir[n++] = '/'; Most_C_Dir[n] = 0;
|
||||
# endif
|
||||
return;
|
||||
}
|
||||
strcpy(Most_C_Dir,tmp_dir);
|
||||
(void) chdir(Most_C_Dir);
|
||||
most_message("Unable to change directory.",1);
|
||||
}
|
||||
#endif
|
||||
|
||||
void most_user_get_file()
|
||||
{
|
||||
char path[MAX_PATHLEN], file[MAX_PATHLEN], *name;
|
||||
#ifdef VMS
|
||||
unsigned int i, imax;
|
||||
#endif
|
||||
|
||||
if (Most_Secure_Mode)
|
||||
{
|
||||
most_message ("Getting a file is not permitted in secure mode.", 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!most_head(Most_Win->buf->file,file))
|
||||
strcpy(file,Most_C_Dir);
|
||||
|
||||
if (most_read_from_minibuffer("Find File: ", file, file, sizeof(file)) == -1)
|
||||
return;
|
||||
|
||||
if (most_head(file,path))
|
||||
{
|
||||
expand_path(path);
|
||||
tail(file,&name);
|
||||
strcat(path,name);
|
||||
name = path;
|
||||
}
|
||||
else name = file;
|
||||
#ifdef VMS
|
||||
imax = strlen (name);
|
||||
for (i = 0; i < imax; i++)
|
||||
name [i] = toupper (name[i]);
|
||||
#endif
|
||||
|
||||
if (find_file_in_window(name) < 0) return;
|
||||
|
||||
/*
|
||||
** add to file ring if successful
|
||||
*/
|
||||
if ((NULL != most_file_visible(name))
|
||||
&& (Most_Num_Files < MOST_MAX_FILES))
|
||||
{
|
||||
Most_File_Ring[Most_Num_Files] = (char*) MOSTMALLOC(strlen(name) + 1);
|
||||
strcpy(Most_File_Ring[Most_Num_Files++],name);
|
||||
}
|
||||
}
|
||||
|
||||
void most_get_cdir(char *dir)
|
||||
{
|
||||
#ifdef sequent
|
||||
getwd(dir);
|
||||
#else
|
||||
# ifdef HAVE_GETCWD
|
||||
getcwd(dir, MAX_PATHLEN);
|
||||
# else
|
||||
getwd(dir);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef VMS
|
||||
{
|
||||
int i;
|
||||
i = strlen(dir);
|
||||
if (i && (dir[i - 1] != '/')) dir[i++] = '/';
|
||||
dir[i] = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
This file is part of MOST.
|
||||
|
||||
Copyright (c) 1991, 1999, 2002, 2005-2018, 2019 John E. Davis
|
||||
|
||||
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 2 of the License, 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.
|
||||
*/
|
||||
#include "config.h"
|
||||
#define MOST_MAX_FILES 4096
|
||||
#define MOST_MAX_FILES 4096
|
||||
#define MOST_GUNZIP_POPEN_FORMAT "gzip -dc \"%s\""
|
||||
#define MOST_BZIP2_POPEN_FORMAT "bzip2 -dc \"%s\""
|
||||
|
||||
extern void most_reread_file (void);
|
||||
extern void most_read_to_line (int);
|
||||
extern Most_Window_Type *most_file_visible (char *);
|
||||
extern void most_user_get_file(void);
|
||||
extern int most_read_file_dsc(int many, int count_lines);
|
||||
extern void most_get_cdir(char *);
|
||||
extern int most_get_dir(char *);
|
||||
extern void most_do_next_file(int *);
|
||||
extern int most_find_file(char *);
|
||||
extern int most_head(char *, char *);
|
||||
|
||||
extern char *Most_File_Ring[MOST_MAX_FILES];
|
||||
extern int Most_Num_Files;
|
||||
extern char Most_C_Dir[MAX_PATHLEN];
|
||||
extern int Most_Tail_Mode;
|
||||
extern int most_close_buffer_file (Most_Buffer_Type *);
|
|
@ -0,0 +1,206 @@
|
|||
/*
|
||||
This file is part of MOST.
|
||||
|
||||
Copyright (c) 1991, 1999, 2002, 2005-2018, 2019 John E. Davis
|
||||
|
||||
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 2 of the License, 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.
|
||||
*/
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef VMS
|
||||
# include <stat.h>
|
||||
#else
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include <slang.h>
|
||||
#include "jdmacros.h"
|
||||
|
||||
#include "most.h"
|
||||
#include "window.h"
|
||||
#include "file.h"
|
||||
#include "display.h"
|
||||
#include "line.h"
|
||||
#include "keym.h"
|
||||
#include "sysdep.h"
|
||||
|
||||
/* This section provided by Mats Akerberg (mats@efd.lth.se) */
|
||||
|
||||
static char *help[] =
|
||||
{
|
||||
"Quitting:",
|
||||
" Q Quit MOST.",
|
||||
" :N,:n Quit this file and view next. ",
|
||||
" (Use UP/DOWN arrow keys to select next file.)",
|
||||
"Movement:",
|
||||
" SPACE, D *Scroll down one Screen.",
|
||||
" U, BACKSPACE *Scroll Up one screen.",
|
||||
" RETURN, DOWN *Move Down one line.",
|
||||
" UP *Move Up one line.",
|
||||
" T Goto Top of File.",
|
||||
" B Goto Bottom of file.",
|
||||
" > , TAB Scroll Window right",
|
||||
" < Scroll Window left",
|
||||
" RIGHT Scroll Window left by 1 column",
|
||||
" LEFT Scroll Window right by 1 column",
|
||||
" J, G Goto line.",
|
||||
" % Goto percent.",
|
||||
"Window Commands:",
|
||||
" Ctrl-X 2, Ctrl-W 2 Split window.",
|
||||
" Ctrl-X 1, Ctrl-W 1 Make only one window.",
|
||||
" O, Ctrl-X O Move to other window.",
|
||||
" Ctrl-X 0 Delete Window.",
|
||||
"Searching:",
|
||||
" S, f, / *Search forward",
|
||||
" ? *Search Backward",
|
||||
" N *Find next in current search direction.",
|
||||
"Miscellaneous:",
|
||||
" W Toggle width between 80 and 132 char mode.",
|
||||
" Ctrl-X Ctrl-F Read a file from disk",
|
||||
" R, Ctrl-R Redraw Screen.",
|
||||
" F Simulate tail -f mode",
|
||||
" :o Toggle options: b-binary, w-wrap, t-tab",
|
||||
" E Edit file. Uses MOST_EDITOR and EDITOR",
|
||||
" environment variables.",
|
||||
"*Note: This command may be repeated `n' times By entering a number then",
|
||||
" the command key, e.g., '5 SPACE' moves 5 screens forward.",
|
||||
NULL
|
||||
};
|
||||
|
||||
static void most_do_help_text (void)
|
||||
{
|
||||
char **p = help, *sect = NULL;
|
||||
int r;
|
||||
|
||||
while (*p != NULL)
|
||||
{
|
||||
SLsmg_cls ();
|
||||
|
||||
r = 0;
|
||||
SLsmg_gotorc (0, 0);
|
||||
|
||||
if ((sect != NULL) && (**p == ' '))
|
||||
{
|
||||
most_tt_bold_video ();
|
||||
SLsmg_gotorc (r, 0);
|
||||
SLsmg_write_string (sect);
|
||||
most_tt_normal_video ();
|
||||
SLsmg_write_string (" (continued)");
|
||||
r += 2;
|
||||
}
|
||||
else sect = NULL;
|
||||
|
||||
while (r < SLtt_Screen_Rows - 1)
|
||||
{
|
||||
if (*p == NULL) break;
|
||||
|
||||
if (**p != ' ')
|
||||
{
|
||||
if (((r + 5) > SLtt_Screen_Rows)
|
||||
&& (**p != '*'))
|
||||
{
|
||||
sect = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
if (sect != NULL)
|
||||
{
|
||||
r++;
|
||||
}
|
||||
|
||||
if (**p != '*')
|
||||
{
|
||||
sect = *p;
|
||||
most_tt_bold_video ();
|
||||
}
|
||||
else sect = NULL;
|
||||
}
|
||||
SLsmg_gotorc (r, 0);
|
||||
SLsmg_write_string (*p);
|
||||
|
||||
if ((**p != ' ') && (**p != '*'))
|
||||
{
|
||||
most_tt_normal_video ();
|
||||
r++;
|
||||
}
|
||||
p++;
|
||||
r++;
|
||||
}
|
||||
|
||||
SLsmg_gotorc (r, 0);
|
||||
|
||||
most_tt_reverse_video();
|
||||
SLsmg_write_string("Press any key to continue.");
|
||||
most_tt_normal_video();
|
||||
|
||||
SLsmg_refresh ();
|
||||
|
||||
most_getkey ();
|
||||
}
|
||||
|
||||
most_redraw_display();
|
||||
}
|
||||
|
||||
static void most_do_help_file (char *helpfile)
|
||||
{
|
||||
char *buf_name;
|
||||
FILE *fp;
|
||||
|
||||
buf_name = "*help*";
|
||||
|
||||
#ifdef MOST_HELPFILE
|
||||
if (helpfile == NULL) helpfile = MOST_HELPFILE;
|
||||
#endif
|
||||
|
||||
if (helpfile != NULL)
|
||||
{
|
||||
if (most_file_visible(buf_name)) return;
|
||||
|
||||
/* See if we can open it */
|
||||
if (NULL != (fp = fopen (helpfile, "r")))
|
||||
{
|
||||
fclose (fp);
|
||||
if (!most_split_window())
|
||||
{
|
||||
most_message("Two many windows.",1);
|
||||
return;
|
||||
}
|
||||
most_update_status(); /* create status line of prev. window */
|
||||
most_other_window(1);
|
||||
(void) most_find_file(helpfile);
|
||||
strcpy(Most_Buf->file, buf_name);
|
||||
Most_B_Opt = 0;
|
||||
most_window_buffer ();
|
||||
most_redraw_window ();
|
||||
most_update_status ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
most_do_help_text ();
|
||||
}
|
||||
|
||||
void most_do_help_command(void)
|
||||
{
|
||||
most_do_help_file (getenv ("MOST_HELP"));
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
#ifndef _JD_MACROS_H_
|
||||
# define _JD_MACROS_H_
|
||||
|
||||
/* This file defines some macros that I use with programs that link to
|
||||
* the slang library.
|
||||
*/
|
||||
|
||||
# ifdef HAVE_MALLOC_H
|
||||
# include <malloc.h>
|
||||
# endif
|
||||
|
||||
# ifdef HAVE_MEMORY_H
|
||||
# include <memory.h>
|
||||
# endif
|
||||
|
||||
# ifndef SLMEMSET
|
||||
# ifdef HAVE_MEMSET
|
||||
# define SLMEMSET memset
|
||||
# else
|
||||
# define SLMEMSET SLmemset
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef SLMEMCHR
|
||||
# ifdef HAVE_MEMCHR
|
||||
# define SLMEMCHR memchr
|
||||
# else
|
||||
# define SLMEMCHR SLmemchr
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef SLMEMCPY
|
||||
# ifdef HAVE_MEMCPY
|
||||
# define SLMEMCPY memcpy
|
||||
# else
|
||||
# define SLMEMCPY SLmemcpy
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* Note: HAVE_MEMCMP requires an unsigned memory comparison!!! */
|
||||
# ifndef SLMEMCMP
|
||||
# ifdef HAVE_MEMCMP
|
||||
# define SLMEMCMP memcmp
|
||||
# else
|
||||
# define SLMEMCMP SLmemcmp
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# if SLANG_VERSION < 9934
|
||||
# define SLmemcmp jed_memcmp
|
||||
# define SLmemcpy jed_memcpy
|
||||
# define SLmemset jed_memset
|
||||
# define SLmemchr jed_memchr
|
||||
# endif
|
||||
|
||||
# ifndef SLFREE
|
||||
# define SLFREE free
|
||||
# endif
|
||||
|
||||
# ifndef SLMALLOC
|
||||
# define SLMALLOC malloc
|
||||
# endif
|
||||
|
||||
# ifndef SLCALLOC
|
||||
# define SLCALLOC calloc
|
||||
# endif
|
||||
|
||||
# ifndef SLREALLOC
|
||||
# define SLREALLOC realloc
|
||||
# endif
|
||||
|
||||
#endif /* _JD_MACROS_H_ */
|
|
@ -0,0 +1,734 @@
|
|||
/*
|
||||
This file is part of MOST.
|
||||
|
||||
Copyright (c) 1991, 1999, 2002, 2005-2018, 2019 John E. Davis
|
||||
|
||||
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 2 of the License, 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.
|
||||
*/
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <slang.h>
|
||||
#include "jdmacros.h"
|
||||
|
||||
#include "most.h"
|
||||
#include "keym.h"
|
||||
#include "display.h"
|
||||
#include "window.h"
|
||||
#include "search.h"
|
||||
#include "edit.h"
|
||||
#include "sysdep.h"
|
||||
#include "file.h"
|
||||
#include "keyparse.h"
|
||||
|
||||
int *Most_Digit_Arg;
|
||||
static char Last_Char;
|
||||
static int Edt_Direction = 1;
|
||||
|
||||
static void digit_arg_cmd(void);
|
||||
|
||||
static void page_down_cmd (void)
|
||||
{
|
||||
int n = 1;
|
||||
|
||||
if (Most_Digit_Arg != (int *) NULL) n = *Most_Digit_Arg;
|
||||
if (n < 0) n = 1;
|
||||
n = Most_C_Line + n * (Most_Win->bot - Most_Win->top + 1);
|
||||
most_read_to_line (n + 50);
|
||||
most_update_windows (n);
|
||||
}
|
||||
|
||||
static void page_up_cmd (void)
|
||||
{
|
||||
int n = 1;
|
||||
if (Most_Digit_Arg != (int *) NULL) n = *Most_Digit_Arg;
|
||||
n = Most_C_Line - n * (Most_Win->bot - Most_Win->top + 1);
|
||||
if (n < 1) n = 1;
|
||||
|
||||
most_update_windows (n);
|
||||
}
|
||||
|
||||
static void page_right_cmd (void)
|
||||
{
|
||||
int n = 1;
|
||||
if (Most_Digit_Arg != (int *) NULL) n = *Most_Digit_Arg;
|
||||
Most_Column = Most_Column + n * 59;
|
||||
most_update_windows(Most_C_Line);
|
||||
}
|
||||
|
||||
static void page_left_cmd(void)
|
||||
{
|
||||
int n = 1;
|
||||
if (Most_Digit_Arg != (int *) NULL) n = *Most_Digit_Arg;
|
||||
Most_Column = Most_Column - n * 59;
|
||||
most_update_windows(Most_C_Line);
|
||||
}
|
||||
|
||||
static void column_right_cmd (void)
|
||||
{
|
||||
int n = 1;
|
||||
if (Most_Digit_Arg != (int *) NULL) n = *Most_Digit_Arg;
|
||||
Most_Column = Most_Column + n;
|
||||
most_update_windows(Most_C_Line);
|
||||
}
|
||||
|
||||
static void column_left_cmd(void)
|
||||
{
|
||||
int n = 1;
|
||||
if (Most_Digit_Arg != (int *) NULL) n = *Most_Digit_Arg;
|
||||
Most_Column = Most_Column - n;
|
||||
most_update_windows(Most_C_Line);
|
||||
}
|
||||
|
||||
static void next_line_cmd(void)
|
||||
{
|
||||
int n = 1;
|
||||
if (Most_Digit_Arg != (int *) NULL) n = *Most_Digit_Arg;
|
||||
|
||||
most_read_to_line (Most_C_Line + n + 50);
|
||||
most_update_windows(Most_C_Line + n);
|
||||
}
|
||||
|
||||
static void previous_line_cmd(void)
|
||||
{
|
||||
int n = 1;
|
||||
if (Most_Digit_Arg != (int *) NULL) n = *Most_Digit_Arg;
|
||||
|
||||
most_update_windows(Most_C_Line - n);
|
||||
}
|
||||
|
||||
static void tail_mode_cmd (void)
|
||||
{
|
||||
Most_Tail_Mode = 1;
|
||||
|
||||
do
|
||||
{
|
||||
if (0 != most_read_file_dsc (-1, 1))
|
||||
most_update_windows (-1);
|
||||
|
||||
most_message ("Most Tail Mode-- MOST keys are still active.", 0);
|
||||
most_put_message ();
|
||||
|
||||
most_point_cursor ();
|
||||
SLsmg_refresh ();
|
||||
}
|
||||
while (0 == SLang_input_pending (15));
|
||||
Most_Tail_Mode = 0;
|
||||
}
|
||||
|
||||
static void top_of_buffer_cmd(void)
|
||||
{
|
||||
most_update_windows(1);
|
||||
}
|
||||
|
||||
static void end_of_buffer_cmd(void)
|
||||
{
|
||||
unsigned int count = 0;
|
||||
/* This will loop forever if the file is changing too fast. */
|
||||
while ((Most_Buf->fd != -1)
|
||||
&& (count < 5)
|
||||
&& (0 != most_read_file_dsc(-1, 1)))
|
||||
count++;
|
||||
most_update_windows (-1);
|
||||
Most_Curs_Offset = (Most_Eob - Most_Beg);
|
||||
}
|
||||
#ifdef unix
|
||||
# include <signal.h>
|
||||
#endif
|
||||
static void sys_spawn_cmd(void)
|
||||
{
|
||||
#ifdef IBMPC_SYSTEM
|
||||
most_message ("Not implemented.", 1);
|
||||
#else
|
||||
int update = 0;
|
||||
# ifndef VMS
|
||||
static int can_suspend = -1;
|
||||
|
||||
if (can_suspend == -1)
|
||||
{
|
||||
can_suspend = 0;
|
||||
# ifdef SIGTSTP
|
||||
if (SIG_DFL == SLsignal (SIGTSTP, SIG_DFL))
|
||||
can_suspend = 1;
|
||||
# endif
|
||||
}
|
||||
if (can_suspend == 0)
|
||||
{
|
||||
most_message ("Shell forbids suspension.", 1);
|
||||
return;
|
||||
}
|
||||
# endif
|
||||
|
||||
if (Most_Secure_Mode || Most_Captive_Mode)
|
||||
{
|
||||
most_message ("Operation not permitted by this account.", 1);
|
||||
return;
|
||||
}
|
||||
most_reset_tty();
|
||||
most_reset_display();
|
||||
# ifdef VMS
|
||||
if (Last_Char == '\032') exit(0);
|
||||
if (most_do_shell_command()) update = 1; /* scroll region reset by message facility */
|
||||
# else
|
||||
# ifdef SIGTSTP
|
||||
kill(0, SIGTSTP);
|
||||
# endif
|
||||
update = 1;
|
||||
# endif
|
||||
most_init_tty();
|
||||
most_init_display ();
|
||||
if (update) most_redraw_display();
|
||||
#endif /* IBMPC_SYSTEM */
|
||||
}
|
||||
|
||||
static void redraw_cmd(void)
|
||||
{
|
||||
most_redraw_display();
|
||||
}
|
||||
|
||||
static int read_integer (char *prompt, MOST_INT *n)
|
||||
{
|
||||
int status;
|
||||
Most_Mini_Buf[0] = 0;
|
||||
|
||||
status = most_read_from_minibuffer(prompt, NULL, (char *) Most_Mini_Buf, MOST_MINI_BUF_LEN);
|
||||
if (status < 0)
|
||||
return -1;
|
||||
|
||||
if (1 != sscanf((char *) Most_Mini_Buf, MOST_INT_D_FMT, n))
|
||||
{
|
||||
most_message ("Expecting an integer", 1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
Most_Mini_Buf[0] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void goto_line_cmd(void)
|
||||
{
|
||||
MOST_INT n;
|
||||
|
||||
if (Most_Digit_Arg != (int *) NULL) n = *Most_Digit_Arg;
|
||||
else
|
||||
{
|
||||
if (-1 == read_integer ("Goto Line: ", &n))
|
||||
return;
|
||||
}
|
||||
most_update_windows ((int)n);
|
||||
}
|
||||
|
||||
static void goto_percent_cmd(void)
|
||||
{
|
||||
unsigned char *pos;
|
||||
MOST_INT n;
|
||||
|
||||
if (Most_Digit_Arg != NULL) n = *Most_Digit_Arg;
|
||||
else
|
||||
{
|
||||
if (-1 == read_integer ("Goto Percent: ", &n))
|
||||
return;
|
||||
}
|
||||
|
||||
if (n < 0) n = 0; else if (n > 100) n = 100;
|
||||
if (Most_Buf->fd != -1) most_read_file_dsc(-1, 1);
|
||||
pos = Most_Beg + (n * (Most_Eob - Most_Beg))/100;
|
||||
n = most_what_line(pos);
|
||||
most_update_windows (n);
|
||||
}
|
||||
|
||||
static void set_mark_cmd(void)
|
||||
{
|
||||
Most_Buf->mark = Most_C_Line;
|
||||
most_message("Mark Set.",0);
|
||||
}
|
||||
|
||||
static void goto_mark_cmd(void)
|
||||
{
|
||||
int mark = Most_Buf->mark;
|
||||
Most_Buf->mark = Most_C_Line;
|
||||
most_update_window(mark);
|
||||
most_message("Mark Set.",0);
|
||||
}
|
||||
|
||||
static void one_window_cmd(void)
|
||||
{
|
||||
most_one_window();
|
||||
}
|
||||
|
||||
static void two_window_cmd(void)
|
||||
{
|
||||
most_two_windows();
|
||||
}
|
||||
|
||||
static void del_window_cmd(void)
|
||||
{
|
||||
most_delete_window();
|
||||
}
|
||||
|
||||
static void other_window_cmd(void)
|
||||
{
|
||||
int n = 1;
|
||||
if (Most_Digit_Arg != (int *) NULL) n = *Most_Digit_Arg;
|
||||
most_other_window(n);
|
||||
}
|
||||
|
||||
static void find_next_cmd(void)
|
||||
{
|
||||
MOST_INT col, line, n = 1;
|
||||
unsigned long ofs;
|
||||
|
||||
if (Most_Digit_Arg != NULL) n = *Most_Digit_Arg;
|
||||
line = most_search ((Most_Beg + Most_Curs_Offset) + Most_Search_Dir, n, &col);
|
||||
if (line < 1) return;
|
||||
|
||||
ofs = Most_Curs_Offset;
|
||||
|
||||
if ((line < Most_Win->beg_line) || (line > Most_Win->beg_line + Most_Win->bot - Most_Win->top))
|
||||
most_update_window(line);
|
||||
|
||||
Most_Curs_Offset = ofs;
|
||||
|
||||
Most_Curs_Row = line - Most_C_Line + 1;
|
||||
Most_Curs_Col = col;
|
||||
}
|
||||
|
||||
static void find_next_opposite_dir_cmd (void)
|
||||
{
|
||||
Most_Search_Dir = -Most_Search_Dir;
|
||||
find_next_cmd ();
|
||||
Most_Search_Dir = -Most_Search_Dir;
|
||||
}
|
||||
|
||||
static void search_cmd_dir (char *prompt, int dir)
|
||||
{
|
||||
char buf[MOST_SEARCH_BUF_LEN];
|
||||
|
||||
if (-1 == most_read_from_minibuffer(prompt, NULL, buf, MOST_SEARCH_BUF_LEN))
|
||||
return;
|
||||
|
||||
Most_Search_Dir = dir;
|
||||
if (*buf)
|
||||
strcpy (Most_Search_Str, buf); /* no buffer overflow here */
|
||||
Most_Curs_Offset = Most_C_Offset;
|
||||
find_next_cmd ();
|
||||
}
|
||||
|
||||
static void search_cmd(void)
|
||||
{
|
||||
char *prompt = "Regexp-Search: ";
|
||||
if (Most_Do_Regexp_Search == 0)
|
||||
prompt += 7;
|
||||
search_cmd_dir (prompt,1);
|
||||
}
|
||||
|
||||
static void search_back_cmd(void)
|
||||
{
|
||||
char *prompt = "Regexp-Search Backwards: ";
|
||||
if (Most_Do_Regexp_Search == 0)
|
||||
prompt += 7;
|
||||
search_cmd_dir (prompt, -1);
|
||||
}
|
||||
|
||||
static void help_cmd(void)
|
||||
{
|
||||
most_do_help_command();
|
||||
}
|
||||
|
||||
static void find_file_cmd(void)
|
||||
{
|
||||
most_user_get_file();
|
||||
}
|
||||
|
||||
static void time_cmd(void)
|
||||
{
|
||||
most_message(most_get_time(),0);
|
||||
}
|
||||
|
||||
static void toggle_width_cmd(void)
|
||||
{
|
||||
if (SLtt_Screen_Cols == 80)
|
||||
{
|
||||
if (!Most_Restore_Width_To) Most_Restore_Width_To = 80;
|
||||
most_set_width(132, 1);
|
||||
}
|
||||
else if (SLtt_Screen_Cols == 132)
|
||||
{
|
||||
if (!Most_Restore_Width_To) Most_Restore_Width_To = 132;
|
||||
most_set_width(80, 1);
|
||||
}
|
||||
}
|
||||
|
||||
static void edt_forward_cmd(void)
|
||||
{
|
||||
Edt_Direction = 1;
|
||||
}
|
||||
|
||||
static void edt_back_cmd(void)
|
||||
{
|
||||
Edt_Direction = 0;
|
||||
}
|
||||
|
||||
static void edt_page_cmd(void)
|
||||
{
|
||||
if (Edt_Direction == 0)
|
||||
{
|
||||
page_up_cmd();
|
||||
}
|
||||
else
|
||||
{
|
||||
page_down_cmd();
|
||||
}
|
||||
}
|
||||
|
||||
static void edt_line_cmd(void)
|
||||
{
|
||||
if (Edt_Direction == 0)
|
||||
{
|
||||
previous_line_cmd();
|
||||
}
|
||||
else
|
||||
{
|
||||
next_line_cmd();
|
||||
}
|
||||
}
|
||||
|
||||
static void edt_find_cmd(void)
|
||||
{
|
||||
if (Edt_Direction == 0)
|
||||
{
|
||||
search_back_cmd();
|
||||
}
|
||||
else
|
||||
{
|
||||
search_cmd();
|
||||
}
|
||||
}
|
||||
|
||||
static void edt_find_next_cmd(void)
|
||||
{
|
||||
if (Edt_Direction == 0)
|
||||
{
|
||||
Most_Search_Dir = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
Most_Search_Dir = 1;
|
||||
}
|
||||
find_next_cmd();
|
||||
}
|
||||
|
||||
#define A_KEY(s, f) {s, (int (*)(void)) f}
|
||||
SLKeymap_Function_Type Most_Functions [] =
|
||||
{
|
||||
A_KEY("edit", most_edit_cmd),
|
||||
A_KEY("suspend", sys_spawn_cmd),
|
||||
A_KEY("next_file", most_next_file),
|
||||
A_KEY("toggle_options", most_toggle_options),
|
||||
A_KEY("toggle_lock", most_toggle_lock),
|
||||
A_KEY("extended_key", most_extended_key_cmd),
|
||||
A_KEY("toggle_case", most_toggle_case),
|
||||
A_KEY("delete_file", most_delete_file_cmd),
|
||||
A_KEY("bob", top_of_buffer_cmd),
|
||||
A_KEY("delete_window", del_window_cmd),
|
||||
A_KEY("digit_arg", digit_arg_cmd),
|
||||
A_KEY("down", next_line_cmd),
|
||||
A_KEY("edt_backward", edt_back_cmd),
|
||||
A_KEY("edt_find", edt_find_cmd),
|
||||
A_KEY("edt_find_next", edt_find_next_cmd),
|
||||
A_KEY("edt_forward", edt_forward_cmd),
|
||||
A_KEY("edt_line", edt_line_cmd),
|
||||
A_KEY("edt_page", edt_page_cmd),
|
||||
A_KEY("eob", end_of_buffer_cmd),
|
||||
A_KEY("exit", most_exit_most),
|
||||
A_KEY("find_file", find_file_cmd),
|
||||
A_KEY("find_next", find_next_cmd),
|
||||
A_KEY("find_next_other_dir", find_next_opposite_dir_cmd),
|
||||
A_KEY("goto_line", goto_line_cmd),
|
||||
A_KEY("goto_mark", goto_mark_cmd),
|
||||
A_KEY("goto_percent", goto_percent_cmd),
|
||||
A_KEY("help", help_cmd),
|
||||
A_KEY("one_window", one_window_cmd),
|
||||
A_KEY("other_window", other_window_cmd),
|
||||
A_KEY("page_down", page_down_cmd ),
|
||||
A_KEY("page_left", page_left_cmd),
|
||||
A_KEY("page_right", page_right_cmd ),
|
||||
A_KEY("page_up", page_up_cmd ),
|
||||
A_KEY("column_left", column_left_cmd ),
|
||||
A_KEY("column_right", column_right_cmd ),
|
||||
A_KEY("redraw", redraw_cmd),
|
||||
A_KEY("search_backward", search_back_cmd),
|
||||
A_KEY("search_forward", search_cmd),
|
||||
A_KEY("set_mark", set_mark_cmd),
|
||||
A_KEY("show_time", time_cmd),
|
||||
A_KEY("tail_mode", tail_mode_cmd),
|
||||
A_KEY("toggle_width", toggle_width_cmd),
|
||||
A_KEY("two_windows", two_window_cmd),
|
||||
A_KEY("up", previous_line_cmd),
|
||||
{(char *) NULL, NULL}
|
||||
};
|
||||
|
||||
SLKeyMap_List_Type *Most_Keymap;
|
||||
|
||||
#ifdef IBMPC_SYSTEM
|
||||
static void gobble_mouse_cmd(void)
|
||||
{
|
||||
SLang_flush_input ();
|
||||
}
|
||||
#endif
|
||||
|
||||
void most_init_keymaps (void)
|
||||
{
|
||||
char *err = "Unable to create keymaps!";
|
||||
char esc[3], gold[5], dig[2];
|
||||
int i;
|
||||
|
||||
if (NULL == (Most_Keymap = SLang_create_keymap ("Most", NULL)))
|
||||
most_exit_error (err);
|
||||
|
||||
Most_Keymap->functions = Most_Functions;
|
||||
|
||||
esc[0] = 27; esc[2] = 0;
|
||||
gold[0] = 27; gold[1] = 'O'; gold[2] = 'P'; gold[4] = 0;
|
||||
dig[1] = 0;
|
||||
|
||||
for (i = '0'; i <= '9'; i++)
|
||||
{
|
||||
dig[0] = (char) i;
|
||||
esc[1] = (char) i;
|
||||
gold[3] = (char) i;
|
||||
SLkm_define_key (dig, (FVOID_STAR) digit_arg_cmd, Most_Keymap);
|
||||
SLkm_define_key (esc, (FVOID_STAR) digit_arg_cmd, Most_Keymap);
|
||||
SLkm_define_key (gold, (FVOID_STAR) digit_arg_cmd, Most_Keymap);
|
||||
}
|
||||
|
||||
dig[0] = '-'; esc[1] = '-'; gold[3] = '-';
|
||||
SLkm_define_key (dig, (FVOID_STAR) digit_arg_cmd, Most_Keymap);
|
||||
SLkm_define_key (esc, (FVOID_STAR) digit_arg_cmd, Most_Keymap);
|
||||
SLkm_define_key (gold, (FVOID_STAR) digit_arg_cmd, Most_Keymap);
|
||||
|
||||
SLkm_define_key (" ", (FVOID_STAR) page_down_cmd, Most_Keymap);
|
||||
SLkm_define_key ("$", (FVOID_STAR) sys_spawn_cmd, Most_Keymap);
|
||||
SLkm_define_key ("%", (FVOID_STAR) goto_percent_cmd, Most_Keymap);
|
||||
SLkm_define_key (",", (FVOID_STAR) goto_mark_cmd, Most_Keymap);
|
||||
SLkm_define_key ("/", (FVOID_STAR) search_cmd, Most_Keymap);
|
||||
SLkm_define_key (":", (FVOID_STAR) most_extended_key_cmd, Most_Keymap);
|
||||
SLkm_define_key ("<", (FVOID_STAR) page_left_cmd, Most_Keymap);
|
||||
SLkm_define_key (">", (FVOID_STAR) page_right_cmd, Most_Keymap);
|
||||
SLkm_define_key ("?", (FVOID_STAR) search_back_cmd, Most_Keymap);
|
||||
SLkm_define_key ("B", (FVOID_STAR) end_of_buffer_cmd, Most_Keymap);
|
||||
SLkm_define_key ("D", (FVOID_STAR) page_down_cmd, Most_Keymap);
|
||||
SLkm_define_key ("E", (FVOID_STAR) most_edit_cmd, Most_Keymap);
|
||||
SLkm_define_key ("F", (FVOID_STAR) tail_mode_cmd, Most_Keymap);
|
||||
SLkm_define_key ("G", (FVOID_STAR) goto_line_cmd, Most_Keymap);
|
||||
SLkm_define_key ("H", (FVOID_STAR) help_cmd, Most_Keymap);
|
||||
SLkm_define_key ("J", (FVOID_STAR) goto_line_cmd, Most_Keymap);
|
||||
SLkm_define_key ("L", (FVOID_STAR) most_toggle_lock, Most_Keymap);
|
||||
SLkm_define_key ("M", (FVOID_STAR) set_mark_cmd, Most_Keymap);
|
||||
SLkm_define_key ("n", (FVOID_STAR) find_next_cmd, Most_Keymap);
|
||||
SLkm_define_key ("N", (FVOID_STAR) find_next_opposite_dir_cmd, Most_Keymap);
|
||||
SLkm_define_key ("O", (FVOID_STAR) other_window_cmd, Most_Keymap);
|
||||
SLkm_define_key ("Q", (FVOID_STAR) most_exit_most, Most_Keymap);
|
||||
SLkm_define_key ("R", (FVOID_STAR) redraw_cmd, Most_Keymap);
|
||||
SLkm_define_key ("S", (FVOID_STAR) search_cmd, Most_Keymap);
|
||||
SLkm_define_key ("T", (FVOID_STAR) top_of_buffer_cmd, Most_Keymap);
|
||||
SLkm_define_key ("U", (FVOID_STAR) page_up_cmd , Most_Keymap);
|
||||
SLkm_define_key ("V", (FVOID_STAR) next_line_cmd, Most_Keymap);
|
||||
SLkm_define_key ("W", (FVOID_STAR) toggle_width_cmd, Most_Keymap);
|
||||
SLkm_define_key ("X", (FVOID_STAR) most_exit_most, Most_Keymap);
|
||||
SLkm_define_key ("\033$", (FVOID_STAR) sys_spawn_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033<", (FVOID_STAR) top_of_buffer_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033>", (FVOID_STAR) end_of_buffer_cmd, Most_Keymap);
|
||||
#if !defined(IBMPC_SYSTEM)
|
||||
SLkm_define_key ("\033OA", (FVOID_STAR) previous_line_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033OB", (FVOID_STAR) next_line_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033OC", (FVOID_STAR) column_right_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033OD", (FVOID_STAR) column_left_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033OPE", (FVOID_STAR) most_exit_most, Most_Keymap);
|
||||
SLkm_define_key ("\033OPO", (FVOID_STAR) one_window_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033OPQ", (FVOID_STAR) most_exit_most, Most_Keymap);
|
||||
SLkm_define_key ("\033OPS", (FVOID_STAR) sys_spawn_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033OPV", (FVOID_STAR) del_window_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033OPX", (FVOID_STAR) two_window_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033OP\033OR", (FVOID_STAR) edt_find_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033OP\033On", (FVOID_STAR) goto_mark_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033OP\033Ot", (FVOID_STAR) end_of_buffer_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033OP\033Ou", (FVOID_STAR) top_of_buffer_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033OP\033[A", (FVOID_STAR) other_window_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033OP\033[B", (FVOID_STAR) other_window_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033OP\033[C", (FVOID_STAR) page_right_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033OP\033[D", (FVOID_STAR) page_left_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033OQ", (FVOID_STAR) help_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033OR", (FVOID_STAR) edt_find_next_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033On", (FVOID_STAR) set_mark_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033Op", (FVOID_STAR) edt_line_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033Ot", (FVOID_STAR) edt_forward_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033Ou", (FVOID_STAR) edt_back_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033Ox", (FVOID_STAR) edt_page_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033V", (FVOID_STAR) page_up_cmd , Most_Keymap);
|
||||
SLkm_define_key ("\033[1~", (FVOID_STAR) search_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033[2~", (FVOID_STAR) goto_mark_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033[28~", (FVOID_STAR) help_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033[4~", (FVOID_STAR) set_mark_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033[5~", (FVOID_STAR) page_up_cmd , Most_Keymap);
|
||||
SLkm_define_key ("\033[6~", (FVOID_STAR) page_down_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033[A", (FVOID_STAR) previous_line_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033[B", (FVOID_STAR) next_line_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033[C", (FVOID_STAR) column_right_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033[D", (FVOID_STAR) column_left_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033[7~", (FVOID_STAR) top_of_buffer_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033[8~", (FVOID_STAR) end_of_buffer_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^@", (FVOID_STAR) set_mark_cmd, Most_Keymap);
|
||||
#else
|
||||
SLkm_define_key ("^@H", (FVOID_STAR) previous_line_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^@P", (FVOID_STAR) next_line_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^@M", (FVOID_STAR) column_right_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^@K", (FVOID_STAR) column_left_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^@Q", (FVOID_STAR) page_down_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^@I", (FVOID_STAR) page_up_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^@G", (FVOID_STAR) top_of_buffer_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^@O", (FVOID_STAR) end_of_buffer_cmd, Most_Keymap);
|
||||
|
||||
SLkm_define_key ("\xE0H", (FVOID_STAR) previous_line_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\xE0P", (FVOID_STAR) next_line_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\xE0M", (FVOID_STAR) column_right_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\xE0K", (FVOID_STAR) column_left_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\xE0Q", (FVOID_STAR) page_down_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\xE0I", (FVOID_STAR) page_up_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\xE0G", (FVOID_STAR) top_of_buffer_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\xE0O", (FVOID_STAR) end_of_buffer_cmd, Most_Keymap);
|
||||
SLkm_define_key ("\033[M", (FVOID_STAR) gobble_mouse_cmd, Most_Keymap);
|
||||
#endif
|
||||
SLkm_define_key ("\t", (FVOID_STAR) page_right_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^", (FVOID_STAR) previous_line_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^?", (FVOID_STAR) page_up_cmd , Most_Keymap);
|
||||
SLkm_define_key ("^D", (FVOID_STAR) page_down_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^F", (FVOID_STAR) search_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^H", (FVOID_STAR) help_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^KE", (FVOID_STAR) most_exit_most, Most_Keymap);
|
||||
SLkm_define_key ("^KG", (FVOID_STAR) find_file_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^K^B", (FVOID_STAR) set_mark_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^K^J", (FVOID_STAR) goto_mark_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^K^M", (FVOID_STAR) goto_mark_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^L", (FVOID_STAR) redraw_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^M", (FVOID_STAR) next_line_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^N", (FVOID_STAR) next_line_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^P", (FVOID_STAR) previous_line_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^R", (FVOID_STAR) redraw_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^T", (FVOID_STAR) time_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^U", (FVOID_STAR) page_up_cmd , Most_Keymap);
|
||||
SLkm_define_key ("^V", (FVOID_STAR) page_down_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^W0", (FVOID_STAR) del_window_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^W1", (FVOID_STAR) one_window_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^W2", (FVOID_STAR) two_window_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^WO", (FVOID_STAR) other_window_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^X0", (FVOID_STAR) del_window_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^X1", (FVOID_STAR) one_window_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^X2", (FVOID_STAR) two_window_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^XO", (FVOID_STAR) other_window_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^X^C", (FVOID_STAR) most_exit_most, Most_Keymap);
|
||||
SLkm_define_key ("^X^F", (FVOID_STAR) find_file_cmd, Most_Keymap);
|
||||
SLkm_define_key ("^Z", (FVOID_STAR) sys_spawn_cmd, Most_Keymap);
|
||||
SLkm_define_key ("b", (FVOID_STAR) end_of_buffer_cmd, Most_Keymap);
|
||||
SLkm_define_key ("d", (FVOID_STAR) page_down_cmd, Most_Keymap);
|
||||
SLkm_define_key ("e", (FVOID_STAR) most_edit_cmd, Most_Keymap);
|
||||
SLkm_define_key ("f", (FVOID_STAR) search_cmd, Most_Keymap);
|
||||
SLkm_define_key ("g", (FVOID_STAR) goto_line_cmd, Most_Keymap);
|
||||
SLkm_define_key ("j", (FVOID_STAR) goto_line_cmd, Most_Keymap);
|
||||
SLkm_define_key ("l", (FVOID_STAR) most_toggle_lock, Most_Keymap);
|
||||
SLkm_define_key ("m", (FVOID_STAR) set_mark_cmd, Most_Keymap);
|
||||
SLkm_define_key ("n", (FVOID_STAR) find_next_cmd, Most_Keymap);
|
||||
SLkm_define_key ("o", (FVOID_STAR) other_window_cmd, Most_Keymap);
|
||||
SLkm_define_key ("q", (FVOID_STAR) most_exit_most, Most_Keymap);
|
||||
SLkm_define_key ("r", (FVOID_STAR) redraw_cmd, Most_Keymap);
|
||||
SLkm_define_key ("s", (FVOID_STAR) search_cmd, Most_Keymap);
|
||||
SLkm_define_key ("t", (FVOID_STAR) top_of_buffer_cmd, Most_Keymap);
|
||||
SLkm_define_key ("v", (FVOID_STAR) next_line_cmd, Most_Keymap);
|
||||
SLkm_define_key ("w", (FVOID_STAR) toggle_width_cmd, Most_Keymap);
|
||||
SLkm_define_key ("x", (FVOID_STAR) most_exit_most, Most_Keymap);
|
||||
if (SLang_get_error()) most_exit_error (err);
|
||||
|
||||
(void) most_load_user_keymaps ();
|
||||
}
|
||||
|
||||
static void sldo_key (void)
|
||||
{
|
||||
SLang_Key_Type *key;
|
||||
|
||||
key = SLang_do_key (Most_Keymap, most_getkey);
|
||||
SLKeyBoard_Quit = 0;
|
||||
SLang_set_error (0);
|
||||
Last_Char = SLang_Last_Key_Char;
|
||||
|
||||
if ((key == NULL) || (key->f.f == NULL) || (key->type != SLKEY_F_INTRINSIC))
|
||||
{
|
||||
SLtt_beep ();
|
||||
}
|
||||
else (((void (*)(void))(key->f.f)) ());
|
||||
}
|
||||
|
||||
static void digit_arg_cmd(void)
|
||||
{
|
||||
char num[15], ch;
|
||||
int j = 0;
|
||||
static int digits;
|
||||
|
||||
num[j++] = Last_Char;
|
||||
ch = most_getkey();
|
||||
while ((ch >= '0') && (ch <= '9'))
|
||||
{
|
||||
if (j == 15) return;
|
||||
|
||||
num[j++] = ch;
|
||||
ch = most_getkey();
|
||||
}
|
||||
|
||||
if (((j == 1) && (Last_Char != '-')) || (j > 1))
|
||||
{
|
||||
num[j] = '\0';
|
||||
sscanf(num,"%d",&digits);
|
||||
Most_Digit_Arg = &digits;
|
||||
}
|
||||
Last_Char = ch;
|
||||
SLang_ungetkey (ch);
|
||||
sldo_key ();
|
||||
}
|
||||
|
||||
void most_execute_key (void)
|
||||
{
|
||||
static int refresh_pending = 0;
|
||||
|
||||
if (Most_Want_Exit) return;
|
||||
|
||||
most_check_minibuffer ();
|
||||
if (Most_Mini_Buf[0] != '\0') most_put_message ();
|
||||
Most_Digit_Arg = (int *) NULL;
|
||||
|
||||
most_point_cursor ();
|
||||
|
||||
if (SLang_input_pending (0))
|
||||
refresh_pending++;
|
||||
else
|
||||
refresh_pending = 0;
|
||||
|
||||
if ((refresh_pending == 0) || (refresh_pending > 4))
|
||||
{
|
||||
refresh_pending = 0;
|
||||
SLsmg_refresh ();
|
||||
}
|
||||
|
||||
sldo_key ();
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
This file is part of MOST.
|
||||
|
||||
Copyright (c) 1991, 1999, 2002, 2005-2018, 2019 John E. Davis
|
||||
|
||||
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 2 of the License, 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.
|
||||
*/
|
||||
extern void most_init_keymaps (void);
|
||||
extern void most_execute_key (void);
|
||||
extern int *Most_Digit_Arg;
|
||||
extern void most_do_help_command (void);
|
||||
|
||||
/* These are in cmd.c */
|
||||
extern void most_extended_key_cmd(void);
|
||||
extern void most_next_file (void);
|
||||
extern void most_toggle_case (void);
|
||||
extern void most_delete_file_cmd (void);
|
||||
extern void most_toggle_options (void);
|
||||
extern void most_toggle_research (void);
|
||||
|
||||
#if 0
|
||||
extern void ctrl_x_map_cmd(void);
|
||||
extern void ctrl_k_map_cmd(void);
|
||||
extern void ctrl_w_map_cmd(void);
|
||||
extern void pf1_map_cmd(void);
|
||||
extern void pf1_esc_map_cmd(void);
|
||||
extern void dec_extended_map_cmd(void);
|
||||
extern void esc_map_cmd(void);
|
||||
extern void page_down_cmd(void);
|
||||
extern void search_cmd(void);
|
||||
extern void next_line_cmd(void);
|
||||
extern void previous_line_cmd(void);
|
||||
extern void extended_cmd_cmd(void);
|
||||
extern void redraw_cmd(void);
|
||||
extern void goto_line_cmd(void);
|
||||
extern void time_cmd(void);
|
||||
extern void page_up_cmd(void);
|
||||
extern void page_up_cmd(void);
|
||||
extern void column_left_cmd(void);
|
||||
extern void column_right_cmd(void);
|
||||
extern void page_right_cmd(void);
|
||||
extern void sys_spawn_cmd(void);
|
||||
extern void set_mark_cmd(void);
|
||||
extern void top_of_buffer_cmd(void);
|
||||
extern void goto_mark_cmd(void);
|
||||
extern void search_back_cmd(void);
|
||||
extern void find_next_cmd(void);
|
||||
extern void end_of_buffer_cmd(void);
|
||||
extern void exit_cmd(void);
|
||||
extern void one_window_cmd(void);
|
||||
extern void two_window_cmd(void);
|
||||
extern void del_window_cmd(void);
|
||||
extern void other_window_cmd(void);
|
||||
extern void O_map_cmd(void);
|
||||
extern void find_file_cmd(void);
|
||||
extern void digit_arg_cmd(void);
|
||||
extern void edit_cmd(void);
|
||||
extern void toggle_width_cmd(void);
|
||||
extern void goto_percent_cmd(void);
|
||||
extern void edt_page_cmd(void);
|
||||
extern void edt_forward_cmd(void);
|
||||
extern void edt_back_cmd(void);
|
||||
extern void edt_line_cmd(void);
|
||||
extern void edt_find_cmd(void);
|
||||
extern void edt_find_next_cmd(void);
|
||||
|
||||
extern int do_extended_key(void);
|
||||
extern int do_extended_cmd(void);
|
||||
extern void do_help_command(void);
|
||||
extern void execute_key(void);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,320 @@
|
|||
/*
|
||||
This file is part of MOST.
|
||||
|
||||
Copyright (c) 1991, 1999, 2002, 2005-2018, 2019 John E. Davis
|
||||
|
||||
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 2 of the License, 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.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef __unix__
|
||||
# ifndef MOST_SYSTEM_INITFILE
|
||||
# define MOST_SYSTEM_INITFILE "/etc/most.conf"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* parses user key definition file */
|
||||
|
||||
/* The file is assumed to have a simple format:
|
||||
*
|
||||
* set "keyname" function
|
||||
* unset "keyname"
|
||||
*
|
||||
* For example:
|
||||
*
|
||||
* unsetkey "^K"
|
||||
* setkey exit "^Kx"
|
||||
*
|
||||
* Comments extend from the first '%' character to the end of the line.
|
||||
*/
|
||||
|
||||
#include <slang.h>
|
||||
#include "jdmacros.h"
|
||||
#include "most.h"
|
||||
#include "keyparse.h"
|
||||
#include "display.h"
|
||||
|
||||
static unsigned int Line_Num;
|
||||
|
||||
static void parse_error (char *s)
|
||||
{
|
||||
fprintf(stderr, "Most: Error reading config file on line %u.\n%s\n",
|
||||
Line_Num, s);
|
||||
|
||||
most_exit_error (NULL);
|
||||
}
|
||||
|
||||
static int unsetkey_fun (int, SLcmd_Cmd_Table_Type *);
|
||||
static int setkey_fun (int, SLcmd_Cmd_Table_Type *);
|
||||
static int color_fun (int, SLcmd_Cmd_Table_Type *);
|
||||
static int mono_fun (int, SLcmd_Cmd_Table_Type *);
|
||||
|
||||
static SLcmd_Cmd_Type Startup_File_Cmds[] =
|
||||
{
|
||||
{unsetkey_fun, "unsetkey", "S"},
|
||||
{setkey_fun, "setkey", "SS"},
|
||||
{color_fun, "color", "SSS"},
|
||||
{mono_fun, "mono", "SSsss"},
|
||||
{NULL, "", ""}
|
||||
};
|
||||
static SLcmd_Cmd_Table_Type Cmd_Table;
|
||||
|
||||
static int setkey_fun (int argc, SLcmd_Cmd_Table_Type *table) /*{{{*/
|
||||
{
|
||||
char *fun = table->string_args[1];
|
||||
char *key = table->string_args[2];
|
||||
|
||||
(void) argc;
|
||||
if (NULL == SLang_find_key_function(fun, Most_Keymap))
|
||||
{
|
||||
parse_error ("Undefined function");
|
||||
}
|
||||
|
||||
if (0 != SLang_define_key (key, fun, Most_Keymap))
|
||||
parse_error ("Error setting key");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int unsetkey_fun (int argc, SLcmd_Cmd_Table_Type *table) /*{{{*/
|
||||
{
|
||||
char *key = table->string_args[1];
|
||||
|
||||
(void) argc;
|
||||
|
||||
SLang_undefine_key (key, Most_Keymap);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int parse_file (char *file)
|
||||
{
|
||||
char buf[512];
|
||||
FILE *fp;
|
||||
|
||||
if (NULL == (fp = fopen (file, "r")))
|
||||
return 1;
|
||||
|
||||
Cmd_Table.table = Startup_File_Cmds;
|
||||
|
||||
Line_Num = 0;
|
||||
while (NULL != fgets (buf, sizeof (buf), fp))
|
||||
{
|
||||
Line_Num++;
|
||||
(void) SLcmd_execute_string (buf, &Cmd_Table);
|
||||
if (SLang_get_error())
|
||||
parse_error ("Undefined keyword");
|
||||
}
|
||||
|
||||
fclose (fp);
|
||||
if (SLang_get_error ())
|
||||
{
|
||||
SLang_set_error(0);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int most_load_user_keymaps (void)
|
||||
{
|
||||
#ifndef VMS
|
||||
char filebuf[MAX_PATHLEN];
|
||||
unsigned int len;
|
||||
#endif
|
||||
char *file;
|
||||
|
||||
#ifdef MOST_SYSTEM_INITFILE
|
||||
if (MOST_SYSTEM_INITFILE != NULL)
|
||||
{
|
||||
int status;
|
||||
status = parse_file (MOST_SYSTEM_INITFILE);
|
||||
if (status == -1)
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (NULL == (file = getenv ("MOST_INITFILE")))
|
||||
{
|
||||
#ifdef VMS
|
||||
file = "SYS$LOGIN:MOST.RC";
|
||||
#else
|
||||
*filebuf = 0;
|
||||
file = getenv ("HOME");
|
||||
if (file == NULL)
|
||||
return -1;
|
||||
|
||||
len = strlen (file);
|
||||
if (len + 8 >= sizeof (filebuf)) /* 8 for strlen("/.mostrc") */
|
||||
return -1;
|
||||
|
||||
strcpy (filebuf, file);
|
||||
file = filebuf;
|
||||
|
||||
if (len && (file[len - 1] == '/'))
|
||||
len--;
|
||||
strcpy (file + len, "/.mostrc");
|
||||
#endif
|
||||
}
|
||||
return parse_file (file);
|
||||
}
|
||||
|
||||
/* The following code was borrowed from slrn */
|
||||
/*{{{ Setting Color/Mono Attributes */
|
||||
|
||||
typedef struct /*{{{*/
|
||||
{
|
||||
char *name;
|
||||
int value;
|
||||
char *fg, *bg;
|
||||
SLtt_Char_Type mono;
|
||||
}
|
||||
|
||||
/*}}}*/
|
||||
Color_Handle_Type;
|
||||
|
||||
/* default colors -- suitable for a color xterm */
|
||||
|
||||
static Color_Handle_Type Color_Handles[] = /*{{{*/
|
||||
{
|
||||
{"normal", 0, "default", "default", 0},
|
||||
{"status", MOST_STATUS_COLOR, "yellow", "blue", SLTT_REV_MASK},
|
||||
{"underline", MOST_ULINE_COLOR, "brightgreen", "default", SLTT_ULINE_MASK},
|
||||
{"overstrike", MOST_BOLD_COLOR, "brightred", "default", SLTT_BOLD_MASK},
|
||||
|
||||
{NULL, -1, NULL, NULL, 0}
|
||||
};
|
||||
|
||||
static int set_object_color (char *name, char *fg, char *bg)
|
||||
{
|
||||
Color_Handle_Type *ct = Color_Handles;
|
||||
|
||||
while (ct->name != NULL)
|
||||
{
|
||||
if (!strcmp (ct->name, name))
|
||||
{
|
||||
SLtt_set_color (ct->value, name, fg, bg);
|
||||
return 0;
|
||||
}
|
||||
ct++;
|
||||
}
|
||||
|
||||
parse_error ("Undefined color object");
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int color_fun (int argc, SLcmd_Cmd_Table_Type *table)
|
||||
{
|
||||
char *what = table->string_args[1];
|
||||
char *fg = table->string_args[2];
|
||||
char *bg = table->string_args[3];
|
||||
|
||||
(void) argc;
|
||||
return set_object_color (what, fg, bg);
|
||||
}
|
||||
|
||||
static int mono_fun (int argc, SLcmd_Cmd_Table_Type *table)
|
||||
{
|
||||
char *what = table->string_args[1];
|
||||
char *attr;
|
||||
int i;
|
||||
|
||||
Color_Handle_Type *ct = Color_Handles;
|
||||
|
||||
while (ct->name != NULL)
|
||||
{
|
||||
if (!strcmp (ct->name, what))
|
||||
{
|
||||
SLtt_Char_Type mono_attr = 0;
|
||||
for (i = 2; i < argc; i++)
|
||||
{
|
||||
attr = table->string_args[i];
|
||||
if (!strcmp (attr, "bold")) mono_attr |= SLTT_BOLD_MASK;
|
||||
else if (!strcmp (attr, "blink")) mono_attr |= SLTT_BLINK_MASK;
|
||||
else if (!strcmp (attr, "underline")) mono_attr |= SLTT_ULINE_MASK;
|
||||
else if (!strcmp (attr, "reverse")) mono_attr |= SLTT_REV_MASK;
|
||||
else if (!strcmp (attr, "none")) mono_attr = 0;
|
||||
else
|
||||
{
|
||||
parse_error ("Undefined mono attribute");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
SLtt_set_mono (ct->value, NULL, mono_attr);
|
||||
return 0;
|
||||
}
|
||||
ct++;
|
||||
}
|
||||
parse_error ("Undefined color object");
|
||||
return -1;
|
||||
}
|
||||
|
||||
static char *Ansi_Color_Map[9] =
|
||||
{
|
||||
"black",
|
||||
"red",
|
||||
"green",
|
||||
"yellow",
|
||||
"blue",
|
||||
"magenta",
|
||||
"cyan",
|
||||
"white",
|
||||
"default"
|
||||
};
|
||||
|
||||
void most_setup_colors (void)
|
||||
{
|
||||
Color_Handle_Type *h;
|
||||
int i;
|
||||
int fg, bg, at;
|
||||
|
||||
for (i = 1; i < 128; i++)
|
||||
{
|
||||
SLtt_set_color (i, NULL, "default", "default");
|
||||
SLtt_set_mono (i, NULL, 0);
|
||||
}
|
||||
|
||||
for (at = 0; at < 9; at++)
|
||||
{
|
||||
for (fg = 0; fg < 9; fg++)
|
||||
{
|
||||
for (bg = 0; bg < 9; bg++)
|
||||
{
|
||||
i = fg + 9*(bg + 9*at);
|
||||
if (i == 0)
|
||||
continue;
|
||||
i += MOST_EMBEDDED_COLOR_OFFSET;
|
||||
SLtt_set_color (i, NULL, Ansi_Color_Map[fg], Ansi_Color_Map[bg]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
h = Color_Handles;
|
||||
while (h->name != NULL)
|
||||
{
|
||||
/* if (h->value != 0)*/ /* Let COLORFGBG apply to initial color */
|
||||
SLtt_set_color (h->value, NULL, h->fg, h->bg);
|
||||
SLtt_set_color (h->value+MOST_EMBEDDED_COLOR_OFFSET, NULL, h->fg, h->bg);
|
||||
SLtt_set_mono (h->value, NULL, h->mono);
|
||||
SLtt_set_mono (h->value+MOST_EMBEDDED_COLOR_OFFSET, NULL, h->mono);
|
||||
|
||||
h++;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
This file is part of MOST.
|
||||
|
||||
Copyright (c) 1991, 1999, 2002, 2005-2018, 2019 John E. Davis
|
||||
|
||||
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 2 of the License, 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.
|
||||
*/
|
||||
extern SLKeyMap_List_Type *Most_Keymap;
|
||||
extern int most_load_user_keymaps (void);
|
|
@ -0,0 +1,687 @@
|
|||
/*
|
||||
This file is part of MOST.
|
||||
|
||||
Copyright (c) 1991, 1999, 2002, 2005-2018, 2019 John E. Davis
|
||||
|
||||
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 2 of the License, 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.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <slang.h>
|
||||
#include "jdmacros.h"
|
||||
|
||||
#include "most.h"
|
||||
#include "line.h"
|
||||
#include "window.h"
|
||||
#include "display.h"
|
||||
|
||||
int Most_Tab_Width = 8;
|
||||
|
||||
int Most_Selective_Display = 0;
|
||||
int Most_Show_Wrap_Marker = 1;
|
||||
|
||||
#define IS_BYTE_PRINTABLE(b) \
|
||||
((((b) >= ' ') && ((b) < 0x7F)) \
|
||||
|| ((Most_UTF8_Mode == 0) && ((b) >= SLsmg_Display_Eight_Bit)))
|
||||
|
||||
/* take 16 binary characters and put them in displayable form */
|
||||
static void binary_format_line (unsigned char *beg, unsigned char *end,
|
||||
char *buf)
|
||||
{
|
||||
unsigned char *b;
|
||||
char *s, *s1;
|
||||
unsigned char ch;
|
||||
int count;
|
||||
|
||||
count = 0;
|
||||
b = beg;
|
||||
s = buf;
|
||||
|
||||
while (b < end)
|
||||
{
|
||||
if (count == 4)
|
||||
{
|
||||
*s++ = ' ';
|
||||
count = 0;
|
||||
}
|
||||
count++;
|
||||
|
||||
ch = *b++;
|
||||
|
||||
if ((Most_V_Opt == 0)
|
||||
|| (ch & 0x80))
|
||||
{
|
||||
sprintf (s, "%02X", ch);
|
||||
s += 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((ch >= ' ') && (ch < 0x7F))
|
||||
{
|
||||
*s++ = ' ';
|
||||
*s++ = (char) ch;
|
||||
continue;
|
||||
}
|
||||
|
||||
*s++ = '^';
|
||||
if (ch < ' ') ch += '@';
|
||||
else ch = '?';
|
||||
*s++ = ch;
|
||||
}
|
||||
|
||||
s1 = buf + (9 * 4) + 4;
|
||||
while (s < s1)
|
||||
*s++ = ' ';
|
||||
|
||||
b = beg;
|
||||
while (b < end)
|
||||
{
|
||||
ch = *b++;
|
||||
if (IS_BYTE_PRINTABLE(ch))
|
||||
{
|
||||
*s++ = ch;
|
||||
continue;
|
||||
}
|
||||
*s++ = '.';
|
||||
}
|
||||
*s = 0;
|
||||
}
|
||||
|
||||
static void output_binary_formatted_line (void)
|
||||
{
|
||||
unsigned char *beg, *end;
|
||||
char buf[256];
|
||||
|
||||
beg = Most_Beg + Most_C_Offset;
|
||||
end = beg + 16;
|
||||
|
||||
if (end > Most_Eob) end = Most_Eob;
|
||||
|
||||
sprintf (buf, "0x%08lX: ", (unsigned long) Most_C_Offset);
|
||||
binary_format_line (beg, end, buf + 12);
|
||||
SLsmg_write_string (buf);
|
||||
SLsmg_erase_eol ();
|
||||
}
|
||||
|
||||
/* Here *begp points to the char after \e.
|
||||
* The general escape sequence parsed here is assumed to look like:
|
||||
* \e[ XX ; ... m
|
||||
* If 30 <= XX <= 37, then it specifies the foreground color
|
||||
* If 40 <= XX <= 47, then a background color is specified
|
||||
* If 0 <= XX <= 8, then an attribute (e.g, 8) is specified.
|
||||
* These numbers will be encoded as:
|
||||
* offset + (FG-30 + 8*(BG-40 + 9*attribute))
|
||||
*/
|
||||
int most_parse_color_escape (unsigned char **begp, unsigned char *end, int *colorp)
|
||||
{
|
||||
unsigned char *beg = *begp;
|
||||
int fg = 38, bg = 48, at = 0;
|
||||
int xx;
|
||||
|
||||
if ((beg >= end) || (*beg != '['))
|
||||
return -1;
|
||||
|
||||
beg++; /* skip [ */
|
||||
#if 1
|
||||
if ((beg < end) && (*beg == 'K'))
|
||||
{
|
||||
if (colorp != NULL) *colorp = -1;
|
||||
*begp = beg + 1;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
while (1)
|
||||
{
|
||||
xx = 0;
|
||||
while ((beg < end) && isdigit (*beg))
|
||||
{
|
||||
xx = xx*10 + (*beg - '0');
|
||||
beg++;
|
||||
}
|
||||
if ((xx >= 0) && (xx <= 8))
|
||||
at = xx;
|
||||
else if ((xx >= 20) && (xx <= 28))
|
||||
xx = 0;
|
||||
else if ((xx >= 30) && (xx <= 37))
|
||||
fg = xx;
|
||||
else if ((xx >= 40) && (xx <= 47))
|
||||
bg = xx;
|
||||
else return -1;
|
||||
|
||||
if ((beg < end) && (*beg == ';'))
|
||||
{
|
||||
beg++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((beg < end) && ((*beg == 'm') || (*beg == ']')))
|
||||
{
|
||||
*begp = beg + 1;
|
||||
if (colorp != NULL)
|
||||
{
|
||||
if ((fg != 38) || (bg != 48))
|
||||
xx = ((fg-30) + 9*((bg-40) + 9*at));
|
||||
if (xx != 0)
|
||||
xx += MOST_EMBEDDED_COLOR_OFFSET;
|
||||
*colorp = xx;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char *bytes;
|
||||
unsigned char byte; /* used if bytes is NULL */
|
||||
unsigned int len;
|
||||
int color;
|
||||
}
|
||||
Multibyte_Cell_Type;
|
||||
|
||||
static int most_analyse_line (unsigned char *begg, unsigned char *endd,
|
||||
Multibyte_Cell_Type *cells, unsigned int num_cols, int *start_colorp)
|
||||
{
|
||||
unsigned char *beg, *end;
|
||||
unsigned int min_col, max_col, prev_width;
|
||||
unsigned int col, max_col_reached;
|
||||
int default_attr;
|
||||
Multibyte_Cell_Type *cell, *max_cell;
|
||||
|
||||
beg = begg;
|
||||
end = endd;
|
||||
col = max_col_reached = 0;
|
||||
cell = cells;
|
||||
max_cell = cell;
|
||||
min_col = Most_Column - 1;
|
||||
max_col = min_col + num_cols;
|
||||
|
||||
default_attr = *start_colorp;
|
||||
prev_width = 1;
|
||||
while (beg < end)
|
||||
{
|
||||
int attr = default_attr;
|
||||
unsigned char ch;
|
||||
unsigned char *pch = beg++;
|
||||
char buf[16];
|
||||
|
||||
if ('\n' == (ch = *pch))
|
||||
break;
|
||||
|
||||
if ((ch == '\r') && (Most_V_Opt == 0))
|
||||
{
|
||||
if (col > max_col_reached) max_col_reached = col;
|
||||
col = 0;
|
||||
prev_width = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((ch == '\b') && (Most_V_Opt == 0))
|
||||
{
|
||||
if (col > max_col_reached) max_col_reached = col;
|
||||
if (col < prev_width)
|
||||
col = 0;
|
||||
else
|
||||
col -= prev_width;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (col < max_col_reached) /* overstrike */
|
||||
{
|
||||
attr = MOST_BOLD_COLOR;
|
||||
if ((col >= min_col) && (col < max_col))
|
||||
{
|
||||
cell = cells + (col-min_col);
|
||||
if (cell->bytes[0] == '_')
|
||||
attr = MOST_ULINE_COLOR;
|
||||
else if (ch == '_')
|
||||
{
|
||||
cell->color = MOST_ULINE_COLOR;
|
||||
col++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
/* drop */
|
||||
}
|
||||
|
||||
if (IS_BYTE_PRINTABLE(ch))
|
||||
{
|
||||
if ((col >= min_col) && (col < max_col))
|
||||
{
|
||||
cell = cells + (col-min_col);
|
||||
cell->bytes = pch;
|
||||
cell->len = 1;
|
||||
cell->color = attr;
|
||||
if (cell >= max_cell)
|
||||
max_cell = cell + 1;
|
||||
}
|
||||
col++;
|
||||
prev_width = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((ch == '\t') && (Most_T_Opt == 0) && (Most_Tab_Width))
|
||||
{
|
||||
int nspaces = Most_Tab_Width * (col/Most_Tab_Width + 1) - col;
|
||||
prev_width = nspaces;
|
||||
while (nspaces > 0)
|
||||
{
|
||||
if ((col >= min_col) && (col < max_col))
|
||||
{
|
||||
cell = cells + (col-min_col);
|
||||
cell->bytes = &cell->byte;
|
||||
cell->byte = ' ';
|
||||
cell->color = attr;
|
||||
cell->len = 1;
|
||||
if (cell >= max_cell)
|
||||
max_cell = cell + 1;
|
||||
}
|
||||
col++;
|
||||
nspaces--;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
#if 1
|
||||
if ((ch == 033) && (Most_V_Opt == 0))
|
||||
{
|
||||
int color;
|
||||
if (0 == most_parse_color_escape (&beg, end, &color))
|
||||
{
|
||||
if (color != -1) default_attr = color;
|
||||
continue;
|
||||
}
|
||||
/* drop */
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ch & 0x80)
|
||||
{
|
||||
SLwchar_Type wch;
|
||||
if ((Most_UTF8_Mode)
|
||||
&& (NULL != SLutf8_decode (pch, end, &wch, NULL)))
|
||||
{
|
||||
int width = SLwchar_wcwidth (wch);
|
||||
beg = SLutf8_skip_chars (pch, end, 1, NULL, 1);
|
||||
|
||||
prev_width = width;
|
||||
if (width == 0)
|
||||
{
|
||||
col--;
|
||||
if ((col >= min_col) && (col < max_col))
|
||||
{
|
||||
cell = cells + (col-min_col);
|
||||
cell->len += beg-pch;
|
||||
}
|
||||
col++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((col >= min_col) && (col < max_col))
|
||||
{
|
||||
cell = cells + (col-min_col);
|
||||
cell->bytes = pch;
|
||||
cell->color = attr;
|
||||
cell->len = beg - pch;
|
||||
if (cell >= max_cell)
|
||||
max_cell = cell + 1;
|
||||
}
|
||||
col++;
|
||||
if (width > 1)
|
||||
{
|
||||
if ((col >= min_col) && (col < max_col))
|
||||
{
|
||||
cell = cells + (col-min_col);
|
||||
cell->bytes = pch;
|
||||
cell->color = attr;
|
||||
cell->len = 0;
|
||||
if (cell >= max_cell)
|
||||
max_cell = cell + 1;
|
||||
}
|
||||
col++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Otherwise, this displays as <XX> and takes up 4 character cells */
|
||||
sprintf (buf, "<%02X>", (unsigned int) ch);
|
||||
prev_width = 4;
|
||||
/* drop */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Otherwise we have a Ctrl-char displayed as ^X */
|
||||
if (ch == 0x7F) ch = '?';
|
||||
else ch += '@';
|
||||
|
||||
sprintf (buf, "^%c", ch);
|
||||
prev_width = 2;
|
||||
}
|
||||
|
||||
pch = (unsigned char *)buf;
|
||||
while (*pch)
|
||||
{
|
||||
if ((col >= min_col) && (col < max_col))
|
||||
{
|
||||
cell = cells + (col-min_col);
|
||||
cell->bytes = &cell->byte;
|
||||
cell->byte = *pch;
|
||||
cell->color = attr;
|
||||
cell->len = 1;
|
||||
if (cell >= max_cell)
|
||||
max_cell = cell + 1;
|
||||
}
|
||||
col++;
|
||||
pch++;
|
||||
}
|
||||
}
|
||||
|
||||
if (col < max_col_reached)
|
||||
col = max_col_reached;
|
||||
else
|
||||
max_col_reached = col;
|
||||
|
||||
/* Now add "..." if selective display. To do that, the next line needs to
|
||||
* be dealt with to determine whether or not it will be hidden.
|
||||
*/
|
||||
if (Most_Selective_Display
|
||||
&& (Most_W_Opt == 0)
|
||||
&& (beg < Most_Eob)
|
||||
&& ((col >= min_col) && (col < max_col)))
|
||||
{
|
||||
if (*beg == '\n') beg++;
|
||||
|
||||
while ((beg < Most_Eob)
|
||||
&& ((*beg == ' ') || (*beg == '\t') || (*beg == '\r')))
|
||||
beg++;
|
||||
|
||||
if ((beg >= Most_Eob) || (*beg == '\n')
|
||||
|| (most_apparant_distance(beg) >= Most_Selective_Display))
|
||||
{
|
||||
max_col_reached = col + 3;
|
||||
while (col < max_col_reached)
|
||||
{
|
||||
if (col < max_col)
|
||||
{
|
||||
cell = cells + (col-min_col);
|
||||
cell->bytes = &cell->byte;
|
||||
cell->byte = '.';
|
||||
cell->color = 0;
|
||||
cell->len = 1;
|
||||
if (cell >= max_cell)
|
||||
max_cell = cell + 1;
|
||||
}
|
||||
col++;
|
||||
}
|
||||
}
|
||||
}
|
||||
*start_colorp = default_attr;
|
||||
return max_cell - cells;
|
||||
}
|
||||
|
||||
static void display_cells (Multibyte_Cell_Type *cell, unsigned int n, char dollar)
|
||||
{
|
||||
Multibyte_Cell_Type *cell_max;
|
||||
int last_color = -1;
|
||||
|
||||
cell_max = cell + n;
|
||||
while (cell < cell_max)
|
||||
{
|
||||
if (last_color != cell->color)
|
||||
{
|
||||
last_color = cell->color;
|
||||
SLsmg_set_color (last_color);
|
||||
}
|
||||
SLsmg_write_chars (cell->bytes, cell->bytes + cell->len);
|
||||
cell++;
|
||||
}
|
||||
|
||||
if (last_color != 0)
|
||||
SLsmg_set_color (0);
|
||||
|
||||
SLsmg_erase_eol ();
|
||||
if (dollar)
|
||||
{
|
||||
SLsmg_gotorc (SLsmg_get_row (), SLtt_Screen_Cols-1);
|
||||
SLsmg_write_nchars (&dollar, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void most_display_line (int reset)
|
||||
{
|
||||
unsigned char *beg, *end;
|
||||
unsigned char dollar;
|
||||
static Multibyte_Cell_Type *cells;
|
||||
static unsigned int num_cells;
|
||||
unsigned int screen_cols;
|
||||
unsigned int num_cells_set;
|
||||
static int last_color = 0; /* used for a line that wrapped */
|
||||
|
||||
if (Most_B_Opt)
|
||||
{
|
||||
output_binary_formatted_line ();
|
||||
return;
|
||||
}
|
||||
|
||||
screen_cols = SLtt_Screen_Cols;
|
||||
if (num_cells != screen_cols + 1)
|
||||
{
|
||||
num_cells = screen_cols + 1;
|
||||
|
||||
SLfree ((char *) cells);
|
||||
if (NULL == (cells = (Multibyte_Cell_Type *)SLcalloc (num_cells, sizeof (Multibyte_Cell_Type))))
|
||||
most_exit_error ("Out of memory");
|
||||
}
|
||||
|
||||
(void) most_extract_line (&beg, &end);
|
||||
|
||||
if (reset || (Most_W_Opt == 0))
|
||||
last_color = 0;
|
||||
num_cells_set = most_analyse_line (beg, end, cells, num_cells, &last_color);
|
||||
|
||||
dollar = 0;
|
||||
if (Most_W_Opt)
|
||||
{
|
||||
if (Most_Show_Wrap_Marker
|
||||
&& (end < Most_Eob)
|
||||
&& (*end != '\n'))
|
||||
dollar = '\\';
|
||||
}
|
||||
else if (num_cells_set > screen_cols)
|
||||
dollar = '$';
|
||||
|
||||
display_cells (cells, num_cells_set, dollar);
|
||||
}
|
||||
|
||||
/* given a position in a line, return apparent distance from bol
|
||||
expanding tabs, etc... up to pos */
|
||||
int most_apparant_distance (unsigned char *pos)
|
||||
{
|
||||
int i, prev_width;
|
||||
unsigned char *save_pos, ch;
|
||||
unsigned int save_offset;
|
||||
|
||||
save_offset = Most_C_Offset;
|
||||
save_pos = pos;
|
||||
Most_C_Offset = (unsigned int) (pos - Most_Beg);
|
||||
pos = most_beg_of_line();
|
||||
Most_C_Offset = save_offset;
|
||||
|
||||
i = 0;
|
||||
prev_width = 1;
|
||||
while (pos < save_pos)
|
||||
{
|
||||
ch = *pos++;
|
||||
if (IS_BYTE_PRINTABLE(ch))
|
||||
{
|
||||
i++;
|
||||
prev_width = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((ch == '\b') && (Most_V_Opt == 0))
|
||||
{
|
||||
i -= prev_width;
|
||||
if (i < 0) i = 0;
|
||||
continue;
|
||||
}
|
||||
if ((ch == '\r') && (Most_V_Opt == 0))
|
||||
{
|
||||
if (i != 1) i = 0;
|
||||
prev_width = 1;
|
||||
continue;
|
||||
}
|
||||
if ((ch == '\t') && (Most_T_Opt == 0))
|
||||
{
|
||||
prev_width = Most_Tab_Width * (i/Most_Tab_Width + 1) - i; /* Most_Tab_Width column tabs */
|
||||
i += prev_width;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((ch == 033) && (Most_V_Opt == 0)
|
||||
&& (0 == most_parse_color_escape (&pos, save_pos, NULL)))
|
||||
continue;
|
||||
|
||||
if (ch & 0x80)
|
||||
{
|
||||
SLwchar_Type wch;
|
||||
if ((Most_UTF8_Mode)
|
||||
&& (NULL != SLutf8_decode (pos-1, save_pos, &wch, NULL)))
|
||||
{
|
||||
prev_width = SLwchar_wcwidth (wch);
|
||||
pos = SLutf8_skip_chars (pos-1, save_pos, 1, NULL, 1);
|
||||
i += prev_width;
|
||||
continue;
|
||||
}
|
||||
prev_width = 4;
|
||||
i += prev_width; /* <XX> */
|
||||
continue;
|
||||
}
|
||||
|
||||
prev_width = 2;
|
||||
i += prev_width; /* ^X */
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns a pointer to the num_cols'th character after the one
|
||||
* pointed at b. Invisible character runs are not counted toward this
|
||||
* limit, i.e. strings that represent attributes, such as "_\b" for
|
||||
* underlines.
|
||||
*
|
||||
* If multi_column is non-zero, characters spanning more than one
|
||||
* column will add their extra width to the column count.
|
||||
*
|
||||
* If there the end of the buffer is reached, as delimited by argument
|
||||
* e, then e is returned.
|
||||
*/
|
||||
unsigned char *most_forward_columns (unsigned char *b, unsigned char *e, unsigned int num_cols)
|
||||
{
|
||||
unsigned int col = 0;
|
||||
unsigned int prev_width = 1;
|
||||
|
||||
while (b < e)
|
||||
{
|
||||
unsigned char ch = *b++;
|
||||
|
||||
if (col >=num_cols)
|
||||
{
|
||||
if ((ch == 033) && (Most_V_Opt == 0))
|
||||
{
|
||||
while ((ch == 033)
|
||||
&& (0 == most_parse_color_escape (&b, e, NULL))
|
||||
&& (b < e))
|
||||
ch = *b++;
|
||||
}
|
||||
b--;
|
||||
break;
|
||||
}
|
||||
|
||||
if (IS_BYTE_PRINTABLE(ch))
|
||||
{
|
||||
col++;
|
||||
prev_width = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ch & 0x80)
|
||||
{
|
||||
SLwchar_Type wch;
|
||||
|
||||
if ((Most_UTF8_Mode)
|
||||
&& (NULL != SLutf8_decode (b-1, e, &wch, NULL)))
|
||||
{
|
||||
b = SLutf8_skip_chars (b-1, e, 1, NULL, 1);
|
||||
prev_width = SLwchar_wcwidth (wch);
|
||||
col += prev_width;
|
||||
continue;
|
||||
}
|
||||
prev_width = 4;
|
||||
col += prev_width; /* <XX> */
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ch == '\b')
|
||||
{
|
||||
if (Most_V_Opt == 0)
|
||||
{
|
||||
if (col < prev_width)
|
||||
col = 0;
|
||||
else
|
||||
col -= prev_width;
|
||||
}
|
||||
else col += 2; /* ^H */
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ch == '\r')
|
||||
{
|
||||
if (Most_V_Opt == 0)
|
||||
{
|
||||
prev_width = 1;
|
||||
col = 0;
|
||||
}
|
||||
else col += 2; /* ^M */
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ch == '\t')
|
||||
{
|
||||
if (Most_T_Opt == 0)
|
||||
{
|
||||
prev_width = Most_Tab_Width * (col/Most_Tab_Width + 1) - col;
|
||||
col += prev_width;
|
||||
}
|
||||
else
|
||||
col += 2; /* ^I */
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((ch == 033) && (Most_V_Opt == 0)
|
||||
&& (0 == most_parse_color_escape (&b, e, NULL)))
|
||||
continue;
|
||||
|
||||
/* Ctrl-char ^X */
|
||||
prev_width = 2;
|
||||
col += prev_width;
|
||||
}
|
||||
return b;
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
This file is part of MOST.
|
||||
|
||||
Copyright (c) 1991, 1999, 2002, 2005-2018, 2019 John E. Davis
|
||||
|
||||
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 2 of the License, 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.
|
||||
*/
|
||||
#ifndef _DAVIS_LINE_H_
|
||||
# define _DAVIS_LINE_H_
|
||||
#if 0
|
||||
extern int most_analyse_line(unsigned char *, unsigned char *, char *, char *);
|
||||
extern void most_output(unsigned char *, unsigned int, unsigned char *, unsigned char);
|
||||
#endif
|
||||
|
||||
extern void most_display_line(int);
|
||||
extern int most_apparant_distance(unsigned char *);
|
||||
extern unsigned char *most_forward_columns (unsigned char *b, unsigned char *e, unsigned int num_cols);
|
||||
extern int most_parse_color_escape (unsigned char **begp, unsigned char *end, int *colorp);
|
||||
|
||||
extern int Most_Show_Wrap_Marker;
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
This file is part of MOST.
|
||||
|
||||
Copyright (c) 1991, 1999, 2002, 2005-2018, 2019 John E. Davis
|
||||
|
||||
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 2 of the License, 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.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include <slang.h>
|
||||
#include "most.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#if 0
|
||||
static volatile int debug_me = 1;
|
||||
while (debug_me == 1)
|
||||
{
|
||||
sleep (1);
|
||||
}
|
||||
#endif
|
||||
if (argc > 1)
|
||||
{
|
||||
if ((0 == strcmp (argv[1], "--version"))
|
||||
|| (0 == strcmp (argv[1], "--help")))
|
||||
{
|
||||
most_usage ();
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
most_initialize_most ();
|
||||
return most (argc, argv);
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
buffer
|
||||
cmd
|
||||
display
|
||||
edit
|
||||
file
|
||||
help
|
||||
keym
|
||||
keyparse
|
||||
line
|
||||
main
|
||||
most
|
||||
search
|
||||
sysdep
|
||||
window
|
|
@ -0,0 +1,565 @@
|
|||
/*
|
||||
This file is part of MOST.
|
||||
|
||||
Copyright (c) 1991, 1999, 2002, 2005-2018, 2019 John E. Davis
|
||||
|
||||
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 2 of the License, 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.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef VMS
|
||||
# include <rmsdef.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <slang.h>
|
||||
#include "version.h"
|
||||
|
||||
#include "jdmacros.h"
|
||||
|
||||
#include "most.h"
|
||||
#include "search.h"
|
||||
#include "window.h"
|
||||
#include "file.h"
|
||||
#include "sysdep.h"
|
||||
#include "keym.h"
|
||||
#include "display.h"
|
||||
#include "line.h"
|
||||
|
||||
int Most_S_Opt = 0; /* squeeze liness */
|
||||
int Most_A_Opt = 1; /* automatically choose -b if necessary */
|
||||
int Most_V_Opt = 0; /* display control chars */
|
||||
int Most_B_Opt = 0; /* display Binary File */
|
||||
int Most_T_Opt = 0; /* display tab as ^I-- valid only with V option */
|
||||
int Most_D_Opt = 0; /* delete file mode (see ':D') */
|
||||
int Most_K_Opt = 0; /* Display 8 bit unformatted (Kanji) */
|
||||
int Most_Z_Opt = 0; /* Gunzip on the fly */
|
||||
int Most_Want_Exit;
|
||||
int Most_Secure_Mode;
|
||||
int Most_Captive_Mode;
|
||||
#if MOST_HAS_MMAP
|
||||
int Most_Disable_MMap = 0;
|
||||
#endif
|
||||
int Most_Do_Regexp_Search = 0;
|
||||
|
||||
int Most_UTF8_Mode = -1; /* -1:auto, 0:off, 1:on */
|
||||
|
||||
static int Most_Starting_Line;
|
||||
char *Most_Program; /* Program Name (argv[0]) */
|
||||
|
||||
static char *Most_Version = MOST_VERSION_STR;
|
||||
|
||||
#ifdef VMS
|
||||
# ifndef isalpha
|
||||
# define isalpha(x) \
|
||||
(((x >= 'A') && (x <= 'Z'))||((x >= 'a') && (x <= 'z')) ? 1 : 0)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
void most_usage (void)
|
||||
{
|
||||
fprintf(stderr,"MOST version %s (S-Lang version %s)\n",
|
||||
Most_Version, SLang_Version_String);
|
||||
if (SLang_Version != SLANG_VERSION)
|
||||
fprintf (stderr, " *Note: This executable was compiled against S-Lang %s\n", SLANG_VERSION_STRING);
|
||||
|
||||
fprintf (stderr, "Usage:\n");
|
||||
fprintf(stderr, "most [-1Cbcdkrstvw] [+/string] [+line number] [+s] [+d] file...\n");
|
||||
fputs(" where: -1: assume VT100 terminal. (VMS only)\n", stderr);
|
||||
fputs(" -b: Startup in binary mode.\n", stderr);
|
||||
fputs(" -C: disable color support\n", stderr);
|
||||
fputs(" -c: Make searches case sensitive.\n", stderr);
|
||||
fputs(" -d: Do not display the \\ wrap marker when wrapping lines.\n", stderr);
|
||||
/* fputs(" -k: Kanji mode.\n", stderr); */
|
||||
#if MOST_HAS_MMAP
|
||||
fputs(" -M: Do not attempt to mmap files.\n", stderr);
|
||||
#endif
|
||||
fputs(" -r: Default to regexp search\n", stderr);
|
||||
fputs(" -s: Squeeze out excess blank lines.\n", stderr);
|
||||
fputs(" -t: Display tabs as ^I. If this option is immediately followed\n", stderr);
|
||||
fputs(" by an integer, the integer sets the tab width.\n", stderr);
|
||||
fputs(" -u: Disable UTF-8 mode\n", stderr);
|
||||
fputs(" -v: Do not interpret backspace formatting characters.\n", stderr);
|
||||
fputs(" -w: Wrap lines.\n", stderr);
|
||||
fputs(" -z: No gunzip-on-the-fly.\n", stderr);
|
||||
fputs(" +/string:\n", stderr);
|
||||
fputs(" Search for string\n", stderr);
|
||||
fputs(" +line number\n", stderr);
|
||||
fputs(" Start up at specified line number.\n", stderr);
|
||||
fputs(" +d: Allow file deletion.\n", stderr);
|
||||
fputs(" +s: Secure Mode-- no edit, cd, shell, and reading files not\n", stderr);
|
||||
fputs(" already listed on the command line.\n", stderr);
|
||||
fputs(" +u: Enable UTF-8 mode.\n", stderr);
|
||||
fprintf(stderr, "\nExample: most -ct4 +82 keymap.c\n");
|
||||
fputs(" makes searches case sensitive, sets tabwidth to 4, and displays the file\n", stderr);
|
||||
fputs(" keymap.c starting at line 82.\n", stderr);
|
||||
}
|
||||
|
||||
static void do_switches(char *str);
|
||||
|
||||
static void do_extended_switches(char *str)
|
||||
{
|
||||
int i;
|
||||
char ch;
|
||||
char numstr [256];
|
||||
|
||||
i = 0;
|
||||
ch = *(++str);
|
||||
if ( ch == '/')
|
||||
{
|
||||
strcpy (Most_Search_Str,++str);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ch >= '0' && ch <= '9')
|
||||
{
|
||||
while ((ch >= '0' && ch <= '9') && (i < 10))
|
||||
{
|
||||
numstr[i++] = ch;
|
||||
ch = *(++str);
|
||||
}
|
||||
numstr[i] = '\0';
|
||||
if (1 == sscanf (numstr,"%d", &i))
|
||||
Most_Starting_Line = i;
|
||||
return;
|
||||
}
|
||||
|
||||
if (isalpha(ch))
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
switch (ch)
|
||||
{
|
||||
case 0:
|
||||
return;
|
||||
case ' ':
|
||||
case '+':
|
||||
break;
|
||||
case '-':
|
||||
do_switches (str);
|
||||
return;
|
||||
|
||||
case 'D':
|
||||
case 'd':
|
||||
Most_D_Opt = 1; /* delete file mode */
|
||||
break;
|
||||
case 'S':
|
||||
case 's':
|
||||
Most_Secure_Mode = 1;
|
||||
break;
|
||||
|
||||
case 'U':
|
||||
case 'u':
|
||||
Most_UTF8_Mode = 1; /* +u */
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr,"%s invalid extended option %c ignored.\n",
|
||||
Most_Program, ch);
|
||||
}
|
||||
ch = *(++str);
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr,"%s: switch '+%s' not valid.\n", Most_Program, str);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
/* if non-zero, assume terminal is only a generic vt100 */
|
||||
static int assume_vt100 = 0;
|
||||
static int No_Colors = 0;
|
||||
|
||||
static void do_switches(char *str)
|
||||
{
|
||||
char ch;
|
||||
if (*str == '-') str++;
|
||||
while ((ch = *str++) != '\0')
|
||||
{
|
||||
switch (ch)
|
||||
{
|
||||
default:
|
||||
fprintf(stderr,"%s: invalid switch %c ignored.\n",
|
||||
Most_Program, ch);
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
No_Colors = 1;
|
||||
break;
|
||||
case 'c':
|
||||
Most_Case_Sensitive = 1;
|
||||
break;
|
||||
case 'd':
|
||||
case 'D':
|
||||
Most_Show_Wrap_Marker = 0;
|
||||
break;
|
||||
case 'r':
|
||||
Most_Do_Regexp_Search = 1;
|
||||
break;
|
||||
case 's':
|
||||
case 'S':
|
||||
Most_S_Opt = 1; break;
|
||||
case 'V':
|
||||
case 'v':
|
||||
Most_V_Opt = 1; /* verbose-- convert control chars to '^' 'ch' */
|
||||
break;
|
||||
case 'W':
|
||||
case 'w': Most_W_Opt = 1; break;
|
||||
|
||||
case 'K': /* Kanji option */
|
||||
case 'k':
|
||||
/* Most_K_Opt = 1; break; */
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
case 'b':
|
||||
Most_B_Opt = 1; /* Binary display 8 bit */
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
#if MOST_HAS_MMAP
|
||||
Most_Disable_MMap = 1;
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 'z':
|
||||
case 'Z':
|
||||
Most_Z_Opt = 1; /* NO Gunzip-on-the-fly */
|
||||
break;
|
||||
|
||||
case 't':
|
||||
case 'T': /* expand tabs to '^I'; meaningful only with 'v' */
|
||||
ch = *str;
|
||||
if ((ch <= '9') && (ch >= '0'))
|
||||
{
|
||||
str++;
|
||||
Most_Tab_Width = (int) ch - '0';
|
||||
if (Most_Tab_Width == 0) Most_T_Opt = 1;
|
||||
}
|
||||
else Most_T_Opt = 1;
|
||||
break;
|
||||
|
||||
case 'n': case 'N':
|
||||
/* could be the Gopher Naive user switch --- ignored. */
|
||||
break;
|
||||
case '1': assume_vt100 = 1;
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
case 'U':
|
||||
Most_UTF8_Mode = 0; /* -u */
|
||||
break;
|
||||
|
||||
/* Allow MOST_SWITCHES environment variable to contain + forms,
|
||||
* e.g., "-sn+d" or "-s -n +d"
|
||||
*/
|
||||
case ' ':
|
||||
case '-':
|
||||
break;
|
||||
case '+':
|
||||
do_extended_switches (str - 1); /* include '+' */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void most_exit_error(char *fmt,...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
most_reset_tty ();
|
||||
most_reset_display();
|
||||
if (fmt != NULL)
|
||||
{
|
||||
va_start (ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end (ap);
|
||||
putc ('\n', stderr);
|
||||
}
|
||||
#ifdef MALLOC_DEBUG
|
||||
SLmalloc_dump_statistics ();
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void play_cat(char *file)
|
||||
{
|
||||
char buf[4096 * 4];
|
||||
int n;
|
||||
FILE *fp;
|
||||
|
||||
if (file == NULL) fp = stdin;
|
||||
else
|
||||
{
|
||||
fp = fopen(file, "r");
|
||||
if (fp == NULL) return;
|
||||
}
|
||||
|
||||
while ((n = fread(buf, 1, 4096 * 4, fp)) > 0)
|
||||
{
|
||||
int m;
|
||||
m = fwrite (buf, 1, n, stdout);
|
||||
if (m != n)
|
||||
{
|
||||
fprintf (stderr, "fwrite returned %d, errno = %d\n",
|
||||
m, errno);
|
||||
(void) fclose (fp);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
(void) fclose (fp);
|
||||
}
|
||||
|
||||
void most_initialize_most (void)
|
||||
{
|
||||
Most_S_Opt = 0;
|
||||
Most_A_Opt = 1;
|
||||
Most_V_Opt = 0;
|
||||
Most_B_Opt = 0;
|
||||
Most_T_Opt = 0;
|
||||
Most_D_Opt = 0;
|
||||
Most_K_Opt = 0;
|
||||
Most_W_Opt = 0;
|
||||
|
||||
Most_Selective_Display = 0;
|
||||
*Most_Search_Str = 0; Most_Search_Dir = 1;
|
||||
Most_Top_Win = Most_Win = NULL;
|
||||
Most_Buf = NULL;
|
||||
Most_Eob = NULL;
|
||||
Most_Beg = NULL;
|
||||
Most_Captive_Mode = Most_Secure_Mode = 0;
|
||||
Most_Want_Exit = 0;
|
||||
}
|
||||
|
||||
static void do_most (char *file, int start)
|
||||
{
|
||||
MOST_INT row, col;
|
||||
|
||||
most_get_cdir(Most_C_Dir);
|
||||
|
||||
row = col = 0;
|
||||
|
||||
if ((-1 == most_find_file (file))
|
||||
&& (Most_Num_Files == 1))
|
||||
most_exit_error ("%s: failed to open for reading.", file);
|
||||
|
||||
most_init_display ();
|
||||
|
||||
most_goto_line(start);
|
||||
|
||||
Most_Curs_Offset = Most_C_Offset;
|
||||
|
||||
if (*Most_Search_Str
|
||||
&& ((row = most_search (Most_Beg + Most_C_Offset, 1, &col)) > 0))
|
||||
most_goto_line(row);
|
||||
else
|
||||
{
|
||||
row = Most_C_Line;
|
||||
col = 1;
|
||||
}
|
||||
|
||||
most_window_buffer();
|
||||
Most_Curs_Row = Most_Win->curs_line = row - Most_C_Line + 1;
|
||||
Most_Win->curs_offset = Most_Curs_Offset;
|
||||
Most_Curs_Col = Most_Win->curs_col = col;
|
||||
most_redraw_window();
|
||||
most_update_status();
|
||||
|
||||
while (Most_Want_Exit == 0)
|
||||
{
|
||||
most_execute_key();
|
||||
}
|
||||
}
|
||||
|
||||
void most_exit_most (void)
|
||||
{
|
||||
if (Most_Want_Exit) return;
|
||||
Most_Want_Exit = 1;
|
||||
most_clear_minibuffer ();
|
||||
most_reset_tty ();
|
||||
most_reset_display ();
|
||||
most_free_windows ();
|
||||
#ifdef MALLOC_DEBUG
|
||||
SLmalloc_dump_statistics ();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void utf8_config (void)
|
||||
{
|
||||
int utf8_mode = Most_UTF8_Mode;
|
||||
|
||||
utf8_mode = SLutf8_enable (-1); /* returns 0 or 1 */
|
||||
if (Most_UTF8_Mode == -1)
|
||||
Most_UTF8_Mode = utf8_mode;
|
||||
else if (utf8_mode != Most_UTF8_Mode)
|
||||
{
|
||||
if (utf8_mode == 1)
|
||||
(void) SLsmg_utf8_enable (0); /* locale is UTF-8, but -u passed */
|
||||
else
|
||||
(void) SLsmg_utf8_enable (1); /* locale not UTF-8, but +u passed */
|
||||
}
|
||||
}
|
||||
|
||||
int most (int argc, char **argv)
|
||||
{
|
||||
char file[MAX_PATHLEN], *switches;
|
||||
int file_i = 0, quit,i,piped;
|
||||
int status = 0;
|
||||
|
||||
#ifdef VMS
|
||||
char filename[256];
|
||||
#else
|
||||
int j;
|
||||
#endif
|
||||
|
||||
Most_Program = argv[0];
|
||||
piped = 0;
|
||||
|
||||
switches = getenv ("MOST_PROMPT");
|
||||
if ((switches != NULL) && (*switches != 0)) Most_Global_Msg = switches;
|
||||
|
||||
switches = getenv("MOST_SWITCHES");
|
||||
if (switches != NULL) do_switches(switches);
|
||||
|
||||
i = 1;
|
||||
if (argc > 1)
|
||||
{
|
||||
quit = 0;
|
||||
while ((!quit) && (i < argc))
|
||||
{
|
||||
if (argv[i][0] == '-')
|
||||
do_switches(argv[i++]);
|
||||
else if (argv[i][0] == '+')
|
||||
do_extended_switches(argv[i++]);
|
||||
else quit = 1;
|
||||
}
|
||||
}
|
||||
|
||||
#if MOST_HAS_MMAP
|
||||
/* if (Most_D_Opt) */
|
||||
/* Most_Disable_MMap = 1; */
|
||||
#endif
|
||||
|
||||
if (i == argc)
|
||||
{
|
||||
if (isatty(0)) /* 1 if stdin is a terminal, 0 otherwise */
|
||||
{
|
||||
most_usage ();
|
||||
return 0;
|
||||
}
|
||||
/* assume input is from stdin */
|
||||
file[0] = '\0'; /* tells most this is stdin */
|
||||
piped = 1;
|
||||
if (!isatty(fileno(stdout)))
|
||||
{
|
||||
play_cat(NULL);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy (file, argv[i], sizeof(file));
|
||||
file[sizeof(file)-1] = 0;
|
||||
}
|
||||
|
||||
if (!isatty(fileno(stdout)))
|
||||
{
|
||||
while (i < argc) play_cat(argv[i++]);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
Most_Num_Files = 0;
|
||||
|
||||
SLtt_get_terminfo();
|
||||
utf8_config ();
|
||||
SLtt_Ignore_Beep = 1;
|
||||
if (No_Colors)
|
||||
SLtt_Use_Ansi_Colors = 0;
|
||||
|
||||
most_setup_colors ();
|
||||
most_init_tty ();
|
||||
most_init_keymaps ();
|
||||
|
||||
if (Most_B_Opt) Most_A_Opt = 0; /* explicit b overrides a */
|
||||
|
||||
if (!piped)
|
||||
{
|
||||
file_i = i;
|
||||
#ifdef VMS
|
||||
while(i < argc)
|
||||
{
|
||||
if (Most_Num_Files >= MOST_MAX_FILES) break;
|
||||
if (argv[i][0] == '.') strcpy(file,"*"); else *file = 0;
|
||||
strcat(file, most_unix2vms(argv[i++]));
|
||||
while (RMS$_NORMAL == (status = most_expand_file_name(file,filename)))
|
||||
{
|
||||
Most_File_Ring[Most_Num_Files] = (char*) MOSTMALLOC(strlen(filename) + 1);
|
||||
strcpy(Most_File_Ring[Most_Num_Files++], filename);
|
||||
}
|
||||
if (status == RMS$_NMF) status = RMS$_NORMAL; /* avoid spurious warning message */
|
||||
}
|
||||
|
||||
if (Most_Num_Files) strcpy(file,Most_File_Ring[0]);
|
||||
else fputs("%%MOST-W-NOFILES, no files found\n", stderr);
|
||||
#else
|
||||
Most_Num_Files = argc - i;
|
||||
if (Most_Num_Files > MOST_MAX_FILES)
|
||||
{
|
||||
Most_Num_Files = MOST_MAX_FILES;
|
||||
argc = Most_Num_Files + i;
|
||||
}
|
||||
|
||||
j = 0;
|
||||
while (i < argc)
|
||||
{
|
||||
Most_File_Ring[j++] = argv[i++];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (Most_Num_Files || piped) do_most(file, Most_Starting_Line);
|
||||
else if (Most_Num_Files == 0)
|
||||
fprintf(stderr,"File %s not found\n", argv[file_i]);
|
||||
|
||||
most_exit_most ();
|
||||
return status;
|
||||
}
|
||||
|
||||
#if SLANG_VERSION <= 10409
|
||||
|
||||
int SLang_set_error (int x)
|
||||
{
|
||||
SLang_Error = x;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SLang_get_error (void)
|
||||
{
|
||||
return SLang_Error;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
This file is part of MOST.
|
||||
|
||||
Copyright (c) 1991, 1999, 2002, 2005-2018, 2019 John E. Davis
|
||||
|
||||
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 2 of the License, 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.
|
||||
*/
|
||||
#include "config.h"
|
||||
extern int Most_S_Opt;
|
||||
extern int Most_A_Opt; /* automatically choose -b if necessary */
|
||||
extern int Most_V_Opt; /* display control chars */
|
||||
extern int Most_B_Opt; /* display Binary File */
|
||||
extern int Most_T_Opt; /* display tab as ^I-- valid only with V option */
|
||||
extern int Most_D_Opt; /* delete file mode (see ':D') */
|
||||
extern int Most_L_Opt; /* use ^L (formfeed) to clear screen */
|
||||
extern int Most_W_Opt; /* Wrap mode */
|
||||
extern int Most_K_Opt; /* Kanji mode */
|
||||
extern int Most_Z_Opt; /* gunzip-on-the-fly */
|
||||
|
||||
#if MOST_HAS_MMAP
|
||||
extern int Most_Disable_MMap;
|
||||
#endif
|
||||
|
||||
extern int Most_UTF8_Mode;
|
||||
|
||||
extern int Most_Secure_Mode;
|
||||
extern int Most_Captive_Mode;
|
||||
extern char *Most_Program;
|
||||
|
||||
extern int most(int, char **);
|
||||
extern char *Most_Global_Msg;
|
||||
extern int Most_Want_Exit;
|
||||
extern void most_initialize_most(void);
|
||||
extern void most_exit_most (void);
|
||||
extern void most_exit_error (char *, ...);
|
||||
|
||||
extern void most_usage (void);
|
||||
#define MOSTMALLOC most_malloc
|
||||
#define MOSTREALLOC most_realloc
|
||||
extern unsigned char *most_malloc(unsigned int);
|
||||
extern unsigned char *most_realloc(unsigned char *, unsigned int);
|
||||
extern int Most_Tab_Width;
|
||||
|
||||
#ifdef VMS
|
||||
# ifndef isdigit
|
||||
# define isdigit(x) \
|
||||
(((x >= '0') && (x <= '9')) ? 1 : 0)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SNPRINTF
|
||||
# define _pSLsnprintf snprintf
|
||||
#else
|
||||
# if SLANG_VERSION < 20000
|
||||
# define _pSLsnprintf _SLsnprintf
|
||||
extern int _pSLsnprintf (char *, unsigned int, char *, ...);
|
||||
# else
|
||||
# define _pSLsnprintf SLsnprintf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if SLANG_VERSION <= 10409
|
||||
extern int SLang_get_error (void);
|
||||
extern int SLang_set_error (int);
|
||||
#endif
|
||||
|
||||
#define SLANG_REGEX 1
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Use sysconf.h for unix!!! This file is for NON-unix systems.
|
||||
*
|
||||
* This file is used to indicate capabilities of the C compiler and
|
||||
* operating system.
|
||||
*/
|
||||
|
||||
/* Basic include files. */
|
||||
|
||||
#if defined(__os2__) || defined (__DECC) || defined(VAXC)
|
||||
# define HAVE_STDLIB_H 1
|
||||
#else
|
||||
# define HAVE_MALLOC_H 1
|
||||
#endif
|
||||
|
||||
#if defined (__os2__)
|
||||
# define HAVE_UNISTD_H 1
|
||||
# define HAVE_MEMORY_H 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Basic C library functions.
|
||||
*/
|
||||
|
||||
#if defined(__os2__)
|
||||
# define HAVE_PUTENV 1
|
||||
#endif
|
||||
|
||||
#define HAVE_GETCWD 1
|
||||
#define HAVE_MEMSET 1
|
||||
#define HAVE_MEMCPY 1
|
||||
#define HAVE_MEMCHR 1
|
||||
|
||||
#ifdef VMS
|
||||
# ifndef __GNUC__
|
||||
# include <unixio.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define MAX_PATHLEN 256
|
||||
|
||||
#define MOST_INT long
|
||||
#define MOST_UINT unsigned long
|
||||
#define MOST_INT_D_FMT "%ld"
|
||||
|
||||
#define MOST_HAS_MMAP 0
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,667 @@
|
|||
/* -*- mode: C; mode: fold -*- */
|
||||
/*
|
||||
This file is part of MOST.
|
||||
|
||||
Copyright (c) 1991, 1999, 2002, 2005-2018, 2019 John E. Davis
|
||||
|
||||
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 2 of the License, 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.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <slang.h>
|
||||
|
||||
#include "most.h"
|
||||
#include "window.h"
|
||||
#include "line.h"
|
||||
#include "file.h"
|
||||
#include "display.h"
|
||||
#include "search.h"
|
||||
|
||||
/* Note!!! The regular expression searches may not work. I have not
|
||||
* tested them.
|
||||
* FIXME!!! This whole thing needs to be rewritten. It is a mess.
|
||||
*/
|
||||
|
||||
int Most_Case_Sensitive = 0;
|
||||
char Most_Search_Str[256];
|
||||
int Most_Search_Dir = 1;
|
||||
|
||||
#include "jdmacros.h"
|
||||
|
||||
typedef struct Search_Type_ Search_Type;
|
||||
struct Search_Type_
|
||||
{
|
||||
void *cd;
|
||||
unsigned char *(*fsearch_method) (Search_Type *, unsigned char *, unsigned char *, unsigned char *);
|
||||
unsigned char *(*bsearch_method) (Search_Type *, unsigned char *, unsigned char *, unsigned char *);
|
||||
void (*close_method)(Search_Type *);
|
||||
};
|
||||
|
||||
|
||||
static unsigned char Ascii_Upper[256];
|
||||
|
||||
static void bs_search_init (void)
|
||||
{
|
||||
static int inited = 0;
|
||||
unsigned int i;
|
||||
|
||||
if (inited) return;
|
||||
for (i = 0; i < 256; i++) Ascii_Upper[i] = i;
|
||||
for (i = 'a'; i <= 'z'; i++) Ascii_Upper[i] = (i - 32);
|
||||
inited = 1;
|
||||
}
|
||||
|
||||
#define UPCASE(ch) (Ascii_Upper[(ch)])
|
||||
|
||||
#define CHAR_EQS(a,b) \
|
||||
(((a) == (b)) || (!Most_Case_Sensitive && (UPCASE(a) == UPCASE(b))))
|
||||
|
||||
static int is_ansi_escape (unsigned char **begp, unsigned char *end)
|
||||
{
|
||||
unsigned char *p, ch;
|
||||
|
||||
p = *begp;
|
||||
if ((p == end) || (*p++ != '[')) return 0;
|
||||
|
||||
/* Look for "ESC X m", where X is one of:
|
||||
* X = ""
|
||||
* X = digit
|
||||
* X = digit ; digit ...
|
||||
*/
|
||||
ch = *p++;
|
||||
while (isdigit (ch))
|
||||
{
|
||||
while ((p < end) && isdigit (*p))
|
||||
p++;
|
||||
|
||||
if (p == end)
|
||||
return 0;
|
||||
|
||||
ch = *p++;
|
||||
if (ch == 'm')
|
||||
break;
|
||||
|
||||
if ((ch != ';') || (p == end))
|
||||
return 0;
|
||||
|
||||
ch = *p++;
|
||||
}
|
||||
if (ch != 'm')
|
||||
return 0;
|
||||
|
||||
*begp = p;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int is_rev_ansi_escape (unsigned char *beg, unsigned char **endp)
|
||||
{
|
||||
unsigned char *p, ch;
|
||||
|
||||
p = *endp;
|
||||
if (p == beg)
|
||||
return 0;
|
||||
|
||||
ch = *p--;
|
||||
while (isdigit (ch))
|
||||
{
|
||||
while ((p > beg) && isdigit (*p))
|
||||
p--;
|
||||
|
||||
if (p == beg)
|
||||
return 0;
|
||||
|
||||
ch = *p--;
|
||||
|
||||
if (ch == '[')
|
||||
break;
|
||||
|
||||
if ((ch != ';') || (p == beg))
|
||||
return 0;
|
||||
|
||||
ch = *p--;
|
||||
}
|
||||
|
||||
if ((ch != '[') || (p < beg) || (*p != 033))
|
||||
return 0;
|
||||
|
||||
*endp = p-1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* These routines have special processing for ANSI escape sequence and backspace handling.
|
||||
* For example, "hello world" may occur as:
|
||||
* plain: hello world
|
||||
* underlined: h_e_l_l_o_ world
|
||||
* underlined: _h_e_l_l_o world
|
||||
* bold: hheelllloo world
|
||||
* ansi: [5mhello[m world
|
||||
* ansi: [5mh[32;43mello[m world
|
||||
*/
|
||||
|
||||
/* This routine returns the 1 + position of first match of key in str.
|
||||
* searches from beg up to but not including end. Handles backspace, etc
|
||||
*/
|
||||
static unsigned char *
|
||||
bs_fsearch (Search_Type *st,
|
||||
unsigned char *beg, unsigned char *end,
|
||||
unsigned char *key)
|
||||
{
|
||||
unsigned char ch, ch1, ch1up;
|
||||
unsigned char *pos;
|
||||
int cis, key_len, j, str_len;
|
||||
|
||||
(void) st;
|
||||
key_len = strlen ((char *)key);
|
||||
if (key_len == 0)
|
||||
return Most_Eob;
|
||||
|
||||
str_len = (int) (end - beg);
|
||||
if (str_len < key_len) return (Most_Eob);
|
||||
|
||||
cis = (Most_Case_Sensitive == 0);
|
||||
ch1 = key[0];
|
||||
ch1up = UPCASE(ch1);
|
||||
|
||||
while (1)
|
||||
{
|
||||
/* Find first character that matches */
|
||||
while (1)
|
||||
{
|
||||
if (beg == end) return Most_Eob;
|
||||
|
||||
ch = *beg++;
|
||||
if ((ch == ch1)
|
||||
|| (cis && (ch1up == UPCASE(ch))))
|
||||
break;
|
||||
}
|
||||
|
||||
/* so we have a position of possible match */
|
||||
j = 1;
|
||||
|
||||
pos = beg; /* save this position so we start from here again */
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (j == key_len)
|
||||
return pos - 1;
|
||||
|
||||
if (beg == end)
|
||||
break;
|
||||
|
||||
ch = *beg++;
|
||||
|
||||
/* FIXME: This only works for x^Hx but not x^Hx^Hx...
|
||||
* It is probably better to skip all the ^H characters
|
||||
* until the end. That is, regard "a^Hb^Hc" as 'c'.
|
||||
*/
|
||||
if ((ch == 8)
|
||||
&& (beg + 1 < end)
|
||||
&& (CHAR_EQS(key[j - 1], *beg)
|
||||
|| (*beg == '_')))
|
||||
{
|
||||
ch = *(beg + 1);
|
||||
beg += 2;
|
||||
}
|
||||
else if ((ch == '_') && (beg + 1 < end))
|
||||
{
|
||||
ch = *beg++;
|
||||
if (ch == 8) ch = *beg++;
|
||||
else
|
||||
{
|
||||
ch = '_';
|
||||
beg--;
|
||||
}
|
||||
}
|
||||
else if ((ch == 033) && is_ansi_escape (&beg, end))
|
||||
continue;
|
||||
|
||||
if (!CHAR_EQS(ch, key[j]))
|
||||
break;
|
||||
|
||||
j++;
|
||||
}
|
||||
|
||||
beg = pos;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Search backwards in the buffer "beg" up to, but not including "end" for
|
||||
* pattern "key". It handles backspaces, etc
|
||||
*/
|
||||
static unsigned char *
|
||||
bs_bsearch (Search_Type *st,
|
||||
unsigned char *beg, unsigned char *end,
|
||||
unsigned char *key)
|
||||
{
|
||||
unsigned char ch, ch1, ch1up;
|
||||
unsigned char *pos;
|
||||
int key_len,j, str_len;
|
||||
int cis;
|
||||
|
||||
(void) st;
|
||||
key_len = strlen ((char *)key);
|
||||
if (key_len == 0) return Most_Eob;
|
||||
|
||||
str_len = (int) (end - beg);
|
||||
if (str_len < key_len) return Most_Eob;
|
||||
|
||||
ch1 = key[key_len-1];
|
||||
ch1up = UPCASE(ch1);
|
||||
cis = (Most_Case_Sensitive == 0);
|
||||
|
||||
while (1)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
if (end < beg)
|
||||
return Most_Eob;
|
||||
|
||||
ch = *end--;
|
||||
if ((ch == ch1)
|
||||
|| (cis && (ch1up == UPCASE(ch))))
|
||||
break;
|
||||
}
|
||||
|
||||
pos = end; /* save this position so we start from here again */
|
||||
|
||||
j = key_len - 2;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (j < 0)
|
||||
return end + 1;
|
||||
if (end < beg)
|
||||
break;
|
||||
|
||||
ch = *end--;
|
||||
|
||||
if ((ch == 8)
|
||||
&& (end >= beg + 1)
|
||||
&& (CHAR_EQS(key[j + 1], *end)
|
||||
|| (*end == '_')))
|
||||
{
|
||||
ch = *(end - 1);
|
||||
end -= 2;
|
||||
}
|
||||
else if ((ch == '_')
|
||||
&& (end >= beg + 1))
|
||||
{
|
||||
ch = *end--;
|
||||
if (ch == 8) ch = *end--;
|
||||
else
|
||||
{
|
||||
ch = '_';
|
||||
end++;
|
||||
}
|
||||
}
|
||||
else if ((ch == 'm') && is_rev_ansi_escape (beg, &end))
|
||||
continue;
|
||||
|
||||
if (!CHAR_EQS(ch, key[j]))
|
||||
break;
|
||||
|
||||
j--;
|
||||
}
|
||||
end = pos;
|
||||
}
|
||||
}
|
||||
|
||||
static int bs_open_search (Search_Type *st, char *key)
|
||||
{
|
||||
(void) key;
|
||||
|
||||
bs_search_init ();
|
||||
st->fsearch_method = bs_fsearch;
|
||||
st->bsearch_method = bs_bsearch;
|
||||
st->close_method = NULL;
|
||||
st->cd = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned char *sl_fsearch (Search_Type *st,
|
||||
unsigned char *beg, unsigned char *end,
|
||||
unsigned char *key)
|
||||
{
|
||||
unsigned char *p;
|
||||
|
||||
(void) key;
|
||||
if (NULL == (p = SLsearch_forward ((SLsearch_Type *)st->cd, beg, end)))
|
||||
p = Most_Eob;
|
||||
return p;
|
||||
}
|
||||
|
||||
static unsigned char *sl_bsearch (Search_Type *st,
|
||||
unsigned char *beg, unsigned char *end,
|
||||
unsigned char *key)
|
||||
{
|
||||
unsigned char *p;
|
||||
|
||||
(void) key;
|
||||
if (NULL == (p = SLsearch_backward ((SLsearch_Type *)st->cd, beg, end, end)))
|
||||
p = Most_Eob;
|
||||
return p;
|
||||
}
|
||||
|
||||
static void sl_search_close (Search_Type *st)
|
||||
{
|
||||
if (st->cd != NULL)
|
||||
SLsearch_delete ((SLsearch_Type *) st->cd);
|
||||
}
|
||||
|
||||
static int sl_open_search (Search_Type *st, char *key)
|
||||
{
|
||||
unsigned int flags = 0;
|
||||
|
||||
if (Most_Case_Sensitive == 0) flags |= SLSEARCH_CASELESS;
|
||||
if (Most_UTF8_Mode) flags |= SLSEARCH_UTF8;
|
||||
|
||||
if (NULL == (st->cd = SLsearch_new ((SLuchar_Type *) key, flags)))
|
||||
return -1;
|
||||
|
||||
st->fsearch_method = sl_fsearch;
|
||||
st->bsearch_method = sl_bsearch;
|
||||
st->close_method = sl_search_close;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
do_search_internal (Search_Type *st,
|
||||
unsigned char *from, int repeat, MOST_INT *col)
|
||||
{
|
||||
/* return the line match was found as well as line number,
|
||||
* search from i on; assume that line_array match the i so we need
|
||||
* no initial lookup */
|
||||
|
||||
int test;
|
||||
MOST_INT save_line, the_col, row, s_len;
|
||||
char string[300];
|
||||
unsigned char *pos, *eob;
|
||||
unsigned int save_ofs;
|
||||
unsigned int found_ofs;
|
||||
|
||||
if (*Most_Search_Str == 0)
|
||||
{
|
||||
most_message("Search string not specified.",1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((from < Most_Beg) || (from > Most_Eob)) return -1;
|
||||
|
||||
save_ofs = Most_C_Offset;
|
||||
save_line = Most_C_Line;
|
||||
found_ofs = Most_Eob - Most_Beg;
|
||||
*col = 0;
|
||||
s_len = strlen (Most_Search_Str);
|
||||
pos = from;
|
||||
|
||||
eob = Most_Eob;
|
||||
|
||||
test = repeat && (pos < Most_Eob) && (pos >= Most_Beg);
|
||||
while(test)
|
||||
{
|
||||
if (Most_Search_Dir == 1)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
unsigned int pos_ofs;
|
||||
|
||||
pos = (*st->fsearch_method)(st, pos, Most_Eob, (unsigned char*) Most_Search_Str);
|
||||
pos_ofs = (unsigned int) (Most_Eob - Most_Beg);
|
||||
|
||||
if (pos < Most_Eob)
|
||||
break;
|
||||
|
||||
if (0 == most_read_file_dsc (10, 0))
|
||||
{
|
||||
/* Pointer may be invalid after this call */
|
||||
pos = Most_Beg + pos_ofs;
|
||||
break;
|
||||
}
|
||||
|
||||
/* This might need an adjustment */
|
||||
pos = Most_Beg + (pos_ofs - s_len);
|
||||
if (pos < Most_Beg) pos = Most_Beg;
|
||||
}
|
||||
}
|
||||
else
|
||||
pos = (*st->bsearch_method)(st, Most_Beg, pos, (unsigned char *) Most_Search_Str);
|
||||
|
||||
if (pos < Most_Eob)
|
||||
{
|
||||
repeat--;
|
||||
found_ofs = pos - Most_Beg;
|
||||
if (Most_Search_Dir == 1)
|
||||
pos += s_len;
|
||||
else pos--;
|
||||
}
|
||||
test = repeat && (pos < Most_Eob) && (pos >= Most_Beg);
|
||||
if (SLKeyBoard_Quit)
|
||||
{
|
||||
most_message ("Search Interrupted.", 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (eob != Most_Eob)
|
||||
Most_Num_Lines = most_count_lines (Most_Beg, Most_Eob);
|
||||
|
||||
if (repeat) /* not found */
|
||||
{
|
||||
*col = 0;
|
||||
|
||||
(void) sprintf(string,"Search failed: %s",Most_Search_Str);
|
||||
most_message(string,1);
|
||||
row = -1;
|
||||
}
|
||||
else /* if ( !Most_T_Opt && !Most_B_Opt) */ /* expand tabs to get col correct */
|
||||
{
|
||||
most_find_row_column(Most_Beg + found_ofs, &row, &the_col);
|
||||
if (Most_B_Opt) *col = the_col + 52;
|
||||
else
|
||||
*col = 1 + most_apparant_distance(Most_Beg + found_ofs);
|
||||
}
|
||||
|
||||
Most_C_Offset = save_ofs;
|
||||
Most_C_Line = save_line;
|
||||
if (row > 0) Most_Curs_Offset = found_ofs;
|
||||
|
||||
return row;
|
||||
}
|
||||
|
||||
static int search_internal (Search_Type *st, unsigned char *from, int repeat, MOST_INT *colp)
|
||||
{
|
||||
int status;
|
||||
|
||||
status = do_search_internal (st, from, repeat, colp);
|
||||
|
||||
if (st->close_method != NULL)
|
||||
(st->close_method)(st);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int simple_search (unsigned char *from, int repeat, MOST_INT *colp)
|
||||
{
|
||||
Search_Type st;
|
||||
|
||||
if (Most_V_Opt || Most_B_Opt)
|
||||
{
|
||||
/* Nothing special about the ^H and _ chars. User faster SLsearch */
|
||||
if (-1 == sl_open_search (&st, Most_Search_Str))
|
||||
return -1;
|
||||
}
|
||||
else if (-1 == bs_open_search (&st, Most_Search_Str))
|
||||
return -1;
|
||||
|
||||
return search_internal (&st, from, repeat, colp);
|
||||
}
|
||||
|
||||
|
||||
static void re_search_close (Search_Type *st)
|
||||
{
|
||||
if (st->cd != NULL)
|
||||
SLregexp_free ((SLRegexp_Type *) st->cd);
|
||||
}
|
||||
|
||||
static unsigned char *
|
||||
re_fsearch (Search_Type *st,
|
||||
unsigned char *beg, unsigned char *end,
|
||||
unsigned char *key)
|
||||
{
|
||||
SLRegexp_Type *re;
|
||||
unsigned char *p;
|
||||
unsigned int flags;
|
||||
|
||||
(void) key;
|
||||
|
||||
re = (SLRegexp_Type *)st->cd;
|
||||
(void) SLregexp_get_hints (re, &flags);
|
||||
|
||||
while (beg < end)
|
||||
{
|
||||
unsigned char *line_end = beg;
|
||||
|
||||
while (line_end < end)
|
||||
{
|
||||
unsigned char ch = *line_end++;
|
||||
if (ch == '\n') break;
|
||||
}
|
||||
|
||||
p = (unsigned char *)SLregexp_match (re, (char *)beg, (line_end - beg));
|
||||
if (p != NULL)
|
||||
{
|
||||
if ((0 == (flags & SLREGEXP_HINT_BOL))
|
||||
|| (p != beg)
|
||||
|| (beg == Most_Beg)
|
||||
|| (*(beg - 1) == '\n'))
|
||||
return p;
|
||||
}
|
||||
beg = line_end;
|
||||
}
|
||||
|
||||
return Most_Eob;
|
||||
}
|
||||
|
||||
static unsigned char *
|
||||
re_bsearch (Search_Type *st,
|
||||
unsigned char *beg, unsigned char *end,
|
||||
unsigned char *key)
|
||||
{
|
||||
SLRegexp_Type *re;
|
||||
unsigned char *line_end, *eob;
|
||||
unsigned int flags;
|
||||
|
||||
(void) key;
|
||||
re = (SLRegexp_Type *)st->cd;
|
||||
(void) SLregexp_get_hints (re, &flags);
|
||||
|
||||
line_end = end;
|
||||
eob = Most_Eob;
|
||||
while (line_end < eob)
|
||||
{
|
||||
if (*line_end == '\n')
|
||||
break;
|
||||
line_end++;
|
||||
}
|
||||
|
||||
while (end > beg)
|
||||
{
|
||||
unsigned char *p, *match;
|
||||
unsigned char *line = end;
|
||||
while (line > beg)
|
||||
{
|
||||
line--;
|
||||
if (*line == '\n')
|
||||
{
|
||||
line++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* line is now at the start of a line */
|
||||
if (NULL != (match = (unsigned char *)SLregexp_match (re, (char *)line, line_end-line)))
|
||||
{
|
||||
if (match >= end)
|
||||
{
|
||||
/* Match occurs to right of boundary. Try previous line */
|
||||
end = line_end = line-1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (flags & SLREGEXP_HINT_BOL)
|
||||
return match;
|
||||
|
||||
/* t tt z t t t z */
|
||||
/* Find match closest to end */
|
||||
while ((line < end)
|
||||
&& (NULL != (p = (unsigned char *)SLregexp_match (re, (char *)line, (line_end - line))))
|
||||
&& (p < end))
|
||||
{
|
||||
match = p;
|
||||
line++;
|
||||
}
|
||||
return match;
|
||||
}
|
||||
|
||||
end = line-1;
|
||||
line_end = end;
|
||||
}
|
||||
|
||||
return Most_Eob;
|
||||
}
|
||||
|
||||
|
||||
static int regexp_search (unsigned char *from, int repeat, MOST_INT *colp)
|
||||
{
|
||||
Search_Type st;
|
||||
SLRegexp_Type *re;
|
||||
char *pattern;
|
||||
unsigned int flags;
|
||||
|
||||
pattern = Most_Search_Str;
|
||||
|
||||
flags = 0;
|
||||
if (Most_Case_Sensitive == 0) flags |= SLREGEXP_CASELESS;
|
||||
|
||||
re = SLregexp_compile (pattern, flags);
|
||||
if (re == NULL)
|
||||
return -1;
|
||||
|
||||
(void) SLregexp_get_hints (re, &flags);
|
||||
if (flags & SLREGEXP_HINT_OSEARCH)
|
||||
{
|
||||
SLregexp_free (re);
|
||||
return simple_search (from, repeat, colp);
|
||||
}
|
||||
|
||||
st.cd = (void *)re;
|
||||
st.fsearch_method = re_fsearch;
|
||||
st.bsearch_method = re_bsearch;
|
||||
st.close_method = re_search_close;
|
||||
|
||||
return search_internal (&st, from, repeat, colp);
|
||||
}
|
||||
|
||||
int most_search (unsigned char *from, int repeat, MOST_INT *colp)
|
||||
{
|
||||
if (Most_Do_Regexp_Search)
|
||||
return regexp_search (from, repeat, colp);
|
||||
|
||||
return simple_search (from, repeat, colp);
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
#ifndef _DAVIS_SEARCH_H_
|
||||
# define _DAVIS_SEARCH_H_
|
||||
/*
|
||||
This file is part of MOST.
|
||||
|
||||
Copyright (c) 1991, 1999, 2002, 2005-2018, 2019 John E. Davis
|
||||
|
||||
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 2 of the License, 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.
|
||||
*/
|
||||
# include <stdio.h>
|
||||
# include <string.h>
|
||||
|
||||
extern int Most_Case_Sensitive;
|
||||
extern int Most_Do_Regexp_Search;
|
||||
extern int Most_Search_Dir;
|
||||
#define MOST_SEARCH_BUF_LEN 256
|
||||
extern char Most_Search_Str[MOST_SEARCH_BUF_LEN];
|
||||
extern int most_search(unsigned char *, int, MOST_INT *);
|
||||
#endif
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
/* src/sysconf.h. Generated from config.hin by configure. */
|
||||
/* -*- C -*- */
|
||||
|
||||
/* Note: this is for authentic unix systems only.
|
||||
* See mostconf.h for other systems.
|
||||
*/
|
||||
|
||||
#ifndef MOST_CONFIG_H
|
||||
#define MOST_CONFIG_H
|
||||
|
||||
/* Define if you want the MMAP support */
|
||||
#define USE_MMAP 1
|
||||
|
||||
/* define if you have long long type */
|
||||
#define HAVE_LONG_LONG 1
|
||||
|
||||
/* #undef off_t */
|
||||
/* #undef size_t */
|
||||
#define SIZEOF_OFF_T 8
|
||||
#define SIZEOF_SHORT 2
|
||||
#define SIZEOF_INT 4
|
||||
#define SIZEOF_LONG 8
|
||||
#define SIZEOF_FLOAT 4
|
||||
#define SIZEOF_DOUBLE 8
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
|
||||
/* The following set defines may be necessary to activate long file support */
|
||||
/* #undef _FILE_OFFSET_BITS */
|
||||
/* #undef _LARGE_FILES */
|
||||
/* #undef _LARGEFILE_SOURCE */
|
||||
|
||||
/* define if you have stdlib.h */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* define if you have unistd.h */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* define if you have memory.h */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* define if you have malloc.h */
|
||||
#define HAVE_MALLOC_H 1
|
||||
|
||||
/* define if you have memset */
|
||||
#define HAVE_MEMSET 1
|
||||
|
||||
/* define if you have memcpy */
|
||||
#define HAVE_MEMCPY 1
|
||||
|
||||
/* define if you have this. */
|
||||
#define HAVE_GETCWD 1
|
||||
|
||||
#define HAVE_MMAP 1
|
||||
|
||||
#define HAVE_TCGETPGRP 1
|
||||
#define HAVE_GETPGRP 1
|
||||
|
||||
#define HAVE_DIRENT_H 1
|
||||
/* #undef HAVE_SYS_NDIR_H */
|
||||
/* #undef HAVE_SYS_DIR_H */
|
||||
/* #undef HAVE_NDIR_H */
|
||||
|
||||
#define HAVE_SNPRINTF 1
|
||||
#define HAVE_SYS_MMAN_H 1
|
||||
|
||||
/* #undef mode_t */
|
||||
/* #undef pid_t */
|
||||
/* #undef uid_t */
|
||||
/* #undef pid_t */
|
||||
|
||||
|
||||
#ifdef _AIX
|
||||
# ifndef _POSIX_SOURCE
|
||||
# define _POSIX_SOURCE
|
||||
# endif
|
||||
# ifndef _ALL_SOURCE
|
||||
# define _ALL_SOURCE 1
|
||||
# endif
|
||||
/* This may generate warnings but the fact is that without it, xlc will
|
||||
* INCORRECTLY inline many str* functions. */
|
||||
/* # undef __STR__ */
|
||||
#endif
|
||||
|
||||
#define MAX_PATHLEN 1024
|
||||
#if defined(USE_MMAP) && defined(HAVE_MMAP) && defined(HAVE_SYS_MMAN_H)
|
||||
# define MOST_HAS_MMAP 1
|
||||
#else
|
||||
# define MOST_HAS_MMAP 0
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LONG_LONG) && (SIZEOF_OFF_T == SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG > SIZEOF_LONG)
|
||||
typedef long long MOST_INT;
|
||||
typedef unsigned long long MOST_UINT;
|
||||
# define MOST_INT_D_FMT "%lld"
|
||||
#else
|
||||
# if (SIZEOF_OFF_T == SIZEOF_INT)
|
||||
typedef int MOST_INT;
|
||||
typedef unsigned int MOST_UINT;
|
||||
# define MOST_INT_D_FMT "%d"
|
||||
# else
|
||||
typedef long MOST_INT;
|
||||
typedef unsigned long MOST_UINT;
|
||||
# define MOST_INT_D_FMT "%ld"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* MOST_CONFIG_H */
|
|
@ -0,0 +1,773 @@
|
|||
/*
|
||||
This file is part of MOST.
|
||||
|
||||
Copyright (c) 1991, 1999, 2002, 2005-2018, 2019 John E. Davis
|
||||
|
||||
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 2 of the License, 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.
|
||||
*/
|
||||
#include "config.h"
|
||||
/*
|
||||
* HISTORY
|
||||
* {1} 19-Mar-91 Henk D. Davids <hdavids@mswe.dnet.ms.philips.nl>
|
||||
* History started. Added default input file name so you do not
|
||||
* have to specify name or type if you want it to be *.
|
||||
* Changes indicated by "-hdd" in comment.
|
||||
*
|
||||
* 2. 4/4/91 John E. Davis
|
||||
* I added code to read the teminal size for unix systems-- at least it
|
||||
* works on a sun4 (BSD ?). In addition I have also recently added file
|
||||
* deletion code for both unix and vms.
|
||||
*/
|
||||
#ifdef VMS
|
||||
# include <ssdef.h>
|
||||
# include <rmsdef.h>
|
||||
# include <dvidef.h>
|
||||
# include <jpidef.h>
|
||||
# include <libdef.h>
|
||||
# include <descrip.h>
|
||||
# include <iodef.h>
|
||||
# include <ttdef.h>
|
||||
# include <starlet.h>
|
||||
|
||||
/* #include <unixlib.h> */
|
||||
|
||||
#endif /* VMS */
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include <slang.h>
|
||||
#include "jdmacros.h"
|
||||
|
||||
#ifdef unix
|
||||
# include <signal.h>
|
||||
# ifdef SYSV
|
||||
# include <sys/types.h>
|
||||
# include <fcntl.h>
|
||||
# endif
|
||||
# include <sys/file.h>
|
||||
#endif
|
||||
|
||||
#ifdef __os2__
|
||||
# include <signal.h>
|
||||
#endif
|
||||
|
||||
#ifdef __WIN32__
|
||||
#include <windows.h>
|
||||
/* Sleep is defined badly in MSVC... */
|
||||
# ifdef _MSC_VER
|
||||
# define sleep(n) _sleep((n)*1000)
|
||||
# else
|
||||
# ifdef sleep
|
||||
# undef sleep
|
||||
# endif
|
||||
# define sleep(x) if(x)Sleep((x)*1000)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "display.h"
|
||||
#include "window.h"
|
||||
#include "most.h"
|
||||
|
||||
#ifdef VMS
|
||||
typedef struct
|
||||
{
|
||||
/* I/O status block */
|
||||
short i_cond; /* Condition value */
|
||||
short i_xfer; /* Transfer count */
|
||||
long i_info; /* Device information */
|
||||
}
|
||||
iosb;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* Terminal characteristics */
|
||||
char t_class; /* Terminal class */
|
||||
char t_type; /* Terminal type */
|
||||
short t_width; /* Terminal width in characters */
|
||||
long t_mandl; /* Terminal's mode and length */
|
||||
long t_extend; /* Extended terminal characteristics */
|
||||
}
|
||||
termchar;
|
||||
|
||||
static short TTY_CHANNEL_GLOBAL;
|
||||
static int zero = 0;
|
||||
|
||||
#else
|
||||
int TTY_DESCR;
|
||||
#endif /* VMS */
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* SHELL COMMANDS
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef VMS
|
||||
|
||||
/* these two from emacs source */
|
||||
# if 0
|
||||
static define_logical_name (char *varname, char *string)
|
||||
{
|
||||
static char sstring[200], svarname[200];
|
||||
|
||||
struct dsc$descriptor_s strdsc =
|
||||
{strlen (string), DSC$K_DTYPE_T, DSC$K_CLASS_S, sstring};
|
||||
struct dsc$descriptor_s envdsc =
|
||||
{strlen (varname), DSC$K_DTYPE_T, DSC$K_CLASS_S, svarname};
|
||||
struct dsc$descriptor_s lnmdsc =
|
||||
{7, DSC$K_DTYPE_T, DSC$K_CLASS_S, "LNM$JOB"};
|
||||
|
||||
strcpy(sstring, string); strcpy(svarname, varname);
|
||||
|
||||
LIB$SET_LOGICAL (&envdsc, &strdsc, &lnmdsc, 0, 0);
|
||||
}
|
||||
|
||||
static delete_logical_name (char *varname)
|
||||
{
|
||||
struct dsc$descriptor_s envdsc =
|
||||
{strlen (varname), DSC$K_DTYPE_T, DSC$K_CLASS_S, varname};
|
||||
struct dsc$descriptor_s lnmdsc =
|
||||
{7, DSC$K_DTYPE_T, DSC$K_CLASS_S, "LNM$JOB"};
|
||||
|
||||
LIB$DELETE_LOGICAL (&envdsc, &lnmdsc);
|
||||
}
|
||||
|
||||
int most_do_emacs_command()
|
||||
{
|
||||
unsigned long pid;
|
||||
char *pidstr;
|
||||
|
||||
if((pidstr = getenv("EMACS_PID")) != NULL)
|
||||
{
|
||||
(void) sscanf(pidstr,"%X",&pid);
|
||||
if (lib$attach(&pid) == SS$_NORMAL) /* we attach to emacs */
|
||||
return(1);
|
||||
else
|
||||
return(0);
|
||||
/* printf("Can't attach to pid %X\n",pid); */
|
||||
}
|
||||
else return(0);
|
||||
}
|
||||
# endif /* if 0 */
|
||||
|
||||
static unsigned long SHELL_PID = 0;
|
||||
|
||||
/* returns 0 on success */
|
||||
int most_do_shell_command()
|
||||
{
|
||||
/* here we try to attach to the parent otherwise just spawn a new one */
|
||||
unsigned long parent_pid;
|
||||
unsigned long status = 0;
|
||||
char str[80];
|
||||
|
||||
$DESCRIPTOR(MOST_$_descr, "MOST > ");
|
||||
|
||||
if (Most_Secure_Mode)
|
||||
{
|
||||
most_message ("Spawning not permitted in secure mode.", 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
parent_pid = getppid();
|
||||
|
||||
if (parent_pid && (parent_pid != 0xffffffffU))
|
||||
/* we attach to parent */
|
||||
status = lib$attach(&parent_pid);
|
||||
|
||||
else if (SHELL_PID && (SHELL_PID != 0xffffffffU))
|
||||
/* try to attach to previous shell */
|
||||
status = lib$attach (&SHELL_PID);
|
||||
|
||||
if (status != SS$_NORMAL) /* others fail so spawn a new shell */
|
||||
{
|
||||
status = 0;
|
||||
SLtt_write_string("Spawning MOST DCL SUBPROCESS (Logout when finished)...");
|
||||
lib$spawn(0,0,0,0,0,&SHELL_PID,&status,0,0,0,&MOST_$_descr);
|
||||
/* if we attach back, status may come back unchanged */
|
||||
if ((status != 0) && (status != SS$_NORMAL))
|
||||
{
|
||||
sprintf(str,"Unable to spawn subprocess. Error = %X", status);
|
||||
most_message(str,1);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
most_message(" ",0); /* make sure message window is restored */
|
||||
return(1);
|
||||
}
|
||||
|
||||
#endif /* VMS */
|
||||
|
||||
/*
|
||||
* FILE IO
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef VMS
|
||||
int most_expand_file_name(char *file,char *expanded_file)
|
||||
{
|
||||
unsigned long status;
|
||||
static int context = 0, len = 0;
|
||||
static char inputname[MAX_PATHLEN] = "";
|
||||
$DESCRIPTOR(file_desc,inputname);
|
||||
$DESCRIPTOR(default_dsc,"SYS$DISK:[]*.*;");
|
||||
static struct dsc$descriptor_s result =
|
||||
{0, DSC$K_DTYPE_T, DSC$K_CLASS_D, NULL};
|
||||
|
||||
if (strcmp(inputname, file))
|
||||
{
|
||||
if (context)
|
||||
{
|
||||
lib$find_file_end(&context);
|
||||
}
|
||||
context = 0;
|
||||
strcpy(inputname, file);
|
||||
len = strlen(inputname);
|
||||
}
|
||||
file_desc.dsc$w_length = len;
|
||||
|
||||
status = lib$find_file(&file_desc,&result,&context,
|
||||
&default_dsc,0,0,&zero);
|
||||
|
||||
if (status == RMS$_NORMAL)
|
||||
{
|
||||
memcpy(expanded_file, result.dsc$a_pointer, result.dsc$w_length);
|
||||
expanded_file[result.dsc$w_length] = '\0';
|
||||
}
|
||||
else
|
||||
expanded_file[0] = '\0'; /* so file comes back as zero width */
|
||||
|
||||
return status;
|
||||
}
|
||||
#endif /* VMS */
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* Terminal IO
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef VMS
|
||||
/*
|
||||
* Exit Handler Control Block
|
||||
*/
|
||||
static struct argument_block
|
||||
{
|
||||
int forward_link;
|
||||
int (*exit_routine)();
|
||||
int arg_count;
|
||||
int *status_address;
|
||||
int exit_status;
|
||||
}
|
||||
Exit_Block =
|
||||
{
|
||||
0,
|
||||
NULL,
|
||||
1,
|
||||
&Exit_Block.exit_status,
|
||||
0
|
||||
};
|
||||
|
||||
#endif /* VMS */
|
||||
|
||||
#ifdef unix
|
||||
|
||||
# include <sys/time.h>
|
||||
|
||||
# if !defined(sun)
|
||||
# include <sys/ioctl.h>
|
||||
# endif
|
||||
|
||||
# ifndef NO_UNISTD_H
|
||||
# include <unistd.h>
|
||||
# endif
|
||||
|
||||
# if HAS_TERMIOS
|
||||
# include <termios.h>
|
||||
# endif
|
||||
# ifdef SYSV
|
||||
# include <sys/termio.h>
|
||||
# include <sys/stream.h>
|
||||
# include <sys/ptem.h>
|
||||
# include <sys/tty.h>
|
||||
# endif
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
# include <errno.h>
|
||||
|
||||
#if defined(SIGHUP) && !defined(IBMPC_SYSTEM)
|
||||
static void unix_hangup(int sig)
|
||||
{
|
||||
most_exit_error ("most: Exiting on signal %d.", sig);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* unix */
|
||||
|
||||
static int Want_Window_Size_Change;
|
||||
static int Most_TTY_Inited = 0;
|
||||
|
||||
#ifdef REAL_UNIX_SYSTEM
|
||||
static int handle_interrupts (void)
|
||||
{
|
||||
if (Want_Window_Size_Change)
|
||||
most_resize_display ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SIGWINCH
|
||||
static void sigwinch_handler (int sig)
|
||||
{
|
||||
(void) sig;
|
||||
Want_Window_Size_Change = 1;
|
||||
(void) SLsignal_intr (SIGWINCH, sigwinch_handler);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SIGBUS) && MOST_HAS_MMAP
|
||||
static void sigbus_handler (int sig)
|
||||
{
|
||||
(void) sig;
|
||||
most_reset_tty ();
|
||||
most_reset_display ();
|
||||
|
||||
fprintf (stderr, "SIGBUS caught--- fatal error\n");
|
||||
if ((Most_Buf != NULL)
|
||||
&& Most_Buf->is_mmaped)
|
||||
fprintf (stderr, "This may be due to a modified memory mapped file\n");
|
||||
|
||||
exit (1);
|
||||
}
|
||||
#endif
|
||||
|
||||
void most_resize_display (void)
|
||||
{
|
||||
Want_Window_Size_Change = 0;
|
||||
|
||||
if (Most_Display_Inited == 0)
|
||||
return;
|
||||
|
||||
most_get_term_dimensions(&SLtt_Screen_Cols, &SLtt_Screen_Rows);
|
||||
|
||||
if (Most_Win != NULL)
|
||||
most_one_window ();
|
||||
#if SLANG_VERSION > 10305
|
||||
SLsmg_reinit_smg ();
|
||||
#else
|
||||
SLsmg_reset_smg ();
|
||||
SLsmg_init_smg ();
|
||||
#endif
|
||||
most_redraw_display ();
|
||||
}
|
||||
|
||||
static int init_tty (void)
|
||||
{
|
||||
#if defined(REAL_UNIX_SYSTEM)
|
||||
SLsig_block_signals ();
|
||||
#endif
|
||||
|
||||
if (-1 == SLang_init_tty (7, 0, 1))
|
||||
{
|
||||
fprintf (stderr, "most: failed to init terminal.\n");
|
||||
exit (1);
|
||||
}
|
||||
#if !defined(IBMPC_SYSTEM)
|
||||
SLtt_enable_cursor_keys ();
|
||||
#endif
|
||||
#if defined(REAL_UNIX_SYSTEM)
|
||||
SLsig_unblock_signals ();
|
||||
SLang_getkey_intr_hook = handle_interrupts;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void most_init_tty (void)
|
||||
{
|
||||
int i;
|
||||
if (Most_TTY_Inited) return;
|
||||
|
||||
(void) init_tty ();
|
||||
#if !defined(IBMPC_SYSTEM)
|
||||
SLsig_block_signals ();
|
||||
#endif
|
||||
|
||||
for (i = 1; i < 32; i++)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
#ifdef SIGHUP
|
||||
case SIGHUP:
|
||||
#endif
|
||||
#ifdef SIGQUIT
|
||||
case SIGQUIT:
|
||||
#endif
|
||||
#ifdef SIGTERM
|
||||
case SIGTERM:
|
||||
# ifdef REAL_UNIX_SYSTEM
|
||||
SLsignal_intr (i, unix_hangup);
|
||||
# else
|
||||
(void) i;
|
||||
# endif
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef SIGWINCH
|
||||
case SIGWINCH:
|
||||
(void) SLsignal_intr (SIGWINCH, sigwinch_handler);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(SIGBUS) && MOST_HAS_MMAP
|
||||
case SIGBUS:
|
||||
(void) SLsignal_intr (SIGBUS, sigbus_handler);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef SIGCONT
|
||||
case SIGCONT:
|
||||
#endif
|
||||
#ifdef SIGTSTP
|
||||
case SIGTSTP:
|
||||
#endif
|
||||
#ifdef SIGINT
|
||||
case SIGINT:
|
||||
#endif
|
||||
#ifdef SIGCHLD
|
||||
case SIGCHLD:
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
#ifdef SIGPIPE
|
||||
case SIGPIPE:
|
||||
(void) SLsignal_intr (SIGPIPE, SIG_IGN);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
SLang_set_abort_signal (NULL);
|
||||
|
||||
Most_TTY_Inited = 1;
|
||||
#if !defined(IBMPC_SYSTEM)
|
||||
SLsig_unblock_signals ();
|
||||
#endif
|
||||
}
|
||||
|
||||
void most_reset_tty (void)
|
||||
{
|
||||
if (Most_TTY_Inited == 0) return;
|
||||
SLang_reset_tty ();
|
||||
Most_TTY_Inited = 0;
|
||||
}
|
||||
|
||||
int most_reinit_terminal (void)
|
||||
{
|
||||
if (Most_TTY_Inited == 0)
|
||||
return 0;
|
||||
most_reset_tty ();
|
||||
(void) init_tty ();
|
||||
Most_TTY_Inited = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* slang uses select to wait for terminal input. If SIGINT is
|
||||
* generated, then slang returns ^G and sets SLKeyBoard_Quit
|
||||
* to 1 bypassing the read altogether. If most was used in
|
||||
* conjunction with xargs (find . -print | xargs most) and ^G
|
||||
* is pressed, a SIGINT will be generated killing xargs and
|
||||
* leaving most an orphan unable to access the terminal.
|
||||
* Unfortunately, the select call will continue to time-out
|
||||
* causing most continue running in the background. To
|
||||
* workaround this problem, exit if the terminal is not in the
|
||||
* same process group as most.
|
||||
*/
|
||||
static void check_if_foreground (void)
|
||||
{
|
||||
#if defined(HAVE_GETPGRP) && defined(HAVE_TCGETPGRP)
|
||||
pid_t pgid = getpgrp ();
|
||||
|
||||
if ((SLang_TT_Read_FD != -1)
|
||||
&& (pgid != tcgetpgrp (SLang_TT_Read_FD)))
|
||||
{
|
||||
most_exit_error ("\007Fatal Error: Most is not in the terminal's process group.");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int most_getkey()
|
||||
{
|
||||
unsigned int ch;
|
||||
static int last_was_sigint;
|
||||
|
||||
/* This non-sense involving last_was_sigint is to handle a race condition.
|
||||
* The shell may not have had time to change the pgids, so sleep a bit
|
||||
* here. Yea, its ugly and does not really solve the problem...
|
||||
*/
|
||||
if (last_was_sigint)
|
||||
{
|
||||
sleep (1);
|
||||
check_if_foreground ();
|
||||
last_was_sigint = 0;
|
||||
}
|
||||
|
||||
ch = SLang_getkey ();
|
||||
if (ch == SLANG_GETKEY_ERROR)
|
||||
most_exit_error ("most: getkey error.");
|
||||
|
||||
if (SLKeyBoard_Quit)
|
||||
{
|
||||
check_if_foreground ();
|
||||
last_was_sigint = 1;
|
||||
}
|
||||
SLKeyBoard_Quit = 0;
|
||||
SLang_set_error (0);
|
||||
return (int) ch;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Misc Termial stuff
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/* This is to get the size of the terminal */
|
||||
void most_get_term_dimensions(int *cols, int *rows)
|
||||
{
|
||||
SLtt_get_screen_size ();
|
||||
*rows = SLtt_Screen_Rows;
|
||||
*cols = SLtt_Screen_Cols;
|
||||
}
|
||||
|
||||
/* returns 0 on failure, 1 on sucess */
|
||||
int most_delete_file(char *filename)
|
||||
{
|
||||
#ifdef VMS
|
||||
return (1 + delete(filename)); /* 0: sucess; -1 failure */
|
||||
#else
|
||||
return(1 + remove(filename));
|
||||
#endif
|
||||
}
|
||||
|
||||
/* This routine converts unix type names to vms names */
|
||||
#ifdef VMS
|
||||
static int locate(char ch, char *string)
|
||||
{
|
||||
int i;
|
||||
char c;
|
||||
|
||||
i = 0;
|
||||
while (c = string[i++], (c != ch) && (c != '\0'));
|
||||
if (c == ch) return(i); else return (0);
|
||||
}
|
||||
|
||||
char *most_unix2vms(char *file)
|
||||
{
|
||||
int i,device,j,first,last;
|
||||
static char vms_name[MAX_PATHLEN];
|
||||
char ch;
|
||||
|
||||
if (locate('[',file)) return(file); /* vms_name syntax */
|
||||
if (!locate('/',file)) return(file); /* vms_name syntax */
|
||||
|
||||
/* search for the ':' which means a device is present */
|
||||
device = locate(':',file);
|
||||
|
||||
i = 0;
|
||||
if (device)
|
||||
{
|
||||
while (ch = file[i], i < device) vms_name[i++] = ch;
|
||||
}
|
||||
j = i;
|
||||
|
||||
/* go from the end looking for a '/' and mark it */
|
||||
i = strlen(file) - 1;
|
||||
while(ch = file[i], ch != '/' && i-- >= 0);
|
||||
if (ch == '/')
|
||||
{
|
||||
file[i] = ']';
|
||||
last = 0;
|
||||
}
|
||||
else last = 1;
|
||||
|
||||
i = j;
|
||||
vms_name[j++] = '[';
|
||||
vms_name[j++] = '.';
|
||||
first = 0;
|
||||
while(ch = file[i++], ch != '\0')
|
||||
{
|
||||
switch (ch)
|
||||
{
|
||||
case '.':
|
||||
if (last) vms_name[j++] = '.';
|
||||
if (last) break;
|
||||
ch = file[i++];
|
||||
if (ch == '.')
|
||||
{
|
||||
if (!first) j--; /* overwrite the dot */
|
||||
vms_name[j++] = '-';
|
||||
}
|
||||
else if (ch == '/'); /* './' combinations-- do nothing */
|
||||
else if (ch == ']')
|
||||
{
|
||||
last = 1;
|
||||
if (vms_name[j-1] == '.') j--;
|
||||
vms_name[j++] = ']';
|
||||
}
|
||||
|
||||
else vms_name[j++] = '.';
|
||||
break;
|
||||
case '/':
|
||||
if (first)
|
||||
{
|
||||
vms_name[j++] = '.';
|
||||
}
|
||||
else
|
||||
{
|
||||
first = 1;
|
||||
/* if '/' is first char or follows a colon do nothing */
|
||||
if ((i!=1) && (file[i-2] != ':'))
|
||||
{
|
||||
vms_name[j++] = '.';
|
||||
}
|
||||
else j--; /* overwrite the '.' following '[' */
|
||||
}
|
||||
break;
|
||||
case ']':
|
||||
last = 1;
|
||||
if (vms_name[j-1] == '.') j--;
|
||||
vms_name[j++] = ']';
|
||||
break;
|
||||
default:
|
||||
vms_name[j++] = ch;
|
||||
}
|
||||
}
|
||||
return (vms_name);
|
||||
}
|
||||
|
||||
/*
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
puts(unix2vms(argv[1]));
|
||||
}
|
||||
*/
|
||||
|
||||
#endif /* VMS */
|
||||
|
||||
#include <time.h>
|
||||
|
||||
char *most_get_time()
|
||||
{
|
||||
time_t clk;
|
||||
char *the_time;
|
||||
|
||||
clk = time((time_t *) 0);
|
||||
the_time = (char *) ctime(&clk);
|
||||
/* returns the form Sun Sep 16 01:03:52 1985\n\0 */
|
||||
the_time[24] = '\0';
|
||||
return(the_time);
|
||||
}
|
||||
|
||||
void most_set_width (int width, int redraw)
|
||||
{
|
||||
#ifdef IBMPC_SYSTEM
|
||||
(void) width; (void) redraw;
|
||||
#else
|
||||
#ifdef VMS
|
||||
short fd;
|
||||
int status;
|
||||
iosb iostatus;
|
||||
static termchar tc; /* Terminal characteristics */
|
||||
$DESCRIPTOR( devnam, "SYS$ERROR");
|
||||
#else
|
||||
# ifdef TIOCGWINSZ
|
||||
struct winsize wind_struct;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Switching physical terminal to narrow/wide mode.*/
|
||||
|
||||
if(width <= 80)
|
||||
{
|
||||
width = 80;
|
||||
most_narrow_width();
|
||||
}
|
||||
else
|
||||
{
|
||||
width = 132;
|
||||
most_wide_width();
|
||||
}
|
||||
SLtt_Screen_Cols = width;
|
||||
|
||||
#ifdef VMS
|
||||
/* Assign input to a channel */
|
||||
status = sys$assign(&devnam, &fd, 0, 0);
|
||||
if ((status & 1) == 0)
|
||||
exit(status);
|
||||
/* Get current terminal characteristics */
|
||||
status = sys$qiow( /* Queue and wait */
|
||||
0, /* Wait on event flag zero */
|
||||
fd, /* Channel to input terminal */
|
||||
IO$_SENSEMODE, /* Get current characteristic */
|
||||
&iostatus, /* Status after operation */
|
||||
0, 0, /* No AST service */
|
||||
&tc, /* Terminal characteristics buf */
|
||||
sizeof(tc), /* Size of the buffer */
|
||||
0, 0, 0, 0); /* P3-P6 unused */
|
||||
|
||||
/*set terminal characteristics */
|
||||
tc.t_width=width;
|
||||
status = sys$qiow( /* Queue and wait */
|
||||
0, /* Wait on event flag zero */
|
||||
fd, /* Channel to input terminal */
|
||||
IO$_SETMODE, /* Get current characteristic */
|
||||
&iostatus, /* Status after operation */
|
||||
0, 0, /* No AST service */
|
||||
&tc, /* Terminal characteristics buf */
|
||||
sizeof(tc), /* Size of the buffer */
|
||||
0, 0, 0, 0); /* P3-P6 unused */
|
||||
|
||||
if( (sys$dassgn(fd) & 1)==0)
|
||||
exit(status);
|
||||
|
||||
/* here we redraw the screen, on unix, we assume that the terminal
|
||||
* driver sends the appropriate signal that most catches to redraw so we
|
||||
* do not redraw because it is likely that screen will be redrawn twice */
|
||||
|
||||
if (redraw)
|
||||
most_resize_display ();
|
||||
|
||||
#else
|
||||
(void) redraw;
|
||||
# ifdef TIOCGWINSZ
|
||||
/* this may need work on other unix-- works for sun4 */
|
||||
if (-1 != ioctl(TTY_DESCR,TIOCGWINSZ,&wind_struct))
|
||||
{
|
||||
wind_struct.ws_col = width;
|
||||
ioctl(TTY_DESCR,TIOCSWINSZ,&wind_struct);
|
||||
}
|
||||
# endif
|
||||
#endif /* VMS */
|
||||
#endif /* NOT IBMPC_SYSTEM */
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
#ifndef __DAVIS_SYSDEP_H__
|
||||
# define __DAVIS_SYSDEP_H__
|
||||
/*
|
||||
This file is part of MOST.
|
||||
|
||||
Copyright (c) 1991, 1999, 2002, 2005-2018, 2019 John E. Davis
|
||||
|
||||
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 2 of the License, 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.
|
||||
*/
|
||||
|
||||
# include <stdio.h>
|
||||
|
||||
# if defined(sequent) || defined(apollo)
|
||||
# define HAS_TERMIOS 0
|
||||
# else
|
||||
# define HAS_TERMIOS 1
|
||||
# endif
|
||||
|
||||
# ifdef VMS
|
||||
extern int most_do_emacs_command(void);
|
||||
|
||||
extern int most_do_shell_command();
|
||||
extern int most_expand_file_name(char *,char *);
|
||||
extern char *most_unix2vms(char *);
|
||||
|
||||
# endif /* VMS */
|
||||
|
||||
extern int most_reinit_terminal (void);
|
||||
extern void most_init_tty(void);
|
||||
extern void most_reset_tty(void);
|
||||
extern int most_getkey(void);
|
||||
extern void most_get_term_dimensions(int *, int *);
|
||||
extern int most_delete_file(char *);
|
||||
extern void most_set_width(int, int);
|
||||
extern char *most_get_time(void);
|
||||
|
||||
extern void most_resize_display (void);
|
||||
#endif /* __DAVIS_SYSDEP_H__ */
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
This file is part of MOST.
|
||||
|
||||
Copyright (c) 2006-2018, 2019 John E. Davis
|
||||
|
||||
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 2 of the License, 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.
|
||||
*/
|
||||
#ifndef MOST_VERSION
|
||||
#define MOST_VERSION 50100
|
||||
|
||||
#define MOST_VERSION_STR "5.1.0"
|
||||
#endif /* MOST_VERSION */
|
|
@ -0,0 +1,39 @@
|
|||
/* -*- C -*- */
|
||||
|
||||
/* Note: this is for DJGPP and WIN32 systems only.
|
||||
* See mostconf.h for other systems, e.g., Unix.
|
||||
*/
|
||||
|
||||
#ifndef MOST_CONFIG_H
|
||||
# define MOST_CONFIG_H
|
||||
|
||||
/* define if you have stdlib.h */
|
||||
# define HAVE_STDLIB_H 1
|
||||
|
||||
/* define if you have unistd.h */
|
||||
# define HAVE_UNISTD_H 1
|
||||
|
||||
/* define if you have memory.h */
|
||||
# define HAVE_MEMORY_H 1
|
||||
|
||||
/* define if you have malloc.h */
|
||||
# define HAVE_MALLOC_H 1
|
||||
|
||||
/* define if you have memset */
|
||||
# define HAVE_MEMSET 1
|
||||
|
||||
/* define if you have memcpy */
|
||||
# define HAVE_MEMCPY 1
|
||||
|
||||
/* define if you have this. */
|
||||
# define HAVE_GETCWD 1
|
||||
|
||||
# define HAVE_DIRENT_H 1
|
||||
|
||||
# define MAX_PATHLEN 1024
|
||||
|
||||
#define MOST_INT long
|
||||
#define MOST_UINT unsigned long
|
||||
#define MOST_INT_D_FMT "%ld"
|
||||
|
||||
#endif /* MOST_CONFIG_H */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,88 @@
|
|||
#ifndef _DAVIS_WINDOW_H_
|
||||
# define _DAVIS_WINDOW_H_
|
||||
/*
|
||||
This file is part of MOST.
|
||||
|
||||
Copyright (c) 1991, 1999, 2002, 2005-2018, 2019 John E. Davis
|
||||
|
||||
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 2 of the License, 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.
|
||||
*/
|
||||
# include "buffer.h"
|
||||
|
||||
typedef struct _Most_Window_Type
|
||||
{
|
||||
unsigned long top_offset; /* offset of top line of window from bob */
|
||||
int beg_line; /* line number of top */
|
||||
int curs_line; /* line number of curs pos */
|
||||
int curs_col; /* column number of curs pos */
|
||||
unsigned long curs_offset; /* pos of cursor from bob*/
|
||||
int col; /* column offset */
|
||||
int n_lines; /* number of lines of buffer (mode dependent) */
|
||||
int top; /* screen location of top */
|
||||
int bot; /* screen location of bot */
|
||||
int display; /* value of MOST_S_OPT for selective display */
|
||||
#if 0
|
||||
char *status; /* status line */
|
||||
#endif
|
||||
Most_Buffer_Type *buf; /* buffer structure in window */
|
||||
struct _Most_Window_Type *next; /* next window */
|
||||
struct _Most_Window_Type *prev; /* prev window */
|
||||
int flags; /* Squeeze lines, etc.. */
|
||||
int lock; /* true if locked */
|
||||
int dirty_flag;
|
||||
}
|
||||
Most_Window_Type;
|
||||
|
||||
extern Most_Window_Type *Most_Win;
|
||||
extern Most_Window_Type *Most_Top_Win;
|
||||
extern unsigned long Most_Curs_Offset;
|
||||
extern int Most_Column;
|
||||
extern int Most_Curs_Row;
|
||||
extern int Most_Curs_Col;
|
||||
#define MOST_MINI_BUF_LEN 256
|
||||
extern char Most_Mini_Buf[MOST_MINI_BUF_LEN];
|
||||
extern int Most_Selective_Display;
|
||||
extern int Most_Restore_Width_To;
|
||||
extern int Most_Display_Inited;
|
||||
|
||||
extern int most_split_window (void);
|
||||
extern void most_toggle_lock(void);
|
||||
extern void most_update_window(int); /* moves window to have arg lines on the top */
|
||||
extern void most_update_status(void);
|
||||
extern void most_redraw_window(void); /* redraws window updating the structure */
|
||||
extern void most_window_buffer(void);
|
||||
extern void most_init_display(void);
|
||||
extern void most_reset_display(void);
|
||||
extern void most_other_window(int);
|
||||
extern void most_set_window (Most_Window_Type *);
|
||||
extern void most_update_windows(int);
|
||||
extern void most_message(char *, int);
|
||||
extern void most_put_message(void);
|
||||
extern void most_clear_minibuffer(void);
|
||||
extern void most_check_minibuffer(void);
|
||||
extern void most_free_window_buffer(void);
|
||||
extern void most_select_minibuffer(void);
|
||||
extern void most_exit_minibuffer(void);
|
||||
extern int most_read_from_minibuffer(char *, char *, char *, unsigned int);
|
||||
extern void most_redraw_display(void);
|
||||
extern void most_one_window(void);
|
||||
extern void most_two_windows(void);
|
||||
extern void most_delete_window(void);
|
||||
extern void most_save_win_flags(Most_Window_Type *);
|
||||
extern void most_free_windows (void);
|
||||
extern void most_flush_message (char *);
|
||||
extern void most_point_cursor (void);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue