├── m4 ├── Makefile.am ├── gnulib-cache.m4 └── .gitignore ├── misc ├── syntax.d │ ├── c-comment │ ├── c++-comment │ ├── c-literal │ ├── tex │ ├── nroff │ ├── golang │ ├── yaml │ ├── haskell │ ├── tcl │ ├── texinfo │ ├── cpp │ ├── ocaml │ ├── as │ ├── metafont │ ├── c │ ├── jinja2 │ ├── shell │ ├── pascal │ ├── java │ ├── pod │ ├── python │ ├── make-file │ ├── awk │ ├── logrotate-conf │ ├── eiffel │ ├── snmp-mib │ ├── ada │ ├── sather │ ├── markdown │ ├── javascript │ ├── c++ │ ├── txt2tags │ ├── gema │ ├── verilog │ ├── named-conf │ ├── html │ ├── puppet │ ├── perl │ ├── php │ └── sql ├── le-icon.png ├── mainmenu-ru ├── le.desktop ├── help ├── colors-blue ├── colors-defbg ├── colors-green ├── colors-white ├── colors-black ├── CMakeLists.txt ├── Makefile.am ├── check-mainmenu ├── gnulib.patch ├── ChangeLog └── mainmenu-default ├── src ├── frames.cc ├── options.cc ├── tables.cc ├── .gitignore ├── make-action-name-func.pl ├── wcwidth1.c ├── make-keymap.pl ├── make-action-enum.pl ├── about.h ├── keynames.h ├── cmd.h ├── bm.h ├── mainmenu.cc ├── getch.h ├── colormnu.h ├── rus.h ├── make-mainmenu.pl ├── file.h ├── mouse.h ├── format.h ├── chset.h ├── keymapdf.cc ├── search.h ├── options.h ├── menu.h ├── calc.h ├── clipbrd.h ├── highli.h ├── menu1.h ├── screen.h ├── block.h ├── bm.cc ├── Makefile.am ├── editcalc.cc ├── color.h ├── colormnu.cc ├── history.h ├── window.h ├── CMakeLists.txt ├── keymapfn.cc ├── keymap.h ├── about.cc ├── textpoin.h ├── rus.cc ├── undo.h ├── make-config.cmake ├── inline.h ├── mb.h ├── user.h ├── mouse.cc ├── ext.cc ├── menu.cc ├── cmd.cc └── getch.cc ├── AUTHORS ├── doc ├── Makefile.am ├── CMakeLists.txt ├── ChangeLog └── README.keymap.ru ├── gnulib └── README ├── BUGS ├── THANKS ├── .travis.yml ├── TODO ├── CMakeLists.txt ├── .gitignore ├── README.regex ├── README.md ├── HISTORY ├── README ├── le.spec.in ├── ChangeLog ├── Makefile.am ├── FEATURES ├── bootstrap.conf ├── lib └── .gitignore ├── configure.ac └── autogen.sh /m4/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST=lftp.m4 gnulib-cache.m4 2 | -------------------------------------------------------------------------------- /misc/syntax.d/c-comment: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | c3=/\\*(?:.|\n)*?\\*/ 3 | -------------------------------------------------------------------------------- /src/frames.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lavv17/le/HEAD/src/frames.cc -------------------------------------------------------------------------------- /src/options.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lavv17/le/HEAD/src/options.cc -------------------------------------------------------------------------------- /src/tables.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lavv17/le/HEAD/src/tables.cc -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Alexander V. Lukyanov , 2 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = le.1 README.keymap.ru 2 | man_MANS = le.1 3 | -------------------------------------------------------------------------------- /misc/le-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lavv17/le/HEAD/misc/le-icon.png -------------------------------------------------------------------------------- /misc/mainmenu-ru: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lavv17/le/HEAD/misc/mainmenu-ru -------------------------------------------------------------------------------- /misc/syntax.d/c++-comment: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | c3=//.*$|/\\*(?:.|\n)*?\\*/ 3 | -------------------------------------------------------------------------------- /doc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | install(FILES le.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1) 2 | -------------------------------------------------------------------------------- /gnulib/README: -------------------------------------------------------------------------------- 1 | This directory contains selected files from gnulib for building with cmake. 2 | -------------------------------------------------------------------------------- /misc/syntax.d/c-literal: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | c3="([^"\n\\]|\\\\(.|\n))*"|'([^'\n\\]|\\\\.)*' 3 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | le 2 | action-enum.h 3 | action-name-func.h 4 | keymap-default.h 5 | mainmenu-default.h 6 | -------------------------------------------------------------------------------- /BUGS: -------------------------------------------------------------------------------- 1 | * double-width characters are handled incorrectly in window.cc 2 | (save/restore/shadow), and in chset.cc (maybe ncurses bug). 3 | -------------------------------------------------------------------------------- /misc/syntax.d/tex: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | # Tex mode, by Serge Vakulenko 3 | c3=%.*$ 4 | c1=\\\\[@A-Za-z]* 5 | c2={|}|\[|\] 6 | -------------------------------------------------------------------------------- /misc/le.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=1.0 3 | Name=le 4 | Icon=le-icon 5 | Type=Application 6 | Terminal=true 7 | Exec=le 8 | Categories=Utility;TextEditor; 9 | -------------------------------------------------------------------------------- /misc/help: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | case "$EXT" in 4 | .pl|.pm|.sub) 5 | case "$WORD" in 6 | [A-Z]*) perldoc "$WORD";; 7 | *) perldoc -f "$WORD";; 8 | esac 9 | ;; 10 | *) 11 | man "$WORD" 12 | ;; 13 | esac 14 | -------------------------------------------------------------------------------- /src/make-action-name-func.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | 5 | while(<>) { 6 | next if /^#/; 7 | chomp; 8 | my ($action,$func)=split; 9 | print qq{\t{"$action", $func},\n}; 10 | } 11 | -------------------------------------------------------------------------------- /misc/syntax.d/nroff: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | c3=^\.\\\\".*$ 3 | c2=^\.[[:alpha:]]* 4 | c1,1=\\\\fB((\\\\[^f]|[^\\])*[^\\]?)(\\\\f|$) 5 | c3,1=\\\\fI((\\\\[^f]|[^\\])*[^\\]?)(\\\\f|$) 6 | c1,1=^\.B[IR]? (.*)$ 7 | c3,1=^\.I (.*)$ 8 | -------------------------------------------------------------------------------- /misc/syntax.d/golang: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | i=c++-comment 3 | i=c-literal 4 | c2=\\[|\\]|\\(|\\)|{|}|, 5 | ci1,2=([^[:alnum:]_$]|^)(if|else|for|switch|case|nil|package|import|type|const|struct|func|var|return|break)([^[:alnum:]_]|$) 6 | -------------------------------------------------------------------------------- /misc/syntax.d/yaml: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | c2=^---$ 3 | c2=^\.\.\.$ 4 | c2,1=^[[:space:]]*(-) 5 | c2,1=^[^#'"]+?(:) 6 | c2,1=^[^#'"]+?:?[[:space:]]([|>]) 7 | c2=^\?[[:space:]] 8 | c3=^[[:space:]]*#.+ 9 | c3="[^"]*?" 10 | c3='[^']*?' 11 | -------------------------------------------------------------------------------- /THANKS: -------------------------------------------------------------------------------- 1 | Abel Morabito 2 | Dmitry S. Luhtionov 3 | Igor Zhbanov 4 | Raphael Geissert 5 | Serge Vakulenko 6 | Vladislav V. Zhuk 7 | -------------------------------------------------------------------------------- /doc/ChangeLog: -------------------------------------------------------------------------------- 1 | 2008-08-18 Raphael Geissert 2 | 3 | * le.1: fixed minor typos. 4 | 5 | 2008-05-08 Raphael Geissert 6 | 7 | * le.1: correctly escape -, indicating that it must be treated as a minus 8 | sign and not as a hyphen. 9 | -------------------------------------------------------------------------------- /misc/syntax.d/haskell: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | c3=^[[:space:]]*--.*$ 3 | # from c-literal: foo' is foo prime, not quoted text 4 | c3="([^"\n\\]|\\\\(.|\n))*" 5 | ci1,2=([^[:alnum:]_$]|^)(import|instance|where|do|let|return)([^[:alnum:]_]|$) 6 | c2=\\[|\\]|::|=>|=|->|<-|\+\+|<<|>>|<<=|>>= 7 | -------------------------------------------------------------------------------- /misc/syntax.d/tcl: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | # Tcl mode, by Serge Vakulenko 3 | c3=#.*$ 4 | i=c-literal 5 | c1,2=([^[:alnum:]/_]|^)(break|case|continue|exit|for|foreach|if|return\ 6 | |switch|while|set|eval|proc|global|else|elseif|default\ 7 | )([^[:alnum:]/_]|$) 8 | c2={|}|\[|\]|\$|;|\(|\)|\| 9 | -------------------------------------------------------------------------------- /src/wcwidth1.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #if REPLACE_WCWIDTH 5 | /* substitute system function (mostly for ncurses/xterm combination) */ 6 | #undef wcwidth 7 | extern int mk_wcwidth(wchar_t ucs); 8 | int wcwidth(wchar_t ch) 9 | { 10 | return mk_wcwidth(ch); 11 | } 12 | #endif 13 | -------------------------------------------------------------------------------- /misc/syntax.d/texinfo: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | # Texinfo mode, by Serge Vakulenko 3 | #c3="([^"\n\\]|\\\\(.|\n))*"|'([^'\n\\]|\\\\.)*' 4 | #c3=^[ \t]*#([^\\\n]|\\\\(.|\n))*$ 5 | c3=^[ \t]*@c\W.*$ 6 | #c3=/\\*(?:.|\n)*?\\*/ 7 | c1,2=([^[:alnum:]_@]|^)(@[[:alnum:]]*\ 8 | )([^[:alnum:]_]|$) 9 | c2={|} 10 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c++ 2 | sudo: false 3 | 4 | compiler: 5 | - clang 6 | - gcc 7 | 8 | addons: 9 | apt: 10 | packages: 11 | - libncurses5-dev 12 | - build-essential 13 | - automake 14 | - autoconf 15 | 16 | script: 17 | - ./bootstrap 18 | - ./configure 19 | - make distcheck 20 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | 1. Make more classes (Text, multibuffer support) 2 | 3 | 3. RCS/CVS interaction 4 | 5 | 4. macros 6 | 7 | 5. ispell interaction 8 | 9 | 6. Get rid of fixed size arrays. 10 | 11 | 8. mail formatting: http://www.newsreaders.com/gnksa/wrapping.tar.gz 12 | 13 | 9. periodic syntax check using an external program. 14 | -------------------------------------------------------------------------------- /misc/syntax.d/cpp: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | c4,1=^[ \t]*((?:#|%:)[ \t]*(?:assert|define|elif|else|endif|error|ident|if|ifdef\ 3 | |ifndef|import|include(?:_next)?|line|pragma(?:[ \t]+once|STDC|pack\b)?\ 4 | |sccs|unassert|undef)\b) 5 | c4,1=^[ \t]*((?:#|%:)) 6 | c3,1=^[ \t]*(?:#|%:)[ \t]*include(?:_next)?[ \t]*(<[^>\n]*>|"[^"\n]*") 7 | -------------------------------------------------------------------------------- /misc/syntax.d/ocaml: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | c3=\(\\*(?:.|\n)*?\\*\) 3 | i=c-literal 4 | ci1,2=([^[:alnum:]_$]|^)(if|then|begin|end|else|in|with|let|\ 5 | open|try|raise|true|false)([^[:alnum:]_]|$) 6 | c2=\\[|\\]|<<|<|>>|>|;|\(|\)|=|!=|&&|\|\||!|\.\.|&|^|->|:: 7 | c2,2=([ \t)]|^)(and|or|xor|eq|ne|cmp|lt|gt|le|ge)([ \t(]|$) 8 | c2,2=([ \t(]|^)(not)([ \t(]|$) 9 | -------------------------------------------------------------------------------- /misc/syntax.d/as: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | # Assembler mode, by Serge Vakulenko 3 | c3=@[^\n]*\n 4 | c3=;[^\n]*\n 5 | c3="([^"\\]|\\\\(.|\n))*" 6 | c3,1=^[ \t]*(#[ \t]*(include[ \t]*<[^>\n]*>|[a-z]*)) 7 | c1,2=([^[:alnum:]_]|^)(\.section|\.func|\.globl|\.global|\.code|\.comm|\.weak\ 8 | |\.endfunc\ 9 | )([^[:alnum:]_]|$) 10 | c2==|,|\(|\)|#|\[|\]|: 11 | -------------------------------------------------------------------------------- /misc/syntax.d/metafont: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | # Metafont mode, by Serge Vakulenko 3 | c3=%.*$ 4 | c3,1=[^\\]("([^"\\]|\\\\(.|\n))*") 5 | c1,2=([^[:alnum:]/_]|^)(if|else|elif|fi|lft|rt|top|bot|iff|not\ 6 | |def|vardef|enddef|suffix|whatever|expr\ 7 | |fill|draw|filldraw|pickup|let|beginchar|endchar\ 8 | )([^[:alnum:]/_]|$) 9 | c2=:=|\(|\)|#|=|;|\[|]|---|--|\.\.\.|\.\.|{|}|, 10 | -------------------------------------------------------------------------------- /misc/syntax.d/c: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | # C language mode (lav) 3 | i=c++-comment 4 | i=c-comment 5 | i=cpp 6 | i=c-literal 7 | c1,2=([^[:alnum:]_]|^)(asm|else|if|switch|case|while|for|goto|break\ 8 | |continue|char|short|int|long|unsigned|signed|auto\ 9 | |const|default|do|double|enum|extern|float|register\ 10 | |return|sizeof|static|struct|typedef|union|void|volatile\ 11 | )([^[:alnum:]_]|$) 12 | c2=\\[|\\]|\\(|\\)|{|}|, 13 | -------------------------------------------------------------------------------- /misc/syntax.d/jinja2: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | # Jinja2 mode 3 | #c3=#.*$ 4 | #c3="([^"\\]|\\\\(.|\n))*"|'([^'\\]|\\\\(.|\n))*' 5 | c1,2=({%-?[ ]+)(for|endfor|if not|if|elif|else|endif|raw|block|endblock|extends\ 6 | |macro|endmacro|call|endcall|filter|endfilter|set|endset\ 7 | |include|from|trans|endtrans|pluralize|do|with|endwith\ 8 | |autoescape|endautoescape|not\ 9 | )([ ]+) 10 | c1,2=({[{%]-?[ ]+).+(\||join).+(-?[%+]}) 11 | c2={{|}}|{%-?|-?%}|{#|#} 12 | -------------------------------------------------------------------------------- /src/make-keymap.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | 5 | while(<>) { 6 | chomp; 7 | my ($name,$code)=split; 8 | ($name,my $arg)=($name=~/^([^(]*)(?:\((.*)\))?$/); 9 | my $A=uc($name); 10 | $A=~s/-/_/g; 11 | $arg//=''; 12 | if($arg ne '') { 13 | $arg=~s{([^\\]|^)_}{$1 }g; 14 | $arg=~s{\\_}{_}g; 15 | $arg=qq{,(char*)"$arg"}; 16 | } 17 | $code=~s{\\([\$|])}{\\\\$1}; 18 | print qq{\t{A_$A,(char*)"$code"$arg},\n}; 19 | } 20 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | 3 | execute_process( 4 | COMMAND gnulib/git-version-gen .tarball-version 5 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 6 | OUTPUT_VARIABLE git_version 7 | ) 8 | string(REGEX REPLACE "-.*$" "" version ${git_version}) 9 | 10 | project(le VERSION ${version}) 11 | 12 | if(NOT CMAKE_BUILD_TYPE) 13 | set(CMAKE_BUILD_TYPE "Release") 14 | endif() 15 | 16 | add_subdirectory(doc) 17 | add_subdirectory(src) 18 | add_subdirectory(misc) 19 | -------------------------------------------------------------------------------- /misc/syntax.d/shell: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | # Shell mode, by Serge Vakulenko 3 | c3,2=([^$]|^)(#.*)$ 4 | c3,1=[^\\]("([^"\\]|\\\\(.|\n))*"|'([^'\\]|\\\\(.|\n))*') 5 | c1,2=([^[:alnum:]/_]|^)(if|then|else|elif|fi|while|do|done|for|break|continue\ 6 | |case|in|esac|local|return|exit|alias|bg|cd|eval|exec|export|fc|fg|getopts|hash\ 7 | |jobid|jobs|pwd|read|readonly|set|setvar|shift|trap|ulimit|umask|unalias|unset\ 8 | |wait)([^[:alnum:]/_]|$) 9 | c2={|}|<<|<|>>|>|;;|;|\(|\)|\| 10 | -------------------------------------------------------------------------------- /misc/syntax.d/pascal: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | # Pascal mode, by Raphael Geissert 3 | c3={[^}]*?} 4 | c3='[^'\n]*?' 5 | ci1,2=([^[:alnum:]_]|^)(\ 6 | begin|end|program\ 7 | |if|in|else|do|while|then|for|(down)?to|until|repeat|case|with|of\ 8 | |and|or|not\ 9 | |var|type|real|integer|char|boolean|string|nil|array|const|file|packed|byte\ 10 | |procedure|record|set\ 11 | |new|function|goto|label|uses\ 12 | )([^[:alnum:]_]|$) 13 | ci2,1=^end(\.) 14 | ci2=<|>|;|\(|\)|\[|\]|:|=|[+*/-]|div|mod|\.\. 15 | -------------------------------------------------------------------------------- /misc/syntax.d/java: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | # java mode (bird@yars.free.net) 3 | i=c-literal 4 | i=c++-comment 5 | c1,2=([^[:alnum:]_]|^)(abstract|default|if|private|throw|boolean|do|implements\ 6 | |protected|throws|break|double|import|public|transient|byte|else|instanceof\ 7 | |return|try|case|extends|int|short|void|catch|final|interface|static|volatile\ 8 | |char|finally|long|super|while|class|float|native|switch|const|for|new\ 9 | |synchronized|continue|goto|package|this|null|true|false\ 10 | )([^[:alnum:]_]|$) 11 | c2=\\[|\\]|\\(|\\)|{|}|, 12 | -------------------------------------------------------------------------------- /misc/syntax.d/pod: -------------------------------------------------------------------------------- 1 | # perl POD -*- LE-syntax -*- 2 | c2=^=(pod|head[1234]|over|item|back|begin|end|for|encoding|cut) 3 | si(html)3=^=begin html\n\n((?:.|\n)*?)\n\n=end html$|^=for html ((?:.|\n)*?)\n\n 4 | si(nroff)6=^=begin (roff|man)\n\n((?:.|\n)*?)\n\n=end \1$|^=for (?:roff|man) ((?:.|\n)*?)\n\n 5 | si(tex)6=^=begin (tex|latex)\n\n((?:.|\n)*?)\n\n=end \1$|^=for (?:tex|latex) ((?:.|\n)*?)\n\n 6 | c1,1=^=head[1234] (.*) 7 | c1,1=B<([^>]*)> 8 | c3,1=I<([^>]*)> 9 | si(perl)7=C<<<((?:.|\n)*?)>>>|C<<((?:.|\n)*?)>>|C<([^>]*)> 10 | c4,1=L<([^>]*)> 11 | -------------------------------------------------------------------------------- /misc/syntax.d/python: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | # Python mode, by Serge Vakulenko 3 | c3=#.*$ 4 | c3='''(?:.|\n)*?'''|"""(?:.|\n)*?""" 5 | c3="([^"\\]|\\\\(.|\n))*"|'([^'\\]|\\\\(.|\n))*' 6 | c1,2=([^[:alnum:]_]|^)(False|None|True|and|as|assert|async|await|break|class\ 7 | |continue|def|del|elif|else|except|finally|for|from|global|if|import|in|is\ 8 | |lambda|nonlocal|not|or|pass|raise|return|try|while|with|yield|abs|divmod|pow\ 9 | |bool|bytes|complex|dict|float|frozenset|int|list|range|set|str|tuple|type\ 10 | )([^[:alnum:]_]|$) 11 | c2=: 12 | -------------------------------------------------------------------------------- /misc/syntax.d/make-file: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | # makefile mode, by Raphael Geissert 3 | s(shell)1=^\t[@-]*(.*(?:\\\\\n(?:.*\\\\\n)*.*)?) 4 | c3=^[ \t]*#.*$ 5 | c3="|' 6 | c1,2=([^[:alnum:]_-]|^)(findstring|ifn?eq|endif|define|shell\ 7 | |else|while|if|fi|then|do|done|for|case|esac|export|MAKE|ifn?def\ 8 | |(pat)?subst|filter(-out)?|foreach|words|call|wildcard\ 9 | )([^[:alnum:]_-]|$) 10 | c1,2=([^[:alnum:]_]|^)(include)([ \t].+$) 11 | c2=:|\$|[+-:?]?=|>|<|`|\||\[|\]|\(|\)|{|}|&|\$[@*] 12 | ci1,1=^([ [:alnum:]/%()$,_.-]+):[^=] 13 | c4,1=^\t([@-]+) 14 | -------------------------------------------------------------------------------- /src/make-action-enum.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | 5 | my $base=1024; 6 | 7 | print <) { 13 | next if /^#/; 14 | chomp; 15 | my ($action,$func)=split; 16 | $action=uc($action); 17 | $action=~s/-/_/g; 18 | print "\tA_$action=$n,\n"; 19 | ++$n; 20 | } 21 | --$n; 22 | print "\tA__LAST=$n,\n"; 23 | 24 | $n=2048; # special action codes 25 | print "\tMOUSE_ACTION=$n,\n";$n++; 26 | print "\tWINDOW_RESIZE=$n,\n";$n++; 27 | print "\tNO_ACTION=$n,\n"; 28 | 29 | print "};\n"; 30 | -------------------------------------------------------------------------------- /misc/syntax.d/awk: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | # GNU Awk mode, by Abel Morabito 3 | c3,1=#.*$ 4 | i=c-literal 5 | c1,2=([^[:alnum:]/_]|^)(if|while|do|for|in|break|continue|switch\ 6 | |case|default|asort|asorti|index|length|match|split|sprintf\ 7 | |strtonum|sub|gsub|gensub|substr|tolower|toupper|return|exit|next\ 8 | |getline|print|printf|nextfile\ 9 | |ARGV|ARGC|CONVFMT|ENVIRON|FILENAME|FNR|FS|NF|NR|OFMT|OFS|ORS\ 10 | |RLENGTH|RSTART|RS|SUBSEP|ARGIND|BINMODE|ERRNO|FIELDWIDTHS|IGNORECASE\ 11 | |LINT|PROCINFO|RT|TEXTDOMAIN|BEGIN|END\ 12 | )([^[:alnum:]/_]|$) 13 | c2=\[|\]|\$|\^|\+|\/|=|~|!|{|}|<|>|;|\(|\)|\| 14 | -------------------------------------------------------------------------------- /misc/syntax.d/logrotate-conf: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | c3=^[ \t]*#.* 3 | s(shell)1=^[ \t]*(?:(?:pre|post)rotate|(?:first|last)action)[ \t]*\n((?:.|\n)*?)\n[\t ]*endscript[ \t\n] 4 | c1,1=^[ \t]*((?:no)?compress|(?:un)?compresscmd|compressext|compressoptions\ 5 | |(?:no)?copy(?:truncate)?|(?:no)?create|daily|(?:no)?dateext|(?:no)?delaycompress\ 6 | |extension|(?:not)?ifempty|include|(?:no)?mail(?:first|last)?|maxage|minsize\ 7 | |(?:no)?missingok|monthly|(?:no)?olddir|(?:no)?shred|(?:pre|post)rotate|endscript\ 8 | |(?:first|last)action|rotate|size|sharedscripts|shredcycles|start|tabooext\ 9 | |weekly|yearly\ 10 | )(?:[^[:alnum:]_]|$) 11 | c3,1=^[ \t]*(.*)[ \t]*{ 12 | c2={|} 13 | -------------------------------------------------------------------------------- /misc/syntax.d/eiffel: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | # Eiffel mode, by Serge Vakulenko 3 | c3=--[^\n]*\n 4 | c3="([^"\\]|\\\\(.|\n))*" 5 | c1,2=([^[:alnum:]_]|^)(alias|all|and|as|check|class|creation|debug\ 6 | |deferred|do|else|elseif|end|ensure|expanded|export|external|false\ 7 | |feature|from|frozen|if|implies|indexing|infix|inherit|inspect|invariant\ 8 | |is|like|local|loop|not|obsolete|old|once|or|prefix|redefine|rename\ 9 | |require|rescue|retry|select|separate|strip|then|true|undefine|unique\ 10 | |until|variant|when|xor|Current|Result|True|False|Void\ 11 | |ARRAY|BIT|BOOLEAN|CHARACTER|DOUBLE|INTEGER|NONE|POINTER|REAL|STRING\ 12 | )([^[:alnum:]_]|$) 13 | c2=<<|>> 14 | -------------------------------------------------------------------------------- /misc/syntax.d/snmp-mib: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | # SNMP MIB mode, by Serge Vakulenko 3 | c3=--.*$|/\\*(?:.|\n)*?\\*/ 4 | i=c-literal 5 | c1,2=([^[:alnum:]_]|^)(\ 6 | BEGIN|END|DEFINITIONS|OBJECT-TYPE|OBJECT|OBJECTS|IDENTIFIER|FROM|SIZE|INDEX|\ 7 | IMPORTS|SYNTAX|ACCESS|STATUS|DESCRIPTION|INTEGER|SEQUENCE|OF|OCTET|STRING|\ 8 | TRAP-TYPE|ENTERPRISE|VARIABLES|NOTIFICATION-TYPE|MODULE-IDENTITY|\ 9 | OBJECT-IDENTITY|MAX-ACCESS|OBJECT-GROUP|NOTIFICATION-GROUP|MODULE-COMPLIANCE|\ 10 | TEXTUAL-CONVENTION|REVISION|LAST-UPDATED|ORGANIZATION|CONTACT-INFO|\ 11 | DISPLAY-HINT|NOTIFICATIONS|MODULE|MANDATORY-GROUPS|GROUP\ 12 | )([^[:alnum:]_]|$) 13 | c2=\||\)|\(|::=|=|\|\||{|}|; 14 | -------------------------------------------------------------------------------- /misc/syntax.d/ada: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | # Ada mode, by Serge Vakulenko 3 | c3=--[^\n]*\n 4 | c3="([^"\\]|\\\\(.|\n))*" 5 | c1,2=([^[:alnum:]_]|^)(abort|else|new|return|abs|elsif|not|reverse|abstract\ 6 | |end|null|accept|entry|select|access|exception|separate|aliased|exit|of\ 7 | |subtype|all|or|and|for|others|tagged|array|function|out|task|at|terminate\ 8 | |generic|package|then|begin|goto|pragma|type|body|private|if|procedure\ 9 | |case|in|protected|until|constant|is|use|raise|declare|range|when|delay\ 10 | |limited|record|while|delta|loop|rem|with|digits|renames|do|mod|requeue|xor\ 11 | )([^[:alnum:]_]|$) 12 | c2=<<|>>|:=|\\[|\\]|\\(|\\)|{|}|,|:|#|'Access|'Address|'Size 13 | -------------------------------------------------------------------------------- /misc/syntax.d/sather: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | # Sather mode, by Serge Vakulenko 3 | c3=--[^\n]*$ 4 | c3="([^"\\]|\\\\(.|\n))*" 5 | c1,2=([^[:alnum:]_]|^)(abstract|and|any|assert|attr|bind|break!|builtin|case\ 6 | |class|clusters!|cohort|const|else|elsif|end|exception|external|false|far\ 7 | |fork|guard|if|immutable|inout|include|initial|is|ITER|lock|loop|near|new\ 8 | |once|or|out|par|parloop|post|pre|private|protect|quit|raise|readonly|result\ 9 | |return|ROUT|SAME|self|shared|sync|then|true|typecase|unlock|until|void|when\ 10 | |while!|with|yuild|ARRAY|BOOL|CHAR|FLTD|INT|INTI|FLT|FLTI|STR|\\$OB|AREF|AVAL\ 11 | |TUP|SYS|\\$NIL|\\$FINALIZE\ 12 | )([^[:alnum:]_]|$) 13 | c2=\||#|::=|:=|:: 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | 6 | # Compiled Dynamic libraries 7 | *.so 8 | 9 | # Compiled Static libraries 10 | *.lai 11 | *.la 12 | *.a 13 | 14 | libtool 15 | .deps 16 | 17 | # backup files 18 | *~ 19 | 20 | # http://www.gnu.org/software/automake 21 | Makefile.in 22 | 23 | # http://www.gnu.org/software/autoconf 24 | Makefile 25 | /autom4te.cache 26 | /aclocal.m4 27 | /compile 28 | /configure 29 | /config.cache 30 | /config.log 31 | /config.status 32 | /le.spec 33 | 34 | # LE editor 35 | .le.ini 36 | 37 | # gettext 38 | /ABOUT-NLS 39 | 40 | /build-aux 41 | /INSTALL 42 | /.version 43 | /build 44 | 45 | # generated distributions 46 | /le-*.tar.gz 47 | /*.AppImage 48 | -------------------------------------------------------------------------------- /misc/syntax.d/markdown: -------------------------------------------------------------------------------- 1 | # Markdown -*- LE-syntax -*- 2 | c1,1=^(.*)\n(?:=\{2,\}|-\{2,\}) 3 | c1,1=^[[:space:]]*([-*+])[^-*+] 4 | c1,1=^#+ (.*) 5 | c1,1=\*\*([^[:space:]].*?)\* 6 | c3,1=\*([^*[:space:]].*?)\* 7 | c1,2=__([^[:space:]].*?)__ 8 | c3,2=_([^_[:space:]].*?)_ 9 | c4,1=\[(.*?)\] 10 | c2,1=\[(?:.*?)\]\((.*?)\) 11 | si(html)=^<([[:alpha:]]+)(?: [^>]*)?>(?:.|\n)* 12 | si(c++)1=```(?:c\+\+|cpp)\n((?:\n|.)*?)\n``` 13 | si(c)1=```(?:c)\n((?:\n|.)*?)\n``` 14 | si(python)1=```(?:py|python)\n((?:\n|.)*?)\n``` 15 | si(perl)1=```(?:pl|perl)\n((?:\n|.)*?)\n``` 16 | si(js)1=```(?:js|javascript)\n((?:\n|.)*?)\n``` 17 | si(java)1=```(?:java)\n((?:\n|.)*?)\n``` 18 | si(shell)1=```(?:sh|bash)\n((?:\n|.)*?)\n``` 19 | c2=`.*?` 20 | -------------------------------------------------------------------------------- /README.regex: -------------------------------------------------------------------------------- 1 | A note about regex in LE editor 2 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3 | 4 | I had a bad luck finding an efficient and bug-free regex library 5 | implementing re_search_2 function. Fortunately, GNU Emacs contained such a 6 | function, which I borrowed. 7 | 8 | I needed re_search_2 function because LE stores the text in the memory as 9 | two part string with a gap between the parts. The efficiency was needed 10 | mostly because regex was used for dynamic syntax highlighting. 11 | 12 | New version of regex implements non-greedy modifiers which were successfully 13 | used for C-like comment matching. Without such modifier it was impossible to 14 | create a perfect pattern for C comments. 15 | 16 | -- 17 | Alexander. 18 | -------------------------------------------------------------------------------- /misc/syntax.d/javascript: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | i=c-literal 3 | i=c++-comment 4 | c1,1=(?:[^[:alnum:]_]|^)(\ 5 | abstract|alert|arguments|Array|boolean|Boolean|break|byte|case|catch|char|\ 6 | class|confirm|const|continue|Date|debugger|default|delete|do|document|double|\ 7 | else|enum|escape|event|export|extends|false|final|finally|float|for|Function|\ 8 | goto|if|implements|import|in|instanceof|int|interface|location|long|native|\ 9 | new|null|Number|Object|package|parent|private|prompt|protected|public|RegExp|\ 10 | return|self|short|static|status|String|super|switch|synchronized|this|throw|\ 11 | throws|top|transient|true|try|typeof|undefined|unescape|var|volatile|while|\ 12 | window|with)(?:[^[:alnum:]_]|$) 13 | c4,1=(?:[^[:alnum:]_]|^)(function)(?:[^[:alnum:]_]|$) 14 | c2=\\[|\\]|\\(|\\)|{|}|, 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | LE text editor 2 | === 3 | 4 | LE has many block operations with stream and rectangular blocks, can edit 5 | both unix and dos style files (LF/CRLF), is binary clean, has hex mode, can 6 | edit text with multibyte character encoding, has full undo/redo, can edit 7 | files and mmap'able devices in mmap shared mode (only replace), has tunable 8 | syntax highlighting, tunable color scheme (can use default colors), tunable 9 | key map, tunable menu. It is slightly similar to Norton Editor for DOS, but 10 | has more features. 11 | 12 | You can use either auto-tools or cmake to build from sources. 13 | 14 | * Build with cmake: 15 | ```shell 16 | mkdir build 17 | cd build 18 | cmake .. 19 | make 20 | make install 21 | ``` 22 | * Build with auto-tools: 23 | ```shell 24 | ./autogen.sh 25 | mkdir build 26 | cd build 27 | ../configure 28 | make 29 | make install 30 | ``` 31 | -------------------------------------------------------------------------------- /src/about.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-1997 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | void ShowAbout(); 20 | void HideAbout(); 21 | 22 | void PrintVersion(); 23 | -------------------------------------------------------------------------------- /misc/syntax.d/c++: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | # C++ mode (lav) 3 | i=c++-comment 4 | i=cpp 5 | c3=R"([^[:space:]()\\]\{0,16\})\((?:.|\n)*?\)\1" 6 | i=c-literal 7 | c1,1=(?:[^[:alnum:]_]|^)(asm|else|if|switch|case|while|for|goto|break\ 8 | |continue|char|short|int|long|unsigned|signed|auto\ 9 | |const|default|do|double|enum|extern|float|register\ 10 | |return|sizeof|static|struct|typedef|union|void|volatile\ 11 | |try|catch|throw|class|new|delete|private|public|protected|this|virtual\ 12 | |inline|bool|true|false|operator|overload|template|friend|namespace|using\ 13 | |typeid|dynamic_cast|const_cast|static_cast|reinterpret_cast|typename|explicit\ 14 | |nullptr|constexpr|decltype|static_assert|noexcept|alignas|alignof|override|final\ 15 | |mutable|thread_local|char(?:8|16|32)_t|wchar_t|export\ 16 | |bitand|bitor|compl|(?:and|not|or|xor)(?:_eq)?\ 17 | |concept|requires\ 18 | )(?:[^[:alnum:]_]|$) 19 | c2=\\[|\\]|\\(|\\)|{|}|,|<%|%>|<:|:>|\?\?[<>()=/'!-] 20 | -------------------------------------------------------------------------------- /src/keynames.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-1997 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef KEYNAMES_H 20 | #define KEYNAMES_H 21 | 22 | int FindKeyCode(const char *name); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /misc/syntax.d/txt2tags: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | ### Txt2tags by Stefano D'Archino 3 | # Comments 4 | c3=^(%%%)\n(.|\n)*(^(%%%)$) 5 | c3=^%.*$ 6 | # Blocks 7 | c2=^(""")\n(.|\n)*(^(""")$) 8 | c2=^(```)\n(.|\n)*(^(```)$) 9 | c2=^(```) .*$ 10 | # Special characters and beautifiers 11 | c2=(@|- |+ |^: |\|\||\| | \|) 12 | c2=(\/\/.*\/\/) 13 | c2=(\*\*.*\*\*) 14 | c2=(__.*__) 15 | c2=(``.*``) 16 | c2=(^--------------------.*$) 17 | c2=(^====================.*$) 18 | # Link 19 | c2=(\[[^ \[].*[^ ]\]) 20 | c2=(\[\[[^ ].*[^ ]\] [A-Za-z0-9._-]*\]) 21 | c2=([A-Za-z0-9._-]+\@[A-Za-z0-9._-]+\.[A-Za-z0-9._-]+) 22 | # Title 23 | c1=(^=[^=].*[^=]=[\n|\[]) 24 | c1=(^==[^=].*[^=]==[\n|\[]) 25 | c1=(^===[^=].*[^=]===) 26 | c1=(^====[^=].*[^=]====) 27 | c1=(^=====[^=].*[^=]=====) 28 | c1=(^\+[^\+].*[^\+]\+[\n|\[]) 29 | c1=(^\+\+[^\+].*[^\+]\+\+[\n|\[]) 30 | c1=(^\+\+\+[^\+].*[^\+]\+\+\+) 31 | c1=(^\+\+\+\+[^\+].*[^\+]\+\+\+\+) 32 | c1=(^\+\+\+\+\+[^\+].*[^\+]\+\+\+\+\+) 33 | ######### 34 | -------------------------------------------------------------------------------- /src/cmd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-2015 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | void cmd(const char *cmd,bool autosave,bool pauseafter); 19 | void DoMake(); 20 | void DoCompile(); 21 | void DoRun(); 22 | void DoShell(); 23 | -------------------------------------------------------------------------------- /src/bm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | /* $Id: bm.h,v 1.1 2001/05/14 13:48:37 lav Exp $ */ 20 | 21 | void SetBookmark(int n); 22 | void ClearBookmark(int n); 23 | void GoBookmark(int n); 24 | void ResetBookmarks(); 25 | -------------------------------------------------------------------------------- /src/mainmenu.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-2015 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include 20 | #include "edit.h" 21 | #include "menu1.h" 22 | #include "keymap.h" 23 | 24 | Menu1 MainMenu[]={ 25 | #include "mainmenu-default.h" 26 | }; 27 | -------------------------------------------------------------------------------- /misc/syntax.d/gema: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | # GEMA mode, by Abel Morabito 3 | c3=(^!.*$)|([^\\]!.*$) 4 | c2,2=([^\\])(\*|?|#|=|\$|(\\\)|\^|;|@|:|<|>|/|{|}) 5 | c1,2=(@)(abort|add|and|append|bind|center|char-int|close|cmpi|cmpn|cmps\ 6 | |column|date|datime|decr|define|div|downcase|end|err|exit-status\ 7 | |expand-wild|fail|file|file-time|fill-center|fill-left|fill-right\ 8 | |getenv|get-switch|incr|inpath|int-char|left|length|line|makepath\ 9 | |mergepath|mod|mul|name|not|or|out|out-column|outpath|pop|probe\ 10 | |push|quote|radix|read|relative-path|repeat|reset-syntax\ 11 | |reverse|right|set|set-locale|set-parm|set-switch|set-syntax|set-wrap\ 12 | |shell|show-help|special-character|sub|subst|substring|tab|terminate\ 13 | |time|unbind|undefine|upcase|var|version|wrap|write)($|{|;| ) 14 | c1,2=(\\\)(a|b|d|e|f|n|r|s|t|v|A|B|C|E|G|I|J|L|N|P|S|W|X|Z) 15 | c1,2=(\\\)((x[[:xdigit:]]+)|([0-7]+)|(c[[:alpha:]])) 16 | c1,2=(\$)([0-9]+|[[:alpha:]]) 17 | ci1,2=(<)((-?)(A|C|D|F|G|I|J|K|L|N|O|P|S|T|U|W|X|Y)([0-9]*))(>) 18 | -------------------------------------------------------------------------------- /HISTORY: -------------------------------------------------------------------------------- 1 | I started this project as a laboratory work being first year student of 2 | Yaroslavl State University in 1993. That time I worked on a BESTA machine 3 | under some kind of Unix. It had 8M of memory and 14 terminals plugged in. 4 | (That was fun :) And it had no good editor, except vi... Honestly, that 5 | time I did not know that emacs or internet exist :) 6 | 7 | The first version of the editor could do not too much -- load a file, 8 | browse, insert, delete, save -- that's all. Since that, the editor was 9 | almost completely rewritten in C++. Some old code is still there, since I 10 | don't know what to do with it. Now it become quite a powerful editor and I 11 | decided at last to publish it under GPL and did it in early 1997. (See 12 | FEATURES for brief description of capabilities) 13 | 14 | I understand that there are many other text editors out there, but I 15 | used to my own editor and some my friends told me that the editor is 16 | actually better than many others. 17 | 18 | Alexander V. Lukyanov 19 | -------------------------------------------------------------------------------- /misc/syntax.d/verilog: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | # Verilog mode, by Serge Vakulenko 3 | c3="([^"\n\\]|\\\\(.|\n))*" 4 | c3,1=`[ \t]*(include[ \t]*"[^"\n]*"|define*) 5 | i=c++-comment 6 | c1,2=([^[:alnum:]_]|^)(always|and|assign|attribute|begin|buf|bufif0|bufif1\ 7 | |case|casex|casez|cmos|deassign|default|defparam|disable|edge|else|end\ 8 | |endattribute|endcase|endfunction|endmodule|endprimitive|endspecify|endtable\ 9 | |endtask|event|for|force|forever|fork|function|highz0|highz1|if|ifnone\ 10 | |initial|inout|input|integer|join|medium|module|large|macromodule|nand\ 11 | |negedge|nmos|nor|not|notif0|notif1|or|output|parameter|pmos|posedge\ 12 | |primitive|pull0|pull1|pulldown|pullup|rcmos|real|realtime|reg|release\ 13 | |repeat|rnmos|rpmos|rtran|rtranif0|rtranif1|scalared|signed|small|specify\ 14 | |specparam|strength|strong0|strong1|supply0|supply1|table|task|time|tran\ 15 | |tranif0|tranif1|tri|tri0|tri1|triand|trior|trireg|unsigned|vectored|wait\ 16 | |wand|weak0|weak1|while|wire|wor|xnor|xor\ 17 | )([^[:alnum:]_]|$) 18 | c2=\\[|\\]|\\(|\\)|{|}|,|@|<= 19 | -------------------------------------------------------------------------------- /src/getch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-1997 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GETCH_H 20 | #define GETCH_H 21 | 22 | int GetRawKey(); 23 | int WaitForKey(int delay=-1); /* ERR - no key */ 24 | int GetKey(int delay=-1); 25 | int CheckPending(); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /misc/colors-blue: -------------------------------------------------------------------------------- 1 | default_colors=1 2 | status_line=fg:black,bg:cyan 3 | status_line_bw=rev,dim 4 | normal_text=fg:white,bg:blue 5 | normal_text_bw=normal 6 | block_text=fg:black,bg:white 7 | block_text_bw=rev 8 | error_win=bold,fg:white,bg:red 9 | error_win_bw=rev,bold 10 | verify_win=fg:black,bg:cyan 11 | verify_win_bw=rev 12 | curr_button=bold,fg:white,bg:black 13 | curr_button_bw=normal 14 | help_win=fg:black,bg:cyan 15 | help_win_bw=rev 16 | dialogue_win=fg:black,bg:white 17 | dialogue_win_bw=rev 18 | menu_win=fg:black,bg:cyan 19 | menu_win_bw=rev 20 | disabled_item=fg:black,bg:cyan 21 | disabled_item_bw=rev 22 | scroll_bar=fg:cyan,bg:black 23 | scroll_bar_bw=dim 24 | shadowed=fg:white,bg:black 25 | shadowed_bw=dim 26 | syntax1=bold,fg:yellow,bg:blue 27 | syntax1_bw=bold 28 | syntax2=bold,fg:cyan,bg:blue 29 | syntax2_bw=bold 30 | syntax3=bold,fg:green,bg:blue 31 | syntax3_bw=dim 32 | syntax4=bold,fg:magenta,bg:blue 33 | syntax4_bw=dim 34 | syntax5=fg:magenta,bg:blue 35 | syntax5_bw=dim 36 | syntax6=fg:yellow,bg:blue 37 | syntax6_bw=underline 38 | highlight=bold,fg:yellow,bg:black 39 | highlight_bw=bold 40 | -------------------------------------------------------------------------------- /src/colormnu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1998 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | void ColorsOpt(); 20 | void ColorsSave(); 21 | void ColorsSaveForTerminal(); 22 | void LoadColorDefault(); 23 | void LoadColorDefaultBG(); 24 | void LoadColorBlack(); 25 | void LoadColorBlue(); 26 | void LoadColorWhite(); 27 | void LoadColorGreen(); 28 | -------------------------------------------------------------------------------- /misc/colors-defbg: -------------------------------------------------------------------------------- 1 | # This is an alternative color scheme for LE editor. 2 | # Copy it to ~/.le/colors if you like. 3 | default_colors=1 4 | status_line=fg:black,bg:cyan 5 | status_line_bw=rev,dim 6 | normal_text=normal 7 | normal_text_bw=normal 8 | block_text=rev 9 | block_text_bw=rev 10 | error_win=bold,fg:white,bg:red 11 | error_win_bw=rev,bold 12 | verify_win=fg:black,bg:cyan 13 | verify_win_bw=rev 14 | curr_button=bold,fg:white,bg:black 15 | curr_button_bw=normal 16 | help_win=fg:black,bg:cyan 17 | help_win_bw=rev 18 | dialogue_win=fg:black,bg:white 19 | dialogue_win_bw=rev 20 | menu_win=fg:black,bg:cyan 21 | menu_win_bw=rev 22 | disabled_item=fg:black,bg:cyan 23 | disabled_item_bw=rev 24 | scroll_bar=fg:cyan 25 | scroll_bar_bw=dim 26 | shadowed=dim,fg:white,bg:black 27 | shadowed_bw=dim 28 | syntax1=fg:red 29 | syntax1_bw=bold 30 | syntax2=fg:magenta 31 | syntax2_bw=bold 32 | syntax3=fg:green 33 | syntax3_bw=dim 34 | syntax4=fg:cyan 35 | syntax4_bw=dim 36 | syntax5=bold,fg:blue 37 | syntax5_bw=dim 38 | syntax6=fg:yellow 39 | syntax6_bw=underline 40 | highlight=bold,fg:yellow,bg:black 41 | highlight_bw=bold 42 | -------------------------------------------------------------------------------- /misc/colors-green: -------------------------------------------------------------------------------- 1 | default_colors=1 2 | status_line=fg:white,bg:blue 3 | status_line_bw=rev,dim 4 | normal_text=bold,fg:white,bg:green 5 | normal_text_bw=normal 6 | block_text=fg:red,bg:white 7 | block_text_bw=rev 8 | error_win=bold,fg:white,bg:magenta 9 | error_win_bw=rev,bold 10 | verify_win=fg:magenta,bg:white 11 | verify_win_bw=rev 12 | curr_button=bold,fg:white,bg:black 13 | curr_button_bw=normal 14 | help_win=fg:blue,bg:white 15 | help_win_bw=rev 16 | dialogue_win=fg:black,bg:white 17 | dialogue_win_bw=rev 18 | menu_win=bold,fg:white,bg:red 19 | menu_win_bw=rev 20 | disabled_item=fg:green,bg:red 21 | disabled_item_bw=rev 22 | scroll_bar=fg:cyan,bg:black 23 | scroll_bar_bw=dim 24 | shadowed=fg:white,bg:black 25 | shadowed_bw=dim 26 | syntax1=bold,fg:yellow,bg:green 27 | syntax1_bw=bold 28 | syntax2=fg:blue,bg:green 29 | syntax2_bw=bold 30 | syntax3=bold,fg:cyan,bg:green 31 | syntax3_bw=dim 32 | syntax4=bold,fg:magenta,bg:green 33 | syntax4_bw=dim 34 | syntax5=fg:magenta,bg:green 35 | syntax5_bw=dim 36 | syntax6=fg:yellow,bg:green 37 | syntax6_bw=underline 38 | highlight=bold,fg:yellow,bg:black 39 | highlight_bw=bold 40 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | This is terminal text editor - LE. 2 | 3 | 4 | Read the file FEATURES to learn what LE can do. 5 | Read the file HISTORY to learn about LE beginning. 6 | 7 | 8 | You can try to find out how to use the editor by reading help, 9 | browsing the menu and reading the man page. Some hints: 10 | F10 or C-n -- menu 11 | F1 -- help 12 | C-x -- exit (cancel) 13 | Arrows -- navigate 14 | 15 | In the editor the following key description is used: 16 | Key1-Key2 -- simultaneous key1 and key2 press 17 | Key1+Key2 -- sequential keys press 18 | Key1 | Key2 -- press Key1 OR Key2 19 | ^Key -- Ctrl-Key 20 | ~Key -- Shift-Key 21 | ^~Key -- Ctrl-Shift-Key | Alt-Key 22 | Some of ^Fx, ~Fx, ^~Fx can be typed as ESC+Fx 23 | 24 | 25 | LE can be downloaded from the following location: 26 | http://lav.yar.ru/download/le/ 27 | 28 | Binaries for Fedora are located here: 29 | http://lav.yar.ru/download/le/binaries/ 30 | 31 | For the development version see https://github.com/lavv17/le 32 | 33 | Submit bug reports via github: https://github.com/lavv17/le/issues 34 | 35 | 36 | Author: Alexander V. Lukyanov 37 | -------------------------------------------------------------------------------- /src/rus.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-1997 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | extern int coding; 20 | #define NONE 0 21 | #define ALT 1 22 | #define JO_ALT 2 23 | #define KOI8 3 24 | #define D211_KOI 4 25 | #define MAIN 5 26 | 27 | int isrussian(byte); 28 | int islowerrus(byte); 29 | int isupperrus(byte); 30 | byte tolowerrus(byte); 31 | byte toupperrus(byte); 32 | -------------------------------------------------------------------------------- /misc/colors-white: -------------------------------------------------------------------------------- 1 | # This is an alternative color scheme for LE editor. 2 | # Copy it to ~/.le/colors if you like. 3 | default_colors=1 4 | status_line=bg:cyan,fg:black 5 | status_line_bw=rev,dim 6 | normal_text=bg:white,fg:black 7 | normal_text_bw=normal 8 | block_text=bold,fg:white,bg:blue 9 | block_text_bw=rev 10 | error_win=bold,fg:white,bg:red 11 | error_win_bw=rev,bold 12 | verify_win=bg:cyan,fg:black 13 | verify_win_bw=rev 14 | curr_button=bold,fg:white,bg:black 15 | curr_button_bw=normal 16 | help_win=bg:cyan,fg:black 17 | help_win_bw=rev 18 | dialogue_win=bg:white,fg:black 19 | dialogue_win_bw=rev 20 | menu_win=bg:cyan,fg:black 21 | menu_win_bw=rev 22 | disabled_item=bg:cyan,fg:black 23 | disabled_item_bw=rev 24 | scroll_bar=fg:cyan,bg:black 25 | scroll_bar_bw=dim 26 | shadowed=fg:white,bg:black 27 | shadowed_bw=dim 28 | syntax1=fg:red,bg:white 29 | syntax1_bw=bold 30 | syntax2=fg:magenta,bg:white 31 | syntax2_bw=bold 32 | syntax3=fg:blue,bg:white 33 | syntax3_bw=dim 34 | syntax4=fg:green,bg:white 35 | syntax4_bw=dim 36 | syntax5=fg:cyan,bg:white 37 | syntax5_bw=dim 38 | syntax6=fg:yellow,bg:white 39 | syntax6_bw=underline 40 | highlight=bold,fg:yellow,bg:black 41 | highlight_bw=bold 42 | -------------------------------------------------------------------------------- /misc/colors-black: -------------------------------------------------------------------------------- 1 | # This is an alternative color scheme for LE editor. 2 | # Copy it to ~/.le/colors if you like. 3 | default_colors=1 4 | status_line=fg:black,bg:cyan 5 | status_line_bw=rev,dim 6 | normal_text=fg:white,bg:black 7 | normal_text_bw=normal 8 | block_text=fg:blue,bg:white 9 | block_text_bw=rev 10 | error_win=bold,fg:white,bg:red 11 | error_win_bw=rev,bold 12 | verify_win=fg:black,bg:cyan 13 | verify_win_bw=rev 14 | curr_button=bold,fg:white,bg:black 15 | curr_button_bw=normal 16 | help_win=fg:black,bg:cyan 17 | help_win_bw=rev 18 | dialogue_win=fg:black,bg:white 19 | dialogue_win_bw=rev 20 | menu_win=fg:black,bg:cyan 21 | menu_win_bw=rev 22 | disabled_item=fg:black,bg:cyan 23 | disabled_item_bw=rev 24 | scroll_bar=fg:cyan,bg:black 25 | scroll_bar_bw=dim 26 | shadowed=dim,fg:white,bg:black 27 | shadowed_bw=dim 28 | syntax1=bold,fg:yellow,bg:black 29 | syntax1_bw=bold 30 | syntax2=bold,fg:green,bg:black 31 | syntax2_bw=bold 32 | syntax3=bold,fg:cyan,bg:black 33 | syntax3_bw=dim 34 | syntax4=bold,fg:magenta,bg:black 35 | syntax4_bw=dim 36 | syntax5=fg:magenta,bg:black 37 | syntax5_bw=dim 38 | syntax6=fg:yellow,bg:black 39 | syntax6_bw=underline 40 | highlight=bold,fg:yellow,bg:black 41 | highlight_bw=bold 42 | -------------------------------------------------------------------------------- /src/make-mainmenu.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | 5 | while(<>) { 6 | next if /^#/; 7 | chomp; 8 | my ($type,$text,$action,$options)=(m'^\s*(\w+)(?:\s+("[^"]+")(?:\s+(\S+)(.*))?)?'); 9 | ($action,my $arg)=($action=~/^([^(]*)(?:\((.*)\))?$/); 10 | my $A='A_'.uc($action); 11 | $A=~s/-/_/g; 12 | if(defined $arg && $arg ne '') { 13 | $arg=~s{([^\\]|^)_}{$1 }g; 14 | $arg=~s{\\_}{_}g; 15 | $A.=qq{,{(char*)"$arg"}}; 16 | } 17 | 18 | $options=~s/^\s+|\s+$//g; 19 | my @options=split ' ',$options; 20 | my $hide=''; 21 | for(@options) { 22 | $hide='|HIDE',undef $_,next if $_ eq 'hide'; 23 | s/-/_/g; 24 | $_='MENU_COND_'.uc($_); 25 | } 26 | 27 | $options=join('|',grep {$_} @options); 28 | $options='|'.$options if $options; 29 | $text='(char*)'.$text; 30 | if($type eq 'submenu') { 31 | print "{$text, SUBM$options},\n"; 32 | } elsif($type eq 'function') { 33 | die if !$action; 34 | $type='FUNC'.$hide; 35 | print "{$text, FUNC$hide$options, { $A } },\n"; 36 | } elsif($type eq 'end') { 37 | print "{NULL},\n"; 38 | } elsif($type eq 'hline') { 39 | print qq{{(char*)"---"},\n}; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/file.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-1997 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | const char *le_basename(const char *); 20 | const char *le_dirname(const char *); 21 | static inline char *le_basename(char *f) { return const_cast(le_basename(const_cast(f))); } 22 | static inline char *le_dirname(char *f) { return const_cast(le_dirname(const_cast(f))); } 23 | 24 | int ChooseFileName(char *pattern, unsigned nbytes); 25 | -------------------------------------------------------------------------------- /le.spec.in: -------------------------------------------------------------------------------- 1 | %define version @VERSION@ 2 | %define release 1 3 | 4 | Summary: Terminal text editor LE. 5 | Name: le 6 | Version: %{version} 7 | Release: %{release} 8 | License: GNU GPL 9 | Group: Applications/Editors 10 | Source: http://lav.yar.ru/download/le/le-%{version}.tar.gz 11 | BuildRoot: %{_tmppath}/%{name}-buildroot 12 | 13 | %description 14 | LE has many block operations with stream and rectangular blocks, can edit 15 | unix, dos and mac style files (LF/CRLF/CR), is binary clean, has hex mode, 16 | tunable syntax highlighting, tunable color scheme, tunable key map and some 17 | more useful features. It is slightly similar to Norton Editor from DOS. 18 | 19 | %prep 20 | %setup 21 | 22 | %build 23 | %define __libtoolize : 24 | %configure 25 | make 26 | 27 | %install 28 | rm -rf %{buildroot} 29 | make install DESTDIR=%{buildroot} 30 | 31 | %clean 32 | rm -rf %{buildroot} 33 | 34 | %files 35 | %defattr(0644 root root 0755) 36 | %doc FEATURES HISTORY NEWS README doc/README.keymap.ru 37 | %attr(0755 root root) %{_bindir}/le 38 | %attr(0755 root root) %{_datadir}/le/help 39 | %attr(0644 root man) %{_mandir}/man*/* 40 | %{_datadir}/le 41 | %{_datadir}/applications/le.desktop 42 | %{_datadir}/icons/hicolor/48x48/apps/le-icon.png 43 | -------------------------------------------------------------------------------- /src/mouse.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-1997 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef MOUSE_H 20 | #define MOUSE_H 21 | 22 | #ifdef WITH_MOUSE 23 | 24 | bool InTextWin(int line,int col); 25 | bool InScrollBar(int line,int col); 26 | void MoveToScreenLC(int line,int col); 27 | void MouseInTextWin(MEVENT &mev); 28 | void MouseInScrollBar(MEVENT &mev); 29 | 30 | extern int UseMouse; 31 | 32 | void SetupMouse(); 33 | 34 | #endif 35 | 36 | #endif // MOUSE_H 37 | -------------------------------------------------------------------------------- /src/format.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-1997 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef FORMAT_H 20 | #define FORMAT_H 21 | 22 | void FormatAll(); 23 | void FormatFunc(); 24 | void FormatPara(); 25 | void CenterLine(); 26 | void ShiftRightLine(); 27 | void WordWrapInsertHook(); 28 | 29 | extern int LineLen; 30 | extern int LeftMargin; 31 | extern int FirstLineMargin; 32 | extern int RightAdj,LeftAdj; 33 | extern int wordwrap; 34 | 35 | #endif // FORMAT_H 36 | -------------------------------------------------------------------------------- /src/chset.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-2004 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #define CHSET_BITS_PER_BYTE 4 20 | #define CHSET_SIZE ((256+CHSET_BITS_PER_BYTE-1)/CHSET_BITS_PER_BYTE) 21 | 22 | extern byte chset[CHSET_SIZE+1]; 23 | 24 | void init_chset(); 25 | void set_chset_8bit(); 26 | void set_chset_8bit_noctrl(); 27 | 28 | void addch_visual(chtype ch); 29 | chtype visualize(const attr *a,chtype ch); 30 | #if USE_MULTIBYTE_CHARS 31 | wchar_t visualize_wchar(wchar_t ch); 32 | #endif 33 | 34 | bool chset_isprint(int); 35 | -------------------------------------------------------------------------------- /src/keymapdf.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-2015 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | /*_________________________________________________________________________ 20 | ** 21 | ** File: keymapdf.cc 22 | ** 23 | ** Desc: Default keyboard mapping 24 | **_________________________________________________________________________ 25 | */ 26 | 27 | #include 28 | #include 29 | #include "keymap.h" 30 | 31 | const ActionCodeRec DefaultActionCodeTable[]= 32 | { 33 | #include "keymap-default.h" 34 | {-1,NULL} 35 | }; 36 | -------------------------------------------------------------------------------- /src/search.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-1997 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | void NotFound(); 20 | int CharMatch(); 21 | int Match1(); 22 | int Match(); 23 | void ReplaceFound(); 24 | void FindMatch(); 25 | 26 | void StartSearch(void); 27 | void ContSearch(void); 28 | void StartReplace(void); 29 | void ContReplace(void); 30 | void StartSearchBackward(void); 31 | 32 | extern History SearchHistory; 33 | 34 | extern unsigned char map_to_lower[256]; 35 | void map_to_lower_init(); 36 | -------------------------------------------------------------------------------- /misc/syntax.d/named-conf: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | i=c-literal 3 | i=c++-comment 4 | c1,2=([^[:alnum:]_-]|^)(acl|address|algorithm|allow-query|allow-recursion|allow-transfer\ 5 | |also-notify|auth-nxdomain|blackhole|bogus|category|channel|check-names|cleaning-interval\ 6 | |controls|coresize|datasize|deallocate-on-exit|dialup|directory|dump-file|fake-iquery\ 7 | |fetch-glue|files?|first|forward|forwarders|has-old-clients|heartbeat-interval|hint\ 8 | |host-statistics|include|interface-interval|keys?|lame-ttl|listen-on|logging\ 9 | |maintain-ixfr-base|masters?|match-clients|max-ixfr-log-size|max-n?cache-ttl\ 10 | |max-transfer-time-in|memstatistics-file|min-roots|multiple-cnames|named-xfer|no|notify\ 11 | |only|options|pid-file|port|print-category|print-severity|print-time|pubkey|query-source(|-v6)\ 12 | |recursion|rfc2308-type1|rrset-order|secret|server|severity|size|slave|sortlist|stacksize\ 13 | |statistics-file|statistics-interval|stub|syslog|topology|transfer-format|transfer-source(|-v6)\ 14 | |transfers|transfers-in|transfers-out|transfers-per-ns|treat-cr-as-space|trusted-keys|type\ 15 | |use-id-pool|versions?|view|yes|zone|notify-source(|-v6)|recursive-clients|dnssec-enable\ 16 | |dnssec-validation|dnssec-lookaside|bindkeys-file|managed-keys-directory|session-keyfile\ 17 | |inet|allow|no-case-compress)([^[:alnum:]_-]|$) 18 | c2={|}|,|; 19 | -------------------------------------------------------------------------------- /src/options.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-1997 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | struct init 20 | { 21 | const char *name; 22 | int format; 23 | void *var; 24 | }; 25 | 26 | void SaveConfToOpenFile(FILE *f,const struct init *init); 27 | void SaveConfToFile(const char *f,const struct init *init); 28 | void ReadConfFromFile(const char *file,const struct init *init,bool mine); 29 | 30 | void ColorsOpt(); 31 | void ProgOpt(); 32 | void UndoOpt(); 33 | 34 | extern const struct init colors[]; 35 | 36 | extern bool ExplicitInitName; 37 | extern char InitName[256]; 38 | -------------------------------------------------------------------------------- /misc/syntax.d/html: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | c3,1= 3 | c3,1=]\{0,100\})> 4 | c3,1=("([^"\n\\]|\\\\.)\{0,100\}"|'([^\n'\\]|\\\\.)\{0,100\}')[^<]\{0,1000\}> 5 | c2=|<[/!]|<|>|&[a-zA-Z]\{1,64\};|&#[0-9]\{1,8\}; 6 | ci1,1=) 20 | ci1,1=]\{0,80\}>((?:.|\n)*?)(?:]\{0,100\}>|\') 22 | si(css)1=]\{0,80\}>((?:.|\n)*?) 23 | -------------------------------------------------------------------------------- /src/menu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-1997 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef MENU_H 20 | #define MENU_H 21 | 22 | struct menu 23 | { 24 | const char *text; 25 | int x,y; 26 | }; 27 | 28 | char ItemChar(const char *i); 29 | int ItemLen(const char *i); 30 | void DisplayItem(int x,int y,const char *i,const attr *a); 31 | int ReadMenu(const struct menu *m,int dir,const attr *a,const attr *a1,int curr=0); 32 | int ReadMenuBox(struct menu *m,int dir,const char *msg,const char *title,const attr *a,const attr *a1); 33 | 34 | #define HORIZ 1 35 | #define VERT 2 36 | 37 | #endif//MENU_H 38 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 2013-03-13 Raphael Geissert 2 | 3 | * misc/Makefile.am, misc/syntax, misc/syntax.d/ocaml, 4 | misc/syntax.d/haskell: merge Debian changes. 5 | 6 | 2013-03-13 Raphael Geissert 7 | 8 | * doc/le.1, src/edit.cc: document missing opts. 9 | * src/loadsave.cc: fixed fd leak. 10 | * src/about.cc: fixed program name. 11 | * src/help.cc: fixed fd leak. 12 | * src/screen.cc: fixed condition check order. 13 | * src/file.cc: fixed overlapped strcpy. 14 | * src/history.cc: fixed NULL dereference when malloc returns NULL. 15 | 16 | 2005-04-26 lav 17 | 18 | * configure.ac: check for sys/syslimits.h, sys/param.h. 19 | 20 | 2004-04-12 lav 21 | 22 | * configure.ac: check for nl_langinfo; call LE_FUNC_WCWIDTH_REPLACE. 23 | 24 | 2001-01-17 Paul Slootman 25 | 26 | * acinclude.m4: add quotes (fixes build on alpha). 27 | 28 | 2000-01-21 lav 29 | 30 | * acinclude.m4: check if curses.h tries to declare bool in C++. 31 | * acconfig.h: rename CURSES_BOOL to LE_CURSES_BOOL_TYPE. 32 | 33 | 1999-10-06 lav 34 | 35 | * acinclude.m4: LE_CURSES_BOOL test for curses' bool type. 36 | * acconfig.h: CURSES_BOOL definition. 37 | * configure.in: call LE_CURSES_BOOL. 38 | 39 | 1999-08-26 lav 40 | 41 | * configure.in, acinclude.m4: test if gcc can be used to link simple 42 | c++ programs to avoid libstdc++ linkage. 43 | 44 | -------------------------------------------------------------------------------- /src/calc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-2006 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #define STSIZE 256 20 | 21 | #define OKAY 0 22 | #define STUNDERFLOW (-1) 23 | #define STOVERFLOW (-2) 24 | #define ILLEGALFN (-3) 25 | #define INVALIDFN (-4) 26 | #define INVALIDNUM (-5) 27 | 28 | struct calc_value 29 | { 30 | long double value; 31 | unsigned char base; 32 | const char *to_string(); 33 | operator long double() { return value; } 34 | }; 35 | 36 | extern int sp; 37 | extern calc_value stack[STSIZE]; 38 | extern int calcerrno; 39 | 40 | const char *calcerrmsg(); 41 | int calculator(const char *); 42 | void initcalc(); 43 | -------------------------------------------------------------------------------- /src/clipbrd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-1997 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef CLIPBRD_H 20 | #define CLIPBRD_H 21 | 22 | class ClipBoard 23 | { 24 | char *text; 25 | int width; 26 | int height; 27 | bool rect; 28 | bool toeol; 29 | 30 | public: 31 | ClipBoard(); 32 | ~ClipBoard(); 33 | 34 | void Empty(); 35 | bool IsEmpty() { return text==0; } 36 | int Copy(); 37 | int Paste(bool mark=false); 38 | int PasteAndMark() { return Paste(true); } 39 | 40 | int Write(int fd); 41 | int Linearize(char **buf,int *len); 42 | }; 43 | 44 | extern ClipBoard MainClipBoard; 45 | 46 | #endif//CLIPBRD_H 47 | -------------------------------------------------------------------------------- /misc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | install(FILES le.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications) 2 | 3 | install(FILES le-icon.png DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/48x48/apps) 4 | 5 | set(colors colors-black colors-blue colors-defbg colors-green colors-white) 6 | set(keymaps keymap-emacs keymap-default) 7 | set(mainmenus mainmenu-default mainmenu-ru) 8 | 9 | install(FILES help syntax ${colors} ${keymaps} ${mainmenus} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/le) 10 | 11 | install(FILES 12 | syntax.d/ada 13 | syntax.d/as 14 | syntax.d/awk 15 | syntax.d/c 16 | syntax.d/c++ 17 | syntax.d/c++-comment 18 | syntax.d/c-comment 19 | syntax.d/c-literal 20 | syntax.d/cpp 21 | syntax.d/css 22 | syntax.d/eiffel 23 | syntax.d/fvwm2 24 | syntax.d/gema 25 | syntax.d/golang 26 | syntax.d/haskell 27 | syntax.d/html 28 | syntax.d/java 29 | syntax.d/javascript 30 | syntax.d/jinja2 31 | syntax.d/logrotate-conf 32 | syntax.d/lout 33 | syntax.d/make-file 34 | syntax.d/markdown 35 | syntax.d/metafont 36 | syntax.d/named-conf 37 | syntax.d/nroff 38 | syntax.d/ocaml 39 | syntax.d/pascal 40 | syntax.d/perl 41 | syntax.d/php 42 | syntax.d/pod 43 | syntax.d/puppet 44 | syntax.d/python 45 | syntax.d/sather 46 | syntax.d/shell 47 | syntax.d/snmp-mib 48 | syntax.d/sql 49 | syntax.d/tcl 50 | syntax.d/tex 51 | syntax.d/texinfo 52 | syntax.d/txt2tags 53 | syntax.d/verilog 54 | syntax.d/yaml 55 | DESTINATION ${CMAKE_INSTALL_PREFIX}/share/le/syntax.d) 56 | -------------------------------------------------------------------------------- /misc/syntax.d/puppet: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | i=c-literal 3 | c3,1=^[ \t]*(#.*$) 4 | c1,2=([^[:alnum:]_]|^)(\ 5 | and|case|class|default|define|else|elsif|false|if|in|import|inherits\ 6 | |node|or|true|undef\ 7 | \ 8 | |attr|function|type|private\ 9 | \ 10 | )([^[:alnum:]_]|$) 11 | c2=\\[|\\]|\\(|\\)|{|}|,|:|=>|=|->|~>|<-|<~|!|!=|<<|>>|!~|%|<|> 12 | c1,2=([^[:alnum:]_]|^)(\ 13 | augeas|computer|cron|exec|file|filebucket|group|host|interface|k5login\ 14 | |macauthorization|mailalias|maillist|mcx|mount|nagios_command\ 15 | |nagios_contact|nagios_contactgroup|nagios_host|nagios_hostdependency\ 16 | |nagios_hostescalation|nagios_hostextinfo|nagios_hostgroup\ 17 | |nagios_service|nagios_servicedependency|nagios_serviceescalation\ 18 | |nagios_serviceextinfo|nagios_servicegroup|nagios_timeperiod|notify\ 19 | |package|resources|router|schedule|scheduled_task|selboolean|selmodule\ 20 | |service|ssh_authorized_key|sshkey|stage|tidy|user|vlan|yumrepo|zfs\ 21 | |zone|zpool\ 22 | )([[:space:]]*{|$) 23 | c1,2=([^[:alnum:]_]|^)(\ 24 | Class\ 25 | |Augeas|Computer|Cron|Exec|File|Filebucket|Group|Host|Interface|K5login\ 26 | |Macauthorization|Mailalias|Maillist|Mcx|Mount|Nagios_command\ 27 | |Nagios_contact|Nagios_contactgroup|Nagios_host|Nagios_hostdependency\ 28 | |Nagios_hostescalation|Nagios_hostextinfo|Nagios_hostgroup\ 29 | |Nagios_service|Nagios_servicedependency|Nagios_serviceescalation\ 30 | |Nagios_serviceextinfo|Nagios_servicegroup|Nagios_timeperiod|notify\ 31 | |Package|Resources|Router|Schedule|Scheduled_task|Selboolean|Selmodule\ 32 | |Service|Ssh_authorized_key|Sshkey|Stage|Tidy|User|Vlan|Yumrepo|Zfs\ 33 | |Zone|Zpool\ 34 | )[[:space:]]*\\[ 35 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = doc lib src misc m4 2 | EXTRA_DIST = FEATURES HISTORY le.spec 3 | ACLOCAL_AMFLAGS = -I m4 4 | 5 | EXTRA_DIST += $(top_srcdir)/.version 6 | BUILT_SOURCES = $(top_srcdir)/.version 7 | $(top_srcdir)/.version: 8 | echo $(VERSION) > $@-t && mv $@-t $@ 9 | dist-hook: 10 | echo $(VERSION) > $(distdir)/.tarball-version 11 | 12 | REL_DIR=/home/lav/www/download/le 13 | release: 14 | make distcheck 15 | mv $(PACKAGE)-$(VERSION).tar.gz $(REL_DIR) 16 | cd $(REL_DIR) && \ 17 | (addbz $(PACKAGE)-$(VERSION).tar.gz; \ 18 | gpg -ba $(PACKAGE)-$(VERSION).tar.gz; \ 19 | gpg -ba $(PACKAGE)-$(VERSION).tar.bz2; \ 20 | gpg -ba $(PACKAGE)-$(VERSION).tar.xz; \ 21 | md5sum $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION).tar.bz2 $(PACKAGE)-$(VERSION).tar.xz > $(PACKAGE)-$(VERSION).md5sum) 22 | 23 | # AppImage building rules 24 | linuxdeployqt=linuxdeployqt-continuous-$(build_cpu).AppImage 25 | le_desktop=$(prefix)/share/applications/le.desktop 26 | le_appimage=$(PACKAGE)-$(VERSION)-$(host_cpu).AppImage 27 | CLEANFILES=$(le_appimage) 28 | DISTCLEANFILES=$(linuxdeployqt) 29 | 30 | $(linuxdeployqt): 31 | test -x src/le || $(MAKE) $(AM_MAKEFLAGS) all 32 | wget https://github.com/probonopd/linuxdeployqt/releases/download/continuous/$(linuxdeployqt) 33 | chmod a+x $(linuxdeployqt) 34 | 35 | $(le_appimage): $(linuxdeployqt) 36 | $(MAKE) $(AM_MAKEFLAGS) install DESTDIR="`readlink -f appdir`" 37 | unset QTDIR QT_PLUGIN_PATH LD_LIBRARY_PATH \ 38 | && ./$(linuxdeployqt) ./appdir$(le_desktop) -bundle-non-qt-libs \ 39 | && ./$(linuxdeployqt) ./appdir$(le_desktop) -appimage 40 | mv -f le-$(host_cpu).AppImage $(le_appimage) 41 | -rm -rf appdir 42 | 43 | appimage: $(le_appimage) 44 | .PHONY: appimage 45 | 46 | clean-local: 47 | -rm -rf appdir 48 | -------------------------------------------------------------------------------- /src/highli.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-1997 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef HIGHLI_H 20 | #define HIGHLI_H 21 | 22 | #include 23 | 24 | extern "C" { 25 | #include 26 | } 27 | 28 | extern int hl_option,hl_active,hl_lines; 29 | 30 | void InitHighlight(); 31 | 32 | struct syntax_hl 33 | { 34 | char *rexp; 35 | int mask; 36 | int color; 37 | re_pattern_buffer rexp_c; 38 | re_registers regs; 39 | 40 | syntax_hl *next; 41 | syntax_hl *sub; 42 | 43 | static char *selector; 44 | static syntax_hl *chain; 45 | static void free_chain(syntax_hl*); 46 | static void attrib_line(const char *buf1,int len1,const char *buf2,int len2, 47 | unsigned char *line); 48 | static void make_els(const char *buf1,int len1,const char *buf2,int len2,int pos,int ll,syntax_hl *c,class element **els); 49 | 50 | syntax_hl(int color,int mask); 51 | ~syntax_hl(); 52 | const char *set_rexp(const char *rexp,bool icase); 53 | }; 54 | 55 | #endif//HIGHLI_H 56 | -------------------------------------------------------------------------------- /src/menu1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-1997 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | /* Definitions for pull-down menu */ 20 | 21 | #ifndef MENU1_H 22 | #define MENU1_H 23 | 24 | #include 25 | 26 | enum menu_conds 27 | { 28 | SUBM=1, 29 | FUNC=2, 30 | HIDE=4, 31 | FREE_TEXT=8, 32 | MENU_COND_RW=16, 33 | MENU_COND_RO=32, 34 | MENU_COND_BLOCK=64, 35 | MENU_COND_NO_MM=128, 36 | MENU_COND_CLIPBOARD=256 37 | }; 38 | 39 | typedef struct sr_menu 40 | { 41 | char *text; /* the text of the item, NULL means end of (sub)menu */ 42 | unsigned fl; 43 | union { 44 | int action; // for FUNC 45 | int curritem; // for END (text==NULL) 46 | }; 47 | union { 48 | char *arg; // for FUNC 49 | WIN *win; // for SUBM 50 | }; 51 | 52 | void FreeText() { 53 | if(fl&FREE_TEXT) { 54 | free(text); 55 | text=0; 56 | } 57 | } 58 | void SetText(char *new_text) { 59 | FreeText(); 60 | text=new_text; 61 | fl|=FREE_TEXT; 62 | } 63 | } Menu1; 64 | 65 | void LoadMainMenu(); 66 | 67 | #endif /* MENU1_H */ 68 | -------------------------------------------------------------------------------- /src/screen.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-1997 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef SCREEN_H 20 | #define SCREEN_H 21 | 22 | void CenterView(); 23 | void Redisplay(num line,offs ptr,num limit); 24 | void RedisplayAll(); 25 | void RedisplayLine(); 26 | void RedisplayAfter(); 27 | void StatusLine(); 28 | void LocateCursor(); 29 | void SetCursor(); 30 | void SyncTextWin(); 31 | 32 | void Message(const char *msg); 33 | void MessageSync(const char *msg); 34 | void AddMessage(const char *msg); 35 | void ClearMessage(); 36 | 37 | void ErrMsg(const char *msg); 38 | 39 | void TestPosition(); 40 | 41 | #define HexPos 11 42 | #define AsciiPos (HexPos+3*16+2) 43 | 44 | extern int ScrollBarPos; 45 | 46 | extern int TextWinX,TextWinY,TextWinWidth,TextWinHeight,ScrollBarX,StatusLineY; 47 | 48 | extern int ShowScrollBar; 49 | extern int ShowStatusLine; 50 | 51 | extern int ShowMatchPos; // for hex mode 52 | 53 | enum { 54 | SHOW_RIGHT=0, 55 | SHOW_NONE=1, 56 | SHOW_LEFT=2, 57 | SHOW_BOTTOM=0, 58 | SHOW_TOP=2 59 | }; 60 | 61 | extern num ScrShift; 62 | 63 | #endif//SCREEN_H 64 | -------------------------------------------------------------------------------- /src/block.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-2004 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | static inline int InBlock(offs ptr) 20 | { 21 | return(!hide && ptr>=BlockBegin && ptr 3 | si(pod)=^=[a-z](?:.|\n)*?^=cut[[:space:]]*$ 4 | c3,2=(^|[^$\\])(#.*)$ 5 | c3,1=[^\\$]("(?:[^"\\]|\\\\(?:.|\n))*?"|'(?:[^'\\]|\\\\(?:.|\n))*?') 6 | si(sql)1=->(?:prepare(?:_cached)?|do|selectrow_array(?:ref)?|selectcol_arrayref|selectall_(?:hash|array)ref)[ \t]*\(\ 7 | q?q{((?:'[^']*?'|"[^"]*?"|[^'"])+?)} 8 | c1,2=([^[:alnum:]_\$@%#]|^)(abs|accept|alarm|atan2|bind|binmode|bless|caller\ 9 | |chdir|chmod|chomp|chop|chown|chr|chroot|close|closedir|connect|cos|crypt\ 10 | |dbmclose|dbmopen|define|delete|die|do|dump|each|eof|eval|exec|exists|exit|exp\ 11 | |fcntl|fileno|flock|fock|for|foreach|format|formline|getc|getlogin|getpeername\ 12 | |getpgrp|getppid|getpriority|getsockname|getsockopt|glob|gmtime|goto|grep\ 13 | |hex|if|import|index|int|ioctl|join|keys|kill|last|lc|lcfirst|length|link\ 14 | |listen|local|localtime|log|lstat|map|mkdir|msgctl|msgget|msgsnd|msgrcv|my|next\ 15 | |no Module|oct|open|opendir|ord|pack|pipe|pop|pos|s?printf?|push|quotemeta\ 16 | |rand|read|readdir|readline|readlink|recv|redo|ref|rename|require|reset|return|reverse\ 17 | |rewindir|rindex|rmdir|scalar|seek|seekdir|select|select( RBITS| WBITS| EBITS| TIMEOUT)?\ 18 | |semctl|semget|semop|send|setpgrp|setpriority|setsockopt|shift|shmget|shmget\ 19 | |shmread|shutdown|sin|sleep|socket|socketpair|sort|splice|split|sqrt\ 20 | |srand|stat|study|substr|symlink|syscall|sysread|sysseek|system|syswrite|tell|telldir\ 21 | |tied?|times?|truncate|uc|ucfirst|umask|undef|unless|unlink|unpack|untie|unshift\ 22 | |use|utime|values|vec|wait|waitpid|wantarray|warn|while|write|else|elsif\ 23 | |package|sub|BEGIN|END|INIT|CHECK|UNITCHECK|socket|defined|our|given|when\ 24 | |default|state|say\ 25 | )([^[:alnum:]/_]|$) 26 | c1,1=\\\\(my|our)([^[:alnum:]/_]|$) 27 | c2={|}|<<|<|>>|>|;;|;|\(|\)|=|=~|!=|&&|\|\||!|\.\.|<=>|&|^|->|// 28 | c2,2=([ \t)]|^)(and|or|xor|eq|ne|cmp|lt|gt|le|ge)([ \t(]|$) 29 | c2,2=([ \t(]|^)(not)([ \t(]|$) 30 | -------------------------------------------------------------------------------- /misc/syntax.d/php: -------------------------------------------------------------------------------- 1 | # -*- LE-syntax -*- 2 | c3=#.*$|//.*$|/\\*(?:.|\n)*?\\*/ 3 | i=c-literal 4 | ci1,2=([^[:alnum:]_$]|^)(if|elseif|else|for|foreach|in|break|continue|while|var\ 5 | |function|use|class|return|global|in|or|and|xor|not|echo|print|exit|die|as|do|unset\ 6 | |str_i?replace|substr|strlen|empty|str?ri?pos|trim|each|stri?str\ 7 | |preg_(quote|match(|_all)|replace(|_callback)|last_error|grep|split)\ 8 | |strcmp|str(nat)?(case)?cmp|(md5|sha1)(_file)?|strtr\ 9 | |(str|chunk)_split|parse_(str|url)|pathinfo|http_build_query\ 10 | |strto(lower|upper)|gettype|get_class|instanceof\ 11 | |(user|trigger)_error|(set|restore)_(exception|error)_handler\ 12 | |(add|strip)c?slashes|(raw)?url(en|de)code|base64_(de|en)code\ 13 | |is(set|_(bool|int(eger)?|a([^[:alnum:]]|rray)|string|binary|buffer|callable\ 14 | |double|float|long|null|object|real|scalar|numeric|resource|unicode))\ 15 | |switch|case|default|explode|implode\ 16 | |(([sf]|)print(f||_r))|var_dump\ 17 | |f(open|eof|close|flush|lock|read|put(csv|s)|scanf|stat|seek|truncate|write\ 18 | |get(c|csv|s|ss)|ile(|_(exists|(get|put)_contents)|[acm]time|group|inode|owner\ 19 | |perms|size|type))\ 20 | |count|defined?|new|reset|key|current|next|prev|end|list\ 21 | |array(|_(change_key_case|chunk|combine|count_values|diff(_(u?assoc|u?key))?\ 22 | |fill(_keys)?|filter|flip|u?intersect(|_(u?assoc|u?key))|key_exists|map\ 23 | |merge(_recursive)?|multisort|pas|pop|product|push|rand|reduce|reverse|search\ 24 | |shift|sp?lice|sum|udiff(|_u?assoc)|unique|keys|values|walk(_recursive)?))|\ 25 | |microtime|timestamp|pow|rand|round|pi|min|max|ceil|floor\ 26 | |a?(cos|sin|tan)h?|atan2?\ 27 | |is_(in)?finite|is_nan|true|false|in_array|(int|float|str|bool)val\ 28 | |function_exists|namespace|extends|implements|is_numeric|settype\ 29 | |public|private|protected|static|final|clone|try|catch|finally|throw|const\ 30 | |end(if|switch|for|while)\ 31 | )([^[:alnum:]_]|$) 32 | ci1=(\$this)([^[:alnum:]_]|$) 33 | #c2=:|\$|-> 34 | c2={|}|<<|<|<\?(php)?|>>|>|\?>|;;|;|\(|\)|[.+-*]?=|!=|&&|\|\||!|\.\.|<=>|&|^|@|->|\?\? 35 | -------------------------------------------------------------------------------- /src/bm.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | /* $Id: bm.cc,v 1.2 2001/05/16 14:42:28 lav Exp $ */ 20 | 21 | #include 22 | #include 23 | #include "edit.h" 24 | #include "bm.h" 25 | 26 | #define N 256 27 | 28 | static TextPoint *bm[N]; 29 | static TextPoint *bm_scrtop[N]; 30 | static num bm_scrshift[N]; 31 | 32 | void SetBookmark(int n) 33 | { 34 | assert(n>=0 && n=0 && n=0 && n 3 | c3=--.*$|/\\*(?:.|\n)*?\\*/ 4 | c3="([^"\n\\]|\\\\.)*"|'([^\n'\\]|\\\\.)*' 5 | ci1,1=(?:[^[:alnum:]_]|^)(\ 6 | abort|accept|access|add|after|all|alter|and|any|array|arraylen|as|asc|\ 7 | assert|assign|at|audit|authorization|avg|base_table|before|begin|between|\ 8 | binary_integer|body|boolean|by|cascade|case|char|char_base|check|close|\ 9 | cluster|clusters|colauth|column|columns|comment|commit|compress|connect|\ 10 | constant|constraint|count|crash|create|current|cursor|curval|database|\ 11 | data_base|date|dba|debugoff|debugon|decimal|declare|decode|default|\ 12 | definition|delay|delete|delimiter|delta|desc|digits|disable|dispose|\ 13 | distinct|do|drop|each|else|elsif|enable|end|engine|entry|exception|\ 14 | exception_init|exclusive|exists|exit|false|fetch|file|float|for|foreign|\ 15 | form|from|full|function|generic|goto|grant|group|having|identified|if|\ 16 | immediate|in|increment|index|indexes|indicator|initial|inner|insert|int|\ 17 | integer|interface|intersect|into|is|join|key|left|level|like|limit|\ 18 | limited|lock|long|loop|max|maxextents|min|minus|mlslabel|mod|mode|modify|\ 19 | natural|naturaln|new|nextval|nvl|noaudit|nocompress|not|nowait|null(if)?|number|\ 20 | number_base|of|offline|on|online|open|option|or|order|others|out|outer|\ 21 | package|partition|pctfree|pls_integer|positive|positiven|pragma|primary|\ 22 | prior|private|privileges|procedure|public|raise|range|raw|real|record|ref|\ 23 | references|release|rem|rename|replace|resource|return|returning|reverse|\ 24 | revoke|right|rollback|row|rowid|rowlabel|rownum|rows|rowtype|run|\ 25 | savepoint|schema|select|separate|sequence|session|set|share|size|smallint|\ 26 | space|sql|sqlcode|sqlerrm|start|statement|stddev|subtype|successful|sum|\ 27 | synonym|sysdate|tabauth|table|tables|task|terminate|then|to|transaction|\ 28 | trigger|true|type|uid|union|unique|unsigned|update|use|user|using|validate|\ 29 | values|varchar|varchar2|variance|view|views|when|whenever|where|while|with|\ 30 | work|write|xor|continue|lower|upper|initcap\ 31 | )(?:[^[:alnum:]_]|$) 32 | c2=\||\)|\(|:=|=|\|\||<|>|!= 33 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = le 2 | 3 | le_SOURCES = about.cc block.cc calc.cc chset.cc cmd.cc color.cc edit.cc\ 4 | editcalc.cc ext.cc file.cc format.cc frames.cc getch.cc getstr.cc\ 5 | help.cc history.cc kern.cc keymap.cc keymapdf.cc keymapfn.cc loadsave.cc\ 6 | mainmenu.cc menu.cc menu1.cc options.cc pipe.cc rus.cc screen.cc search.cc\ 7 | signals.cc tables.cc textpoin.cc user.cc window.cc about.h block.h\ 8 | calc.h chset.h cmd.h color.h edit.h file.h history.h inline.h keymap.h\ 9 | menu.h menu1.h options.h rus.h screen.h search.h textpoin.h user.h\ 10 | window.h highli.cc highli.h clipbrd.cc clipbrd.h keynames.h keynames.cc\ 11 | mouse.h mouse.cc getch.h format.h colormnu.cc colormnu.h bm.cc bm.h\ 12 | mb.cc mb.h undo.cc undo.h regex.c regex.h wcwidth.c wcwidth1.c\ 13 | action-name-func 14 | 15 | GNULIB = $(top_builddir)/lib/libgnu.a 16 | 17 | le_DEPENDENCIES = $(GNULIB) 18 | le_LDADD = $(GNULIB) $(CURSES_LIBS) $(LIBINTL) $(LIBSOCKET) $(LIB_POLL) $(LIB_SELECT) 19 | 20 | AM_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib $(CURSES_INCLUDES) 21 | 22 | EXTRA_DIST = le.hlp make-action-enum.pl make-action-name-func.pl make-keymap.pl make-mainmenu.pl 23 | pkgdata_DATA = le.hlp 24 | 25 | action-enum.h: action-name-func make-action-enum.pl 26 | $(PERL) $(srcdir)/make-action-enum.pl $(srcdir)/action-name-func > $@ 27 | action-name-func.h: action-name-func make-action-name-func.pl 28 | $(PERL) $(srcdir)/make-action-name-func.pl $(srcdir)/action-name-func > $@ 29 | keymap-default.h: $(top_srcdir)/misc/keymap-default make-keymap.pl 30 | $(PERL) $(srcdir)/make-keymap.pl $(top_srcdir)/misc/keymap-default > $@ 31 | mainmenu-default.h: $(top_srcdir)/misc/mainmenu-default make-mainmenu.pl 32 | $(PERL) $(srcdir)/make-mainmenu.pl $(top_srcdir)/misc/mainmenu-default > $@ 33 | 34 | block.o chset.o edit.o file.o format.o frames.o getstr.o help.o kern.o \ 35 | keymap.o keymapdf.o keymapfn.o loadsave.o mainmenu.o menu1.o menu.o \ 36 | options.o search.o user.o: action-enum.h 37 | keymap.o: action-name-func.h 38 | keymapdf.o: keymap-default.h 39 | mainmenu.o: mainmenu-default.h 40 | 41 | CLEANFILES = action-enum.h action-name-func.h keymap-default.h mainmenu-default.h 42 | -------------------------------------------------------------------------------- /FEATURES: -------------------------------------------------------------------------------- 1 | The text editor LE 1.15 has the following functions: 2 | 3 | Rectangular and stream blocks: copy, move, delete, write to file, read 4 | from file, filtering through external command, shift left, shift right, 5 | upper-lower conversion, prefix inserting, yanking buffered block. 6 | 7 | Search and replace with full regular expressions. 8 | 9 | Navigation -- by line number, offset, to the place of last edit, to 10 | block begin/end. 11 | 12 | Text formatting, line centering (Hint: ESC+F4). Optional automatic word 13 | wrap. 14 | 15 | Pseudo-graphics drawing (including UTF-8 encoding). 16 | 17 | Full undo/redo. 18 | 19 | Hex viewing/editing files. 20 | 21 | Binary clean -- you can safely load binary files in `Exact' or `Hex' 22 | mode (Exact is the default). 23 | 24 | Multibyte character encoding support (e.g. UTF-8) with ncurses library 25 | version 5.4 or newer, built with --enable-widechar option. 26 | 27 | Viewing/editing (replace only) of very large files or even devices using 28 | mmap system call (--mmap or --mmap-rw option). Use with caution --mmap-rw 29 | option: changes go directly to file (MAP_SHARED mode), undo is available. 30 | It's possible to map a portion of a large file using FILE:BEGIN:LENGTH 31 | syntax in place of the file name. 32 | 33 | Various options tuning form (Hint: ^O, also in menu) 34 | 35 | Pull down menu (Hint: ^N or F10) 36 | 37 | Tunable syntax highlighting (rules are stored in $(pkgdatadir)/syntax or 38 | ~/.le/syntax or ./.le.syntax) 39 | 40 | Tunable key sequences: place output of `le --dump-keymap' to 41 | ~/.le/keymap, ~/.le/keymap-$TERM or to $(pkgdatadir)/keymap[-$TERM] and 42 | edit as you wish. 43 | 44 | Tunable colors: place output of `le --dump-colors' to 45 | ~/.le/colors[-$TERM] or $(pkgdatadir)/colors[-$TERM] and edit as you wish. 46 | You can also edit and save color palette with color editing form available 47 | from Options menu. There are several color maps in misc/ subdirectory. 48 | There are also several predefined palettes which can be chosen from menu. 49 | 50 | On new xterms (v120 and later) and appropriate terminfo some extra keys 51 | are recognized. E.g. Shift-Arrows do text selection; the same for native 52 | Linux console. 53 | 54 | Mouse support via ncurses. 55 | -------------------------------------------------------------------------------- /misc/Makefile.am: -------------------------------------------------------------------------------- 1 | colors = colors-black colors-blue colors-defbg colors-green colors-white 2 | keymaps = keymap-emacs keymap-default 3 | mainmenus = mainmenu-default mainmenu-ru 4 | syntax = syntax \ 5 | syntax.d/ada \ 6 | syntax.d/as \ 7 | syntax.d/awk \ 8 | syntax.d/c \ 9 | syntax.d/c++ \ 10 | syntax.d/c++-comment \ 11 | syntax.d/c-comment \ 12 | syntax.d/c-literal \ 13 | syntax.d/cpp \ 14 | syntax.d/css \ 15 | syntax.d/eiffel \ 16 | syntax.d/fvwm2 \ 17 | syntax.d/gema \ 18 | syntax.d/golang \ 19 | syntax.d/haskell \ 20 | syntax.d/html \ 21 | syntax.d/java \ 22 | syntax.d/javascript \ 23 | syntax.d/jinja2 \ 24 | syntax.d/logrotate-conf \ 25 | syntax.d/lout \ 26 | syntax.d/make-file \ 27 | syntax.d/markdown \ 28 | syntax.d/metafont \ 29 | syntax.d/named-conf \ 30 | syntax.d/nroff \ 31 | syntax.d/ocaml \ 32 | syntax.d/pascal \ 33 | syntax.d/perl \ 34 | syntax.d/php \ 35 | syntax.d/pod \ 36 | syntax.d/puppet \ 37 | syntax.d/python \ 38 | syntax.d/sather \ 39 | syntax.d/shell \ 40 | syntax.d/snmp-mib \ 41 | syntax.d/sql \ 42 | syntax.d/tcl \ 43 | syntax.d/tex \ 44 | syntax.d/texinfo \ 45 | syntax.d/txt2tags \ 46 | syntax.d/verilog \ 47 | syntax.d/yaml 48 | 49 | nobase_pkgdata_DATA = $(colors) $(keymaps) $(mainmenus) $(syntax) 50 | pkgdata_SCRIPTS = help 51 | 52 | appdir = $(datadir)/applications 53 | icondir = $(datadir)/icons/hicolor/48x48/apps 54 | 55 | app_DATA = le.desktop 56 | icon_DATA = le-icon.png 57 | 58 | EXTRA_DIST = $(nobase_pkgdata_DATA) $(pkgdata_SCRIPTS) $(app_DATA) $(icon_DATA) \ 59 | gnulib.patch 60 | 61 | colors: ../src/le 62 | ../src/le --dump-colors > $@ 63 | 64 | CLEANFILES = colors 65 | -------------------------------------------------------------------------------- /src/editcalc.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-2014 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include 20 | 21 | #include "edit.h" 22 | #include "calc.h" 23 | 24 | void editcalc() 25 | { 26 | WIN *w; 27 | static char expr[256]=""; 28 | char str[256]; 29 | int i,y; 30 | static History CalcHistory; 31 | 32 | w=CreateWin(FRIGHT,FDOWN,40,16,DIALOGUE_WIN_ATTR," Calculator ",0); 33 | DisplayWin(w); 34 | 35 | calcerrno=0; 36 | do 37 | { 38 | Clear(); 39 | if(calcerrno) 40 | PutStr(2,1,calcerrmsg()); 41 | if(sp<1) 42 | PutStr(MIDDLE,2,"Stack empty"); 43 | else 44 | { 45 | i=sp-Upper->h+3; 46 | if(i<0) 47 | i=0; 48 | for(y=2; i=0; i--) 63 | { 64 | snprintf(str, sizeof(str), "%s%s", stack[i].to_string(), &" "[i==0]); 65 | InsertBlock(str,strlen(str)); 66 | SetStdCol(); 67 | } 68 | CalcHistory-=expr; 69 | break; 70 | } 71 | calcerrno=0; 72 | calculator(expr); 73 | } 74 | while(1); 75 | CloseWin(); 76 | DestroyWin(w); 77 | } 78 | -------------------------------------------------------------------------------- /src/color.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-2017 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | enum 20 | { 21 | STATUS_LINE=0, 22 | NORMAL_TEXT, 23 | BLOCK_TEXT, 24 | ERROR_WIN, 25 | VERIFY_WIN, 26 | CURR_BUTTON, 27 | HELP_WIN, 28 | DIALOGUE_WIN, 29 | MENU_WIN, 30 | DISABLED_ITEM, 31 | SCROLL_BAR, 32 | SHADOWED, 33 | SYNTAX1, 34 | SYNTAX2, 35 | SYNTAX3, 36 | SYNTAX4, 37 | SYNTAX5, 38 | SYNTAX6, 39 | HIGHLIGHT, 40 | 41 | MAX_COLOR_NO 42 | }; 43 | 44 | #define SYNTAX_COLORS 6 45 | 46 | struct attr 47 | { 48 | chtype n_attr; // normal 49 | chtype so_attr; // stand-out 50 | }; 51 | 52 | struct color 53 | { 54 | int no; 55 | chtype attr; 56 | int fg,bg; 57 | }; 58 | 59 | void init_attrs(); 60 | 61 | extern attr attr_table[MAX_COLOR_NO]; 62 | 63 | static inline 64 | const attr *find_attr(int no) 65 | { 66 | return attr_table+no; 67 | } 68 | 69 | extern char color_descriptions[MAX_COLOR_NO*2][256]; 70 | 71 | void ParseColors(); 72 | const color *FindColor(const color *pal,int no); 73 | static inline color *FindColor(color *pal,int no) { return const_cast(FindColor(const_cast(pal),no)); } 74 | void DescribeColors(const color *,const color *); 75 | void DumpDefaultColors(FILE *); 76 | 77 | extern color color_pal[MAX_COLOR_NO+1]; 78 | extern color bw_pal[MAX_COLOR_NO+1]; 79 | extern const color default_color_pal[MAX_COLOR_NO+1]; 80 | extern const color default_bw_pal[MAX_COLOR_NO+1]; 81 | 82 | void le_start_color(); 83 | 84 | #define NO_COLOR (-1) 85 | -------------------------------------------------------------------------------- /m4/gnulib-cache.m4: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2002-2024 Free Software Foundation, Inc. 2 | # 3 | # This file is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This file is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this file. If not, see . 15 | # 16 | # As a special exception to the GNU General Public License, 17 | # this file may be distributed as part of a program that 18 | # contains a configuration script generated by Autoconf, under 19 | # the same distribution terms as the rest of that program. 20 | # 21 | # Generated by gnulib-tool. 22 | # 23 | # This file represents the specification of how gnulib-tool is used. 24 | # It acts as a cache: It is written and read by gnulib-tool. 25 | # In projects that use version control, this file is meant to be put under 26 | # version control, like the configure.ac and various Makefile.am files. 27 | 28 | 29 | # Specification in the form of a command-line invocation: 30 | # gnulib-tool --import \ 31 | # --local-dir=gl \ 32 | # --lib=libgnu \ 33 | # --source-base=lib \ 34 | # --m4-base=m4 \ 35 | # --doc-base=doc \ 36 | # --tests-base=tests \ 37 | # --aux-dir=build-aux \ 38 | # --no-conditional-dependencies \ 39 | # --no-libtool \ 40 | # --macro-prefix=gl \ 41 | # alloca \ 42 | # btowc \ 43 | # configmake \ 44 | # fnmatch \ 45 | # ftruncate \ 46 | # getcwd \ 47 | # getopt-gnu \ 48 | # git-version-gen \ 49 | # mbswidth \ 50 | # mkdir \ 51 | # poll \ 52 | # sockets \ 53 | # strdup-posix \ 54 | # strerror \ 55 | # times 56 | 57 | # Specification in the form of a few gnulib-tool.m4 macro invocations: 58 | gl_LOCAL_DIR([gl]) 59 | gl_MODULES([ 60 | alloca 61 | btowc 62 | configmake 63 | fnmatch 64 | ftruncate 65 | getcwd 66 | getopt-gnu 67 | git-version-gen 68 | mbswidth 69 | mkdir 70 | poll 71 | sockets 72 | strdup-posix 73 | strerror 74 | times 75 | ]) 76 | gl_AVOID([]) 77 | gl_SOURCE_BASE([lib]) 78 | gl_M4_BASE([m4]) 79 | gl_PO_BASE([]) 80 | gl_DOC_BASE([doc]) 81 | gl_TESTS_BASE([tests]) 82 | gl_LIB([libgnu]) 83 | gl_MAKEFILE_NAME([]) 84 | gl_MACRO_PREFIX([gl]) 85 | gl_PO_DOMAIN([]) 86 | gl_WITNESS_C_MACRO([]) 87 | -------------------------------------------------------------------------------- /bootstrap.conf: -------------------------------------------------------------------------------- 1 | # Bootstrap configuration. 2 | 3 | # Copyright (C) 2006-2015 Free Software Foundation, Inc. 4 | 5 | # This program is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3 of the License, or 8 | # (at your option) any later version. 9 | 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | 19 | # gnulib modules used by this package. 20 | gnulib_modules=" 21 | configmake 22 | alloca 23 | btowc 24 | fnmatch 25 | ftruncate 26 | getcwd 27 | getopt-gnu 28 | git-version-gen 29 | mbswidth 30 | mkdir 31 | poll 32 | sockets 33 | strdup 34 | strerror 35 | strtol 36 | times 37 | " 38 | 39 | # Additional xgettext options to use. Use "\\\newline" to break lines. 40 | XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\ 41 | --from-code=UTF-8\\\ 42 | --flag=asprintf:2:c-format --flag=vasprintf:2:c-format\\\ 43 | --flag=asnprintf:3:c-format --flag=vasnprintf:3:c-format\\\ 44 | --flag=wrapf:1:c-format\\\ 45 | ' 46 | 47 | # If "AM_GNU_GETTEXT(external" or "AM_GNU_GETTEXT([external]" 48 | # appears in configure.ac, exclude some unnecessary files. 49 | # Without grep's -E option (not portable enough, pre-configure), 50 | # the following test is ugly. Also, this depends on the existence 51 | # of configure.ac, not the obsolescent-named configure.in. But if 52 | # you're using this infrastructure, you should care about such things. 53 | 54 | gettext_external=0 55 | grep '^[ ]*AM_GNU_GETTEXT(external\>' configure.ac > /dev/null && 56 | gettext_external=1 57 | grep '^[ ]*AM_GNU_GETTEXT(\[external\]' configure.ac > /dev/null && 58 | gettext_external=1 59 | 60 | if test $gettext_external = 1; then 61 | # Gettext supplies these files, but we don't need them since 62 | # we don't have an intl subdirectory. 63 | excluded_files=' 64 | m4/glibc2.m4 65 | m4/intdiv0.m4 66 | m4/lcmessage.m4 67 | m4/lock.m4 68 | m4/printf-posix.m4 69 | m4/size_max.m4 70 | m4/uintmax_t.m4 71 | m4/ulonglong.m4 72 | m4/visibility.m4 73 | m4/xsize.m4 74 | ' 75 | fi 76 | 77 | # Build prerequisites 78 | buildreq="\ 79 | autoconf 2.59 80 | automake 1.9.6 81 | git 1.5.5 82 | tar - 83 | " 84 | 85 | checkout_only_file=.travis.yml 86 | gnulib_name=libgnu 87 | -------------------------------------------------------------------------------- /src/colormnu.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1998 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include "edit.h" 24 | #include "colormnu.h" 25 | #include "options.h" 26 | #ifdef HAVE_ALLOCA_H 27 | #include 28 | #endif 29 | 30 | void ColorsSaveToFile(const char *f) 31 | { 32 | DescribeColors(bw_pal,color_pal); 33 | SaveConfToFile(f,colors); 34 | } 35 | 36 | static const char *const colors_file="/.le/colors"; 37 | void ColorsSave() 38 | { 39 | unsigned nbytes=strlen(HOME)+strlen(colors_file)+1; 40 | char *f=(char*)alloca(nbytes); 41 | snprintf(f,nbytes,"%s%s",HOME,colors_file); 42 | ColorsSaveToFile(f); 43 | } 44 | 45 | void ColorsSaveForTerminal() 46 | { 47 | unsigned nbytes=strlen(HOME)+strlen(colors_file)+1+strlen(TERM)+1; 48 | char *f=(char*)alloca(nbytes); 49 | snprintf(f,nbytes,"%s%s-%s",HOME,colors_file,TERM); 50 | ColorsSaveToFile(f); 51 | } 52 | 53 | void LoadColor(const char *f) 54 | { 55 | if(access(f,R_OK)==-1) 56 | { 57 | FError(f); 58 | return; 59 | } 60 | ReadConfFromFile(f,colors,false); 61 | ParseColors(); 62 | init_attrs(); 63 | clearok(stdscr,1); 64 | flag=REDISPLAY_ALL; 65 | } 66 | 67 | void LoadColorDefault() 68 | { 69 | memcpy(color_pal,default_color_pal,sizeof(default_color_pal)); 70 | memcpy(bw_pal,default_bw_pal,sizeof(default_bw_pal)); 71 | init_attrs(); 72 | #if !defined(NCURSES_VERSION_PATCH) || NCURSES_VERSION_PATCH<980627 73 | clearok(stdscr,1); 74 | #endif 75 | flag=REDISPLAY_ALL; 76 | } 77 | 78 | void LoadColorDefaultBG() 79 | { 80 | LoadColor(PKGDATADIR"/colors-defbg"); 81 | } 82 | void LoadColorBlue() 83 | { 84 | LoadColor(PKGDATADIR"/colors-blue"); 85 | } 86 | void LoadColorBlack() 87 | { 88 | LoadColor(PKGDATADIR"/colors-black"); 89 | } 90 | void LoadColorWhite() 91 | { 92 | LoadColor(PKGDATADIR"/colors-white"); 93 | } 94 | void LoadColorGreen() 95 | { 96 | LoadColor(PKGDATADIR"/colors-green"); 97 | } 98 | -------------------------------------------------------------------------------- /m4/.gitignore: -------------------------------------------------------------------------------- 1 | /00gnulib.m4 2 | /alloca.m4 3 | /btowc.m4 4 | /chdir-long.m4 5 | /close.m4 6 | /closedir.m4 7 | /codeset.m4 8 | /configmake.m4 9 | /d-ino.m4 10 | /dirent_h.m4 11 | /dirfd.m4 12 | /double-slash-root.m4 13 | /dup.m4 14 | /dup2.m4 15 | /errno_h.m4 16 | /error.m4 17 | /extensions.m4 18 | /extern-inline.m4 19 | /fchdir.m4 20 | /fcntl-o.m4 21 | /fcntl.m4 22 | /fcntl_h.m4 23 | /fdopendir.m4 24 | /filenamecat.m4 25 | /fnmatch.m4 26 | /fstat.m4 27 | /fstatat.m4 28 | /ftruncate.m4 29 | /getcwd-abort-bug.m4 30 | /getcwd-path-max.m4 31 | /getcwd.m4 32 | /getdtablesize.m4 33 | /getopt.m4 34 | /gnulib-common.m4 35 | /gnulib-comp.m4 36 | /gnulib-tool.m4 37 | /include_next.m4 38 | /largefile.m4 39 | /libunistring-base.m4 40 | /localcharset.m4 41 | /locale-fr.m4 42 | /locale-ja.m4 43 | /locale-zh.m4 44 | /lstat.m4 45 | /malloc.m4 46 | /mbrtowc.m4 47 | /mbsinit.m4 48 | /mbsrtowcs.m4 49 | /mbstate_t.m4 50 | /mbswidth.m4 51 | /mbtowc.m4 52 | /memchr.m4 53 | /mempcpy.m4 54 | /memrchr.m4 55 | /mkdir.m4 56 | /mmap-anon.m4 57 | /mode_t.m4 58 | /msvc-inval.m4 59 | /msvc-nothrow.m4 60 | /multiarch.m4 61 | /nocrash.m4 62 | /off_t.m4 63 | /open.m4 64 | /openat.m4 65 | /opendir.m4 66 | /pathmax.m4 67 | /poll.m4 68 | /poll_h.m4 69 | /readdir.m4 70 | /realloc.m4 71 | /rewinddir.m4 72 | /save-cwd.m4 73 | /select.m4 74 | /signal_h.m4 75 | /socketlib.m4 76 | /sockets.m4 77 | /socklen.m4 78 | /sockpfaf.m4 79 | /ssize_t.m4 80 | /stat.m4 81 | /stdalign.m4 82 | /stddef_h.m4 83 | /stdint.m4 84 | /stdlib_h.m4 85 | /strdup.m4 86 | /strerror.m4 87 | /string_h.m4 88 | /sys_select_h.m4 89 | /sys_socket_h.m4 90 | /sys_stat_h.m4 91 | /sys_time_h.m4 92 | /sys_times_h.m4 93 | /sys_types_h.m4 94 | /sys_uio_h.m4 95 | /time_h.m4 96 | /times.m4 97 | /unistd_h.m4 98 | /warn-on-use.m4 99 | /wchar_h.m4 100 | /wctype_h.m4 101 | /wcwidth.m4 102 | /wint_t.m4 103 | /absolute-header.m4 104 | /stdio_h.m4 105 | /getprogname.m4 106 | /builtin-expect.m4 107 | /flexmember.m4 108 | /limits-h.m4 109 | /malloca.m4 110 | /open-cloexec.m4 111 | /fnmatch_h.m4 112 | /stat-time.m4 113 | /locale_h.m4 114 | /open-slash.m4 115 | /setlocale_null.m4 116 | /threadlib.m4 117 | /__inline.m4 118 | /inttypes.m4 119 | /isblank.m4 120 | /pid_t.m4 121 | /std-gnu11.m4 122 | /strnlen.m4 123 | /visibility.m4 124 | /wmemchr.m4 125 | /wmempcpy.m4 126 | /zzgnulib.m4 127 | /ctype_h.m4 128 | /free.m4 129 | /assert_h.m4 130 | /c-bool.m4 131 | /vararrays.m4 132 | /build-to-host.m4 133 | /error_h.m4 134 | /inline.m4 135 | /iswblank.m4 136 | /iswctype.m4 137 | /iswdigit.m4 138 | /iswpunct.m4 139 | /iswxdigit.m4 140 | /mbrtoc32.m4 141 | /musl.m4 142 | /uchar_h.m4 143 | /unicase_h.m4 144 | /unictype_h.m4 145 | /uninorm_h.m4 146 | /wctype.m4 147 | /c32rtomb.m4 148 | /extensions-aix.m4 149 | /locale-en.m4 150 | /off64_t.m4 151 | /sys_cdefs_h.m4 152 | -------------------------------------------------------------------------------- /misc/check-mainmenu: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | #################### 4 | # Copyright (C) 2014 by Raphael Geissert 5 | # 6 | # This file is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This file is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this file If not, see . 18 | # 19 | # On Debian systems, the complete text of the GNU General 20 | # Public License 3 can be found in '/usr/share/common-licenses/GPL-3'. 21 | #################### 22 | 23 | use warnings; 24 | use strict; 25 | 26 | # recursive function 27 | sub parse_submenu; 28 | 29 | sub should_skip; 30 | sub is_submenu; 31 | sub is_function; 32 | sub get_shortcut; 33 | 34 | our $found_error = 0; 35 | 36 | # there's a main, implicit, menu so start over there: 37 | parse_submenu('main'); 38 | 39 | exit($found_error); 40 | 41 | sub parse_submenu { 42 | my $this_submenu = shift; 43 | my %shortcuts; 44 | 45 | while (<>) { 46 | chomp; 47 | s/^\s+//; 48 | next if should_skip($_); 49 | 50 | if (is_submenu($_) || is_function($_)) { 51 | my $text = get_text($_); 52 | my $short = get_shortcut($text); 53 | 54 | if ($short && exists($shortcuts{$short})) { 55 | print STDERR "error: shortcut '$short' of '$this_submenu' menu already in use\n"; 56 | print STDERR "\tfirst declared on line $shortcuts{$short}, collision on line $.\n"; 57 | $found_error = 1; 58 | } elsif ($short) { 59 | $shortcuts{$short} = $.; 60 | } 61 | 62 | if (is_submenu($_)) { 63 | parse_submenu($text); 64 | } 65 | } elsif ($_ eq 'end') { 66 | return; 67 | } elsif ($_ eq 'hline') { 68 | next; 69 | } else { 70 | die ('error: unknown item found'); 71 | } 72 | } 73 | } 74 | 75 | sub should_skip { 76 | my $l = shift; 77 | return (length($l) == 0 || $l =~ m/^#/); 78 | } 79 | 80 | sub is_submenu { 81 | my $l = shift; 82 | return ($l =~ m/^submenu/); 83 | } 84 | 85 | sub is_function { 86 | my $l = shift; 87 | return ($l =~ m/^function/); 88 | } 89 | 90 | sub get_text { 91 | my $l = shift; 92 | $l =~ m/"(.*?)"/; 93 | return ($1 || ''); 94 | } 95 | 96 | sub get_shortcut { 97 | my $l = shift; 98 | $l =~ m/&(.)/; 99 | return uc($1 || ''); 100 | } 101 | -------------------------------------------------------------------------------- /src/history.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-1997 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #undef lines 20 | #undef cols 21 | 22 | #define HISTORY_LINE_LEN 256 23 | #define HISTORY_SIZE 128 24 | 25 | class HistoryLine 26 | { 27 | int len; 28 | char *line; 29 | time_t cr_time; 30 | friend class History; 31 | 32 | public: 33 | HistoryLine(); 34 | HistoryLine(const HistoryLine &h); 35 | HistoryLine(const HistoryLine *h); 36 | HistoryLine(const char *s,unsigned short len=0); 37 | 38 | bool equals(const char *s,int n) const { return(len==n && !memcmp(line,s,len)); } 39 | bool operator!=(const HistoryLine &h) const { return !equals(h.line,h.len); } 40 | const HistoryLine& operator=(const HistoryLine&); 41 | 42 | const char *get_line() const { return line; } 43 | int get_len() const { return len; } 44 | }; 45 | 46 | class History 47 | { 48 | protected: 49 | HistoryLine **lines; 50 | int curr; 51 | 52 | public: 53 | History(); 54 | 55 | void Open(); 56 | const HistoryLine *Next(); 57 | const HistoryLine *Prev(); 58 | const HistoryLine *Curr(); 59 | void operator+=(const HistoryLine&); 60 | void operator-=(const HistoryLine&); 61 | void operator+=(const HistoryLine *h) { *this+=*h; } 62 | void operator-=(const HistoryLine *h) { *this-=*h; } 63 | void Push(); 64 | void ReadFrom(FILE*); 65 | void WriteTo(FILE*); 66 | void Merge(const History& h); 67 | }; 68 | 69 | class InodeInfo 70 | { 71 | ino_t inode; 72 | dev_t device; 73 | time_t time; 74 | size_t size; 75 | 76 | public: 77 | num line,col,offset; 78 | 79 | InodeInfo(struct stat *st,num line=0,num col=0,num o=0); 80 | InodeInfo(const HistoryLine *line); 81 | InodeInfo(); 82 | 83 | int SameFile(const InodeInfo&) const; 84 | int SameFileModified(const InodeInfo&) const; 85 | int SameAndOlder(const InodeInfo&) const; 86 | 87 | const char *to_string() const; 88 | const char *key() const; 89 | }; 90 | 91 | class InodeHistory : public History 92 | { 93 | public: 94 | int FindInodeIndex(const InodeInfo&); 95 | const InodeInfo *FindInode(const InodeInfo&); 96 | void operator+=(const InodeInfo&); 97 | }; 98 | -------------------------------------------------------------------------------- /src/window.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-2005 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef WINDOW_H 20 | #define WINDOW_H 21 | 22 | #ifdef USE_MULTIBYTE_CHARS 23 | #define win_cell cchar_t 24 | # ifdef CURSES_CCHAR_MAX // NetBSD 25 | #define win_cell_set_attrs(ch,a) (ch)->attributes=((ch)->attributes&A_ALTCHARSET)|((a)&~(A_CHARTEXT|A_ALTCHARSET)) 26 | # else // ncurses 27 | #define win_cell_set_attrs(ch,a) (ch)->attr=((ch)->attr&A_ALTCHARSET)|((a)&~(A_CHARTEXT|A_ALTCHARSET)) 28 | # endif 29 | #define scr_get_cell(y,x,out) mvin_wch(y,x,out) 30 | #define scr_put_cell(y,x,ch) mvadd_wchnstr(y,x,ch,1) 31 | #else 32 | #define win_cell chtype 33 | #define win_cell_set_attrs(ch,a) (*ch)=((*ch)&(A_CHARTEXT|A_ALTCHARSET))|((a)&~(A_CHARTEXT|A_ALTCHARSET)) 34 | #define scr_get_cell(y,x,out) (*out)=mvinch(y,x) 35 | #define scr_put_cell(y,x,ch) mvaddch(y,x,*(ch)) 36 | #endif 37 | 38 | typedef struct win 39 | { 40 | win_cell *buf; 41 | int x,y; 42 | int w,h; 43 | int clip_x; 44 | const attr *a; 45 | const char *title; 46 | struct win *prev; 47 | int flags; 48 | } WIN; 49 | 50 | #define SIGN 0x1000 51 | #define FRIGHT 0x2000 52 | #define MIDDLE 0x4000 53 | #define FDOWN FRIGHT 54 | 55 | /* window flags */ 56 | #define NOSHADOW 1 57 | 58 | WIN *CreateWin(int x,int y,unsigned w,unsigned h,const attr *a, 59 | const char *title,int flags=0); 60 | void DisplayWin(WIN *); 61 | void CloseWin(); 62 | void DestroyWin(WIN *); 63 | 64 | void Absolute(int *x,int width,int field); 65 | void GotoXY(int x,int y); 66 | void Clear(); 67 | void PutStr(int x,int y,const char *s); 68 | void PutCh(int x,int y,chtype ch); 69 | #ifdef USE_MULTIBYTE_CHARS 70 | void PutWCh(int x,int y,wchar_t ch); 71 | void PutCCh(int x,int y,cchar_t *ch); 72 | # define PutACS(x,y,a) do { int x0=(x),y0=(y);\ 73 | if(mb_mode) PutCCh(x0,y0,WACS_##a);\ 74 | else PutCh(x0,y0,ACS_##a); } while(0) 75 | #else 76 | # define PutWCh(x,y,c) PutCh((x),(y),(c)) 77 | # define PutACS(x,y,a) PutCh((x),(y),ACS_##a) 78 | #endif 79 | 80 | extern const struct attr *curr_attr; 81 | extern WIN *Upper; 82 | 83 | static inline void SetAttr(const struct attr *a) 84 | { 85 | curr_attr=a; 86 | attrset(a->n_attr); 87 | } 88 | 89 | #endif /* WINDOW_H */ 90 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_CXX_FLAGS "-O2 -Wall -Wwrite-strings -Woverloaded-virtual -Wno-invalid-source-encoding -fno-exceptions -fno-rtti -fno-implement-inlines") 2 | 3 | add_definitions(-DVERSION="${CMAKE_PROJECT_VERSION}") 4 | add_definitions(-DPKGDATADIR="${CMAKE_INSTALL_PREFIX}/share/le") 5 | 6 | include(FindNcursesw.cmake) 7 | 8 | add_custom_command( 9 | OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/action-enum.h 10 | COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/make-action-enum.pl 11 | ${CMAKE_CURRENT_SOURCE_DIR}/action-name-func 12 | > ${CMAKE_CURRENT_BINARY_DIR}/action-enum.h 13 | DEPENDS make-action-enum.pl action-name-func 14 | ) 15 | add_custom_command( 16 | OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/action-name-func.h 17 | COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/make-action-name-func.pl 18 | ${CMAKE_CURRENT_SOURCE_DIR}/action-name-func 19 | > ${CMAKE_CURRENT_BINARY_DIR}/action-name-func.h 20 | DEPENDS make-action-name-func.pl action-name-func 21 | ) 22 | add_custom_command( 23 | OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/keymap-default.h 24 | COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/make-keymap.pl 25 | ${CMAKE_SOURCE_DIR}/misc/keymap-default 26 | > ${CMAKE_CURRENT_BINARY_DIR}/keymap-default.h 27 | DEPENDS make-keymap.pl ../misc/keymap-default 28 | ) 29 | add_custom_command( 30 | OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mainmenu-default.h 31 | COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/make-mainmenu.pl 32 | ${CMAKE_SOURCE_DIR}/misc/mainmenu-default 33 | > ${CMAKE_CURRENT_BINARY_DIR}/mainmenu-default.h 34 | DEPENDS make-mainmenu.pl ../misc/mainmenu-default 35 | ) 36 | 37 | include(make-config.cmake) 38 | 39 | add_executable(le 40 | about.cc 41 | block.cc 42 | calc.cc 43 | chset.cc 44 | cmd.cc 45 | color.cc 46 | edit.cc 47 | editcalc.cc 48 | ext.cc 49 | file.cc 50 | format.cc 51 | frames.cc 52 | getch.cc 53 | getstr.cc 54 | help.cc 55 | history.cc 56 | kern.cc 57 | keymap.cc 58 | keymapdf.cc 59 | keymapfn.cc 60 | loadsave.cc 61 | mainmenu.cc 62 | menu.cc 63 | menu1.cc 64 | options.cc 65 | pipe.cc 66 | rus.cc 67 | screen.cc 68 | search.cc 69 | signals.cc 70 | tables.cc 71 | textpoin.cc 72 | user.cc 73 | window.cc 74 | highli.cc 75 | clipbrd.cc 76 | keynames.cc 77 | mouse.cc 78 | colormnu.cc 79 | bm.cc 80 | mb.cc 81 | undo.cc 82 | regex.c 83 | wcwidth.c 84 | wcwidth1.c 85 | ../gnulib/localcharset.c 86 | action-enum.h 87 | action-name-func.h 88 | keymap-default.h 89 | mainmenu-default.h 90 | ) 91 | target_include_directories(le PUBLIC 92 | . 93 | ../lib 94 | ../gnulib 95 | ${CMAKE_CURRENT_BINARY_DIR} 96 | ${CURSES_INCLUDE_DIRS} 97 | ) 98 | target_link_libraries(le ${CURSES_LIBRARIES}) 99 | install(TARGETS le DESTINATION bin) 100 | 101 | install(FILES le.hlp DESTINATION ${CMAKE_INSTALL_PREFIX}/share/le) 102 | -------------------------------------------------------------------------------- /src/keymapfn.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-2000 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include "edit.h" 23 | #include "keymap.h" 24 | 25 | #include "block.h" 26 | #include "options.h" 27 | #include "keymap.h" 28 | #include "format.h" 29 | #include "search.h" 30 | #include "colormnu.h" 31 | 32 | void EditorReadKeymap() 33 | { 34 | char filename[1024]; 35 | FILE *f; 36 | 37 | snprintf(filename,sizeof(filename),"%s/.le/keymap-%s",HOME,TERM); 38 | f=fopen(filename,"r"); 39 | if(f==NULL) 40 | { 41 | snprintf(filename,sizeof(filename),"%s/keymap-%s",PKGDATADIR,TERM); 42 | f=fopen(filename,"r"); 43 | if(f==NULL) 44 | { 45 | snprintf(filename,sizeof(filename),"%s/.le/keymap",HOME); 46 | f=fopen(filename,"r"); 47 | if(f==NULL) 48 | { 49 | snprintf(filename,sizeof(filename),"%s/keymap",PKGDATADIR); 50 | f=fopen(filename,"r"); 51 | if(f==NULL) 52 | return; 53 | } 54 | } 55 | } 56 | 57 | errno=0; 58 | ReadActionMap(f); 59 | if(errno) 60 | { 61 | FError(filename); 62 | } 63 | 64 | fclose(f); 65 | } 66 | 67 | void LoadKeymapEmacs() 68 | { 69 | const char *k=PKGDATADIR"/keymap-emacs"; 70 | FILE *f=fopen(k,"r"); 71 | if(!f) 72 | { 73 | FError(k); 74 | return; 75 | } 76 | ReadActionMap(f); 77 | fclose(f); 78 | RebuildKeyTree(); 79 | LoadMainMenu(); 80 | } 81 | void LoadKeymapDefault() 82 | { 83 | FreeActionCodeTable(); 84 | ActionCodeTable=DefaultActionCodeTable; 85 | RebuildKeyTree(); 86 | LoadMainMenu(); 87 | } 88 | void SaveKeymap() 89 | { 90 | char filename[1024]; 91 | FILE *f; 92 | 93 | snprintf(filename,sizeof(filename),"%s/.le/keymap",HOME); 94 | f=fopen(filename,"w"); 95 | if(!f) 96 | { 97 | FError(filename); 98 | return; 99 | } 100 | WriteActionMap(f); 101 | fclose(f); 102 | } 103 | void SaveKeymapForTerminal() 104 | { 105 | char filename[1024]; 106 | FILE *f; 107 | 108 | snprintf(filename,sizeof(filename),"%s/.le/keymap-%s",HOME,TERM); 109 | f=fopen(filename,"w"); 110 | if(!f) 111 | { 112 | FError(filename); 113 | return; 114 | } 115 | WriteActionMap(f); 116 | fclose(f); 117 | } 118 | -------------------------------------------------------------------------------- /src/keymap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-1997 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef KEYMAP_H 20 | #define KEYMAP_H 21 | 22 | #include "action-enum.h" 23 | 24 | // some compatibility defines 25 | #define CHAR_LEFT A_BACKWARD_CHAR 26 | #define CHAR_RIGHT A_FORWARD_CHAR 27 | #define LINE_UP A_PREVIOUS_LINE 28 | #define LINE_DOWN A_NEXT_LINE 29 | #define LINE_BEGIN A_BEGINNING_OF_LINE 30 | #define LINE_END A_END_OF_LINE 31 | #define CANCEL A_ESCAPE 32 | #define QUIT_EDITOR A_ESCAPE 33 | #define A_QUIT_EDITOR A_ESCAPE 34 | #define NEWLINE A_NEW_LINE 35 | #define NEXT_PAGE A_NEXT_PAGE 36 | #define PREV_PAGE A_PREVIOUS_PAGE 37 | #define EDITOR_HELP A_HELP 38 | #define REFRESH_SCREEN A_REFRESH_SCREEN 39 | #define BACKSPACE_CHAR A_BACKWARD_DELETE_CHAR 40 | #define DELETE_CHAR A_DELETE_CHAR 41 | #define DELETE_TO_EOL A_DELETE_TO_EOL 42 | #define CHOOSE_CHAR A_CHOOSE_CHARACTER 43 | #define ENTER_CHAR_CODE A_INSERT_CHAR_BY_CODE 44 | #define ENTER_WCHAR_CODE A_INSERT_WCHAR_BY_CODE 45 | #define ENTER_CONTROL_CHAR A_QUOTED_INSERT 46 | #define ENTER_MENU A_ENTER_MENU 47 | #define SAVE_FILE A_SAVE_FILE_AS 48 | #define SAVE_FILE_AS A_SAVE_FILE 49 | 50 | typedef void (*ActionProc)(); 51 | 52 | struct ActionNameProcRec 53 | { 54 | const char *name; 55 | ActionProc proc; 56 | }; 57 | 58 | struct ActionCodeRec 59 | { 60 | int action; 61 | char *code; 62 | char *arg; 63 | }; 64 | 65 | extern unsigned char StringTyped[]; 66 | extern int StringTypedLen; 67 | extern int LastActionCode; 68 | extern const char *ActionArgument; 69 | extern int ActionArgumentLen; 70 | extern const ActionCodeRec *ActionCodeTable; 71 | extern const ActionCodeRec DefaultActionCodeTable[]; 72 | 73 | int GetNextAction(void); 74 | const char *GetActionString(int action); 75 | const char *GetActionArgument(const char *prompt,class History* history=0,const char *help=0,const char *title=0); 76 | void ReadActionMap(FILE*); 77 | void WriteActionMap(FILE*); 78 | ActionProc GetActionProc(int action); 79 | void EditorReadKeymap(); 80 | void RebuildKeyTree(); 81 | void FreeActionCodeTable(); 82 | 83 | int FindActionCode(const char *); 84 | int ParseActionNameArg(char *action,const char **arg); 85 | char *ParseActionArgumentAlloc(const char *); 86 | 87 | const char *ShortcutPrettyPrint(int c,const char *arg); 88 | 89 | void LoadKeymapEmacs(); 90 | void LoadKeymapDefault(); 91 | void SaveKeymap(); 92 | void SaveKeymapForTerminal(); 93 | 94 | #endif /* KEYMAP_H */ 95 | -------------------------------------------------------------------------------- /src/about.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-2019 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include 20 | #include "edit.h" 21 | #include "about.h" 22 | 23 | WIN *about_window; 24 | 25 | const char version_string[]="Text editor LE version " VERSION; 26 | const char copyright[]="Copyright (C) 1993-2021 by Alexander V. Lukyanov"; 27 | 28 | void ShowAbout() 29 | { 30 | if(about_window) 31 | return; 32 | 33 | about_window=CreateWin(MIDDLE,MIDDLE,69,22,DIALOGUE_WIN_ATTR," About ",0); 34 | DisplayWin(about_window); 35 | 36 | PutStr(MIDDLE,2,"Text editor LE"); 37 | PutStr(MIDDLE,3,"Version " VERSION); 38 | PutStr(MIDDLE,5,copyright); 39 | PutStr(MIDDLE,6,"E-Mail: " EMAIL); 40 | 41 | PutStr(MIDDLE,8,"LE is free software: you can redistribute it and/or modify it"); 42 | PutStr(MIDDLE,9,"under the terms of the GNU General Public License as published by"); 43 | PutStr(MIDDLE,10,"the Free Software Foundation, either version 3 of the License, or"); 44 | PutStr(MIDDLE,11,"(at your option) any later version."); 45 | 46 | PutStr(MIDDLE,13,"This program is distributed in the hope that it will be useful,"); 47 | PutStr(MIDDLE,14,"but WITHOUT ANY WARRANTY; without even the implied warranty of"); 48 | PutStr(MIDDLE,15,"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"); 49 | PutStr(MIDDLE,16,"GNU General Public License for more details."); 50 | 51 | PutStr(MIDDLE,18,"You should have received a copy of the GNU General Public License"); 52 | PutStr(MIDDLE,19,"along with LE. If not, see ."); 53 | } 54 | 55 | void HideAbout() 56 | { 57 | if(!about_window) 58 | return; 59 | CloseWin(); 60 | DestroyWin(about_window); 61 | about_window=NULL; 62 | } 63 | 64 | void PrintVersion() 65 | { 66 | printf("%s - %s\n%s <%s>\n\n%s",Program,version_string,copyright,EMAIL, 67 | "LE is free software: you can redistribute it and/or modify it\n" 68 | "under the terms of the GNU General Public License as published by\n" 69 | "the Free Software Foundation, either version 3 of the License, or\n" 70 | "(at your option) any later version.\n" 71 | "\n" 72 | "This program is distributed in the hope that it will be useful,\n" 73 | "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" 74 | "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" 75 | "GNU General Public License for more details.\n" 76 | "\n" 77 | "You should have received a copy of the GNU General Public License\n" 78 | "along with LE. If not, see .\n"); 79 | } 80 | -------------------------------------------------------------------------------- /misc/gnulib.patch: -------------------------------------------------------------------------------- 1 | diff --git a/lib/uniwidth.in.h b/lib/uniwidth.in.h 2 | index e67f2a1..ba4e630 100644 3 | --- a/lib/uniwidth.in.h 4 | +++ b/lib/uniwidth.in.h 5 | @@ -41,6 +41,13 @@ extern int 6 | uc_width (ucs4_t uc, const char *encoding) 7 | _UC_ATTRIBUTE_PURE; 8 | 9 | +extern int 10 | + uc_width1 (ucs4_t uc) 11 | +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) 12 | + __attribute__ ((__pure__)) 13 | +#endif 14 | + ; 15 | + 16 | /* Determine number of column positions required for first N units 17 | (or fewer if S ends before this) in S. */ 18 | extern int 19 | diff --git a/lib/uniwidth/width.c b/lib/uniwidth/width.c 20 | index 9e6758a..b4305b5 100644 21 | --- a/lib/uniwidth/width.c 22 | +++ b/lib/uniwidth/width.c 23 | @@ -412,7 +412,7 @@ static const signed char nonspacing_table_ind[248] = { 24 | 25 | /* Determine number of column positions required for UC. */ 26 | int 27 | -uc_width (ucs4_t uc, const char *encoding) 28 | +uc_width1 (ucs4_t uc) 29 | { 30 | /* Test for non-spacing or control character. */ 31 | if ((uc >> 9) < 248) 32 | @@ -459,10 +459,17 @@ uc_width (ucs4_t uc, const char *encoding) 33 | || (uc >= 0x30000 && uc <= 0x3ffff) /* Tertiary Ideographic Plane */ 34 | ) ) 35 | return 2; 36 | + return 1; 37 | +} 38 | + 39 | +int 40 | +uc_width (ucs4_t uc, const char *encoding) 41 | +{ 42 | + int w = uc_width1 (uc); 43 | /* In ancient CJK encodings, Cyrillic and most other characters are 44 | double-width as well. */ 45 | if (uc >= 0x00A1 && uc < 0xFF61 && uc != 0x20A9 46 | - && is_cjk_encoding (encoding)) 47 | + && w == 1 && is_cjk_encoding (encoding)) 48 | return 2; 49 | - return 1; 50 | + return w; 51 | } 52 | diff --git a/lib/wcwidth.c b/lib/wcwidth.c 53 | index 1f081cc..54994c1 100644 54 | --- a/lib/wcwidth.c 55 | +++ b/lib/wcwidth.c 56 | @@ -59,7 +59,7 @@ wcwidth (wchar_t wc) 57 | { 58 | /* We assume that in a UTF-8 locale, a wide character is the same as a 59 | Unicode character. */ 60 | - return uc_width (wc, "UTF-8"); 61 | + return uc_width1 (wc); 62 | } 63 | else 64 | { 65 | diff --git a/m4/wcwidth.m4 b/m4/wcwidth.m4 66 | index cb5935a..a38bd8f 100644 67 | --- a/m4/wcwidth.m4 68 | +++ b/m4/wcwidth.m4 69 | @@ -53,6 +53,7 @@ AC_DEFUN([gl_FUNC_WCWIDTH], 70 | dnl On OpenBSD 5.0, wcwidth(0x05B0) (HEBREW POINT SHEVA) returns 1. 71 | dnl On OSF/1 5.1, wcwidth(0x200B) (ZERO WIDTH SPACE) returns 1. 72 | dnl On OpenBSD 5.8, wcwidth(0xFF1A) (FULLWIDTH COLON) returns 0. 73 | + dnl On Solaris 8, wcwidth(0x2022) (BULLET) returns 2. 74 | dnl This leads to bugs in 'ls' (coreutils). 75 | dnl On Solaris 11.4, wcwidth(0x2202) (PARTIAL DIFFERENTIAL) returns 2, 76 | dnl even in Western locales. 77 | @@ -82,7 +83,8 @@ int wcwidth (int); 78 | int main () 79 | { 80 | int result = 0; 81 | - if (setlocale (LC_ALL, "en_US.UTF-8") != NULL) 82 | + if (setlocale (LC_ALL, "fr_FR.UTF-8") != NULL 83 | + || setlocale (LC_ALL, "en_US.UTF-8") != NULL) 84 | { 85 | if (wcwidth (0x0301) > 0) 86 | result |= 1; 87 | @@ -92,6 +94,8 @@ int main () 88 | result |= 4; 89 | if (wcwidth (0xFF1A) == 0) 90 | result |= 8; 91 | + if (wcwidth (0x2022) != 1) 92 | + result |= 16; 93 | if (wcwidth (0x2202) > 1) 94 | result |= 16; 95 | } 96 | -------------------------------------------------------------------------------- /src/textpoin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-2021 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef TEXTPOINT_H 20 | #define TEXTPOINT_H 21 | 22 | #include 23 | 24 | #define COLUNDEFINED 1 25 | #define LINEUNDEFINED 2 26 | #define CHAR_SPLIT 4 27 | 28 | class TextPoint 29 | { 30 | offs offset; 31 | num line,col; 32 | int flags; 33 | static TextPoint cached_array[]; 34 | static int cached_array_ptr; 35 | 36 | TextPoint *next; 37 | static TextPoint *base; 38 | 39 | void AddTextPoint(); 40 | void DeleteTextPoint(); 41 | 42 | void FindOffset(); 43 | void FindLineCol(); 44 | 45 | void Init() { 46 | offset=line=col=flags=0; 47 | } 48 | 49 | public: 50 | offs Offset() const 51 | { 52 | return(offset); 53 | } 54 | num Line(); 55 | num Col(); 56 | 57 | num LineSimple() const 58 | { 59 | if(flags&LINEUNDEFINED) 60 | return -1; 61 | return(line); 62 | } 63 | num ColSimple() const 64 | { 65 | if(flags&(COLUNDEFINED|LINEUNDEFINED)) 66 | return -1; 67 | return(col); 68 | } 69 | 70 | TextPoint(); 71 | TextPoint(offs); 72 | TextPoint(num,num); 73 | TextPoint(const TextPoint&); 74 | TextPoint(offs,num,num); 75 | 76 | void CacheTextPoint() const; 77 | 78 | ~TextPoint(); 79 | 80 | const TextPoint& operator=(const TextPoint& tp) 81 | { 82 | offset=tp.offset; 83 | line=tp.line; 84 | col=tp.col; 85 | flags=tp.flags; 86 | return(*this); 87 | } 88 | const TextPoint& operator+=(num shift); 89 | const TextPoint& operator-=(num shift) 90 | { 91 | return(*this+=-shift); 92 | } 93 | operator offs() const 94 | { 95 | return(offset); 96 | } 97 | 98 | static TextPoint ForcedLineCol(num l,num c); 99 | 100 | static void ResetTextPoints(); 101 | static void OrFlags(int mask); 102 | static void CheckSplit(offs,offs); 103 | 104 | friend int InsertBlock(const char *,num,const char *,num); 105 | friend int DeleteBlock(num,num); 106 | friend int ReplaceBlock(const char *,num); 107 | 108 | void Check() const {}; 109 | }; 110 | 111 | extern TextPoint CurrentPos; 112 | extern TextPoint ScreenTop; 113 | extern TextPoint BlockBegin; 114 | extern TextPoint BlockEnd; 115 | extern TextPoint TextEnd; 116 | extern TextPoint TextBegin; 117 | 118 | #define ScrPtr ScreenTop.Offset() 119 | #define ScrLine ScreenTop.Line() 120 | 121 | #endif 122 | -------------------------------------------------------------------------------- /src/rus.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-1997 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include 20 | #include "edit.h" 21 | #include "rus.h" 22 | 23 | int coding=0; 24 | 25 | int isrussian(byte ch) 26 | { 27 | switch(coding) 28 | { 29 | case(KOI8): 30 | return(ch>=0xC0); 31 | case(D211_KOI): 32 | return(ch>=0xC0 && ch!=0xFF && ch!=0xDF); 33 | case(JO_ALT): 34 | return((ch>=0x80 && ch<0xB0) || (ch>=0xE0 && ch<0xF2)); 35 | case(ALT): 36 | return((ch>=0x80 && ch<0xB0) || (ch>=0xE0 && ch<0xF0)); 37 | case(MAIN): 38 | return(ch>=0xB0 && ch<0xF2); 39 | } 40 | return(0); 41 | } 42 | int islowerrus(byte ch) 43 | { 44 | switch(coding) 45 | { 46 | case(KOI8): 47 | return(ch>=0xC0 && ch<0xE0); 48 | case(D211_KOI): 49 | return(ch>=0xE0 && ch<0xFF); 50 | case(JO_ALT): 51 | return((ch>=0xA0 && ch<0xB0) || (ch>=0xE0 && ch<0xF1)); 52 | case(ALT): 53 | return((ch>=0xA0 && ch<0xB0) || (ch>=0xE0 && ch<0xF0)); 54 | case(MAIN): 55 | return(ch>=0xD0 && ch<0xF1); 56 | } 57 | return(0); 58 | } 59 | int isupperrus(byte ch) 60 | { 61 | switch(coding) 62 | { 63 | case(KOI8): 64 | return(ch>=0xE0); 65 | case(D211_KOI): 66 | return(ch>=0xC0 && ch<0xDF); 67 | case(JO_ALT): 68 | return((ch>=0x80 && ch<0xA0) || ch==0xF1); 69 | case(ALT): 70 | return(ch>=0x80 && ch<0xA0); 71 | case(MAIN): 72 | return((ch>=0xB0 && ch<0xD0) || ch==0xF1); 73 | } 74 | return(0); 75 | } 76 | byte tolowerrus(byte ch) 77 | { 78 | if(!isupperrus(ch)) 79 | return(ch); 80 | 81 | switch(coding) 82 | { 83 | case(KOI8): 84 | return(ch-0x20); 85 | case(D211_KOI): 86 | return(ch+0x20); 87 | case(JO_ALT): 88 | if(ch==0xF0) 89 | return(0xF1); 90 | case(ALT): 91 | if(ch>=0x80 && ch<0x90) 92 | return(ch+0x20); 93 | return(ch+0x50); 94 | case(MAIN): 95 | if(ch==0xF0) 96 | return(0xF1); 97 | return(ch+0x20); 98 | } 99 | return(ch); 100 | } 101 | byte toupperrus(byte ch) 102 | { 103 | if(!islowerrus(ch)) 104 | return(ch); 105 | 106 | switch(coding) 107 | { 108 | case(KOI8): 109 | return(ch+0x20); 110 | case(D211_KOI): 111 | return(ch-0x20); 112 | case(JO_ALT): 113 | if(ch==0xF1) 114 | return(0xF0); 115 | case(ALT): 116 | if(ch>=0xE0 && ch<0xF0) 117 | return(ch-0x50); 118 | return(ch-0x20); 119 | case(MAIN): 120 | if(ch==0xF1) 121 | return(0xF0); 122 | return(ch-0x20); 123 | } 124 | return(ch); 125 | } 126 | -------------------------------------------------------------------------------- /src/undo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "edit.h" 20 | #include 21 | 22 | class Undo 23 | { 24 | struct GroupHead 25 | { 26 | offs pos; 27 | num stdcol; 28 | offs block_begin; 29 | offs block_end; 30 | bool block_hide; 31 | 32 | GroupHead(); 33 | void Undo(); 34 | }; 35 | class Change 36 | { 37 | friend class Undo; 38 | unsigned group; 39 | GroupHead *group_head; 40 | Change *next; 41 | Change *prev; 42 | bool Join(const Change *); 43 | protected: 44 | enum type_t { INSERT, DELETE, REPLACE } type; 45 | offs pos; 46 | char *left; 47 | num left_size; 48 | char *right; 49 | num right_size; 50 | bool old_modified; 51 | public: 52 | Change(type_t t,const char *l,num ls,const char *r,num rs); 53 | ~Change() { free(left); free(right); } 54 | size_t GetSize() 55 | { 56 | return (left?left_size:0) 57 | +(right?right_size:0) 58 | +(group_head?sizeof(*group_head):0) 59 | +sizeof(Change); 60 | } 61 | void Undo(); 62 | void Redo(); 63 | }; 64 | 65 | Change *chain_head; 66 | Change *chain_ptr; 67 | Change *chain_tail; 68 | int group_open; 69 | unsigned current_group; 70 | GroupHead *group_head; 71 | 72 | bool locked; 73 | bool enabled; 74 | 75 | time_t last_change_time; 76 | 77 | bool glue_changes; 78 | int glue_max_time; 79 | num max_size; 80 | int min_groups; 81 | 82 | void CheckSize(); 83 | 84 | public: 85 | struct Delete : public Change { 86 | Delete(const char *l,num ls,const char *r,num rs) : Change(DELETE,l,ls,r,rs) {} }; 87 | struct Insert : public Change { 88 | Insert(const char *l,num ls,const char *r,num rs) : Change(INSERT,l,ls,r,rs) {} }; 89 | struct Replace : public Change { 90 | Replace(const char *l,num ls,const char *r,num rs) : Change(REPLACE,l,ls,r,rs) {} }; 91 | 92 | void BeginUndoGroup(); 93 | void AddChange(Change *); 94 | void EndUndoGroup(); 95 | 96 | void UndoGroup(); 97 | void RedoGroup(); 98 | void UndoOne(); 99 | void RedoOne(); 100 | void FileSaved(); 101 | 102 | void Clear(); 103 | 104 | Undo(); 105 | ~Undo(); 106 | 107 | bool Enabled() { return enabled&&!locked; } 108 | bool Locked() { return locked; } 109 | 110 | void SetMaxSize(num ms) { max_size=ms; } 111 | void SetMinGroups(int mg) { min_groups=mg; } 112 | void SetEnable(bool en) { if(enabled!=en) Clear(); enabled=en; } 113 | void SetGlue(bool g) { glue_changes=g; } 114 | }; 115 | 116 | extern Undo undo; 117 | -------------------------------------------------------------------------------- /src/make-config.cmake: -------------------------------------------------------------------------------- 1 | include(CheckIncludeFile) 2 | include(CheckSymbolExists) 3 | 4 | set(CONFIG ${CMAKE_CURRENT_BINARY_DIR}/config.h) 5 | 6 | file(WRITE ${CONFIG} "// DO NOT EDIT THIS FILE MANUALLY! It's generated by cmake.\n") 7 | 8 | # Define to enable multibyte support. 9 | file(APPEND ${CONFIG} "#define USE_MULTIBYTE_CHARS 1\n") 10 | 11 | # Define to 1 if you have the header file. 12 | check_include_file("unistd.h" HAVE_UNISTD_H) 13 | if(HAVE_UNISTD_H) 14 | file(APPEND ${CONFIG} "#define HAVE_UNISTD_H 1\n") 15 | endif() 16 | 17 | # Define to 1 if you have the header file, and it defines `DIR'. 18 | check_include_file("dirent.h" HAVE_DIRENT_H) 19 | if(HAVE_DIRENT_H) 20 | file(APPEND ${CONFIG} "#define HAVE_DIRENT_H 1\n") 21 | endif() 22 | 23 | # Define to 1 if you have the header file. 24 | check_include_file("linux/tiocl.h" HAVE_LINUX_TIOCL_H) 25 | if(HAVE_LINUX_TIOCL_H) 26 | file(APPEND ${CONFIG} "#define HAVE_LINUX_TIOCL_H 1\n") 27 | endif() 28 | 29 | # Define to 1 if you have and it should be used (not on Ultrix). 30 | check_include_file("alloca.h" HAVE_ALLOCA_H) 31 | if(HAVE_ALLOCA_H) 32 | file(APPEND ${CONFIG} "#define HAVE_ALLOCA_H 1\n") 33 | endif() 34 | 35 | # Define to 1 if you have the header file. 36 | check_include_file("sys/ioctl.h" HAVE_SYS_IOCTL_H) 37 | if(HAVE_SYS_IOCTL_H) 38 | file(APPEND ${CONFIG} "#define HAVE_SYS_IOCTL_H 1\n") 39 | endif() 40 | 41 | # Define to 1 if you have the header file. 42 | check_include_file("sys/mman.h" HAVE_SYS_MMAN_H) 43 | if(HAVE_SYS_MMAN_H) 44 | file(APPEND ${CONFIG} "#define HAVE_SYS_MMAN_H 1\n") 45 | endif() 46 | 47 | # Define to 1 if you have the header file. 48 | check_include_file("sys/mount.h" HAVE_SYS_MOUNT_H) 49 | if(HAVE_SYS_MOUNT_H) 50 | file(APPEND ${CONFIG} "#define HAVE_SYS_MOUNT_H 1\n") 51 | endif() 52 | 53 | # Define to 1 if you have the header file. 54 | check_include_file("sys/param.h" HAVE_SYS_PARAM_H) 55 | if(HAVE_SYS_PARAM_H) 56 | file(APPEND ${CONFIG} "#define HAVE_SYS_PARAM_H 1\n") 57 | endif() 58 | 59 | # Define to 1 if you have the header file. 60 | check_include_file("sys/syslimits.h" HAVE_SYS_SYSLIMITS_H) 61 | if(HAVE_SYS_SYSLIMITS_H) 62 | file(APPEND ${CONFIG} "#define HAVE_SYS_SYSLIMITS_H 1\n") 63 | endif() 64 | 65 | # Define to 1 if you have the header file. 66 | check_include_file("sys/times.h" HAVE_SYS_TIMES_H) 67 | if(HAVE_SYS_TIMES_H) 68 | file(APPEND ${CONFIG} "#define HAVE_SYS_TIMES_H 1\n") 69 | endif() 70 | 71 | # Define to 1 if you have the `fchmod' function. 72 | check_symbol_exists(fchmod "sys/stat.h" HAVE_FCHMOD) 73 | if(HAVE_FCHMOD) 74 | file(APPEND ${CONFIG} "#define HAVE_FCHMOD 1\n") 75 | endif() 76 | 77 | # Define to 1 if you have the `ftruncate' function. 78 | check_symbol_exists(ftruncate "unistd.h" HAVE_FTRUNCATE) 79 | if(HAVE_FTRUNCATE) 80 | file(APPEND ${CONFIG} "#define HAVE_FTRUNCATE 1\n") 81 | endif() 82 | 83 | # Define to 1 if you have the `mmap' function. 84 | check_symbol_exists(mmap "sys/mman.h" HAVE_MMAP) 85 | if(HAVE_MMAP) 86 | file(APPEND ${CONFIG} "#define HAVE_MMAP 1\n") 87 | endif() 88 | 89 | # Define to 1 if you have the `times' function. 90 | check_symbol_exists(times "sys/times.h" HAVE_TIMES) 91 | if(HAVE_TIMES) 92 | file(APPEND ${CONFIG} "#define HAVE_TIMES 1\n") 93 | endif() 94 | 95 | # Define to 1 if you have the `strcoll' function and it is properly defined. 96 | check_symbol_exists(strcoll "string.h" HAVE_STRCOLL) 97 | if(HAVE_STRCOLL) 98 | file(APPEND ${CONFIG} "#define HAVE_STRCOLL 1\n") 99 | endif() 100 | 101 | # Define if you have and nl_langinfo(CODESET). 102 | check_include_file("langinfo.h" HAVE_LANGINFO_H) 103 | check_symbol_exists(nl_langinfo "langinfo.h" HAVE_NL_LANGINFO) 104 | if(HAVE_LANGINFO_H AND HAVE_NL_LANGINFO) 105 | file(APPEND ${CONFIG} "#define HAVE_LANGINFO_CODESET 1\n") 106 | endif() 107 | -------------------------------------------------------------------------------- /src/inline.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-2004 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | static inline 20 | byte CharAt(offs offset) 21 | { 22 | if(offset>=ptr1) 23 | offset+=GapSize; 24 | if(offset>=0 && offset=ptr1) 33 | offset+=GapSize; 34 | return(buffer[offset]); 35 | } 36 | static inline 37 | offs Size() 38 | { 39 | return(BufferSize-GapSize); 40 | } 41 | static inline 42 | offs Offset() 43 | { 44 | return(CurrentPos.Offset()); 45 | } 46 | static inline 47 | int Eof() 48 | { 49 | return(Offset()>=Size()); 50 | } 51 | static inline 52 | int EofAt(offs o) 53 | { 54 | return(o>=Size()); 55 | } 56 | static inline 57 | int Bof() 58 | { 59 | return(Offset()<=0); 60 | } 61 | static inline 62 | int BofAt(offs o) 63 | { 64 | return(o<=0); 65 | } 66 | static inline 67 | byte Char() 68 | { 69 | return(CharAt(Offset())); 70 | } 71 | static inline 72 | byte CharRel(offs sh) 73 | { 74 | return(CharAt(Offset()+sh)); 75 | } 76 | static inline 77 | byte CharRel_NoCheck(offs sh) 78 | { 79 | return(CharAt_NoCheck(Offset()+sh)); 80 | } 81 | static inline 82 | bool IsAlNumRel(offs sh) 83 | { 84 | return IsAlNumAt(Offset()+sh); 85 | } 86 | 87 | #include "mb.h" 88 | 89 | static inline 90 | bool IsAlNumLeft() 91 | { 92 | return IsAlNumAt(Offset()-CharSizeLeft()); 93 | } 94 | static inline 95 | void MoveRight() 96 | { 97 | CurrentPos+=1; 98 | } 99 | static inline 100 | void MoveLeft() 101 | { 102 | CurrentPos-=1; 103 | } 104 | static inline 105 | num GetLine() 106 | { 107 | return(CurrentPos.Line()); 108 | } 109 | static inline 110 | bool le_isspace(int c) 111 | { 112 | return c==' ' || c=='\t'; 113 | } 114 | static inline 115 | bool Space() 116 | { 117 | return le_isspace(WChar()); 118 | } 119 | static inline 120 | bool SpaceLeft() 121 | { 122 | return le_isspace(WCharLeft()); 123 | } 124 | static inline 125 | bool SpaceLeftAt(offs pos) 126 | { 127 | return le_isspace(WCharLeftAt(pos)); 128 | } 129 | 130 | static inline bool BlockEqLeftAt(offs o,const char *s,int len) { return BlockEqAt(o-len,s,len); } 131 | static inline bool BlockEq(const char *s,int len) { return BlockEqAt(Offset(),s,len); } 132 | static inline bool BlockEqLeft(const char *s,int len) { return BlockEqLeftAt(Offset(),s,len); } 133 | 134 | static inline int xstrcmp(const char *s1,const char *s2) 135 | { 136 | if(s1==s2) 137 | return 0; 138 | if(s1==0 || s2==0) 139 | return 1; 140 | return strcmp(s1,s2); 141 | } 142 | static inline int xstrncmp(const char *s1,const char *s2,size_t len) 143 | { 144 | if(s1==s2 || len==0) 145 | return 0; 146 | if(s1==0 || s2==0) 147 | return 1; 148 | return strncmp(s1,s2,len); 149 | } 150 | static inline int xstrcasecmp(const char *s1,const char *s2) 151 | { 152 | if(s1==s2) 153 | return 0; 154 | if(s1==0 || s2==0) 155 | return 1; 156 | return strcasecmp(s1,s2); 157 | } 158 | static inline size_t xstrlen(const char *s) 159 | { 160 | if(s==0) 161 | return 0; 162 | return strlen(s); 163 | } 164 | -------------------------------------------------------------------------------- /src/mb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003-2015 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef MB_H 20 | #define MB_H 21 | 22 | #ifdef USE_MULTIBYTE_CHARS 23 | #include 24 | #include 25 | 26 | extern bool mb_mode; 27 | extern int MBCharSize; 28 | extern int MBCharWidth; 29 | extern bool MBCharInvalid; 30 | extern bool MBCharSplit; 31 | 32 | [[nodiscard]] bool MBCheckLeftAt(offs o); 33 | [[nodiscard]] bool MBCheckAt(offs o); 34 | wchar_t WCharAt(offs o); 35 | wchar_t WCharLeftAt(offs o); 36 | void InsertWChar(wchar_t ch); 37 | wchar_t WCharAtLC(num,num); 38 | wchar_t getcode_wchar(); 39 | wchar_t choose_wch(); 40 | void ReplaceWCharExt(wchar_t); 41 | void ReplaceWCharExtMove(wchar_t); 42 | void ReplaceWCharMove(wchar_t); 43 | 44 | [[nodiscard]] static inline bool MBCheckRight() { return MBCheckAt(Offset()); } 45 | [[nodiscard]] static inline bool MBCheckLeft() { return MBCheckLeftAt(Offset()); } 46 | static inline int CharWidthAt(offs o) { return MBCheckAt(o) ? MBCharWidth : 1; } 47 | static inline int CharSizeAt(offs o) { return MBCheckAt(o) ? MBCharSize : 1; } 48 | static inline int CharSizeLeftAt(offs o) { return MBCheckLeftAt(o) ? MBCharSize : 1; } 49 | static inline int CharSize() { return CharSizeAt(Offset()); } 50 | static inline int CharWidth() { return CharWidthAt(Offset()); } 51 | static inline int CharSizeLeft() { return CharSizeLeftAt(Offset()); } 52 | static inline int WChar() { return WCharAt(Offset()); } 53 | static inline int WCharLeft() { return WCharLeftAt(Offset()); } 54 | 55 | void mb_get_col(const char *buf,int pos,int *col,int len); 56 | void mb_char_left(const char *buf,int *pos,int *col,int len); 57 | void mb_char_right(const char *buf,int *pos,int *col,int len); 58 | int mb_get_pos_for_col(const char *buf,int width,int len); 59 | int mb_len(const char *buf,int len); 60 | wchar_t mb_to_wc(const char *buf,int len,int *ch_len,int *ch_width); 61 | 62 | #else 63 | # define mb_mode (false) 64 | # define MBCheckLeft() (false) 65 | # define MBCheckLeftAt(o) (false) 66 | # define MBCheckAt(o) (false) 67 | # define MBCharSize (1) 68 | # define MBCharWidth (1) 69 | # define MBCharInvalid (false) 70 | # define MBCharSplit (false) 71 | # define MBCheckRight() (false) 72 | # define CharWidthAt(o) (1) 73 | # define CharSizeAt(o) (1) 74 | # define CharWidth() (1) 75 | # define CharSize() (1) 76 | # define WCharAt(o) CharAt((o)) 77 | # define WCharLeftAt(o) CharAt((o)-1) 78 | # define WCharLeft() CharRel(-1) 79 | # define WChar() Char() 80 | # define WCharAtLC(l,c) CharAtLC(l,c) 81 | # define getcode_wchar() getcode_char() 82 | # define choose_wch() choose_ch() 83 | # define InsertWChar(ch) InsertChar(ch) 84 | # define ReplaceWCharExt(c) ReplaceCharExt(c) 85 | # define ReplaceWCharExtMove(c) ReplaceCharExtMove(c) 86 | # define ReplaceWCharMove(c) ReplaceCharMove(c) 87 | # define mb_get_col(buf,pos,col,len) *(col)=(pos) 88 | # define mb_char_left(buf,pos,col,len) *(col)=--(*pos) 89 | # define mb_char_right(buf,pos,col,len) *(col)=++(*pos) 90 | # define mb_get_pos_for_col(buf,width,len) (width) 91 | # define mb_len(buf,len) (1) 92 | # define mb_to_wc(buf,len,ch_len,ch_width) (((ch_len)?*(ch_len)=1:0),((ch_width)?*(ch_width)=1:0),*(buf)) 93 | # include // avoid MB_LEN_MAX mismatch error 94 | # ifndef MB_CUR_MAX 95 | # define MB_CUR_MAX 1 96 | # define MB_LEN_MAX 1 97 | # endif 98 | #endif 99 | 100 | #endif//MB_H 101 | -------------------------------------------------------------------------------- /src/user.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-2012 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | /* functions, invoked with the keyboard by the user */ 20 | 21 | void UserDeleteToEol(); 22 | void UserDeleteLine(); 23 | void UserDeleteWord(); 24 | void UserForwardDeleteWord(); 25 | void UserBackwardDeleteWord(); 26 | 27 | void UserCopyFromDown(); 28 | void UserCopyFromUp(); 29 | 30 | void UserDeleteBlock(); 31 | void UserCopyBlock(); 32 | void UserMoveBlock(); 33 | void UserMarkWord(); 34 | void UserMarkLine(); 35 | void UserMarkToEol(); 36 | void UserMarkAll(); 37 | 38 | void UserLineUp(); 39 | void UserLineDown(); 40 | void UserScrollUp(); 41 | void UserScrollDown(); 42 | void UserCharLeft(); 43 | void UserCharRight(); 44 | void UserPageTop(); 45 | void UserPageUp(); 46 | void UserPageBottom(); 47 | void UserPageDown(); 48 | void UserWordLeft(); 49 | void UserWordRight(); 50 | void UserLineBegin(); 51 | void UserLineEnd(); 52 | 53 | void UserMarkCharLeft(); 54 | void UserMarkCharRight(); 55 | void UserMarkWordLeft(); 56 | void UserMarkWordRight(); 57 | void UserMarkLineBegin(); 58 | void UserMarkLineEnd(); 59 | void UserMarkFileBegin(); 60 | void UserMarkFileEnd(); 61 | void UserMarkPageDown(); 62 | void UserMarkPageUp(); 63 | void UserMarkPageTop(); 64 | void UserMarkPageBottom(); 65 | void UserMarkLineUp(); 66 | void UserMarkLineDown(); 67 | 68 | void UserMenu(); 69 | 70 | void UserCommentLine(); 71 | 72 | void UserSetBlockBegin(); 73 | void UserSetBlockEnd(); 74 | void UserFindBlockBegin(); 75 | void UserFindBlockEnd(); 76 | void UserPipeBlock(); 77 | 78 | void UserFileBegin(); 79 | void UserFileEnd(); 80 | 81 | void UserPreviousEdit(); 82 | 83 | void UserBackSpace(); 84 | void UserDeleteChar(); 85 | 86 | void UserLoad(); 87 | int UserSave(); 88 | void UserSwitch(); 89 | int UserSaveAs(); 90 | 91 | void UserInfo(); 92 | 93 | void UserToLineNumber(); 94 | void UserToOffset(); 95 | 96 | void UserIndent(); 97 | void UserUnindent(); 98 | 99 | void UserAutoindent(); 100 | void UserNewLine(); 101 | 102 | void UserUndelete(); 103 | void UserUndo(); 104 | void UserRedo(); 105 | void UserUndoStep(); 106 | void UserRedoStep(); 107 | 108 | void UserEnterControlChar(); 109 | 110 | void UserWordHelp(); 111 | void UserKeysHelp(); 112 | void UserAbout(); 113 | 114 | void UserRefreshScreen(); 115 | 116 | void UserChooseChar(); 117 | void UserChooseWChar(); 118 | void UserChooseByte(); 119 | void UserInsertCharCode(); 120 | void UserInsertWCharCode(); 121 | void UserInsertByteCode(); 122 | 123 | void UserInsertChar(char ch); 124 | void UserInsertControlChar(char ch); 125 | void UserReplaceChar(char ch); 126 | 127 | void UserSwitchHexMode(); 128 | void UserSwitchTextMode(); 129 | void UserSwitchInsertMode(); 130 | void UserSwitchAutoindentMode(); 131 | void UserSwitchRussianMode(); 132 | void UserSwitchGraphMode(); 133 | 134 | void UserBlockPrefixIndent(); 135 | 136 | void UserShellCommand(); 137 | 138 | void UserYankBlock(); 139 | void UserRememberBlock(); 140 | 141 | void UserStartDragMark(); 142 | void UserStopDragMark(); 143 | 144 | void UserOptimizeText(); 145 | 146 | void UserSetBookmark(); 147 | void UserGoBookmark(); 148 | 149 | #define S(n) void UserSetBookmark##n(); 150 | S(0) S(1) S(2) S(3) S(4) S(5) S(6) S(7) S(8) S(9) 151 | #undef S 152 | #define G(n) void UserGoBookmark##n(); 153 | G(0) G(1) G(2) G(3) G(4) G(5) G(6) G(7) G(8) G(9) 154 | #undef G 155 | 156 | extern class History ShellHistory; 157 | extern class History PipeHistory; 158 | -------------------------------------------------------------------------------- /src/mouse.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-2012 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include 20 | 21 | #ifdef WITH_MOUSE 22 | 23 | #include "edit.h" 24 | #include "screen.h" 25 | #include "mouse.h" 26 | #include "block.h" 27 | 28 | int UseMouse=true; 29 | 30 | bool InTextWin(int line,int col) 31 | { 32 | return (col>=TextWinX && line>=TextWinY 33 | && col-TextWinX=ScrollBarX && line>=TextWinY 39 | && col-ScrollBarX<1 && line-TextWinY=AsciiPos) 50 | { 51 | ascii=1; 52 | col-=AsciiPos; 53 | } 54 | else 55 | col=(col-HexPos)/3; 56 | if(col>=16) 57 | col=15; 58 | CurrentPos=ScreenTop+16*(line-TextWinY)+col; 59 | } 60 | else 61 | { 62 | CurrentPos=TextPoint(line-TextWinY+ScreenTop.Line(), 63 | stdcol=col-TextWinX+ScrShift); 64 | } 65 | } 66 | 67 | void MouseInTextWin(MEVENT &mev) 68 | { 69 | // printf("\rbstate=0%lo \n\r",mev.bstate); 70 | switch(mev.bstate) 71 | { 72 | case BUTTON1_CLICKED: 73 | MoveToScreenLC(mev.y,mev.x); 74 | break; 75 | case BUTTON1_DOUBLE_CLICKED: 76 | MoveToScreenLC(mev.y,mev.x); 77 | UserMarkWord(); 78 | break; 79 | case BUTTON1_TRIPLE_CLICKED: 80 | MoveToScreenLC(mev.y,mev.x); 81 | UserMarkLine(); 82 | break; 83 | case BUTTON2_CLICKED: 84 | MoveToScreenLC(mev.y,mev.x); 85 | UserCopyBlock(); 86 | break; 87 | case BUTTON2_DOUBLE_CLICKED: 88 | MoveToScreenLC(mev.y,mev.x); 89 | UserMoveBlock(); 90 | break; 91 | case BUTTON3_CLICKED: 92 | MoveToScreenLC(mev.y,mev.x); 93 | if(hide) 94 | UserSetBlockBegin(); 95 | if(CurrentPos>(BlockBegin+BlockEnd)/2) 96 | { 97 | UserSetBlockEnd(); 98 | if(DragMark) 99 | *DragMark=BlockBegin; 100 | } 101 | else 102 | { 103 | UserSetBlockBegin(); 104 | if(DragMark) 105 | *DragMark=BlockEnd; 106 | } 107 | break; 108 | case BUTTON1_PRESSED: 109 | mousemask(ALL_MOUSE_EVENTS|REPORT_MOUSE_POSITION,0); 110 | MoveToScreenLC(mev.y,mev.x); 111 | if(!DragMark) 112 | UserStartDragMark(); 113 | break; 114 | case BUTTON1_RELEASED: 115 | mousemask(ALL_MOUSE_EVENTS,0); 116 | MoveToScreenLC(mev.y,mev.x); 117 | if(DragMark) 118 | { 119 | ProcessDragMark(); 120 | UserStopDragMark(); 121 | } 122 | break; 123 | case BUTTON4_PRESSED: 124 | case BUTTON4_CLICKED: 125 | UserScrollUp(); 126 | break; 127 | #ifdef BUTTON5_PRESSED 128 | case BUTTON5_PRESSED: 129 | case BUTTON5_CLICKED: 130 | #else 131 | // hack for old ncurses mouse ABI 132 | case 0x80: 133 | case 0x8000000: 134 | #endif 135 | UserScrollDown(); 136 | break; 137 | } 138 | } 139 | 140 | void MouseInScrollBar(MEVENT &mev) 141 | { 142 | int pos=mev.y-TextWinY; 143 | switch(mev.bstate) 144 | { 145 | case BUTTON1_CLICKED: 146 | if(pos>ScrollBarPos) 147 | UserPageDown(); 148 | else if(pos 3 | 4 | Перепробовал я с десяток текстмордовых редакторов под *NIX, но удобнее 5 | le ничего не нашел. Первым делом я настроил цвета, чтоб радовали глаз. 6 | А вторым - назначение клавиш для более комфортной работы. 7 | (хотя сам стиль группировки комбинаций клавиш сделан достаточно 8 | понятно и легко запоминается - некоторые из них мне хотелось бы 9 | переназначить). И как оказалось сделать это достаточно просто. 10 | 11 | Вначале необходимо получить файл текущих комбинаций: 12 | le --dump-keymap > ~/.le/keymap , а затем отредактировать его по вкусу. 13 | комментарии в этом файле не предусмотрены, но учитывая, что ошибочные 14 | строки просто игнорируются для комментария можно использовать 15 | классический символ "#". 16 | Названия ключевых слов достаточно ясно описывают выполняемую данной 17 | комбинацией функцию. Для выполнения одной и той же функции можно наз- 18 | начить несколько комбинаций клавиш указав несколько раз ключевое 19 | слово. 20 | Теперь об обозначении комбинаций клавиш: 21 | для начала (по старой русской традиции) желательно ознакомиться с 22 | информацией о терминале (man terminfo, vi /etc/termcap) - это 23 | позволит не только получить описание различных клавиш, но и поможет 24 | разобраться в ситуациях когда что-то не получается. 25 | Для назначения действию клавиши достаточно добавить символ "$" к 26 | ее Cap-name'у: 27 | 28 | Пример описания клавиш в terminfo: 29 | Variable Cap- TCap Description 30 | Numeric name Code 31 | key_f6 kf6 k6 F6 function key 32 | key_f7 kf7 k7 F7 function key 33 | key_f8 kf8 k8 F8 function key 34 | key_f9 kf9 k9 F9 function key 35 | key_home khome kh home key 36 | 37 | И вот как это выглядит в keymap: 38 | beginning-of-line $khome 39 | copy-block $kf5 40 | move-block $kf6 41 | search-forward $kf7 42 | 43 | Комбинации с клавишей Ctrl выглядят как обычно, с добавлением символа 44 | "^". Нижеуказанные комбинации означают одновременное нажатие клавиши 45 | Ctrl и соотв. буквы: 46 | delete-line ^Y 47 | undelete ^U 48 | new-line ^J 49 | 50 | Последовательное нажатие клавиш обозначается символом "|": 51 | switch-autoindent-mode ^A|A 52 | switch-russian-mode ^A|R 53 | данные сокращения обозначают одновременное нажатие Ctrl и A, 54 | и после того как отпустили - клавиша R. 55 | 56 | !!! Замечание: в данном случае регистр последней клавиши имеет 57 | значение, т.е. чтобы однозначно идентифицировать команду с комбинацией 58 | вне зависимости от регистра нужно указать данную последовательность 59 | следующим образом: 60 | switch-russian-mode ^A|R 61 | switch-russian-mode ^A|r 62 | 63 | Клавиша Esc обозначается "\e" (без кавычек). Пример использования: 64 | beginning-of-file \e|$khome 65 | end-of-file \e|$kend 66 | 67 | Нижеуказанные комбинации означают, что команда будет выполнена 68 | как при одновременном нажатии указанных клавиш, так и с паузой 69 | приблизительно в одну секунду между последовательным нажатием 70 | этих клавиш: 71 | start-drag-mark ${kf4}V 72 | mark-all ${kf4}A 73 | 74 | Для обозначения комбинаций можно использовать модификаторы: 75 | $1 - shift, $2 - control, $3 - shift+control или alt, которые 76 | добавляются перед кодом клавиш: 77 | switch-file $1kf3 78 | start-replace $2kf7 79 | compile $3kf9 80 | 81 | Ну, и в добавок ко всему этому многообразию можно непосредственно 82 | указывать Esc-последовательности (например, когда вы не можете найти 83 | Cap-name нужной клавиши). Esc-код можно узнать если запустить cat 84 | и нажать соотв. клавишу (в некоторых случаях перед этим нужно сделать 85 | `tput smkx'). 86 | Например, cat выдает такой код ^[[I (как известно, ^[ - это код 87 | символа Esc), то в keymap нужно записать (с учетом замены ^[ на \e) 88 | следующее: \e[I Например: 89 | mark-beginning-of-file \eO6H 90 | mark-end-of-file \eO6F 91 | mark-next-page \e[6;2~ 92 | mark-previous-page \e[5;2~ 93 | 94 | ----------------------------------------------------------------- 95 | Замечание: 96 | - не всегда удается назначить нужной комбинации нужную функцию - 97 | иногда это определено в termcap, а иногда некоторые комбинации 98 | выдают один и тот же код, как например PageUp и Ctrl-PageUp. 99 | 100 | Желаю творческих успехов!!! 101 | 102 | Благодарности: 103 | - автору программы Александру Лукьянову ("Alexander V. Lukyanov" 104 | ) за столь дивную программу и помощь в ее 105 | настройке. 106 | - разработчикам FreeBSD за замечательную операционную систему :)) 107 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | dnl Process this file with autoconf to produce a configure script. 2 | AC_INIT([le],m4_esyscmd([build-aux/git-version-gen .tarball-version]),[le@uniyar.ac.ru]) 3 | AC_CONFIG_AUX_DIR([build-aux]) 4 | AC_CONFIG_MACRO_DIR([m4]) 5 | AC_CONFIG_LIBOBJ_DIR([lib]) 6 | AC_CONFIG_SRCDIR([src/edit.cc]) 7 | AM_INIT_AUTOMAKE 8 | AC_CONFIG_HEADERS([lib/config.h]) 9 | 10 | AC_ARG_ENABLE([file-locks], 11 | AC_HELP_STRING([--disable-file-locks],[disable file locking]), 12 | [enable_file_locks=$enableval],[enable_file_locks=yes]) 13 | if test "x$enable_file_locks" = xno; then 14 | AC_DEFINE([DISABLE_FILE_LOCKS], 1, [define if file locking does not work or is not desirable]) 15 | fi 16 | 17 | AC_ARG_WITH([default-eol], 18 | AC_HELP_STRING([--with-default-eol=EOL],[set the default EOL string (NL,CRNL,CR)]), 19 | [AC_DEFINE_UNQUOTED([DEFAULT_EOL], ["$withval"], [The default EOL string (NL,CRNL,CR)])]) 20 | 21 | test -z "$CXX" && DEFAULT_CXX=yes 22 | test -z "$CFLAGS" && DEFAULT_CFLAGS=yes 23 | test -z "$CXXFLAGS" && DEFAULT_CXXFLAGS=yes 24 | 25 | dnl Checks for programs. 26 | AC_PROG_CC 27 | gl_EARLY 28 | AC_PROG_CXX 29 | CXX_DYNAMIC_INITIALIZERS 30 | AC_PROG_LN_S 31 | AC_PROG_RANLIB 32 | AC_PATH_PROG(PERL,perl) 33 | 34 | AC_SYS_LARGEFILE 35 | 36 | AC_ARG_WITH([debug], 37 | AC_HELP_STRING([--with-debug],[enable debug info]), 38 | [ with_debug=$withval; ], 39 | [ with_debug=no; ]) 40 | 41 | AC_ARG_WITH(profiling, 42 | AS_HELP_STRING([--with-profiling], [enable profiling]), 43 | [ with_profiling=$withval; ], 44 | [ with_profiling=no; ]) 45 | 46 | 47 | if test x$with_debug = xno; then 48 | if test x$DEFAULT_CFLAGS = xyes; then 49 | CFLAGS="`echo $CFLAGS | sed 's/-g//'`" 50 | if test -z "$CFLAGS"; then 51 | CFLAGS=-O 52 | fi 53 | fi 54 | if test x$DEFAULT_CXXFLAGS = xyes; then 55 | CXXFLAGS="`echo $CXXFLAGS | sed 's/-g//'`" 56 | if test -z "$CXXFLAGS"; then 57 | CXXFLAGS=-O 58 | fi 59 | fi 60 | fi 61 | 62 | if test x$with_profiling = xyes; then 63 | CFLAGS="$CFLAGS -pg" 64 | CXXFLAGS="$CXXFLAGS -pg" 65 | # profiling requires debugging, too, but don't nuke -O 66 | # if test x$with_debug != xyes; then 67 | # CFLAGS="$CFLAGS -g" 68 | # CXXFLAGS="$CXXFLAGS -g" 69 | # fi 70 | fi 71 | 72 | if test x$GCC = xyes; then 73 | CFLAGS="$CFLAGS -Wall" 74 | fi 75 | if test x$GXX = xyes; then 76 | CXXFLAGS="$CXXFLAGS -Wall -Wwrite-strings -Woverloaded-virtual" 77 | # save some bytes 78 | LFTP_CHECK_CXX_FLAGS([-fno-exceptions -fno-rtti]) 79 | # check for -fno-implement-inline (doesn't work without -O in gcc 2.95.4; functions are never inlined) 80 | if test x$with_debug = xno; then 81 | LFTP_NOIMPLEMENTINLINE 82 | fi 83 | fi 84 | 85 | gl_INIT 86 | 87 | if test x$ac_cv_func_wcwidth != xyes || test x$REPLACE_WCWIDTH = x1; then 88 | gl_LIBOBJ([wcwidth]) 89 | AC_DEFINE([REPLACE_WCWIDTH], 1, [Define when using wcwidth replacement]) 90 | fi 91 | 92 | # These are provided by gnulib (not if building with cmake) 93 | AC_DEFINE([HAVE_MBSWIDTH_H], 1, [Define if there is mbswidth.h]) 94 | AC_DEFINE([HAVE_CONFIGMAKE_H], 1, [Define if there is configmake.h]) 95 | 96 | dnl Checks for libraries. 97 | AC_CHECK_LIB(m, exp) 98 | 99 | dnl Checks for header files. 100 | AC_HEADER_DIRENT 101 | AC_HEADER_STDC 102 | AC_HEADER_SYS_WAIT 103 | AC_CHECK_HEADERS([sys/ioctl.h sys/mman.h sys/mount.h sys/syslimits.h sys/param.h]) 104 | AC_CHECK_HEADERS([linux/tiocl.h]) 105 | 106 | LE_PATH_CURSES 107 | if test x$no_curses = xyes 108 | then 109 | AC_MSG_ERROR(No curses found - aborting) 110 | fi 111 | 112 | CURSES_LIBS="" 113 | CURSES_INCLUDES="" 114 | if test x$curses_includes != x -a x$curses_includes != x/usr/include 115 | then 116 | CURSES_INCLUDES="-I$curses_includes" 117 | fi 118 | if test x$curses_libraries != x -a x$curses_libraries != x/usr/lib 119 | then 120 | CURSES_LIBS="-L$curses_libraries $CURSES_LIBS" 121 | fi 122 | if test x$with_ncurses = xyes 123 | then 124 | CURSES_LIBS="$CURSES_LIBS -lncurses" 125 | else 126 | CURSES_LIBS="$CURSES_LIBS -lcurses" 127 | fi 128 | if test x$use_libcursesw = xyes 129 | then 130 | CURSES_LIBS="${CURSES_LIBS}w" 131 | fi 132 | LE_TINFO_CHECK 133 | LE_CURSES_MOUSE 134 | LE_CURSES_BOOL 135 | dnl LE_NCURSES_BUGS 136 | LE_CURSES_WIDECHAR 137 | 138 | AC_SUBST(CURSES_LIBS) 139 | AC_SUBST(CURSES_INCLUDES) 140 | 141 | dnl Checks for typedefs, structures, and compiler characteristics. 142 | AC_C_CONST 143 | AC_TYPE_UID_T 144 | AC_TYPE_MODE_T 145 | AC_TYPE_SIZE_T 146 | AC_TYPE_UINTPTR_T 147 | AC_HEADER_TIME 148 | AC_STRUCT_TM 149 | 150 | dnl Checks for library functions. 151 | AC_PROG_GCC_TRADITIONAL 152 | AC_FUNC_STRCOLL 153 | AC_CHECK_FUNCS(mmap fchmod) 154 | 155 | AC_CONFIG_FILES([Makefile lib/Makefile src/Makefile misc/Makefile doc/Makefile m4/Makefile]) 156 | AC_CONFIG_FILES([le.spec]) 157 | AC_OUTPUT 158 | -------------------------------------------------------------------------------- /src/ext.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-2013 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include 20 | #include 21 | #include "edit.h" 22 | #include "undo.h" 23 | 24 | void ReplaceCharExtMove(byte ch) 25 | { 26 | if(Char()=='\t' && ch!='\t') 27 | ExpandTab(); 28 | InsertChar(ch); 29 | if(!Eol() || Bol()) 30 | DeleteChar(); 31 | } 32 | void ReplaceCharExt(byte ch) 33 | { 34 | ReplaceCharExtMove(ch); 35 | MoveLeft(); 36 | SetStdCol(); 37 | } 38 | void ReplaceWCharExtMove(wchar_t ch) 39 | { 40 | if(Char()=='\t' && ch!='\t') 41 | ExpandTab(); 42 | InsertWChar(ch); 43 | if(!Eol() || Bol()) 44 | DeleteChar(); 45 | } 46 | void ReplaceWCharExt(wchar_t ch) 47 | { 48 | ReplaceWCharExtMove(ch); 49 | MoveLeftOverEOL(); 50 | SetStdCol(); 51 | } 52 | 53 | void ExpandAllTabs() 54 | { 55 | num ol=GetLine(),oc=GetCol(); 56 | static struct menu EATmenu[]={ 57 | {" &Ok ",MIDDLE-6,FDOWN-2}, 58 | {" &Cancel ",MIDDLE+6,FDOWN-2}, 59 | {NULL}}; 60 | 61 | switch(ReadMenuBox(EATmenu,HORIZ,"ALL tab characters will be\nexpanded to spaces", 62 | " Verify ",VERIFY_WIN_ATTR,CURR_BUTTON_ATTR)) 63 | { 64 | case(0): 65 | case('C'): 66 | return; 67 | } 68 | MessageSync("Expanding..."); 69 | CurrentPos=TextBegin; 70 | while(!Eof()) 71 | { 72 | if(Char()=='\t') 73 | ExpandTab(); 74 | MoveRight(); 75 | } 76 | MoveLineCol(ol,oc); 77 | SetStdCol(); 78 | } 79 | 80 | void ExpandSpanTabs() 81 | { 82 | num ol=GetLine(),oc=GetCol(); 83 | static struct menu EATmenu[]={ 84 | {" &Ok ",MIDDLE-6,FDOWN-2}, 85 | {" &Cancel ",MIDDLE+6,FDOWN-2}, 86 | {NULL}}; 87 | 88 | switch(ReadMenuBox(EATmenu,HORIZ,"Spans of tab characters will be\nexpanded to spaces + one tab", 89 | " Verify ",VERIFY_WIN_ATTR,CURR_BUTTON_ATTR)) 90 | { 91 | case(0): 92 | case('C'): 93 | return; 94 | } 95 | MessageSync("Expanding..."); 96 | CurrentPos=TextBegin; 97 | while(!Eof()) 98 | { 99 | if(Char()=='\t' && CharRel(1)=='\t') 100 | ExpandTab(); 101 | MoveRight(); 102 | } 103 | MoveLineCol(ol,oc); 104 | SetStdCol(); 105 | } 106 | 107 | void ReplaceAll(const char *str1,const char *str2) 108 | { 109 | int len1=strlen(str1); 110 | int len2=strlen(str2); 111 | offs pos=0; 112 | for(;;) { 113 | pos=ScanForCharForward(pos,str1[0]); 114 | if(pos==-1) 115 | break; 116 | if(BlockEqAt(pos,str1,len1)) { 117 | CurrentPos=pos; 118 | DeleteBlock(0,len1); 119 | InsertBlock(str2,len2,NULL,0); 120 | pos+=len2; 121 | } else { 122 | ++pos; 123 | } 124 | } 125 | } 126 | 127 | void DOS_UNIX(void) 128 | { 129 | const char *TargetEol=(!EolIs(EOL_UNIX)?EOL_UNIX:EOL_DOS); 130 | 131 | num ol=GetLine(),oc=GetCol(); 132 | static struct menu YesNoCancel[]={ 133 | {" &Yes ",MIDDLE-10,FDOWN-2}, 134 | {" &No ",MIDDLE,FDOWN-2}, 135 | {" &Cancel ",MIDDLE+10,FDOWN-2}, 136 | {NULL}}; 137 | 138 | switch(ReadMenuBox(YesNoCancel,HORIZ,"Do you want to change EOLs?"," UNIX<->DOS ", 139 | VERIFY_WIN_ATTR,CURR_BUTTON_ATTR)) 140 | { 141 | case(0): 142 | case('C'): 143 | return; 144 | case('Y'): 145 | MessageSync("Changing EOLs between DOS and UNIX formats..."); 146 | undo.BeginUndoGroup(); 147 | CurrentPos=TextBegin; 148 | ReplaceAll(EolStr,TargetEol); 149 | SetEolStr(TargetEol); 150 | CurrentPos=TextBegin; 151 | ScrShift=0; 152 | ScreenTop=CurrentPos; 153 | TextPoint::OrFlags(COLUNDEFINED|LINEUNDEFINED); 154 | MoveLineCol(ol,oc); 155 | undo.EndUndoGroup(); 156 | break; 157 | case('N'): 158 | SetEolStr(TargetEol); 159 | CurrentPos=TextBegin; 160 | ScrShift=0; 161 | ScreenTop=CurrentPos; 162 | TextPoint::OrFlags(COLUNDEFINED|LINEUNDEFINED); 163 | } 164 | SetStdCol(); 165 | } 166 | 167 | int Suffix(const char *str,const char*pr) 168 | { 169 | int shift=strlen(str)-strlen(pr); 170 | 171 | return(shift>=0 && !strcmp(str+shift,pr)); 172 | } 173 | -------------------------------------------------------------------------------- /misc/ChangeLog: -------------------------------------------------------------------------------- 1 | 2013-10-01 Raphael Geissert 2 | 3 | * syntax: improve patch/diff syntax highlighting 4 | 5 | 2013-08-01 Raphael Geissert 6 | 7 | * syntax, syntax.d/golang, Makefile.am: add basic golang patterns. 8 | 9 | 2013-07-03 Raphael Geissert 10 | 11 | * syntax: Add missing syntax highlighting for some Debian control file fields. 12 | * syntax.d/sql: Add more SQL keywords used in MySQL and Oracle. 13 | 14 | 2013-05-30 Raphael Geissert 15 | 16 | * syntax: enable syntax highlighting to /usr/bin/python-like scripts. 17 | 18 | 2013-01-31 lav 19 | 20 | syntax.d/sql: more keywords 21 | synax: fixed empty comment in m4 22 | 23 | 2010-11-23 lav 24 | 25 | * syntax: add -*-autoconf-*- selector. 26 | 27 | 2010-11-08 lav 28 | 29 | * mainmenu: new function expand-tab-spans. 30 | 31 | 2009-07-10 Raphael Geissert 32 | 33 | * syntax: improve the syntax colouring regexes of the Debian control file mode. 34 | 35 | 2009-06-22 Raphael Geissert 36 | 37 | * mainmenu, mainmenu-ru: fixed typos. 38 | 39 | 2009-05-15 lav 40 | 41 | * syntax.d/html: fixed comment pattern. 42 | * syntax: improved makefile mode by including shell patterns. 43 | 44 | 2009-05-12 Raphael Geissert 45 | 46 | * syntax: Recognise files starting with ^diff; Colourise the whole added/removed lines, 47 | not just the symbols; s/Enhaces/Enhances; Fix an error related to active/passive caused 48 | by accident. 49 | 50 | 2008-10-07 lav 51 | 52 | * syntax: fixed tags. 53 | 54 | 2008-09-20 lav 55 | 56 | * syntax: speed optimize some patterns. 57 | 58 | 2008-09-02 Aldis Berjoza aka killasmurf86 59 | 60 | * syntax: added fvwm2 mode. 61 | 62 | 2008-08-18 Raphael Geissert 63 | 64 | * syntax: 65 | + Improved syntax highlighting for php. 66 | + Fixed an incorrect highlighting of $" in perl mode. 67 | + Fixed an incorrect highlighting of \# in perl mode. 68 | + Increased the height up to 20 for some long constructors. 69 | + Added makefile mode. 70 | + Also match *.ini in the generic config file mode. 71 | + Added Debian control (control, dsc, changes) file mode. 72 | + Added Debian changelog mode. 73 | + Also match *.pot in po mode. 74 | + Added basic lsm mode. 75 | + Added watch file, uscan(1), mode. 76 | + Added gdbinit mode. 77 | + Added .desktop (and eventsrc) mode. 78 | + Added basic quilt series mode. 79 | + Added basic .ac and .m4 mode. 80 | + Added generic changelog mode. 81 | 82 | 2008-04-04 Igor Zhbanov 83 | 84 | * syntax: better sh comment pattern; add *.php4, *.php5 files; 85 | add php constants true, false, null and keywords public, private, protected. 86 | 87 | 2008-04-08 lav 88 | 89 | * syntax: add sql pattern. 90 | 91 | 2008-01-21 lav 92 | 93 | * syntax: (perl) add *.pm; fix soket typo; add sysseek. 94 | 95 | 2007-05-31 lav 96 | 97 | * syntax: add missed keywords (java,perl,c++); fixed -*-\c++-*- pattern. 98 | 99 | 2006-11-30 lav 100 | 101 | * syntax: add readline keyword for perl and ci for syntax. 102 | 103 | 2006-11-29 lav 104 | 105 | * syntax: add syntax and named.conf modes; improve perl mode. 106 | 107 | 2006-08-23 Serge Vakulenko 108 | 109 | * syntax: new Verilog mode. 110 | 111 | 2006-08-23 lav 112 | 113 | * syntax: add our keyword for perl. 114 | 115 | 2005-12-23 Abel Morabito 116 | 117 | * syntax: update GEMA patterns. 118 | 119 | 2005-12-21 lav 120 | 121 | * syntax: add patch file name patterns. 122 | 123 | 2005-12-21 Abel Morabito 124 | 125 | * syntax: add Awk and GEMA patterns. 126 | 127 | 2005-07-08 lav 128 | 129 | * syntax: add c comments for php. 130 | 131 | 2005-04-26 lav 132 | 133 | * syntax: add more keywords for sql, php, tcl. 134 | 135 | 2005-03-10 lav 136 | 137 | * syntax: make sql key words case insensitive. 138 | 139 | 2005-03-03 Serge Vakulenko 140 | 141 | * syntax: 1) Ada 2) GNU Assembler 3) Oracle PL/SQL 4) SNMP MIB 5) 142 | Texinfo 6) TeX 7) PHP 8) Tcl 9) Metafont 10) Patch (diff output) 11) 143 | Generic config files. 144 | 145 | 2001-09-05 lav 146 | 147 | * syntax: perl patterns improved. 148 | 149 | 2001-07-05 lav 150 | 151 | * keymap-emacs: add suspend-editor $kspd. 152 | * syntax: add defined keyword to perl mode. 153 | * mainmenu: add set-bookmark and go-bookmark to menu. 154 | 155 | 2001-06-25 Abel Morabito 156 | 157 | * syntax: more complete lout mode. 158 | 159 | 2001-05-23 Vladislav V. Zhuk 160 | 161 | * syntax: add perl mode. 162 | 163 | 2001-04-09 Abel Morabito 164 | 165 | * syntax: add lout mode. 166 | 167 | 2000-02-19 lav 168 | 169 | * syntax: add *.shtml 170 | 171 | 2000-02-17 lav 172 | 173 | * syntax: add html patterns. 174 | -------------------------------------------------------------------------------- /src/menu.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-2005 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include "edit.h" 25 | #include "keymap.h" 26 | #include "menu.h" 27 | 28 | char ItemChar(const char *i) 29 | { 30 | for(; *i; i++) 31 | if(*i=='&') 32 | return(toupper(i[1])); 33 | return(0); 34 | } 35 | int ItemLen(const char *i) 36 | { 37 | int len=0; 38 | for(; *i; i++) 39 | if(*i!='&' || !i[1]) 40 | len++; 41 | return(len); 42 | } 43 | void DisplayItem(int x,int y,const char *i,const attr *a) 44 | { 45 | Absolute(&x,ItemLen(i),Upper->w); 46 | if(!strcmp(i,"---")) 47 | { 48 | int w=Upper->w; 49 | SetAttr(a); 50 | while(xso_attr; 56 | for(; *i; i++) 57 | { 58 | if(*i=='&') 59 | { 60 | SetAttr(&r); 61 | PutCh(x++,y,(byte)(*++i)); 62 | } 63 | else 64 | { 65 | SetAttr(a); 66 | PutCh(x++,y,(byte)(*i)); 67 | } 68 | } 69 | SetAttr(a); 70 | } 71 | 72 | void display(const struct menu *mi,const attr *a) 73 | { 74 | DisplayItem(mi->x,mi->y,mi->text,a); 75 | } 76 | 77 | int ReadMenu(const struct menu *m,int dir,const attr *a,const attr *ca,int curr) 78 | { 79 | int i,action,key; 80 | 81 | curs_set(0); 82 | do 83 | { 84 | for(i=0; m[i].text; i++) 85 | { 86 | if(i!=curr) 87 | display(&m[i],a); 88 | else 89 | display(&m[i],ca); 90 | } 91 | move(LINES-1,COLS-1); 92 | action=GetNextAction(); 93 | switch(action) 94 | { 95 | case(CHAR_LEFT): 96 | if(dir==HORIZ) 97 | { 98 | if(curr==0) 99 | while(m[curr].text) 100 | curr++; 101 | curr--; 102 | } 103 | break; 104 | case(CHAR_RIGHT): 105 | if(dir==HORIZ) 106 | { 107 | right: curr++; 108 | if(m[curr].text==NULL) 109 | curr=0; 110 | } 111 | break; 112 | case(LINE_UP): 113 | if(dir==VERT) 114 | { 115 | for(;;) 116 | { 117 | if(curr==0) 118 | while(m[curr].text) 119 | curr++; 120 | curr--; 121 | if(strcmp(m[curr].text,"---")) 122 | break; 123 | } 124 | } 125 | break; 126 | case(LINE_DOWN): 127 | if(dir==VERT) 128 | { 129 | for(;;) 130 | { 131 | curr++; 132 | if(m[curr].text==NULL) 133 | curr=0; 134 | if(strcmp(m[curr].text,"---")) 135 | break; 136 | } 137 | } 138 | break; 139 | case(CANCEL): 140 | return(0); 141 | case(NEWLINE): 142 | i=ItemChar(m[curr].text); 143 | if(i) 144 | return i; 145 | return(-1-curr); 146 | default: 147 | if(StringTypedLen!=1) 148 | break; 149 | if(StringTyped[0]==9) 150 | goto right; 151 | key=toupper(StringTyped[0]); 152 | for(i=0; m[i].text; i++) 153 | if(key==ItemChar(m[i].text)) 154 | return(key); 155 | } 156 | } 157 | while(1); 158 | /*NOTREACHED*/ 159 | } 160 | 161 | void GetTextGeometry(const char *s,int *w,int *h) 162 | { 163 | int x; 164 | 165 | *w=0; 166 | *h=0; 167 | while(*s) 168 | { 169 | (*h)++; 170 | x=0; 171 | while(*s && *s!='\n') 172 | x++,s++; 173 | if(*s) 174 | s++; 175 | if(x>*w) 176 | *w=x; 177 | } 178 | } 179 | 180 | int ReadMenuBox(struct menu *m,int dir,const char *msg,const char *title, 181 | const attr *a,const attr *a1) 182 | { 183 | int w,h; 184 | int len; 185 | int pos; 186 | int i; 187 | 188 | GetTextGeometry(msg,&w,&h); 189 | 190 | if(dir==HORIZ) 191 | { 192 | len=-2; 193 | for(i=0; m[i].text; i++) 194 | { 195 | len+=ItemLen(m[i].text)+2; 196 | m[i].y=FDOWN-2; 197 | } 198 | if(len>w) 199 | w=len; 200 | if(w0) 203 | h+=2; 204 | else 205 | h+=1; 206 | } 207 | else 208 | abort(); 209 | 210 | WIN *win=CreateWin(MIDDLE,MIDDLE,w+4,h+4,a,title); 211 | // get adjusted window size 212 | w=win->w-4; 213 | h=win->h-4; 214 | 215 | if(dir==HORIZ) 216 | { 217 | pos=(w-len)/2; 218 | for(i=0; m[i].text; i++) 219 | { 220 | m[i].x=pos+2; 221 | pos+=ItemLen(m[i].text)+2; 222 | } 223 | } 224 | else 225 | abort(); 226 | 227 | DisplayWin(win); 228 | PutStr(2,2,msg); 229 | int res=ReadMenu(m,dir,a,a1); 230 | CloseWin(); 231 | DestroyWin(win); 232 | 233 | return(res); 234 | } 235 | -------------------------------------------------------------------------------- /src/cmd.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-2017 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #ifdef HAVE_UNISTD_H 23 | #include 24 | #endif 25 | #include 26 | #include 27 | #include "edit.h" 28 | #include "getch.h" 29 | 30 | #ifndef MSDOS 31 | char Shell [256]="exec $SHELL"; 32 | char Make [256]="exec make"; 33 | char Run [256]="exec make run"; 34 | char Compile[256]="exec make \"$FNAME.o\""; 35 | char HelpCmd[256]="exec " PKGDATADIR "/help"; 36 | #else 37 | char Shell [256]="command"; 38 | char Make [256]="make"; 39 | char Run [256]="make run"; 40 | char Compile[256]="make \"$FNAME.o\""; 41 | char HelpCmd[256]="man \"$WORD\""; 42 | #endif 43 | 44 | /* cmd - execute command c */ 45 | void cmd(const char *c,bool autosave,bool pauseafter) 46 | { 47 | char cl[256]; 48 | char file[256],name[256],ext[256]; 49 | char *s,*f,*n,*e,*p; 50 | extern struct menu ConCan4Menu[]; 51 | int exitcode; 52 | int oldalarm=alarm(0); 53 | 54 | errno=0; 55 | if(modified && autosave) 56 | { 57 | SaveFile(FileName); 58 | if(errno) 59 | { 60 | switch(ReadMenuBox(ConCan4Menu,HORIZ,"Cannot save the file"," Warning ", 61 | VERIFY_WIN_ATTR,CURR_BUTTON_ATTR)) 62 | { 63 | case('C'): 64 | case(0): 65 | return; 66 | } 67 | } 68 | } 69 | /* check if the file has lock enforce flag */ 70 | if(autosave && LockEnforce(FileMode)) 71 | { 72 | /* turn off lock feature of the file */ 73 | if(chmod(FileName,LockEnforceStrip(FileMode))==(-1)) 74 | { 75 | FError(FileName); 76 | switch(ReadMenuBox(ConCan4Menu,HORIZ, 77 | "Cannot change the file mode.\nThe file will not be readable.", 78 | " Warning ",VERIFY_WIN_ATTR,CURR_BUTTON_ATTR)) 79 | { 80 | case('C'): 81 | case(0): 82 | return; 83 | } 84 | } 85 | } 86 | for(s=FileName,f=file,n=name,e=ext,p=NULL; *s; s++) 87 | { 88 | #ifndef MSDOS 89 | if(*s=='$' || *s=='`' || *s=='\\' || *s=='"') 90 | *e++ = *n++ = *f++ = '\\'; 91 | #endif 92 | if(*s=='.') 93 | { 94 | p=n; 95 | e=ext; 96 | } 97 | else 98 | { 99 | if(*s=='/') 100 | p=NULL,e=ext; 101 | } 102 | *e++ = *n++ = *f++ = *s; 103 | } 104 | *e = *f = '\0'; 105 | if(p) 106 | *p='\0'; /* there was extension */ 107 | else 108 | *n='\0',*ext='\0'; /* there was no extension */ 109 | #ifndef __MSDOS__ 110 | snprintf(cl,sizeof(cl),"FILE=\"%s\";FNAME=\"%s\";EXT=\"%s\";WORD=\"%s\";export WORD FILE EXT FNAME; %s", 111 | file,name,ext,GetWord(),c); 112 | #else 113 | { 114 | FILE *bat; 115 | bat=fopen("lecmd.bat","wt"); 116 | if(bat==NULL) 117 | { 118 | FError("lecmd.bat"); 119 | return; 120 | } 121 | fprintf(bat,"@echo off\nset FILE=%s\nset FNAME=%s\nset EXT=%s\nset WORD=%s\n%s", 122 | file,name,ext,GetWord(),c); 123 | fclose(bat); 124 | strcpy(cl,"lecmd.bat"); 125 | } 126 | #endif 127 | TermCurses(); 128 | ReleaseSignalHandlers(); 129 | fflush(stdout); 130 | 131 | #ifdef __MSDOS__ 132 | char oldwd[256]; 133 | if(getcwd(oldwd,sizeof(oldwd))==NULL) 134 | { 135 | FError("getcwd()"); 136 | remove("lecmd.bat"); 137 | return; 138 | } 139 | #endif 140 | errno=0; 141 | exitcode=system(cl); 142 | if(exitcode==-1) 143 | { 144 | perror("system()"); 145 | putchar('\r'); 146 | } 147 | #ifdef __MSDOS__ 148 | if(chdir(oldpw)==-1) 149 | FError(oldpw); 150 | remove("lecmd.bat"); 151 | #endif 152 | #ifndef __MSDOS__ 153 | reset_prog_mode(); 154 | #endif 155 | flushinp(); 156 | if(pauseafter || exitcode!=0) 157 | { 158 | if(LockEnforce(FileMode)) 159 | chmod(FileName,FileMode); /* ??? */ 160 | printf("[Press any key to continue]"); 161 | fflush(stdout); 162 | #ifdef __MSDOS__ 163 | if(!GetRawKey()) 164 | #endif 165 | (void)GetRawKey(); 166 | printf("\r\n"); 167 | fflush(stdout); 168 | } 169 | InstallSignalHandlers(); 170 | #ifdef __MSDOS__ 171 | InitCurses(); // In PDCurses, endwin fatally terminates screen I/O, 172 | // so we need to reinitialize. 173 | #endif 174 | alarm(oldalarm); 175 | refresh(); 176 | flag=REDISPLAY_ALL; 177 | } 178 | 179 | void DoMake() 180 | { 181 | if(View) 182 | return; 183 | cmd(Make,1,1); 184 | } 185 | void DoShell() 186 | { 187 | cmd(Shell,0,0); 188 | } 189 | void DoRun() 190 | { 191 | if(View) 192 | return; 193 | cmd(Run,1,1); 194 | } 195 | void DoCompile() 196 | { 197 | if(View) 198 | return; 199 | cmd(Compile,1,1); 200 | } 201 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Run this to generate all the initial makefiles, etc. 3 | 4 | srcdir=`dirname $0` 5 | test -z "$srcdir" && srcdir=. 6 | 7 | PKG_NAME="le" 8 | 9 | (test -f $srcdir/configure.ac \ 10 | && test -d $srcdir/src) || { 11 | echo -n "**Error**: Directory "\`$srcdir\'" does not look like the" 12 | echo " top-level $PKG_NAME directory" 13 | 14 | exit 1 15 | } 16 | 17 | DIE=0 18 | 19 | (autoconf --version) < /dev/null > /dev/null 2>&1 || { 20 | echo 21 | echo "**Error**: You must have \`autoconf' installed to compile $PKG_NAME." 22 | echo "Download the appropriate package for your distribution," 23 | echo "or get the source at ftp://ftp.gnu.org/pub/gnu/autoconf/autoconf-2.60.tar.gz" 24 | DIE=1 25 | } 26 | 27 | (grep "^AM_PROG_LIBTOOL" $srcdir/configure.ac >/dev/null) && { 28 | (libtoolize --version) < /dev/null > /dev/null 2>&1 || { 29 | echo 30 | echo "**Error**: You must have \`libtool' installed to compile $PKG_NAME." 31 | echo "Get ftp://ftp.gnu.org/pub/gnu/libtool/libtool-1.6.tar.gz" 32 | echo "(or a newer version if it is available)" 33 | DIE=1 34 | } 35 | } 36 | 37 | grep "^AM_GNU_GETTEXT" $srcdir/configure.ac >/dev/null && { 38 | grep "sed.*POTFILES" $srcdir/configure.ac >/dev/null || \ 39 | (gettextize --version) < /dev/null > /dev/null 2>&1 || { 40 | echo 41 | echo "**Error**: You must have \`gettext' installed to compile $PKG_NAME." 42 | echo "Get ftp://ftp.gnu.org/pub/gnu/gettext/gettext-0.11.2.tar.gz" 43 | echo "(or a newer version if it is available)" 44 | DIE=1 45 | } 46 | } 47 | 48 | (automake --version) < /dev/null > /dev/null 2>&1 || { 49 | echo 50 | echo "**Error**: You must have \`automake' installed to compile $PKG_NAME." 51 | echo "Get ftp://ftp.gnu.org/pub/gnu/automake/automake-1.9.tar.gz" 52 | echo "(or a newer version if it is available)" 53 | DIE=1 54 | NO_AUTOMAKE=yes 55 | } 56 | 57 | 58 | # if no automake, don't bother testing for aclocal 59 | test -n "$NO_AUTOMAKE" || (aclocal --version) < /dev/null > /dev/null 2>&1 || { 60 | echo 61 | echo "**Error**: Missing \`aclocal'. The version of \`automake'" 62 | echo "installed doesn't appear recent enough." 63 | echo "Get ftp://ftp.gnu.org/pub/gnu/automake/automake-1.9.tar.gz" 64 | echo "(or a newer version if it is available)" 65 | DIE=1 66 | } 67 | 68 | # try to find gnulib-tool 69 | for dir in gnulib ../gnulib "$HOME/gnulib" /usr/share/gnulib; do 70 | if [ -x "$dir/gnulib-tool" ]; then 71 | PATH=$dir:$PATH 72 | break 73 | fi 74 | done 75 | 76 | 77 | (gnulib-tool --version) < /dev/null > /dev/null 2>&1 || { 78 | echo 79 | echo "**Error**: You must have \`gnulib-tool' in PATH to compile $PKG_NAME." 80 | echo "Get it from git://git.savannah.gnu.org/gnulib" 81 | DIE=1 82 | } 83 | 84 | ver=`gettextize --version 2>&1 | sed -n 's/^.*GNU gettext.* \([0-9]*\.[0-9.]*\).*$/\1/p'` 85 | 86 | case $ver in 87 | '') gettext_fail_text="Unknown gettext version.";; 88 | 0.1[5-9]* | 0.[2-9]* | [1-9].*) ;; 89 | *) gettext_fail_text="Old gettext version $ver.";; 90 | esac 91 | 92 | if test "$gettext_fail_text" != ""; then 93 | echo "$gettext_fail_text." 94 | echo "Get ftp://ftp.gnu.org/pub/gnu/gettext/gettext-0.15.tar.gz" 95 | echo "(or a newer version if it is available)" 96 | DIE=1 97 | fi 98 | 99 | if test "$DIE" -eq 1; then 100 | exit 1 101 | fi 102 | 103 | #make -f Makefile.am srcdir=. acinclude.m4 104 | 105 | if test -z "$*"; then 106 | echo "**Warning**: I am going to run \`configure' with no arguments." 107 | echo "If you wish to pass any to it, please specify them on the" 108 | echo \`$0\'" command line." 109 | echo 110 | fi 111 | 112 | case $CC in 113 | xlc ) 114 | am_opt=--include-deps;; 115 | esac 116 | 117 | for coin in `find $srcdir -name configure.ac -print` 118 | do 119 | dr=`dirname $coin` 120 | if test -f $dr/NO-AUTO-GEN; then 121 | echo skipping $dr -- flagged as no auto-gen 122 | else 123 | echo processing $dr 124 | macrodirs=`sed -n -e 's,AM_ACLOCAL_INCLUDE(\(.*\)),\1,gp' < $coin` 125 | ( cd $dr 126 | aclocalinclude="$ACLOCAL_FLAGS" 127 | test -d m4 && aclocalinclude="$aclocalinclude -I m4" 128 | for k in $macrodirs; do 129 | if test -d $k; then 130 | aclocalinclude="$aclocalinclude -I $k" 131 | ##else 132 | ## echo "**Warning**: No such directory \`$k'. Ignored." 133 | fi 134 | done 135 | if grep "^AM_GNU_GETTEXT" configure.ac >/dev/null; then 136 | if grep "sed.*POTFILES" configure.ac >/dev/null; then 137 | : do nothing -- we still have an old unmodified configure.ac 138 | else 139 | echo "Creating $dr/aclocal.m4 ..." 140 | test -r $dr/aclocal.m4 || touch $dr/aclocal.m4 141 | echo "Running gettextize... Ignore non-fatal messages." 142 | echo "no" | gettextize --force --copy --no-changelog 143 | mv configure.ac~ configure.ac 144 | mv m4/Makefile.am~ m4/Makefile.am 145 | echo "Making $dr/aclocal.m4 writable ..." 146 | test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4 147 | fi 148 | fi 149 | if grep "^AM_PROG_LIBTOOL" configure.ac >/dev/null; then 150 | echo "Running libtoolize..." 151 | libtoolize --force --copy 152 | mv Makefile.am~ Makefile.am 153 | fi 154 | gnulib-tool --update 155 | echo "Running aclocal $aclocalinclude ..." 156 | aclocal $aclocalinclude 157 | if grep "^A[MC]_CONFIG_HEADER" configure.ac >/dev/null; then 158 | echo "Running autoheader..." 159 | autoheader 160 | fi 161 | if [ -r Makefile.am ]; then 162 | echo "Running automake --gnu $am_opt ..." 163 | automake --add-missing --gnu $am_opt 164 | fi 165 | echo "Running autoconf ..." 166 | autoconf 167 | ) 168 | fi 169 | done 170 | 171 | if test x$NOCONFIGURE = x; then 172 | echo Running $srcdir/configure "$@" ... 173 | $srcdir/configure "$@" \ 174 | && echo Now type \`make\' to compile $PKG_NAME 175 | else 176 | echo Skipping configure process. 177 | fi 178 | -------------------------------------------------------------------------------- /misc/mainmenu-default: -------------------------------------------------------------------------------- 1 | submenu "&File" 2 | function "&Load" load-file hide 3 | function "&Save" save-file hide rw 4 | function "save &As..." save-file-as hide 5 | function "s&Witch" switch-file hide 6 | function "re&Open R/W" reopen-file-rw hide ro 7 | function "&Info" file-info hide 8 | hline 9 | function "&Make" make hide 10 | function "&Compile" compile hide 11 | function "&Run" make-run hide 12 | hline 13 | function "S&hell" shell-escape hide 14 | function "S&uspend" suspend-editor hide 15 | function "&Quit" quit-editor hide 16 | end 17 | 18 | submenu "&Edit" 19 | function "&Undo" undo hide rw 20 | function "&Redo" redo hide rw 21 | function "Undo step" undo-step hide rw 22 | function "Redo step" redo-step hide rw 23 | hline 24 | function "Cu&t" delete-block hide rw no-mm 25 | function "&Copy" remember-block hide 26 | function "&Paste" yank-block hide rw 27 | function "&Select all" mark-all hide 28 | end 29 | 30 | submenu "&Block" 31 | function "set &Begin" set-block-begin hide 32 | function "set &End" set-block-end hide 33 | function "&Copy" copy-block hide rw block 34 | function "&Move" move-block hide rw block 35 | function "&Delete" delete-block hide rw block no-mm 36 | function "&Read" read-block hide rw 37 | function "&Write" write-block hide block 38 | function "Pipe" pipe-block hide block no-mm 39 | hline 40 | function "&Indent" indent-block hide rw block no-mm 41 | function "&Unindent" unindent-block hide rw block no-mm 42 | function "Insert prefix" insert-prefix hide rw block no-mm 43 | function "&Yank old" yank-block hide rw clipboard 44 | hline 45 | function "to &Lower case" convert-to-lower hide rw 46 | function "to u&Pper case" convert-to-upper hide rw 47 | function "e&Xchange cases" exchange-cases hide rw 48 | hline 49 | function "&Hide/display" hide-block hide 50 | function "Drag mark" start-drag-mark hide 51 | function "block &Type" change-block-type hide no-mm 52 | end 53 | 54 | submenu "&Search" 55 | function "&Search forwards" search-forward hide 56 | function "search &Backwards" search-backward hide 57 | function "start &Replace" start-replace hide rw 58 | function "&Continue search/replace" continue-search hide 59 | function "find &Matching bracket" find-matching-bracket hide 60 | end 61 | 62 | submenu "&Move" 63 | function "&Line number" to-line-number hide 64 | function "&Begin of the file" beginning-of-file hide 65 | function "&End of the file" end-of-file hide 66 | function "&Offset" to-offset hide 67 | function "&Previous edit" to-previous-edit hide rw 68 | function "&Set bookmark" set-bookmark hide 69 | function "&Go bookmark" go-bookmark hide 70 | function "Block begin" find-block-begin hide block 71 | function "Block end" find-block-end hide block 72 | end 73 | 74 | submenu "Fo&rmat" rw no-mm 75 | function "enter &Format mode" format-functions hide rw no-mm 76 | function "format one &Paragraph" format-paragraph hide rw no-mm 77 | function "&Center line" center-line hide rw no-mm 78 | function "&Right adjust line" adjust-right-line hide rw no-mm 79 | function "format &All" format-document hide rw no-mm 80 | end 81 | 82 | submenu "O&thers" 83 | function "&Calculator" calculator hide 84 | function "&Draw tables" draw-frames hide rw no-mm 85 | # function "&Format functions" format-functions hide rw no-mm 86 | function "&Expand all tabs" expand-tabs hide rw no-mm 87 | function "expand spans of tabs" expand-tab-spans hide rw no-mm 88 | function "&Optimize text" optimize-text hide rw no-mm 89 | function "character &Set" choose-character hide 90 | # function "&Wide character set" choose-wide-character hide 91 | function "&Unix<->Dos" change-text-type hide rw no-mm 92 | end 93 | 94 | submenu "&Options" 95 | function "&Editor" editor-options 96 | function "&Format" format-options 97 | function "&Undo" undo-options 98 | submenu "&Terminal" 99 | function "coding, &Graphics, etc..." terminal-options 100 | function "&Character set visualization" edit-charset 101 | function "Full 8-bit" set-charset-8bit hide 102 | function "Full 8-bit, no ctrl chars" set-charset-8bit-no-control hide 103 | function "&Save terminal options" save-terminal-options hide 104 | end 105 | function "&Appearance" appearance-options 106 | submenu "&Colors" 107 | function "&Edit" edit-colors hide 108 | function "&Save" save-colors hide 109 | function "Save as &terminal specific" save-colors-for-terminal hide 110 | hline 111 | function "&Default" load-color-default hide 112 | function "Load default-background" load-color-defbg hide 113 | function "Load black" load-color-black hide 114 | function "Load blue" load-color-blue hide 115 | function "Load green" load-color-green hide 116 | function "Load white" load-color-white hide 117 | end 118 | submenu "&Keyboard map" 119 | function "&Default" load-keymap-default hide 120 | function "Load Emacs-like keymap" load-keymap-emacs hide 121 | hline 122 | function "&Save" save-keymap hide 123 | function "Save as &terminal specific" save-keymap-for-terminal hide 124 | end 125 | function "&Programs" programs-options 126 | function "&Save to current directory" save-options-local hide 127 | function "Update cu&rrent options file" save-options hide 128 | end 129 | 130 | submenu "&Help" 131 | function "&Help on keys" help hide 132 | function "Help on &word" word-help hide 133 | function "&About" about hide 134 | end 135 | end 136 | -------------------------------------------------------------------------------- /src/getch.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-1997 by Alexander V. Lukyanov (lav@yars.free.net) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include 20 | 21 | #define MAX_FAIL_COUNT 100 22 | 23 | #ifdef HAVE_UNISTD_H 24 | #include 25 | #endif 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #ifdef HAVE_SYS_POLL_H 34 | #include 35 | #else 36 | #include 37 | #endif 38 | 39 | #ifdef __linux__ 40 | # include 41 | # if HAVE_LINUX_TIOCL_H 42 | # include 43 | # endif 44 | static int linux_process_key(int); 45 | static int ungetstr(const char *str); 46 | #endif 47 | 48 | #include "edit.h" 49 | #include "getch.h" 50 | 51 | sigjmp_buf getch_return; 52 | bool getch_return_set=false; 53 | 54 | static int fail_count=0; 55 | static void fail() 56 | { 57 | if(++fail_count>=MAX_FAIL_COUNT) 58 | raise(SIGHUP); 59 | } 60 | 61 | void UnrefKey(int key) // ??? 62 | { 63 | if(iscntrl(key)) 64 | { 65 | napms(100); 66 | flushinp(); 67 | } 68 | } 69 | 70 | 71 | int GetRawKey() 72 | { 73 | int key; 74 | 75 | UnblockSignals(); 76 | 77 | timeout(-1); 78 | keypad(stdscr,0); 79 | key=getch(); 80 | if(key==ERR) 81 | fail(); 82 | else 83 | fail_count=0; 84 | keypad(stdscr,1); 85 | 86 | BlockSignals(); 87 | 88 | return(key); 89 | } 90 | 91 | int CheckPending() 92 | { 93 | struct pollfd pfd; 94 | pfd.fd=0; 95 | pfd.events=POLLIN; 96 | return poll(&pfd,1,0); 97 | } 98 | 99 | int WaitForKey(int delay) 100 | { 101 | int key=GetKey(delay); 102 | 103 | #ifdef WITH_MOUSE 104 | if(key==KEY_MOUSE) 105 | { 106 | MEVENT mev; 107 | if(getmouse(&mev)==OK) 108 | ungetmouse(&mev); 109 | } 110 | else 111 | #endif 112 | if(key!=ERR) 113 | ungetch(key); 114 | 115 | return(key); 116 | } 117 | 118 | int GetKey(int delay) 119 | { 120 | if(sigsetjmp(getch_return,1)==0) 121 | { 122 | getch_return_set=true; 123 | UnblockSignals(); 124 | 125 | bkgdset(NORMAL_TEXT_ATTR->n_attr|' '); // recent ncurses uses bkgd for default clearing 126 | timeout(delay); 127 | int key=getch(); 128 | if(key==ERR) 129 | { 130 | if(delay==-1) 131 | fail(); 132 | } 133 | else 134 | fail_count=0; 135 | timeout(-1); 136 | bkgdset(' '); 137 | 138 | BlockSignals(); 139 | getch_return_set=false; 140 | 141 | /* on linux try to interpret shift state */ 142 | #ifdef __linux__ 143 | key=linux_process_key(key); 144 | #endif 145 | 146 | return key; 147 | } 148 | else 149 | { 150 | getch_return_set=false; 151 | return ERR; 152 | } 153 | } 154 | 155 | #ifdef __linux__ 156 | /* I hate it, it does not work over telnet */ 157 | /* Oh why linux cannot just return different codes for different keys? */ 158 | 159 | # ifndef TIOCL_GETSHIFTSTATE 160 | # define TIOCL_GETSHIFTSTATE 6 // older linux versions did not define this 161 | # endif 162 | 163 | int linux_process_key(int key) 164 | { 165 | /* BEWARE OF UNWANTED RECURSION! */ 166 | #ifdef TIOCLINUX 167 | char shift_state=TIOCL_GETSHIFTSTATE; 168 | if(ioctl(0,TIOCLINUX,&shift_state)<0) 169 | return key; 170 | 171 | bool shift=(shift_state & (1<=KEY_F0+11 && key<=KEY_F0+20) 186 | return key+add-10; // ~F11 and ~F12 lose 187 | else if(key>=KEY_F0+1 && key<=KEY_F0+12) 188 | return key+add; 189 | } 190 | // some xterm key sequences are used below. 191 | int xterm_shift=0; 192 | if(shift) xterm_shift=2; 193 | if(ctrl) xterm_shift=5; 194 | if(shift && ctrl) xterm_shift=6; 195 | int code=0; 196 | char str[16]; 197 | switch(key) 198 | { 199 | case KEY_LEFT: 200 | code='D'; 201 | break; 202 | case KEY_RIGHT: 203 | code='C'; 204 | break; 205 | case KEY_UP: 206 | code='A'; 207 | break; 208 | case KEY_DOWN: 209 | code='B'; 210 | break; 211 | case KEY_HOME: 212 | code='H'; 213 | break; 214 | case KEY_END: 215 | code='F'; 216 | break; 217 | } 218 | if(code) 219 | { 220 | snprintf(str,sizeof(str),"\033[1;%d%c",xterm_shift,code); 221 | return ungetstr(str); 222 | } 223 | code=0; 224 | switch(key) 225 | { 226 | case KEY_IC: 227 | code=2; 228 | break; 229 | case KEY_DC: 230 | code=3; 231 | break; 232 | case KEY_PPAGE: 233 | code=5; 234 | break; 235 | case KEY_NPAGE: 236 | code=6; 237 | break; 238 | } 239 | if(code) 240 | { 241 | snprintf(str,sizeof(str),"\033[%d;%d~",code,xterm_shift); 242 | return ungetstr(str); 243 | } 244 | 245 | #endif // TIOCLINUX 246 | return key; 247 | } 248 | 249 | static int ungetstr(const char *str) 250 | { 251 | int len=strlen(str); 252 | if(len==0) 253 | return ERR; 254 | const char *scan=str+len-1; 255 | while(scan>str) 256 | ungetch(*scan--); 257 | return *scan; 258 | } 259 | 260 | #endif 261 | --------------------------------------------------------------------------------