├── .bash_test
├── .bash_test_extra
├── .gitignore
├── .krsrc
├── BitVector.h
├── COPYING
├── GNUmakefile
├── K.ico
├── NOTES.univ-tags
├── README.adoc
├── README.linux_port
├── astyle.cfg
├── attr_format.h
├── bin.lua
├── bld_cmdtbl.lua
├── bld_datetime.lua
├── bld_link_unref.lua
├── build-for-coverity
├── buildexecute.cpp
├── changers.cpp
├── cmdidx.cpp
├── cmdtbl.dat
├── conin_ncurses.md
├── conio.h
├── ctags.d
├── k-kbackup.ctags
├── k-lua51.ctags
└── k-src.ctags
├── cursor.cpp
├── display.cpp
├── dlink.h
├── dlink_unittest.cpp
├── docs
├── musings.adoc
└── wuc.md
├── drmingw_jit_install.bat
├── dump_ntfs_streams.cpp
├── dv.bat
├── ed_core.h
├── ed_edkc.h
├── ed_main.h
├── ed_mem.h
├── ed_os_generic.h
├── ed_protos.h
├── ed_search.h
├── ed_vars.h
├── fbuf.cpp
├── fbuf_edit.cpp
├── fbuf_undo.cpp
├── features
├── cygpath_mode.txt
└── std_filesystem_conv.txt
├── filename.cpp
├── filename.h
├── fn_misc.cpp
├── fn_text.cpp
├── fname_gen.cpp
├── fname_gen.h
├── getopt.cpp
├── getopt.h
├── git_cat_local_config
├── git_set_fwmechanic_ident
├── historical_scans_fair_use
├── 1986.08.04-Z.TXT
├── 1988.09-MS.Journal-Notenboom-Customizing.M.Editor.pdf
├── 2001.07-MSDN.News-Michell-PWB.pdf
├── README.txt
└── Z-cleaned.TXT
├── impl_towinclip.h
├── install_build_tools_ubuntu.sh
├── k.cpp
├── k.filesettings
├── k.luaedit
├── k.luastate
├── k.rc
├── k.workspace
├── keys.cpp
├── krbtree.cpp
├── krbtree.h
├── krmbak
├── krmlog
├── linux_api.cpp
├── linux_base.h
├── linux_process.cpp
├── lua-5.1
├── COPYRIGHT
├── HISTORY
├── INSTALL
├── MANIFEST
├── Makefile
├── README
├── doc
│ ├── contents.html
│ ├── cover.png
│ ├── logo.gif
│ ├── lrexlib
│ │ ├── html4css1.css
│ │ ├── lrexlib.css
│ │ └── manual.html
│ ├── lua.1
│ ├── lua.css
│ ├── lua.html
│ ├── luac.1
│ ├── luac.html
│ ├── manual.css
│ ├── manual.html
│ └── readme.html
├── etc
│ ├── Makefile
│ ├── README
│ ├── all.c
│ ├── lua.hpp
│ ├── lua.ico
│ ├── lua.pc
│ ├── luavs.bat
│ ├── min.c
│ ├── noparser.c
│ └── strict.lua
├── src
│ ├── Makefile
│ ├── fix_coverity.h
│ ├── k_lib.c
│ ├── k_lib.h
│ ├── lapi.c
│ ├── lapi.h
│ ├── lauxlib.c
│ ├── lauxlib.h
│ ├── lbaselib.c
│ ├── lcode.c
│ ├── lcode.h
│ ├── ldblib.c
│ ├── ldebug.c
│ ├── ldebug.h
│ ├── ldo.c
│ ├── ldo.h
│ ├── ldump.c
│ ├── lfunc.c
│ ├── lfunc.h
│ ├── lgc.c
│ ├── lgc.h
│ ├── linit.c
│ ├── liolib.c
│ ├── llex.c
│ ├── llex.h
│ ├── llimits.h
│ ├── lmathlib.c
│ ├── lmem.c
│ ├── lmem.h
│ ├── loadlib.c
│ ├── lobject.c
│ ├── lobject.h
│ ├── lopcodes.c
│ ├── lopcodes.h
│ ├── loslib.c
│ ├── lpack.c
│ ├── lpack.readme.txt
│ ├── lparser.c
│ ├── lparser.h
│ ├── lpcap.c
│ ├── lpcap.h
│ ├── lpcode.c
│ ├── lpcode.h
│ ├── lpcre2.c
│ ├── lpcre2_algo.h
│ ├── lpcre2_common.c
│ ├── lpcre2_common.h
│ ├── lpcre2_f.c
│ ├── lpeg-128.gif
│ ├── lpeg.HISTORY
│ ├── lpeg.html
│ ├── lpprint.c
│ ├── lpprint.h
│ ├── lptree.c
│ ├── lptree.h
│ ├── lptypes.h
│ ├── lpvm.c
│ ├── lpvm.h
│ ├── lstate.c
│ ├── lstate.h
│ ├── lstring.c
│ ├── lstring.h
│ ├── lstrlib.c
│ ├── ltable.c
│ ├── ltable.h
│ ├── ltablib.c
│ ├── ltm.c
│ ├── ltm.h
│ ├── lua.c
│ ├── lua.h
│ ├── lua.link
│ ├── luac.c
│ ├── luaconf.h
│ ├── lualib.h
│ ├── lundump.c
│ ├── lundump.h
│ ├── lvm.c
│ ├── lvm.h
│ ├── lzio.c
│ ├── lzio.h
│ ├── print.c
│ ├── re.html
│ └── re.lua
└── test
│ ├── README
│ ├── bisect.lua
│ ├── cf.lua
│ ├── echo.lua
│ ├── env.lua
│ ├── factorial.lua
│ ├── fib.lua
│ ├── fibfor.lua
│ ├── globals.lua
│ ├── hello.lua
│ ├── k_lib.lua
│ ├── life.lua
│ ├── lpeg.lua
│ ├── luac.lua
│ ├── printf.lua
│ ├── readonly.lua
│ ├── sieve.lua
│ ├── sort.lua
│ ├── table.lua
│ ├── trace-calls.lua
│ ├── trace-globals.lua
│ └── xd.lua
├── lua_edlib.cpp
├── lua_intf.cpp
├── lua_intf_common.h
├── macro.cpp
├── main.cpp
├── mark.cpp
├── menu.lua
├── my_fio.cpp
├── my_fio.h
├── my_log.h
├── my_strutils.cpp
├── my_strutils.h
├── my_types.h
├── ncurses_conin.cpp
├── ncurses_conout.cpp
├── odkey.sh
├── os_services.cpp
├── os_services.h
├── patch-coverity
├── pcre_intf.cpp
├── pdconv.lua
├── re.lua
├── regex_rplc_test.txt
├── rm_util.cpp
├── rm_util.h
├── rsrc.cpp
├── search.cpp
├── setconsoleinfo.cpp
├── show.lua
├── std.dynlib.linux
├── std.dynlib.mingw
├── strict.lua
├── stringlist.cpp
├── stringlist.h
├── switch_impl.cpp
├── switch_impl.h
├── switches.cpp
├── sysbufs.cpp
├── tabs.md
├── tagfind.cpp
├── test
├── pst01.ps1
└── traildisp.txt
├── test_tagfind
├── tu.lua
├── ubuntu_univ-ctags_build_install
├── user.lua
├── util.lua
├── win32.cpp
├── win32_api.cpp
├── win32_base.h
├── win32_clipbd.cpp
├── win32_conin.cpp
├── win32_conout.cpp
├── win32_contit.cpp
├── win32_filename.cpp
├── win32_process.cpp
├── win32_pvt.h
├── wnd.cpp
└── xk.bat
/.bash_test:
--------------------------------------------------------------------------------
1 |
2 | alias alert='notify "$([ $? = 0 ] && echo terminal || echo error)"'
3 | TEST1="this" # comment
4 |
--------------------------------------------------------------------------------
/.bash_test_extra:
--------------------------------------------------------------------------------
1 | alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)"'
2 | alias alert='"$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
3 |
4 | alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
5 |
6 | TEST0="" # comment
7 | TEST0="a" # comment
8 | TEST1="this" # comment
9 | TEST2='this' # comment
10 | TEST3='this "is" not' # comment
11 | TEST4="this 'is' not" # comment
12 | TEST5="this 'is another "test" ' not" # comment
13 | TEST6="this is a 'test containing "more" "quotes" than' I know 'to "really" shake' a stick at" # comment
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | k
2 | dif
3 | lua
4 | k-*.log
5 | .svn/
6 | cov-int/
7 | .kbackup/
8 | bkz/
9 | *_unittest
10 | *.k?
11 | *.args
12 | *.makedeps
13 | *.o
14 | *.obj
15 | *.cod
16 | *.optc
17 | *.sout
18 | *.exe
19 | *.xref
20 | *.pdb
21 | *.a
22 | *.lib
23 | *.ii
24 | *.s
25 | # !pcre.lib this (git syntax) does not work in hg
26 |
27 | cmdtbl.h
28 | fxns
29 | tags
30 | tags_fields
31 | tags_extras
32 | tags_kinds
33 | k_rls.*
34 | k.RES
35 | k_D.LRF
36 | k_E.lrf
37 | _buildtime.c
38 | kx.def
39 | *.dll
40 | *.dllmap
41 | *.exp
42 | *.lrf
43 | *.LRF
44 | *.map
45 | *.mapi
46 | .nfs*
47 |
48 | cfiles
49 | ctout.list
50 | depsout.mak
51 | errors
52 | noisewarnings
53 | vars
54 | warnings
55 | whole_run.out
56 | .hgdif
57 | link.errs
58 | link.unref
59 | mkabat.bat
60 | *.testout
61 |
62 | _buildtime.i
63 | datetime.i
64 |
65 | # coverity data collection file
66 | k_edit.tgz
67 |
--------------------------------------------------------------------------------
/.krsrc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fwmechanic/k_edit/6c2ef6a1151a0ed5f719e868d6bd437538d26587/.krsrc
--------------------------------------------------------------------------------
/BitVector.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2015-2016 by Kevin L. Goodwin [fwmechanic@gmail.com]; All rights reserved
3 | //
4 | // This file is part of K.
5 | //
6 | // K is free software: you can redistribute it and/or modify it under the
7 | // terms of the GNU General Public License as published by the Free Software
8 | // Foundation, either version 3 of the License, or (at your option) any later
9 | // version.
10 | //
11 | // K is distributed in the hope that it will be useful, but WITHOUT ANY
12 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 | // details.
15 | //
16 | // You should have received a copy of the GNU General Public License along
17 | // with K. If not, see .
18 | //
19 |
20 | #pragma once
21 |
22 | /*
23 | The BitVector class is designed for efficiency in checking whether any bit is
24 | set. Initial target is screen refresh code: a set bit indicates a screen line
25 | needing refresh, so if any are set we go off into the refresh logic. Since
26 | the "anything pending" parallel/cached status bit no longer exists, it's
27 | important that the any-bit-set? test be speedy.
28 |
29 | Note that BitVector is as efficient as it gets on a 32-bit CPU (big
30 | shock there!); a BitVector is no better.
31 |
32 | 20090223 kgoodwin
33 | */
34 | template
35 | class BitVector {
36 | typedef T *P;
37 | typedef const T *CP;
38 | enum { BITS_PER_EL = 8*sizeof(T), ALLBITS = ~static_cast(0) };
39 |
40 | const size_t d_T_els ;
41 | const P d_bits ;
42 |
43 | private:
44 |
45 | size_t bitnum( size_t bn ) const { return bn % BITS_PER_EL; }
46 | size_t elenum( size_t bn ) const { return bn / BITS_PER_EL; }
47 |
48 | public:
49 |
50 | BitVector( size_t bits )
51 | : d_T_els( (bits+BITS_PER_EL-1)/BITS_PER_EL )
52 | , d_bits( P( Alloc0d( d_T_els * sizeof(T) ) ) )
53 | {}
54 |
55 | ~BitVector() { delete d_bits; }
56 |
57 | void SetBit ( size_t bn ) { d_bits[ elenum( bn ) ] |= BIT( bitnum( bn ) ); }
58 | void ClrBit ( size_t bn ) { d_bits[ elenum( bn ) ] &= ~BIT( bitnum( bn ) ); }
59 | bool IsBitSet( size_t bn ) const { return (d_bits[ elenum( bn ) ] & BIT( bitnum( bn ) )) != 0; }
60 | bool IsAnyBitSet() const { // _this_ is the reason for this class existing: fast search for any bit being set
61 | const P pastEnd( d_bits + d_T_els );
62 | for( P pel=d_bits ; pel < pastEnd ; ++pel ) {
63 | if( *pel ) {
64 | return true;
65 | }
66 | }
67 | return false;
68 | }
69 | void ClrAllBits() {
70 | const P pastEnd( d_bits + d_T_els );
71 | for( P pel=d_bits ; pel < pastEnd ; ++pel ) {
72 | *pel = 0;
73 | }
74 | }
75 | void SetAllBits() {
76 | const P pastEnd( d_bits + d_T_els );
77 | for( P pel=d_bits ; pel < pastEnd ; ++pel ) {
78 | *pel = ALLBITS;
79 | }
80 | }
81 | };
82 |
--------------------------------------------------------------------------------
/K.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fwmechanic/k_edit/6c2ef6a1151a0ed5f719e868d6bd437538d26587/K.ico
--------------------------------------------------------------------------------
/NOTES.univ-tags:
--------------------------------------------------------------------------------
1 | --fields=+ ID
2 | N/name tag name the first field, being the primary key which the tags file is sorted on
3 | F/input input file name of file in which tagged object is defined
4 | P/pattern pattern content governed by --excmd value: when --excmd=number, this has the value 'n;"' where n is a decimal (line) number
5 |
6 | f/file "File-restricted scoping" (dflt enabled for C++) add a field "file:" to file-scoped tagged objects (don't add to global-scoped tagged objects) (#def macs in .c files, static objects)
7 |
8 | K "Kind of tag as full name"
9 | k "Kind of tag as a single letter" even though this is (dflt enabled for C++), it appears to be overridden by --fields=+K
10 |
11 | s/NONE "Scope of tag definition" does not seem to do anything (C++, with --fields=+f in effect)
12 | p/scopeKind "Kind of scope as full name" does not seem to do anything (C++, with --fields=+f in effect)
13 |
14 | t "Type and name of a variable or typedef" (dflt enabled for C++) add a field "typeref:" for fxns: return type
15 |
--------------------------------------------------------------------------------
/README.linux_port:
--------------------------------------------------------------------------------
1 |
2 | CODING CONVENTIONS *** existing code is uniformly formatted. Get used to it.
3 | Some notable divergences from common conventions are called out next:
4 |
5 | * USE NO TABS (except as required in makefiles)
6 | * USE NO 1-character identifiers! Even "ii" is better than "i"!
7 | * 3 spaces per indent level
8 | * DO NOT slavishly WRAP source code LINES @ 80th column; I haven't used a
9 | no-more-than-80-column terminal ... _ever_ (and I've been using Linux via
10 | xterms and Putty off and on for > 10 years; since it's now essential that
11 | my devenv include the ability to run a browser (Firefox), I can foresee NO
12 | situation in which I'll be _developing_ K under an 80-column constraint).
13 | BTW the market (Hollywood?) has driven monitor aspect ratio in a
14 | pro-width-bias direction, something I don't see being reversed in the next
15 | decade ...
16 | * curly brace format: my preference (as expressed in K source code) has evolved to
17 | https://en.wikipedia.org/wiki/Indent_style#Ratliff_style which is same as
18 | https://en.wikipedia.org/wiki/Indent_style#Banner_style ?
19 | both modified by:
20 | if( bool ) { } // yes
21 | if (bool) { } // NO!
22 | function( my, params ); // yes
23 | function (my,params); // NO!
24 | but: "return yes;"
25 | not "return( no );" // return is not a function call
26 | * terminology: to avoid redundancy, do not use the term "whitespace" or "white";
27 | use "blank" instead.
28 |
29 | Semantic Coding Guidelines
30 |
31 | * When strings are being assembled, prefer std::string
32 | * When strings are being referenced, prefer stref (std::string_view)
33 | * Deprecate (pointer to) ASCI_Z_ string in lieu of the above whereever possible.
34 | * You will see many duplications of methods and functions along the axis of
35 | * std::string vs. Xbuf param or retval
36 | * stref (std::string_view) vs. PCChar param or retval
37 | in all cases, prefer the first to the second (try to rmv the second)
38 | this does not mean that the first is as well-tested as the second!
39 |
40 | Weaknesses
41 |
42 | * As per #1 coding convention, I eschew tabs; Tabs are responsible for a large
43 | amount of cruft in the K code, and even so, are not superbly supported. if
44 | not for GNU Make (which uses tabs as a syntactic element), I would have long
45 | ago declared tab characters an unsupported "feature" and removed from K all
46 | related code.
47 |
48 | Key goals
49 |
50 | * http://fte.sourceforge.net/ seems to have a nicely structured architecture
51 | supporting multiple/diverse screen+kybd I/O environments. While my immediate
52 | goals for K are far less diverse (ncurses should be totally sufficient?),
53 | adopting FTE's framework in toto _MIGHT_ be a net win...
54 |
55 | * when I use K, in direct contrast to the "fingers on home keys" mantra of vi
56 | etc., my right hand is almost always over the numeric keypad; cursor keys,
57 | arg (center key), cut, copy, paste are all "at hand". Note that cut, copy,
58 | paste are used in preference to manually typing alpha(num) strings appearing
59 | on the screen (something I see vi users do on an every minute-basis, which
60 | just seems wrong to me (I am an error-prone transcriber)). A KEY GOAL is to
61 | preserve this capability on all platforms (yes I understand that
62 | small-form-factor laptops (which some people prefer) are problematic in this
63 | regard).
64 |
65 |
66 | Major Tasks
67 |
68 | - screen output [done 20141214]
69 | - reading/processing normal input (keyboard, screen-size change, mouse) events
70 | - react to screen-size changes (even w/>1 window extant) [done 20141111]
71 | - command and dflt-key-mapping tables
72 | - child processes and stdout/err capturing to buffer
73 | - signal handling
74 |
--------------------------------------------------------------------------------
/astyle.cfg:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2015 by Kevin L. Goodwin [fwmechanic@gmail.com]; All rights reserved
3 | #
4 | # This file is part of K.
5 | #
6 | # K is free software: you can redistribute it and/or modify it under the
7 | # terms of the GNU General Public License as published by the Free Software
8 | # Foundation, either version 3 of the License, or (at your option) any later
9 | # version.
10 | #
11 | # K is distributed in the hope that it will be useful, but WITHOUT ANY
12 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 | # details.
15 | #
16 | # You should have received a copy of the GNU General Public License along
17 | # with K. If not, see .
18 | #
19 |
20 | # http://sourceforge.net/projects/astyle/
21 | # invoke with `astyle --config=astyle.cfg ...`
22 |
23 | --indent=spaces=3
24 | --style=banner
25 | --indent-preproc-block
26 | --indent-modifiers
27 | --indent-preproc-cond
28 | --attach-namespaces
29 | --attach-classes
30 | -p
31 | -PUDJo
32 | --align-pointer=name
33 | --align-reference=name
34 | --close-templates
35 | --remove-comment-prefix
36 |
--------------------------------------------------------------------------------
/attr_format.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2015-2018 by Kevin L. Goodwin [fwmechanic@gmail.com]; All rights reserved
3 | //
4 | // This file is part of K.
5 | //
6 | // K is free software: you can redistribute it and/or modify it under the
7 | // terms of the GNU General Public License as published by the Free Software
8 | // Foundation, either version 3 of the License, or (at your option) any later
9 | // version.
10 | //
11 | // K is distributed in the hope that it will be useful, but WITHOUT ANY
12 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 | // details.
15 | //
16 | // You should have received a copy of the GNU General Public License along
17 | // with K. If not, see .
18 | //
19 |
20 | #pragma once
21 |
22 | // https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
23 | #define GCC_VERSION ( __GNUC__ * 10000 \
24 | + __GNUC_MINOR__ * 100 \
25 | + __GNUC_PATCHLEVEL__ )
26 | // Test for GCC > 7.1.0 #if GCC_VERSION > 70100
27 |
28 | // NOTE! Applying ATTR_FORMAT to printf-like function extern declarations
29 | // DOES NOT GUARANTEE that said function will honor 'gnu_printf' style
30 | // format strings e.g. PR_SIZET!!!
31 | // e.g. MinGW GCC 4.8.1 (last 32-bit Nuwen MinGW GCC release):
32 | // vfprintf DOES NOT honor 'gnu_printf', while
33 | // vsnprintf DOES honor 'gnu_printf'
34 | // UNLESS: must
35 | // #define __USE_MINGW_ANSI_STDIO 1
36 | // before
37 | // #include'ing any stdlib h files
38 | // this is (now) done in ed_main.h
39 |
40 | #ifndef ATTR_FORMAT
41 | #ifdef __GNUC__
42 | #define ATTR_FORMAT(xx,yy) __attribute__ ((format (gnu_printf, xx, yy)))
43 | #else
44 | #define ATTR_FORMAT(xx,yy)
45 | #endif
46 | #endif
47 |
48 | #define ATTR_FALLTHRU [[fallthrough]]
49 |
--------------------------------------------------------------------------------
/bin.lua:
--------------------------------------------------------------------------------
1 | -- if you change or add to this module, _please_ update test\k_lib.lua accordingly!
2 |
3 | module( "bin", package.seeall )
4 |
5 | require "util"
6 |
7 | -- very simple un/packer: supports only fixed length byte strings and 1-/2-/4-byte binary numbers
8 |
9 | local function unpack_one( tt, byteSrc, ix, endian )
10 | local at, bytes = tt:match( "^(%a?)(%d+)$" )
11 | local errstr = string.format( "unknown unpack[%d] template specifier '%s'", ix, tt )
12 | util.errassert( bytes, errstr, 3 )
13 | bytes = 0+bytes
14 | local raw = byteSrc( bytes, string.format( "unpack[%d] '%s'", ix, tt ) )
15 | if at =="" then return _bin.unpack_num( raw, endian ) end
16 | if at == "s" then return raw end
17 | error( errstr, 3 )
18 | end
19 |
20 | -- ********** NB!!! There is a 'unpack' function in the Lua global scope! See PiL2e pg 39
21 |
22 | local function unpack( tmplt, endian, byteString )
23 | local bsbs = util.byteSource( byteString )
24 | local aTmplts = util.matches( tmplt )
25 | local rv = {}
26 | for ix,ta in ipairs( aTmplts ) do
27 | rv[ #rv + 1 ] = unpack_one( ta, bsbs, ix, endian )
28 | end
29 | return rv
30 | end
31 |
32 | function unpackLE( tmplt, byteString ) return unpack( tmplt, false, byteString ) end
33 | function unpackBE( tmplt, byteString ) return unpack( tmplt, true , byteString ) end
34 |
35 | ------------
36 |
37 | local function pack_one( tt, data, ix, endian )
38 | local at, bytes = tt:match( "^(%a?)(%d+)$" )
39 | -- print( "pattern '"..tt.."'".. at )
40 | local errstr = string.format( "unknown pack[%d] template specifier '%s'", ix, tt )
41 | util.errassert( bytes, errstr, 3 )
42 | bytes = 0+bytes
43 | local badparam = string.format( "bad pack[%d] parameter (%s) for template specifier '%s'", ix, type(data), tt )
44 | if at == "" then
45 | util.errassert( type(data) == "number", badparam, 3 )
46 | return _bin.pack_num( data, bytes, endian )
47 | end
48 | if at == "s" then
49 | util.errassert( type(data) == "string", badparam, 3 )
50 | local rv = data:sub( 1, bytes )
51 | if #rv < bytes then rv = rv .. string.rep( string.char(0), bytes - #rv ) end
52 | return rv
53 | end
54 | error( errstr, 3 )
55 | end
56 |
57 | local function pack( tmplt, endian, ... )
58 | local aData = { ... }
59 | local aTmplts = util.matches( tmplt )
60 | local rv = {}
61 | for ix,ta in ipairs( aTmplts ) do
62 | local data = table.remove( aData, 1 )
63 | assert( data, "" )
64 | rv[ #rv + 1 ] = pack_one( ta, data, ix, endian )
65 | end
66 | return table.concat( rv )
67 | end
68 |
69 | function packLE( tmplt, ... ) return pack( tmplt, false, ... ) end
70 | function packBE( tmplt, ... ) return pack( tmplt, true , ... ) end
71 |
72 |
--------------------------------------------------------------------------------
/bld_datetime.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2015-2017 by Kevin L. Goodwin [fwmechanic@gmail.com]; All rights reserved
3 | --
4 | -- This file is part of K.
5 | --
6 | -- K is free software: you can redistribute it and/or modify it under the
7 | -- terms of the GNU General Public License as published by the Free Software
8 | -- Foundation, either version 3 of the License, or (at your option) any later
9 | -- version.
10 | --
11 | -- K is distributed in the hope that it will be useful, but WITHOUT ANY
12 | -- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | -- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 | -- details.
15 | --
16 | -- You should have received a copy of the GNU General Public License along
17 | -- with K. If not, see .
18 | --
19 |
20 | io.write( "/* dynamically generated by bld_datetime.lua */\n",
21 | 'const char kszDtTmOfBuild[] = "'..os.date( '%Y%m%d_%H%M%S' )..'";\n'
22 | )
23 |
--------------------------------------------------------------------------------
/bld_link_unref.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2015 by Kevin L. Goodwin [fwmechanic@gmail.com]; All rights reserved
3 | --
4 | -- This file is part of K.
5 | --
6 | -- K is free software: you can redistribute it and/or modify it under the
7 | -- terms of the GNU General Public License as published by the Free Software
8 | -- Foundation, either version 3 of the License, or (at your option) any later
9 | -- version.
10 | --
11 | -- K is distributed in the hope that it will be useful, but WITHOUT ANY
12 | -- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | -- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 | -- details.
15 | --
16 | -- You should have received a copy of the GNU General Public License along
17 | -- with K. If not, see .
18 | --
19 |
20 | require "strict"
21 | require "tu"
22 |
23 | local ofnm = "link.unref"
24 |
25 | local ofh = assert( io.open( ofnm, "wt" ) )
26 |
27 | local unrefs = {}
28 |
29 | for line in io.lines() do
30 | local unref = line:match( "undefined reference to `(.+)'" )
31 | if unref then
32 | unrefs[unref] = (unrefs[unref] or 0) + 1
33 | end
34 | end
35 |
36 | local unrefdCount = 0
37 | for nm, count in pairs( unrefs ) do -- print( "-> \"" .. ix, tb.fxn .. "\"" )
38 | -- for nm, count in tu.pairsBySortedValues( unrefs ) do -- print( "-> \"" .. ix, tb.fxn .. "\"" )
39 | ofh:write( string.format("%3d", count), " '", nm, "'\n" )
40 | unrefdCount = 1+ unrefdCount
41 | end
42 |
43 | if unrefdCount > 0 then
44 | io.stderr:write( unrefdCount, " undefined references, see ", ofnm, "\n" )
45 | os.exit(1)
46 | end
47 |
--------------------------------------------------------------------------------
/build-for-coverity:
--------------------------------------------------------------------------------
1 | # after "installing" (untarring) the coverity tool (which creates directory $coverity_version/), need to create a symlink:
2 | # ln -s $HOME/coverity/$coverity_version $HOME/coverity/cov
3 | cov_bin="$HOME/coverity/cov" ; [ -L "$cov_bin" ] || { printf "symlink $cov_bin does not exist" ; exit 1 ; }
4 | cov_bin="$HOME/coverity/cov/bin" ; [ -d "$cov_bin" ] || { printf "dir $cov_bin does not exist" ; exit 1 ; }
5 | PATH="$PATH:$cov_bin"
6 | cov_bin="$cov_bin/cov-build" ; [ -x "$cov_bin" ] || { printf "$cov_bin is not executable" ; exit 1 ; }
7 |
8 | # apparently the tarball filename MUST BE same as the Coverity Project Name?
9 | my_cov_projnm=k_edit
10 | tarball=${my_cov_projnm}.tgz
11 | cov_output_dir=cov-int
12 | k_make_cmd="make -j 6"
13 |
14 | rm -rf $cov_output_dir \
15 | && rm -f $tarball \
16 | && mkdir -p $cov_output_dir \
17 | && make clean \
18 | && cov-build --dir $cov_output_dir $k_make_cmd \
19 | && tar czvf $tarball $cov_output_dir \
20 | && printf "%s/$tarball\nis ready to submit to\nhttps://scan.coverity.com/projects/fwmechanic-k_edit\n" `pwd`
21 |
--------------------------------------------------------------------------------
/cmdtbl.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fwmechanic/k_edit/6c2ef6a1151a0ed5f719e868d6bd437538d26587/cmdtbl.dat
--------------------------------------------------------------------------------
/ctags.d/k-kbackup.ctags:
--------------------------------------------------------------------------------
1 | #!bash
2 | #
3 | # Copyright 2017 by Kevin L. Goodwin [fwmechanic@gmail.com]; All rights reserved
4 | #
5 | # This file is part of K.
6 | #
7 | # K is free software: you can redistribute it and/or modify it under the
8 | # terms of the GNU General Public License as published by the Free Software
9 | # Foundation, either version 3 of the License, or (at your option) any later
10 | # version.
11 | #
12 | # K is distributed in the hope that it will be useful, but WITHOUT ANY
13 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 | # details.
16 | #
17 | # You should have received a copy of the GNU General Public License along
18 | # with K. If not, see .
19 | #
20 |
21 | # project-level options for https://github.com/universal-ctags/ctags
22 |
23 | # K drops backup files into child dir .kbackup of the dir of the file
24 | # being backed up, which means .kbackup dirs may be encountered anywhere.
25 | # While these backup files have an extension .yyyyMMdd_hhmmss which
26 | # prevents ctags operating in file-extension pattern-matching mode from
27 | # seeing them, if ctags is operated in --guess-language-eagerly mode
28 | # the peculiar extension of backup files does not inhibit ctags from
29 | # scanning these files.
30 | #
31 | # To make this option, which prevents backup files from being tagged,
32 | # globally effective, this file should be copied to one of:
33 | # $HOME/.ctags.d/*.ctags
34 | # $HOMEDRIVE$HOMEPATH/ctags.d/*.ctags (on MSWindows only)
35 | --exclude=.kbackup
36 |
--------------------------------------------------------------------------------
/ctags.d/k-lua51.ctags:
--------------------------------------------------------------------------------
1 | #!bash
2 | #
3 | # Copyright 2020 by Kevin L. Goodwin [fwmechanic@gmail.com]; All rights reserved
4 | #
5 | # This file is part of K.
6 | #
7 | # K is free software: you can redistribute it and/or modify it under the
8 | # terms of the GNU General Public License as published by the Free Software
9 | # Foundation, either version 3 of the License, or (at your option) any later
10 | # version.
11 | #
12 | # K is distributed in the hope that it will be useful, but WITHOUT ANY
13 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 | # details.
16 | #
17 | # You should have received a copy of the GNU General Public License along
18 | # with K. If not, see .
19 | #
20 |
21 | # project-level options for https://github.com/universal-ctags/ctags
22 |
23 | # mask Lua's doc files
24 | --exclude=lua-5.1/doc/*
25 |
--------------------------------------------------------------------------------
/ctags.d/k-src.ctags:
--------------------------------------------------------------------------------
1 | #!bash
2 | #
3 | # Copyright 2018 by Kevin L. Goodwin [fwmechanic@gmail.com]; All rights reserved
4 | #
5 | # This file is part of K.
6 | #
7 | # K is free software: you can redistribute it and/or modify it under the
8 | # terms of the GNU General Public License as published by the Free Software
9 | # Foundation, either version 3 of the License, or (at your option) any later
10 | # version.
11 | #
12 | # K is distributed in the hope that it will be useful, but WITHOUT ANY
13 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 | # details.
16 | #
17 | # You should have received a copy of the GNU General Public License along
18 | # with K. If not, see .
19 | #
20 |
21 | # project-level options for https://github.com/universal-ctags/ctags
22 |
23 | # the two K Lua source files that don't have .lua extension:
24 | --langmap=Lua:+(k.luaedit)(k.filesettings)
25 |
26 | # K uses several macros that hide (expand to) 'static'. This inhibits
27 | # generation of "file:" tag fields, so we unhide them for u-ctags thus:
28 | -I STATIC_FXN=static
29 | -I STATIC_VAR=static
30 | -I STATIC_CONST=static
31 | -I STIL=static
32 | -I GLOBAL_VAR
33 | -I GLOBAL_CONST
34 | -I COMPLEX_STATIC_VAR=static
35 |
--------------------------------------------------------------------------------
/display.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fwmechanic/k_edit/6c2ef6a1151a0ed5f719e868d6bd437538d26587/display.cpp
--------------------------------------------------------------------------------
/dlink_unittest.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2015,2021 by Kevin L. Goodwin [fwmechanic@gmail.com]; All rights reserved
3 | //
4 | // This file is part of K.
5 | //
6 | // K is free software: you can redistribute it and/or modify it under the
7 | // terms of the GNU General Public License as published by the Free Software
8 | // Foundation, either version 3 of the License, or (at your option) any later
9 | // version.
10 | //
11 | // K is distributed in the hope that it will be useful, but WITHOUT ANY
12 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 | // details.
15 | //
16 | // You should have received a copy of the GNU General Public License along
17 | // with K. If not, see .
18 | //
19 |
20 | #include
21 | #include
22 | #include
23 | #include "my_types.h"
24 | #include "dlink.h"
25 |
26 | #define AEOB( array ) array , ELEMENTS(array), #array
27 |
28 | struct inta {
29 | const int a;
30 | DLinkEntry dlink;
31 | inta( int a_ ) : a( a_ ) {}
32 | };
33 |
34 | typedef DLinkHead head_t;
35 |
36 | void assert_inta( const head_t &hd, const int arr[], const size_t els, const char *nm ) {
37 | if( els != hd.length() ) {
38 | std::cerr << nm << ": count miscmp: " << els << " != " << hd.length() << "\n";
39 | exit(1);
40 | }
41 | auto ix = 0u;
42 | DLINKC_FIRST_TO_LASTA( hd, dlink, pEl ) {
43 | if( pEl->a != arr[ix] ) {
44 | std::cerr << nm << "[" << ix << "]: miscmp: " << pEl->a << " != " << arr[ix] << "\n";
45 | exit(1);
46 | }
47 | ++ix;
48 | }
49 | if( els != ix ) {
50 | std::cerr << nm << ": overrun: " << els << " != " << ix << "\n";
51 | exit(1);
52 | }
53 | }
54 |
55 | int main() {
56 | head_t Hd;
57 |
58 | DLINK_INSERT_FIRST(Hd, new inta( 1 ), dlink); { const int ref1[] = { 1 }; assert_inta( Hd, AEOB( ref1 ) ); }
59 | DLINK_INSERT_LAST(Hd, new inta( 2 ), dlink); { const int ref2[] = { 1,2 }; assert_inta( Hd, AEOB( ref2 ) ); }
60 | DLINK_INSERT_LAST(Hd, new inta( 3 ), dlink); { const int ref3[] = { 1,2,3 }; assert_inta( Hd, AEOB( ref3 ) ); }
61 | DLINK_INSERT_FIRST( Hd, new inta( 12 ), dlink ); { const int ref3[] = { 12,1,2,3 }; assert_inta( Hd, AEOB( ref3 ) ); }
62 | auto pNew = new inta( 0 );
63 | DLINK_INSERT_BEFORE( Hd, Hd.front(), pNew, dlink ); { const int ref4[] = { 0,12,1,2,3 }; assert_inta( Hd, AEOB( ref4 ) ); }
64 | assert( Hd.front() == pNew );
65 |
66 | DLINK_INSERT_BEFORE( Hd, pNew, new inta( -1 ), dlink ); { const int ref5[] = { -1,0,12,1,2,3 }; assert_inta( Hd, AEOB( ref5 ) ); }
67 | DLINK_INSERT_AFTER( Hd, pNew, new inta( -2 ), dlink ); { const int ref8[] = { -1,0,-2,12,1,2,3 }; assert_inta( Hd, AEOB( ref8 ) ); }
68 | DLINK_REMOVE(Hd, pNew, dlink); { const int ref6[] = { -1,-2,12,1,2,3 }; assert_inta( Hd, AEOB( ref6 ) ); }
69 | delete pNew;
70 | DLINK_INSERT_BEFORE( Hd, Hd.back(),new inta( 0 ),dlink );
71 | head_t Hd2;
72 | { const int ref7[] = { -1,-2,12,1,2,0,3 }; assert_inta( Hd, AEOB( ref7 ) );
73 | DLINK_MOVE_HD( Hd2, Hd ); assert_inta( Hd2, AEOB( ref7 ) );
74 | assert( Hd.empty() );
75 | }
76 | DLINK_INSERT_FIRST( Hd, new inta( 20 ), dlink );
77 | DLINK_INSERT_FIRST( Hd, new inta( 21 ), dlink );
78 | DLINK_INSERT_FIRST( Hd, new inta( 22 ), dlink ); { const int ref9[] = { 22,21,20 }; assert_inta( Hd, AEOB( ref9 ) ); }
79 | DLINK_JOIN(Hd, Hd2, dlink); { const int refA[] = { 22,21,20,-1,-2,12,1,2,0,3 }; assert_inta( Hd, AEOB( refA ) ); }
80 | assert( Hd2.empty() );
81 | std::cout << "PASS\n";
82 | return 0;
83 | }
84 |
--------------------------------------------------------------------------------
/docs/wuc.md:
--------------------------------------------------------------------------------
1 | ## WUC = "Word Under Cursor" display highlighting
2 |
3 | This is a K facility that (unbidden, as part of the display (highlight)
4 | subsystem) highlights _other_ instances of the WUC.
5 |
6 | WUC-determination is done using the `wordchars` switch setting (plus evolutions; see below).
7 |
8 | This feature _does not highlight_ the actual WUC; I find this too distracting
9 | (highlighting gyrations atop the cursor make it hard to follow the cursor
10 | itself). Highlight changes _away from the cursor_ are less distracting (and are
11 | the _entire_ point of WUC highlighting!).
12 |
13 | The WUC is used (by default) for tag lookups (NOARG `tags`). This of course has
14 | some interesting/unforeseen implications (the effect of "simple changes" is
15 | seldom simple)...
16 |
17 | This feature started out simple, and evolved to become more complex. The
18 | evolution is ongoing...
19 |
20 | ### Evolution: variant-WUC highlighting
21 |
22 | In my career, I encountered identifiers which were semantically identical, but
23 | syntactically different. Examples:
24 |
25 | 1. __bash__ variables: assigned with `var=val`, referenced (read) with `$var` or `${var}`.
26 |
27 | 2. __make__ variables; similar to __bash__; assigned with `VAR=val`, referenced with `$(VAR)`
28 |
29 | 3. Hexadecimal values: some tools inconsistently provide or omit "0x" prefix (in the same file) on hex values.
30 |
31 | Variant-WUC highlighting will highlight-match any variant. These capabilities
32 | are hard-coded in K's C++ code ; see `HiliteAddin_WordUnderCursor::SetNewWuc()`
33 | and are sufficiently non-intersecting or benign that they are enabled always.
34 |
35 | ### Evolution: class/struct name hierarchial-join
36 |
37 | Experimental feature: as I get more involved in comprehending Python code which tends to be coded as
38 |
39 | ```python
40 | def __init__(self, deduct)
41 | self.deduct = deduct
42 | ```
43 |
44 | in such code, existing K WUC highlighting will not distinguish between
45 | `self.deduct` and `deduct`; all instances will be highlighted. There is more
46 | value in highlighting only instances of `self.deduct` or only instances of
47 | `deduct` (the coincidence of variable and member names cannot be relied upon the
48 | confer an actual relationship (worth highlighting) between the two). To
49 | accomplish this in a (mostly-)language-independent manner, a switch `hljoinchars`
50 | was created, and when looking for the left end of the WUC, the set of chars from
51 | the union of hljoinchars and wordchars is used to define the set chars that
52 | comprise the WUC.
53 |
54 | ### More heuristic exploration
55 |
56 | I'm finding that `self.deduct` is an interesting WUC whereas `self.deduct()` is
57 | less so (especially if `deduct()` is a mutator). Meaning I might be more
58 | interested in _all_ occurrences of `deduct()` being called rather than only calls
59 | to `deduct()` on `self`. But there isn't a clear winner here; it's very
60 | situational.
61 |
62 | ### Implementation shortcomings
63 |
64 | Some languages use a multicharacter "hierarchial-join
65 | phrase" (`->`) which does not align correctly with a simpleminded character-set
66 | implementation. `hljoinchars: .->` might be set for such languages, and would
67 | see all of `yourval-myval` as a WUC when a char of `myval` is under the cursor
68 | (instead of `myval` alone). So far this has not bit me, as in most code I would
69 | write `yourval - myval` (spaces surrounding `-`). But for code I didn't write,
70 | this will likely be a problem (and demand switching the WUC parsing
71 | implementation `GetWordUnderPoint()` from charset-based to regex-based).
72 |
73 | The interesting part of the implementation is that `GetWordUnderPoint()`
74 | searches forward __and backward__ from the cursor location. I'm unsure whether
75 | searching backward is something Regex supports (my gut feel is "no"). I think I
76 | would have to find all matches on a line, and then find if the cursor falls
77 | within any of them. This seems to not scale well for very long lines, unless the
78 | result for the line could be cached until the cursor line changes (by the cursor
79 | changing lines or the cursor line content changing).
80 |
--------------------------------------------------------------------------------
/drmingw_jit_install.bat:
--------------------------------------------------------------------------------
1 | @if not exist %~dp0drmingw.exe echo you need to copy this script to a directory containing drmingw.exe& goto :eof
2 | echo versioning&@%~dp0drmingw.exe --version || (echo @%~dp0drmingw.exe --version FAILED& goto :eof)
3 | echo installing&@%~dp0drmingw.exe --install --auto || (echo @%~dp0drmingw.exe --install --auto FAILED& goto :eof)
4 | echo @%~dp0drmingw.exe --install --auto SUCCEEDED
5 |
--------------------------------------------------------------------------------
/dv.bat:
--------------------------------------------------------------------------------
1 | @start dbgview.exe
2 |
--------------------------------------------------------------------------------
/ed_main.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2015-2018 by Kevin L. Goodwin [fwmechanic@gmail.com]; All rights reserved
3 | //
4 | // This file is part of K.
5 | //
6 | // K is free software: you can redistribute it and/or modify it under the
7 | // terms of the GNU General Public License as published by the Free Software
8 | // Foundation, either version 3 of the License, or (at your option) any later
9 | // version.
10 | //
11 | // K is distributed in the hope that it will be useful, but WITHOUT ANY
12 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 | // details.
15 | //
16 | // You should have received a copy of the GNU General Public License along
17 | // with K. If not, see .
18 | //
19 |
20 | #pragma once
21 |
22 | #if !defined(WL)
23 | // porting abbreviation tool
24 | #if defined(_WIN32)
25 | # define WL(ww,ll) ww
26 | #else
27 | # define WL(ww,ll) ll
28 | #endif
29 | #endif
30 |
31 | #if defined(_WIN32)
32 | // in order to use _stat64
33 | // http://stackoverflow.com/questions/12539488/determine-64-bit-file-size-in-c-on-mingw-32-bit
34 | // MUST be defined before any MINGW .h file is #included
35 | #define __MSVCRT_VERSION__ 0x0601
36 | #endif
37 |
38 | #if defined(_WIN32)
39 | // see https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/
40 | // must define __USE_MINGW_ANSI_STDIO before ANY toolchain #includes
41 | // though we're theoretically NOT supposed to be doing this http://mingw.5.n7.nabble.com/snprintf-and-USE-MINGW-ANSI-STDIO-td35399.html
42 | #define __USE_MINGW_ANSI_STDIO 1
43 | #endif
44 |
45 | // std C/C++ headers
46 | #include
47 | #include
48 | #include
49 | #include
50 | #include
51 | #if defined(__USE_MINGW_ANSI_STDIO) && (__USE_MINGW_ANSI_STDIO != 0)
52 | // for some reason, fprintf is excluded from the effect of __USE_MINGW_ANSI_STDIO in stdio.h ?
53 | # define fprintf __mingw_fprintf
54 | #endif
55 | #include
56 | #include
57 | #include
58 | // standard-ish C headers
59 | #include // for alloca()
60 | #include // for struct _stat
61 | #if !defined(_WIN32)
62 | // Linux-specific string fxns: strcasecmp, strncasecmp, etc.
63 | #include "strings.h"
64 | #endif
65 |
66 | // std C++ headers
67 | #include
68 | #include // for std::move,std::swap
69 | #include
70 | #include
71 | #include
72 | #include
73 |
74 | //***************** *****************
75 | //***************** begin project-header includes *****************
76 | //***************** *****************
77 |
78 | // "feature-flags" for project-header includes
79 | #define DEBUG_LOGGING 1
80 | #define OLDGREP 0
81 | #define DBGHILITE 0
82 | #define MOUSE_SUPPORT WL(1,0)
83 | #define VARIABLE_WINBORDER WL(1,0)
84 | #define USE_STAT64 0
85 |
86 | #if defined(_WIN32)
87 | #else
88 | #define _MAX_PATH 513
89 | #endif
90 |
91 | #include "my_types.h"
92 | #include "ed_mem.h"
93 | #include "my_strutils.h"
94 | #include "filename.h"
95 | #include "dlink.h"
96 | #include "stringlist.h"
97 | #include "krbtree.h"
98 | #include "ed_core.h"
99 | #include "ed_os_generic.h"
100 |
101 | //---------------------------------
102 | #define CMDTBL_H_CMD_TBL_PTR_MACROS
103 | #include "cmdtbl.h"
104 | #undef CMDTBL_H_CMD_TBL_PTR_MACROS
105 | //---------------------------------
106 |
107 | #include "ed_vars.h"
108 | #include "ed_edkc.h"
109 | #include "ed_protos.h"
110 | #include "my_log.h"
111 |
--------------------------------------------------------------------------------
/ed_os_generic.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2015, 2021 by Kevin L. Goodwin [fwmechanic@gmail.com]; All rights reserved
3 | //
4 | // This file is part of K.
5 | //
6 | // K is free software: you can redistribute it and/or modify it under the
7 | // terms of the GNU General Public License as published by the Free Software
8 | // Foundation, either version 3 of the License, or (at your option) any later
9 | // version.
10 | //
11 | // K is distributed in the hope that it will be useful, but WITHOUT ANY
12 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 | // details.
15 | //
16 | // You should have received a copy of the GNU General Public License along
17 | // with K. If not, see .
18 | //
19 |
20 | #pragma once
21 |
22 | #include "os_services.h"
23 |
24 | #include "stringlist.h"
25 |
26 | //--------------------------------------------------------------------------------------------
27 |
28 | #if defined(_WIN32)
29 | extern int EditorLoadCount();
30 | extern bool EditorLoadCountChanged();
31 |
32 | extern bool RunChildSpawnOrSystem( PCChar pCmdStr );
33 | extern bool KillAllBkgndProcesses();
34 |
35 | extern bool popen_rd_ok( std::string &dest, PCChar szcmdline );
36 | extern bool cygpath_xlat( std::string &stbuf );
37 |
38 | extern size_t GetProcessMem();
39 |
40 | extern bool IsCompileJobQueueThreadActive();
41 |
42 | extern bool CompileJobQueueWaitExeDoneTimedout( int timeoutMS );
43 |
44 | extern int CompilePty_CmdsAsyncExec( const StringList &sl, bool fAppend );
45 |
46 | extern int CompilePty_KillAllJobs();
47 |
48 | extern void win_fully_on_desktop();
49 |
50 | extern int StartGuiProcess( PCChar pFullCommandLine );
51 | extern int StartConProcess( PCChar pFullCommandLine );
52 | // extern int StartProcess( PCChar pFullCommandLine, int fWaitForProcessDone, int fDetachedProcess );
53 | #else
54 | STIL int EditorLoadCount() { return 1; }
55 | STIL bool EditorLoadCountChanged() { return false; }
56 | STIL bool RunChildSpawnOrSystem( PCChar pCmdStr ) { return true; }
57 | STIL bool KillAllBkgndProcesses() { return true; }
58 | STIL size_t GetProcessMem() { return 8 * 1024 * 1024; }
59 | STIL bool IsCompileJobQueueThreadActive() { return false; }
60 | STIL bool CompileJobQueueWaitExeDoneTimedout( int timeoutMS ) { return true; }
61 | STIL int CompilePty_CmdsAsyncExec( const StringList &sl, bool fAppend ) { return 0; }
62 | STIL int CompilePty_KillAllJobs() { return 1; }
63 | STIL void win_fully_on_desktop() {}
64 | STIL int StartGuiProcess( PCChar pFullCommandLine ) { return 1; }
65 | STIL int StartConProcess( PCChar pFullCommandLine ) { return 1; }
66 | #endif
67 | extern void StartShellExecuteProcess( PCChar pFullCmdLn, PCChar pExeFile=nullptr );
68 |
69 | extern PFBUF StartInternalShellJob( StringList *sl, bool fAppend );
70 | extern void DetachIdleThread();
71 |
72 | extern PCChar OsErrStr( PChar dest, size_t sizeofDest, int errorCode );
73 | extern PCChar OsErrStr( PChar dest, size_t sizeofDest );
74 |
--------------------------------------------------------------------------------
/ed_search.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2015-2016 by Kevin L. Goodwin [fwmechanic@gmail.com]; All rights reserved
3 | //
4 | // This file is part of K.
5 | //
6 | // K is free software: you can redistribute it and/or modify it under the
7 | // terms of the GNU General Public License as published by the Free Software
8 | // Foundation, either version 3 of the License, or (at your option) any later
9 | // version.
10 | //
11 | // K is distributed in the hope that it will be useful, but WITHOUT ANY
12 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 | // details.
15 | //
16 | // You should have received a copy of the GNU General Public License along
17 | // with K. If not, see .
18 | //
19 |
20 | #pragma once
21 |
22 | class RegexMatchCapture {
23 | sridx d_ofs;
24 | stref d_value;
25 | public:
26 | RegexMatchCapture() : d_ofs( eosr ), d_value( ) {}
27 | RegexMatchCapture( int ofs_, stref val_ ) : d_ofs(ofs_ < 0 ? eosr : ofs_), d_value(val_) {}
28 | bool valid() const { return d_ofs != eosr; }
29 | stref value() const { return d_value; }
30 | sridx offset() const { return d_ofs ; }
31 | };
32 | typedef std::vector RegexMatchCaptures;
33 | extern int DbgDumpCaptures( RegexMatchCaptures &captures, PCChar tag );
34 |
35 | #if USE_PCRE
36 |
37 | #include "pcre2.h"
38 |
39 | class CompiledRegex;
40 | extern CompiledRegex *Regex_Compile( stref pszSearchStr, bool fCase );
41 | extern CompiledRegex *Regex_Delete0( CompiledRegex *pcr );
42 | extern RegexMatchCaptures::size_type Regex_Match( CompiledRegex *pcr, RegexMatchCaptures &captures, stref haystack, COL haystack_offset, int pcre_exec_options );
43 | extern void register_atexit_search();
44 | extern stref RegexVersion();
45 |
46 | #else
47 |
48 | #define register_atexit_search()
49 | STIL stref RegexVersion() { return ""; }
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/fbuf.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fwmechanic/k_edit/6c2ef6a1151a0ed5f719e868d6bd437538d26587/fbuf.cpp
--------------------------------------------------------------------------------
/fbuf_edit.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fwmechanic/k_edit/6c2ef6a1151a0ed5f719e868d6bd437538d26587/fbuf_edit.cpp
--------------------------------------------------------------------------------
/features/cygpath_mode.txt:
--------------------------------------------------------------------------------
1 | Problem:
2 | My chosen Windows shell environment is GitForWindows bash. In this
3 | environment, constructing [bash] cmdlines using "Windows format" filenames
4 | provided by K (e.g. from ) is labor-intensive and error-prone.
5 |
6 | Possible solutions:
7 |
8 | Implementation of CYPTL ("CYgPath Translation Layer") mimicking the
9 | functionality of `cygpath` (reinvention of the wheel? Would rather not).
10 |
11 | When to enable this translation layer? if $SHELL:match("[/\\]bash.exe$")
12 |
13 | What about shell cmdline param translation? Ugh, parsing a cmdline would suck.
14 |
15 | What about declaring a bash alias/function cyp() { cygpath "$1" ; } and
16 | (yes, manually) coding cmdline tokens w/ "$(cyp 'pasted-filename')" ; but
17 | that's still __A LOT__ of picky TYPING.
18 |
19 | Maybe a new function derivative of lasttext which runs cygpath on the select text?
20 |
21 | But maybe it's better to wait
22 |
--------------------------------------------------------------------------------
/fn_text.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fwmechanic/k_edit/6c2ef6a1151a0ed5f719e868d6bd437538d26587/fn_text.cpp
--------------------------------------------------------------------------------
/fname_gen.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2015,2021 by Kevin L. Goodwin [fwmechanic@gmail.com]; All rights reserved
3 | //
4 | // This file is part of K.
5 | //
6 | // K is free software: you can redistribute it and/or modify it under the
7 | // terms of the GNU General Public License as published by the Free Software
8 | // Foundation, either version 3 of the License, or (at your option) any later
9 | // version.
10 | //
11 | // K is distributed in the hope that it will be useful, but WITHOUT ANY
12 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 | // details.
15 | //
16 | // You should have received a copy of the GNU General Public License along
17 | // with K. If not, see .
18 | //
19 |
20 | #pragma once
21 |
22 | #include "ed_main.h"
23 |
24 | class PathStrGenerator { // interface class
25 | NO_COPYCTOR(PathStrGenerator);
26 | NO_ASGN_OPR(PathStrGenerator);
27 | std::string d_src;
28 | public:
29 | PathStrGenerator( std::string &src ) : d_src( src ) {}
30 | virtual bool VGetNextName( Path::str_t &dest ) = 0;
31 | stref srSrc() { return d_src; }
32 | virtual ~PathStrGenerator() {}
33 | };
34 |
35 | class WildcardFilenameGenerator : public PathStrGenerator {
36 | NO_COPYCTOR(WildcardFilenameGenerator);
37 | NO_ASGN_OPR(WildcardFilenameGenerator);
38 | DirMatches d_dm;
39 | public:
40 | WildcardFilenameGenerator( std::string &&src, PCChar string, WildCardMatchMode matchMode=ONLY_FILES )
41 | : PathStrGenerator( src )
42 | , d_dm( string, nullptr, matchMode )
43 | {}
44 | // DTOR auto-generated
45 | bool VGetNextName( Path::str_t &dest ) override;
46 | };
47 |
48 | class DirListGenerator : public PathStrGenerator {
49 | NO_COPYCTOR( DirListGenerator );
50 | NO_ASGN_OPR( DirListGenerator );
51 | StringList d_input ;
52 | StringList d_output;
53 | void AddName( stref name );
54 | public:
55 | DirListGenerator( std::string &&src, PCChar dirName=nullptr );
56 | ~DirListGenerator();
57 | bool VGetNextName( Path::str_t &dest ) override;
58 | };
59 |
60 | class DicedOnDelimString : public DiceableString {
61 | public:
62 | DicedOnDelimString( stref str, PCChar pszDelims )
63 | : DiceableString( str )
64 | {
65 | extern void ChopAscizzOnDelim( PChar cur, PCChar pszDelim );
66 | ChopAscizzOnDelim( d_heapString, pszDelims );
67 | }
68 | };
69 |
70 | class StrSubstituterGenerator; // "static"
71 |
72 | class CfxFilenameGenerator : public PathStrGenerator {
73 | NO_COPYCTOR(CfxFilenameGenerator);
74 | NO_ASGN_OPR(CfxFilenameGenerator);
75 | WildcardFilenameGenerator *d_pWcGen = nullptr;
76 | StrSubstituterGenerator *d_pSSG = nullptr;
77 | DicedOnDelimString d_splitLine;
78 | WildCardMatchMode d_matchMode;
79 | PCChar d_pszEntrySuffix = nullptr;
80 | public:
81 | CfxFilenameGenerator( std::string &&src, stref macroText, WildCardMatchMode matchMode );
82 | bool VGetNextName( Path::str_t &dest ) override;
83 | virtual ~CfxFilenameGenerator();
84 | };
85 |
86 | //-----------------------------------
87 |
88 | class FilelistCfxFilenameGenerator : public PathStrGenerator {
89 | NO_COPYCTOR( FilelistCfxFilenameGenerator );
90 | NO_ASGN_OPR( FilelistCfxFilenameGenerator );
91 | PFBUF d_pFBuf;
92 | LINE d_curLine = 0;
93 | CfxFilenameGenerator *d_pCfxGen = nullptr;
94 | Path::str_t d_sbuf;
95 | std::string d_nmBuf;
96 | public:
97 | FilelistCfxFilenameGenerator( std::string &&src, PFBUF pFBuf )
98 | : PathStrGenerator( src )
99 | , d_pFBuf( pFBuf )
100 | , d_nmBuf( src )
101 | {}
102 | bool VGetNextName( Path::str_t &dest ) override;
103 | virtual ~FilelistCfxFilenameGenerator() { Delete0( d_pCfxGen ); }
104 | };
105 |
106 | //-----------------------------------
107 |
--------------------------------------------------------------------------------
/getopt.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2015 by Kevin L. Goodwin [fwmechanic@gmail.com]; All rights reserved
3 | //
4 | // This file is part of K.
5 | //
6 | // K is free software: you can redistribute it and/or modify it under the
7 | // terms of the GNU General Public License as published by the Free Software
8 | // Foundation, either version 3 of the License, or (at your option) any later
9 | // version.
10 | //
11 | // K is distributed in the hope that it will be useful, but WITHOUT ANY
12 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 | // details.
15 | //
16 | // You should have received a copy of the GNU General Public License along
17 | // with K. If not, see .
18 | //
19 |
20 | #pragma once
21 |
22 |
23 | #include "ed_main.h"
24 | #include "my_strutils.h"
25 |
26 | class Getopt
27 | {
28 | const int d_argc; // saved parameter
29 | const PPCChar d_argv; // saved parameter
30 | const PCChar d_pOptSet; // saved parameter
31 |
32 | int d_argi = 1; // index of which argument is next
33 | PCChar d_pOptarg = nullptr; // pointer to argument of current option (if any)
34 | PCChar d_pAddlOpt = nullptr; // remember next option char's location. If d_pAddlOpt is not nullptr
35 | // it is pointing into a string at an option character (a SW
36 | // char has already been seen)
37 | typedef char pathbuf[_MAX_PATH+1];
38 |
39 |
40 | protected:
41 |
42 | Path::str_t d_pgm; // name w/o path or extension
43 |
44 | public:
45 |
46 | virtual void VErrorOut( PCChar emsg ) = 0;
47 |
48 | Getopt( int argc_, PPCChar argv_, PCChar optset_ );
49 | virtual ~Getopt() {}
50 | int NextOptCh();
51 | PCChar optarg() const { return d_pOptarg; }
52 | PCChar nextarg() { return (d_argi < d_argc) ? d_argv[d_argi++] : nullptr; }
53 | };
54 |
--------------------------------------------------------------------------------
/git_cat_local_config:
--------------------------------------------------------------------------------
1 | cat .git/config
2 |
--------------------------------------------------------------------------------
/git_set_fwmechanic_ident:
--------------------------------------------------------------------------------
1 | git config --local user.email fwmechanic@gmail.com
2 | git config --local user.name "Kevin Goodwin"
3 |
--------------------------------------------------------------------------------
/historical_scans_fair_use/1988.09-MS.Journal-Notenboom-Customizing.M.Editor.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fwmechanic/k_edit/6c2ef6a1151a0ed5f719e868d6bd437538d26587/historical_scans_fair_use/1988.09-MS.Journal-Notenboom-Customizing.M.Editor.pdf
--------------------------------------------------------------------------------
/historical_scans_fair_use/2001.07-MSDN.News-Michell-PWB.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fwmechanic/k_edit/6c2ef6a1151a0ed5f719e868d6bd437538d26587/historical_scans_fair_use/2001.07-MSDN.News-Michell-PWB.pdf
--------------------------------------------------------------------------------
/historical_scans_fair_use/README.txt:
--------------------------------------------------------------------------------
1 | 1986.08.04-Z.TXT "User's Guide to the Z Editor", Mark Zbikowski, 4 August 1986
2 | retrieved from http://www.pcjs.org/disks/pcx86/tools/microsoft/misc/root/Z.TXT
3 |
4 | Z-cleaned.TXT is 1986.08.04-Z.TXT with pagination and page headers/footers
5 | removed.
6 |
7 | see also a scan of the M 1.00 manual (included as part of MSC 5.1):
8 | http://archive.pcjs.org/pubs/pc/software/tools/microsoft/c/5.10/MSC51-EDITOR.pdf
9 |
--------------------------------------------------------------------------------
/install_build_tools_ubuntu.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #
4 | # Copyright 2015-2021 by Kevin L. Goodwin [fwmechanic@gmail.com]; All rights reserved
5 | #
6 | # This file is part of K.
7 | #
8 | # K is free software: you can redistribute it and/or modify it under the
9 | # terms of the GNU General Public License as published by the Free Software
10 | # Foundation, either version 3 of the License, or (at your option) any later
11 | # version.
12 | #
13 | # K is distributed in the hope that it will be useful, but WITHOUT ANY
14 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | # details.
17 | #
18 | # You should have received a copy of the GNU General Public License along
19 | # with K. If not, see .
20 | #
21 |
22 | # run to unilaterally install prereqs for building & running K
23 |
24 | hdr="$ID K-prereq-install: "
25 | complete() {
26 | local rv="$?"
27 | [ "$rv" -gt "0" ] && { echo "${hdr}FAILED" ; exit 1 ; }
28 | echo "to build & install universal-ctags: run ./ubuntu_univ-ctags_build_install"
29 | echo "${hdr}SUCCEEDED"
30 | exit 0
31 | }
32 |
33 | . /etc/os-release
34 |
35 | if [[ "$ID" = "ubuntu" || "$ID" = "pop" ]] ; then
36 | echo "${hdr}STARTING"
37 | sudo apt-get install -yq \
38 | build-essential \
39 | g++ \
40 | libboost-dev \
41 | libboost-filesystem-dev \
42 | libboost-system-dev \
43 | libncurses5-dev \
44 | libpcre2-dev \
45 | ncurses-term \
46 | libreadline-dev \
47 | universal-ctags \
48 | xclip
49 | complete
50 | fi
51 |
52 | if [ "$ID" = "centos" ] ; then
53 | echo "${hdr}STARTING"
54 | yum -yq groupinstall "Development Tools" &&
55 | yum -yq install boost-devel ncurses-devel pcre2-devel pcre2-static ncurses-term readline-devel &&
56 | yum -yq install exuberant-ctags &&
57 | yum -yq install xclip
58 | complete
59 | fi
60 |
61 | echo "${hdr}FAILED: '$ID' unknown" ;
62 | exit 1
63 |
64 | # notes (not used): alternative yum version
65 | yum groupinstall "Development Tools"
66 | yum install libboost-devel
67 | yum install libboost-filesystem-devel
68 | yum install libboost-system-devel
69 | yum install libncurses5-devel
70 | yum install libpcre3-devel
71 | yum install exuberant-ctags
72 | yum install ncurses-term
73 | yum install xclip
74 |
--------------------------------------------------------------------------------
/k.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2015-2016 by Kevin L. Goodwin [fwmechanic@gmail.com]; All rights reserved
3 | //
4 | // This file is part of K.
5 | //
6 | // K is free software: you can redistribute it and/or modify it under the
7 | // terms of the GNU General Public License as published by the Free Software
8 | // Foundation, either version 3 of the License, or (at your option) any later
9 | // version.
10 | //
11 | // K is distributed in the hope that it will be useful, but WITHOUT ANY
12 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 | // details.
15 | //
16 | // You should have received a copy of the GNU General Public License along
17 | // with K. If not, see .
18 | //
19 |
20 | //
21 | // CONVERTING THIS TO COMPILE WITH C-language to make k.exe smaller DOES NOT
22 | // WORK. Don't bother (again).
23 | //
24 |
25 | #include
26 | #include
27 |
28 | const char entrypoint[] =
29 | #if defined(__GNUC__)
30 |
31 | #ifdef __x86_64
32 | "Main" ;
33 | #else
34 | "Main@12" ;
35 | #endif
36 |
37 | int _CRT_glob = 0; // suppress default MinGW argv globbing http://cygwin.com/ml/cygwin/1999-11/msg00052.html
38 |
39 | #else
40 | "_Main@12";
41 | #endif
42 |
43 | #if defined(_WIN32)
44 | #define CDECL__ __cdecl
45 | #else
46 | #define CDECL__
47 | #endif
48 |
49 | int CDECL__ main( int argc, char *argv[], char *envp[] ) {
50 | char buf[ MAX_PATH+1 ];
51 | const auto len( GetModuleFileName( nullptr, buf, sizeof buf ) );
52 | if( len >= sizeof(buf) ) {
53 | fprintf( stderr, "GetModuleFileName rv (%lu) >= sizeof(buf) (%" PR_SIZET ")\n", len, sizeof(buf) );
54 | return 1;
55 | }
56 |
57 | for( auto pExt = buf + strlen( buf ) - 1; pExt > buf; --pExt ) {
58 | // fprintf( stderr, "'%c' ?\n" );
59 | if( *pExt == '.' ) {
60 | #if 0
61 | pExt[1] = 'd'; // load K.DLL
62 | pExt[2] = 'l';
63 | pExt[3] = 'l';
64 | pExt[4] = 0 ;
65 | #elif 1
66 | pExt[0] = 'x'; // load KX.DLL
67 | pExt[1] = '.';
68 | pExt[2] = 'd';
69 | pExt[3] = 'l';
70 | pExt[4] = 'l';
71 | pExt[5] = 0 ;
72 | #else
73 | # error
74 | #endif
75 |
76 | // fprintf( stderr, "MFN '%s'\n", buf );
77 |
78 | auto hDLL = LoadLibrary( buf );
79 | if( !hDLL ) {
80 | fprintf( stderr, "LoadLibrary( '%s' ) failed; Error: %lu\n", buf, GetLastError() );
81 | return 1;
82 | }
83 |
84 | typedef void (*FxnMain)( int argc, char *argv[], char *envp[] );
85 |
86 | const auto editor_main( FxnMain( GetProcAddress( hDLL, entrypoint ) ) ); // NB: cannot use static_cast to replace C-style cast here
87 | if( !editor_main ) {
88 | FreeLibrary( hDLL );
89 | fprintf( stderr, "GetProcAddress(%s) failed\n", argv[0] );
90 | return 1;
91 | }
92 |
93 | editor_main( argc, argv, envp ); // never returns
94 | return 1; // just in case ...
95 | }
96 | }
97 | return 1; // should not get here
98 | }
99 |
--------------------------------------------------------------------------------
/k.luaedit:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fwmechanic/k_edit/6c2ef6a1151a0ed5f719e868d6bd437538d26587/k.luaedit
--------------------------------------------------------------------------------
/k.rc:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2015 by Kevin L. Goodwin [fwmechanic@gmail.com]; All rights reserved
3 | //
4 | // This file is part of K.
5 | //
6 | // K is free software: you can redistribute it and/or modify it under the
7 | // terms of the GNU General Public License as published by the Free Software
8 | // Foundation, either version 3 of the License, or (at your option) any later
9 | // version.
10 | //
11 | // K is distributed in the hope that it will be useful, but WITHOUT ANY
12 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 | // details.
15 | //
16 | // You should have received a copy of the GNU General Public License along
17 | // with K. If not, see .
18 | //
19 |
20 | // http://stackoverflow.com/questions/708238/how-do-i-add-an-icon-to-a-mingw-gcc-compiled-executable
21 |
22 | id ICON "k.ico"
23 |
24 | 1 VERSIONINFO
25 | FILEVERSION 1,0,0,0
26 | PRODUCTVERSION 1,0,0,0
27 | BEGIN
28 | BLOCK "StringFileInfo"
29 | BEGIN
30 | BLOCK "040904E4"
31 | BEGIN
32 | VALUE "CompanyName", "My Company Name"
33 | VALUE "FileDescription", "Kevin's excellent programmer's text editor"
34 | VALUE "FileVersion", "1.0"
35 | VALUE "InternalName", "K"
36 | VALUE "LegalCopyright", ""
37 | VALUE "OriginalFilename", "k.exe"
38 | VALUE "ProductName", "K Editor"
39 | VALUE "ProductVersion", "1.0"
40 | END
41 | END
42 |
43 | BLOCK "VarFileInfo"
44 | BEGIN
45 | VALUE "Translation", 0x409, 1252
46 | END
47 | END
48 |
--------------------------------------------------------------------------------
/k.workspace:
--------------------------------------------------------------------------------
1 | #!lua
2 | --
3 | -- Copyright 2015 by Kevin L. Goodwin [fwmechanic@gmail.com]; All rights reserved
4 | --
5 | -- This file is part of K.
6 | --
7 | -- K is free software: you can redistribute it and/or modify it under the
8 | -- terms of the GNU General Public License as published by the Free Software
9 | -- Foundation, either version 3 of the License, or (at your option) any later
10 | -- version.
11 | --
12 | -- K is distributed in the hope that it will be useful, but WITHOUT ANY
13 | -- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 | -- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 | -- details.
16 | --
17 | -- You should have received a copy of the GNU General Public License along
18 | -- with K. If not, see .
19 | --
20 |
21 | -- bring ObjectShow !!!
22 |
23 | local a_wsdir = { wsdir }
24 | local a_luasrc = { wsdir.."lua-5.1/src/" }
25 | local wc_c = { "*.h", "*.c", "*.cpp" }
26 |
27 | mfx = {
28 | ksrc = a_cross( a_wsdir , wc_c ),
29 | luac = a_cross( a_luasrc, wc_c ),
30 | }
31 | mfx.all_c = a_cat( mfx.ksrc, mfx.luac )
32 |
33 | show( mfx )
34 |
--------------------------------------------------------------------------------
/krmbak:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | dnm='.kbackup'
3 | dinpath='*/'"$dnm"'/*'
4 | show() (
5 | dct="$(find . -type d -name "$dnm" | wc -l)"
6 | fct="$(find . -path "$dinpath" -type f | wc -l)"
7 | echo "$1 $fct files in $dct $dnm dirs"
8 | )
9 | list() (
10 | find . -path "$dinpath" -type f | sort -i
11 | )
12 | case "$1" in
13 | rmall) show "deleting" ;
14 | find . -type d -name "$dnm" -exec rm -r {} +
15 | ;;
16 | list) list
17 | ;;
18 | *) show "there are"
19 | echo " list to list all files"
20 | echo " rmall to delete all files/dirs"
21 | ;;
22 | esac
23 |
--------------------------------------------------------------------------------
/krmlog:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | find $(dirname $0) -name 'k-*.log' | xargs rm -f
3 |
--------------------------------------------------------------------------------
/linux_base.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2015 by Kevin L. Goodwin [fwmechanic@gmail.com]; All rights reserved
3 | //
4 | // This file is part of K.
5 | //
6 | // K is free software: you can redistribute it and/or modify it under the
7 | // terms of the GNU General Public License as published by the Free Software
8 | // Foundation, either version 3 of the License, or (at your option) any later
9 | // version.
10 | //
11 | // K is distributed in the hope that it will be useful, but WITHOUT ANY
12 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 | // details.
15 | //
16 | // You should have received a copy of the GNU General Public License along
17 | // with K. If not, see .
18 | //
19 |
20 | #pragma once
21 |
22 | #if defined(__GNUC__)
23 | #pragma GCC diagnostic push
24 | #pragma GCC diagnostic ignored "-Wold-style-cast"
25 | #endif
26 |
27 | //##############################################################################
28 |
29 | STIL void DebugLog( PCChar string ) { /* Win32::OutputDebugString( string ); */ }
30 |
31 | extern bool IsFileReadonly( PCChar pFBufName );
32 | extern bool FileOrDirExists( PCChar lpFBufName );
33 |
34 | struct WhileHoldingGlobalVariableLock
35 | {
36 | WhileHoldingGlobalVariableLock() ;
37 | ~WhileHoldingGlobalVariableLock() ;
38 | };
39 |
40 | extern void MainThreadGiveUpGlobalVariableLock() ;
41 | extern void MainThreadWaitForGlobalVariableLock() ;
42 |
--------------------------------------------------------------------------------
/lua-5.1/COPYRIGHT:
--------------------------------------------------------------------------------
1 | Lua License
2 | -----------
3 |
4 | Lua is licensed under the terms of the MIT license reproduced below.
5 | This means that Lua is free software and can be used for both academic
6 | and commercial purposes at absolutely no cost.
7 |
8 | For details and rationale, see http://www.lua.org/license.html .
9 |
10 | ===============================================================================
11 |
12 | Copyright (C) 1994-2012 Lua.org, PUC-Rio.
13 |
14 | Permission is hereby granted, free of charge, to any person obtaining a copy
15 | of this software and associated documentation files (the "Software"), to deal
16 | in the Software without restriction, including without limitation the rights
17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18 | copies of the Software, and to permit persons to whom the Software is
19 | furnished to do so, subject to the following conditions:
20 |
21 | The above copyright notice and this permission notice shall be included in
22 | all copies or substantial portions of the Software.
23 |
24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30 | THE SOFTWARE.
31 |
32 | ===============================================================================
33 |
34 | (end of COPYRIGHT)
35 |
--------------------------------------------------------------------------------
/lua-5.1/MANIFEST:
--------------------------------------------------------------------------------
1 | MANIFEST contents of Lua 5.1 distribution on Mon Feb 20 11:37:30 BRT 2006
2 | lua-5.1
3 | lua-5.1/COPYRIGHT
4 | lua-5.1/HISTORY
5 | lua-5.1/INSTALL
6 | lua-5.1/MANIFEST
7 | lua-5.1/Makefile
8 | lua-5.1/README
9 | lua-5.1/doc
10 | lua-5.1/doc/contents.html
11 | lua-5.1/doc/logo.gif
12 | lua-5.1/doc/lua.1
13 | lua-5.1/doc/lua.css
14 | lua-5.1/doc/lua.html
15 | lua-5.1/doc/luac.1
16 | lua-5.1/doc/luac.html
17 | lua-5.1/doc/manual.html
18 | lua-5.1/doc/readme.html
19 | lua-5.1/etc
20 | lua-5.1/etc/Makefile
21 | lua-5.1/etc/README
22 | lua-5.1/etc/all.c
23 | lua-5.1/etc/lua.hpp
24 | lua-5.1/etc/lua.ico
25 | lua-5.1/etc/lua.pc
26 | lua-5.1/etc/luavs.bat
27 | lua-5.1/etc/min.c
28 | lua-5.1/etc/noparser.c
29 | lua-5.1/etc/strict.lua
30 | lua-5.1/src
31 | lua-5.1/src/Makefile
32 | lua-5.1/src/lapi.c
33 | lua-5.1/src/lapi.h
34 | lua-5.1/src/lauxlib.c
35 | lua-5.1/src/lauxlib.h
36 | lua-5.1/src/lbaselib.c
37 | lua-5.1/src/lcode.c
38 | lua-5.1/src/lcode.h
39 | lua-5.1/src/ldblib.c
40 | lua-5.1/src/ldebug.c
41 | lua-5.1/src/ldebug.h
42 | lua-5.1/src/ldo.c
43 | lua-5.1/src/ldo.h
44 | lua-5.1/src/ldump.c
45 | lua-5.1/src/lfunc.c
46 | lua-5.1/src/lfunc.h
47 | lua-5.1/src/lgc.c
48 | lua-5.1/src/lgc.h
49 | lua-5.1/src/linit.c
50 | lua-5.1/src/liolib.c
51 | lua-5.1/src/llex.c
52 | lua-5.1/src/llex.h
53 | lua-5.1/src/llimits.h
54 | lua-5.1/src/lmathlib.c
55 | lua-5.1/src/lmem.c
56 | lua-5.1/src/lmem.h
57 | lua-5.1/src/loadlib.c
58 | lua-5.1/src/lobject.c
59 | lua-5.1/src/lobject.h
60 | lua-5.1/src/lopcodes.c
61 | lua-5.1/src/lopcodes.h
62 | lua-5.1/src/loslib.c
63 | lua-5.1/src/lparser.c
64 | lua-5.1/src/lparser.h
65 | lua-5.1/src/lstate.c
66 | lua-5.1/src/lstate.h
67 | lua-5.1/src/lstring.c
68 | lua-5.1/src/lstring.h
69 | lua-5.1/src/lstrlib.c
70 | lua-5.1/src/ltable.c
71 | lua-5.1/src/ltable.h
72 | lua-5.1/src/ltablib.c
73 | lua-5.1/src/ltm.c
74 | lua-5.1/src/ltm.h
75 | lua-5.1/src/lua.c
76 | lua-5.1/src/lua.h
77 | lua-5.1/src/luac.c
78 | lua-5.1/src/luaconf.h
79 | lua-5.1/src/lualib.h
80 | lua-5.1/src/lundump.c
81 | lua-5.1/src/lundump.h
82 | lua-5.1/src/lvm.c
83 | lua-5.1/src/lvm.h
84 | lua-5.1/src/lzio.c
85 | lua-5.1/src/lzio.h
86 | lua-5.1/src/print.c
87 | lua-5.1/test
88 | lua-5.1/test/README
89 | lua-5.1/test/bisect.lua
90 | lua-5.1/test/cf.lua
91 | lua-5.1/test/echo.lua
92 | lua-5.1/test/env.lua
93 | lua-5.1/test/factorial.lua
94 | lua-5.1/test/fib.lua
95 | lua-5.1/test/fibfor.lua
96 | lua-5.1/test/globals.lua
97 | lua-5.1/test/hello.lua
98 | lua-5.1/test/life.lua
99 | lua-5.1/test/luac.lua
100 | lua-5.1/test/printf.lua
101 | lua-5.1/test/readonly.lua
102 | lua-5.1/test/sieve.lua
103 | lua-5.1/test/sort.lua
104 | lua-5.1/test/table.lua
105 | lua-5.1/test/trace-calls.lua
106 | lua-5.1/test/trace-globals.lua
107 | lua-5.1/test/xd.lua
108 | END OF MANIFEST
109 |
--------------------------------------------------------------------------------
/lua-5.1/README:
--------------------------------------------------------------------------------
1 | README for Lua 5.1
2 |
3 | See INSTALL for installation instructions.
4 | See HISTORY for a summary of changes since the last released version.
5 |
6 | * What is Lua?
7 | ------------
8 | Lua is a powerful, light-weight programming language designed for extending
9 | applications. Lua is also frequently used as a general-purpose, stand-alone
10 | language. Lua is free software.
11 |
12 | For complete information, visit Lua's web site at http://www.lua.org/ .
13 | For an executive summary, see http://www.lua.org/about.html .
14 |
15 | Lua has been used in many different projects around the world.
16 | For a short list, see http://www.lua.org/uses.html .
17 |
18 | * Availability
19 | ------------
20 | Lua is freely available for both academic and commercial purposes.
21 | See COPYRIGHT and http://www.lua.org/license.html for details.
22 | Lua can be downloaded at http://www.lua.org/download.html .
23 |
24 | * Installation
25 | ------------
26 | Lua is implemented in pure ANSI C, and compiles unmodified in all known
27 | platforms that have an ANSI C compiler. In most Unix-like platforms, simply
28 | do "make" with a suitable target. See INSTALL for detailed instructions.
29 |
30 | * Origin
31 | ------
32 | Lua is developed at Lua.org, a laboratory of the Department of Computer
33 | Science of PUC-Rio (the Pontifical Catholic University of Rio de Janeiro
34 | in Brazil).
35 | For more information about the authors, see http://www.lua.org/authors.html .
36 |
37 | (end of README)
38 |
--------------------------------------------------------------------------------
/lua-5.1/doc/cover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fwmechanic/k_edit/6c2ef6a1151a0ed5f719e868d6bd437538d26587/lua-5.1/doc/cover.png
--------------------------------------------------------------------------------
/lua-5.1/doc/logo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fwmechanic/k_edit/6c2ef6a1151a0ed5f719e868d6bd437538d26587/lua-5.1/doc/logo.gif
--------------------------------------------------------------------------------
/lua-5.1/doc/lrexlib/lrexlib.css:
--------------------------------------------------------------------------------
1 | /*
2 | :Author: Shmuel Zeigerman
3 | :Contact: shmuz at actcom co il
4 | :Copyright: This stylesheet has been placed in the public domain.
5 |
6 | [Optionally place a description here.]
7 | */
8 |
9 | @import url(html4css1.css);
10 |
11 | hr.docutils {
12 | width: 100%
13 | }
14 |
15 | .funcdef {
16 | font-weight: bold ;
17 | font-size: 100%
18 | }
19 |
20 | body {
21 | margin-left: 1em ;
22 | margin-right: 1em ;
23 | font-family: "Verdana", sans-serif ;
24 | }
25 |
26 | table {
27 | border-spacing: 0;
28 | }
29 |
30 | tr {
31 | margin: 0;
32 | padding: 0;
33 | }
34 |
--------------------------------------------------------------------------------
/lua-5.1/doc/lua.css:
--------------------------------------------------------------------------------
1 | body {
2 | color: #000000 ;
3 | background-color: #FFFFFF ;
4 | font-family: Helvetica, Arial, sans-serif ;
5 | text-align: justify ;
6 | margin-right: 30px ;
7 | margin-left: 30px ;
8 | }
9 |
10 | h1, h2, h3, h4 {
11 | font-family: Verdana, Geneva, sans-serif ;
12 | font-weight: normal ;
13 | font-style: italic ;
14 | }
15 |
16 | h2 {
17 | padding-top: 0.4em ;
18 | padding-bottom: 0.4em ;
19 | padding-left: 30px ;
20 | padding-right: 30px ;
21 | margin-left: -30px ;
22 | background-color: #E0E0FF ;
23 | }
24 |
25 | h3 {
26 | padding-left: 0.5em ;
27 | border-left: solid #E0E0FF 1em ;
28 | }
29 |
30 | table h3 {
31 | padding-left: 0px ;
32 | border-left: none ;
33 | }
34 |
35 | a:link {
36 | color: #000080 ;
37 | background-color: inherit ;
38 | text-decoration: none ;
39 | }
40 |
41 | a:visited {
42 | background-color: inherit ;
43 | text-decoration: none ;
44 | }
45 |
46 | a:link:hover, a:visited:hover {
47 | color: #000080 ;
48 | background-color: #E0E0FF ;
49 | }
50 |
51 | a:link:active, a:visited:active {
52 | color: #FF0000 ;
53 | }
54 |
55 | hr {
56 | border: 0 ;
57 | height: 1px ;
58 | color: #a0a0a0 ;
59 | background-color: #a0a0a0 ;
60 | }
61 |
62 | :target {
63 | background-color: #F8F8F8 ;
64 | padding: 8px ;
65 | border: solid #a0a0a0 2px ;
66 | }
67 |
68 | .footer {
69 | color: gray ;
70 | font-size: small ;
71 | }
72 |
73 | input[type=text] {
74 | border: solid #a0a0a0 2px ;
75 | border-radius: 2em ;
76 | -moz-border-radius: 2em ;
77 | background-image: url('images/search.png') ;
78 | background-repeat: no-repeat;
79 | background-position: 4px center ;
80 | padding-left: 20px ;
81 | height: 2em ;
82 | }
83 |
84 |
--------------------------------------------------------------------------------
/lua-5.1/doc/luac.1:
--------------------------------------------------------------------------------
1 | .\" $Id: luac.man,v 1.28 2006/01/06 16:03:34 lhf Exp $
2 | .TH LUAC 1 "$Date: 2006/01/06 16:03:34 $"
3 | .SH NAME
4 | luac \- Lua compiler
5 | .SH SYNOPSIS
6 | .B luac
7 | [
8 | .I options
9 | ] [
10 | .I filenames
11 | ]
12 | .SH DESCRIPTION
13 | .B luac
14 | is the Lua compiler.
15 | It translates programs written in the Lua programming language
16 | into binary files that can be later loaded and executed.
17 | .LP
18 | The main advantages of precompiling chunks are:
19 | faster loading,
20 | protecting source code from accidental user changes,
21 | and
22 | off-line syntax checking.
23 | .LP
24 | Pre-compiling does not imply faster execution
25 | because in Lua chunks are always compiled into bytecodes before being executed.
26 | .B luac
27 | simply allows those bytecodes to be saved in a file for later execution.
28 | .LP
29 | Pre-compiled chunks are not necessarily smaller than the corresponding source.
30 | The main goal in pre-compiling is faster loading.
31 | .LP
32 | The binary files created by
33 | .B luac
34 | are portable only among architectures with the same word size and byte order.
35 | .LP
36 | .B luac
37 | produces a single output file containing the bytecodes
38 | for all source files given.
39 | By default,
40 | the output file is named
41 | .BR luac.out ,
42 | but you can change this with the
43 | .B \-o
44 | option.
45 | .LP
46 | In the command line,
47 | you can mix
48 | text files containing Lua source and
49 | binary files containing precompiled chunks.
50 | This is useful to combine several precompiled chunks,
51 | even from different (but compatible) platforms,
52 | into a single precompiled chunk.
53 | .LP
54 | You can use
55 | .B "'\-'"
56 | to indicate the standard input as a source file
57 | and
58 | .B "'\--'"
59 | to signal the end of options
60 | (that is,
61 | all remaining arguments will be treated as files even if they start with
62 | .BR "'\-'" ).
63 | .LP
64 | The internal format of the binary files produced by
65 | .B luac
66 | is likely to change when a new version of Lua is released.
67 | So,
68 | save the source files of all Lua programs that you precompile.
69 | .LP
70 | .SH OPTIONS
71 | Options must be separate.
72 | .TP
73 | .B \-l
74 | produce a listing of the compiled bytecode for Lua's virtual machine.
75 | Listing bytecodes is useful to learn about Lua's virtual machine.
76 | If no files are given, then
77 | .B luac
78 | loads
79 | .B luac.out
80 | and lists its contents.
81 | .TP
82 | .BI \-o " file"
83 | output to
84 | .IR file ,
85 | instead of the default
86 | .BR luac.out .
87 | (You can use
88 | .B "'\-'"
89 | for standard output,
90 | but not on platforms that open standard output in text mode.)
91 | The output file may be a source file because
92 | all files are loaded before the output file is written.
93 | Be careful not to overwrite precious files.
94 | .TP
95 | .B \-p
96 | load files but do not generate any output file.
97 | Used mainly for syntax checking and for testing precompiled chunks:
98 | corrupted files will probably generate errors when loaded.
99 | Lua always performs a thorough integrity test on precompiled chunks.
100 | Bytecode that passes this test is completely safe,
101 | in the sense that it will not break the interpreter.
102 | However,
103 | there is no guarantee that such code does anything sensible.
104 | (None can be given, because the halting problem is unsolvable.)
105 | If no files are given, then
106 | .B luac
107 | loads
108 | .B luac.out
109 | and tests its contents.
110 | No messages are displayed if the file passes the integrity test.
111 | .TP
112 | .B \-s
113 | strip debug information before writing the output file.
114 | This saves some space in very large chunks,
115 | but if errors occur when running a stripped chunk,
116 | then the error messages may not contain the full information they usually do.
117 | For instance,
118 | line numbers and names of local variables are lost.
119 | .TP
120 | .B \-v
121 | show version information.
122 | .SH FILES
123 | .TP 15
124 | .B luac.out
125 | default output file
126 | .SH "SEE ALSO"
127 | .BR lua (1)
128 | .br
129 | http://www.lua.org/
130 | .SH DIAGNOSTICS
131 | Error messages should be self explanatory.
132 | .SH AUTHORS
133 | L. H. de Figueiredo,
134 | R. Ierusalimschy and
135 | W. Celes
136 | .\" EOF
137 |
--------------------------------------------------------------------------------
/lua-5.1/doc/manual.css:
--------------------------------------------------------------------------------
1 | h3 code {
2 | font-family: inherit ;
3 | font-size: inherit ;
4 | }
5 |
6 | pre, code {
7 | font-size: 12pt ;
8 | }
9 |
10 | span.apii {
11 | float: right ;
12 | font-family: inherit ;
13 | font-style: normal ;
14 | font-size: small ;
15 | color: gray ;
16 | }
17 |
18 | p+h1, ul+h1 {
19 | padding-top: 0.4em ;
20 | padding-bottom: 0.4em ;
21 | padding-left: 30px ;
22 | margin-left: -30px ;
23 | background-color: #E0E0FF ;
24 | }
25 |
--------------------------------------------------------------------------------
/lua-5.1/doc/readme.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Lua documentation
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | Documentation
13 |
14 |
15 | This is the documentation included in the source distribution of Lua 5.1.5.
16 |
17 |