├── Artistic ├── BUGS ├── CHANGES ├── COPYING ├── HISTORY ├── Makefile ├── README ├── README.md ├── TODO ├── bin2c.cpp ├── c_bind.cpp ├── c_bind.h ├── c_cmdtab.h ├── c_color.cpp ├── c_color.h ├── c_commands.h ├── c_config.cpp ├── c_config.h ├── c_desktop.cpp ├── c_desktop.h ├── c_fconfig.h ├── c_hilit.cpp ├── c_hilit.h ├── c_history.cpp ├── c_history.h ├── c_mode.cpp ├── c_mode.h ├── cfte.cpp ├── clip_no.cpp ├── commands.cpp ├── con_dosx.cpp ├── conkbd.h ├── console.h ├── defcfg.fte ├── e_block.cpp ├── e_buffer.cpp ├── e_buffer.h ├── e_cmds.cpp ├── e_djgpp2.cpp ├── e_file.cpp ├── e_fold.cpp ├── e_line.cpp ├── e_loadsave.cpp ├── e_mark.cpp ├── e_mark.h ├── e_print.cpp ├── e_redraw.cpp ├── e_regex.cpp ├── e_regex.h ├── e_search.cpp ├── e_tags.cpp ├── e_tags.h ├── e_trans.cpp ├── e_undo.cpp ├── e_undo.h ├── egui.cpp ├── egui.h ├── feature.h ├── file_id.diz ├── fte.cnf ├── fte.cpp ├── fte.h ├── ftever.h ├── g_draw.cpp ├── g_menu.cpp ├── g_nodlg.cpp ├── g_text.cpp ├── gui.cpp ├── gui.h ├── h_ada.cpp ├── h_c.cpp ├── h_catbs.cpp ├── h_diff.cpp ├── h_fte.cpp ├── h_html.cpp ├── h_ipf.cpp ├── h_make.cpp ├── h_merge.cpp ├── h_msg.cpp ├── h_pascal.cpp ├── h_perl.cpp ├── h_plain.cpp ├── h_rexx.cpp ├── h_sh.cpp ├── h_simple.cpp ├── h_tex.cpp ├── i_ascii.cpp ├── i_ascii.h ├── i_choice.cpp ├── i_choice.h ├── i_complete.cpp ├── i_complete.h ├── i_input.cpp ├── i_input.h ├── i_key.cpp ├── i_key.h ├── i_modelview.cpp ├── i_modelview.h ├── i_oview.cpp ├── i_oview.h ├── i_search.cpp ├── i_search.h ├── i_view.cpp ├── i_view.h ├── indent.cpp ├── log.cpp ├── log.h ├── memicmp.cpp ├── menu_text.cpp ├── o_buffer.cpp ├── o_buflist.cpp ├── o_buflist.h ├── o_directory.cpp ├── o_directory.h ├── o_list.cpp ├── o_list.h ├── o_messages.cpp ├── o_messages.h ├── o_model.cpp ├── o_model.h ├── o_modemap.cpp ├── o_modemap.h ├── o_routine.cpp ├── o_routine.h ├── port.c ├── port.h ├── portdos.c ├── s_direct.cpp ├── s_direct.h ├── s_files.cpp ├── s_files.h ├── s_util.cpp ├── s_util.h ├── simple.fte ├── sysdep.h └── view.cpp /Artistic: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | The "Artistic License" 6 | 7 | Preamble 8 | 9 | The intent of this document is to state the conditions under which a 10 | Package may be copied, such that the Copyright Holder maintains some 11 | semblance of artistic control over the development of the package, 12 | while giving the users of the package the right to use and distribute 13 | the Package in a more-or-less customary fashion, plus the right to make 14 | reasonable modifications. 15 | 16 | Definitions: 17 | 18 | "Package" refers to the collection of files distributed by the 19 | Copyright Holder, and derivatives of that collection of files 20 | created through textual modification. 21 | 22 | "Standard Version" refers to such a Package if it has not been 23 | modified, or has been modified in accordance with the wishes 24 | of the Copyright Holder as specified below. 25 | 26 | "Copyright Holder" is whoever is named in the copyright or 27 | copyrights for the package. 28 | 29 | "You" is you, if you're thinking about copying or distributing 30 | this Package. 31 | 32 | "Reasonable copying fee" is whatever you can justify on the 33 | basis of media cost, duplication charges, time of people involved, 34 | and so on. (You will not be required to justify it to the 35 | Copyright Holder, but only to the computing community at large 36 | as a market that must bear the fee.) 37 | 38 | "Freely Available" means that no fee is charged for the item 39 | itself, though there may be fees involved in handling the item. 40 | It also means that recipients of the item may redistribute it 41 | under the same conditions they received it. 42 | 43 | 1. You may make and give away verbatim copies of the source form of the 44 | Standard Version of this Package without restriction, provided that you 45 | duplicate all of the original copyright notices and associated disclaimers. 46 | 47 | 2. You may apply bug fixes, portability fixes and other modifications 48 | derived from the Public Domain or from the Copyright Holder. A Package 49 | modified in such a way shall still be considered the Standard Version. 50 | 51 | 3. You may otherwise modify your copy of this Package in any way, provided 52 | that you insert a prominent notice in each changed file stating how and 53 | when you changed that file, and provided that you do at least ONE of the 54 | following: 55 | 56 | a) place your modifications in the Public Domain or otherwise make them 57 | Freely Available, such as by posting said modifications to Usenet or 58 | an equivalent medium, or placing the modifications on a major archive 59 | site such as uunet.uu.net, or by allowing the Copyright Holder to include 60 | your modifications in the Standard Version of the Package. 61 | 62 | b) use the modified Package only within your corporation or organization. 63 | 64 | c) rename any non-standard executables so the names do not conflict 65 | with standard executables, which must also be provided, and provide 66 | a separate manual page for each non-standard executable that clearly 67 | documents how it differs from the Standard Version. 68 | 69 | d) make other distribution arrangements with the Copyright Holder. 70 | 71 | 4. You may distribute the programs of this Package in object code or 72 | executable form, provided that you do at least ONE of the following: 73 | 74 | a) distribute a Standard Version of the executables and library files, 75 | together with instructions (in the manual page or equivalent) on where 76 | to get the Standard Version. 77 | 78 | b) accompany the distribution with the machine-readable source of 79 | the Package with your modifications. 80 | 81 | c) give non-standard executables non-standard names, and clearly 82 | document the differences in manual pages (or equivalent), together 83 | with instructions on where to get the Standard Version. 84 | 85 | d) make other distribution arrangements with the Copyright Holder. 86 | 87 | 5. You may charge a reasonable copying fee for any distribution of this 88 | Package. You may charge any fee you choose for support of this 89 | Package. You may not charge a fee for this Package itself. However, 90 | you may distribute this Package in aggregate with other (possibly 91 | commercial) programs as part of a larger (possibly commercial) software 92 | distribution provided that you do not advertise this Package as a 93 | product of your own. You may embed this Package's interpreter within 94 | an executable of yours (by linking); this shall be construed as a mere 95 | form of aggregation, provided that the complete Standard Version of the 96 | interpreter is so embedded. 97 | 98 | 6. The scripts and library files supplied as input to or produced as 99 | output from the programs of this Package do not automatically fall 100 | under the copyright of this Package, but belong to whomever generated 101 | them, and may be sold commercially, and may be aggregated with this 102 | Package. If such scripts or library files are aggregated with this 103 | Package via the so-called "undump" or "unexec" methods of producing a 104 | binary executable image, then distribution of such an image shall 105 | neither be construed as a distribution of this Package nor shall it 106 | fall under the restrictions of Paragraphs 3 and 4, provided that you do 107 | not represent such an executable image as a Standard Version of this 108 | Package. 109 | 110 | 7. C subroutines (or comparably compiled subroutines in other 111 | languages) supplied by you and linked into this Package in order to 112 | emulate subroutines and variables of the language defined by this 113 | Package shall not be considered part of this Package, but are the 114 | equivalent of input as in Paragraph 6, provided these subroutines do 115 | not change the language in any way that would cause it to fail the 116 | regression tests for the language. 117 | 118 | 8. Aggregation of this Package with a commercial distribution is always 119 | permitted provided that the use of this Package is embedded; that is, 120 | when no overt attempt is made to make this Package's interfaces visible 121 | to the end user of the commercial distribution. Such use shall not be 122 | construed as a distribution of this Package. 123 | 124 | 9. The name of the Copyright Holder may not be used to endorse or promote 125 | products derived from this software without specific prior written permission. 126 | 127 | 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR 128 | IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 129 | WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 130 | 131 | The End 132 | -------------------------------------------------------------------------------- /BUGS: -------------------------------------------------------------------------------- 1 | OS/2 notes and limitations: 2 | - pm controls are not disabled while a modal entryfield is active. 3 | - pm subwindows can not be resized. 4 | - does not handle multiple frames well (dialogs are modal for all). 5 | 6 | Linux notes and limitations: 7 | 8 | - Console version: 9 | Runs only on linux console. Requires rw access to /dev/vcsa?? devices. 10 | Runs in raw mode, so switch consoles using Ctrl+Alt+Fn. Currently 11 | operates in no-translation screen mode. Console cut/paste does not currently 12 | work. 13 | 14 | - X11 version: 15 | If your backspace key does not work, make sure it is defined as 16 | BackSpace (using loadkeys/xmodmap). 17 | 18 | - Some stuff may still be OS/2 centric. This will be fixed 19 | in the future. 20 | -------------------------------------------------------------------------------- /CHANGES: -------------------------------------------------------------------------------- 1 | CHANGES since last release (0.46b5): 2 | 3 | - Version numbering changed. 4 | - Readonly files are not editable when loaded. 5 | - Author email/homepage changed 6 | - updated some modes (HTML) 7 | - new modes (sml, mod3, sl, sql, 4gl, sgml) 8 | - source code cleanups (warnings, const correct) 9 | - new commands: 10 | - RunProgramAsync 11 | - new macro expansion variables: 12 | - FileDirectory 13 | - FileBaseName 14 | - FileExtension 15 | - X11: support for I18N, XMB 16 | - bug fixes: 17 | - crash on bookmark handling (pop/push) 18 | - crash when restored position outside valid file 19 | - win95 compiler execution should work again 20 | - run compiler (sync) in dosx version 21 | - linux console version fixes: 22 | - crash on cols/rows > 127 23 | - crash in SaveAll if non-visible file requires interaction 24 | - java indentation fix (private/protected methods) 25 | - Shift+Ins support in input lines 26 | - X11: support for mouse wheel :) 27 | - ability to save All files on exit 28 | - portability fixes 29 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | CC = wcc386 2 | CPP = wpp386 3 | LD = wlink 4 | 5 | INCDIR = 6 | LIBDIR = 7 | 8 | #OPTIMIZE = /d2 9 | OPTIMIZE = /d1 /onatx /oe=40 10 | 11 | CCFLAGS = /zp4 /5r /fp3 /j $(OPTIMIZE) $(INCDIR) /dDOSP32 /d__32BIT__ /dWATCOM /d__DOS4G__ 12 | LDFLAGS = debug all $(LIBDIR) 13 | 14 | OBJS = indent.obj & 15 | e_mark.obj & 16 | o_mode~1.obj & 17 | c_desk~1.obj & 18 | c_bind.obj & 19 | c_color.obj & 20 | c_config.obj & 21 | c_hist~1.obj & 22 | c_hilit.obj & 23 | c_mode.obj & 24 | e_block.obj & 25 | e_buffer.obj & 26 | e_cmds.obj & 27 | e_redraw.obj & 28 | e_file.obj & 29 | e_fold.obj & 30 | e_trans.obj & 31 | e_line.obj & 32 | e_load~1.obj & 33 | e_regex.obj & 34 | e_print.obj & 35 | e_search.obj & 36 | e_undo.obj & 37 | e_tags.obj & 38 | g_draw.obj & 39 | g_menu.obj & 40 | h_ada.obj & 41 | h_c.obj & 42 | h_fte.obj & 43 | h_html.obj & 44 | h_ipf.obj & 45 | h_make.obj & 46 | h_merge.obj & 47 | h_pascal.obj & 48 | h_perl.obj & 49 | h_plain.obj & 50 | h_msg.obj & 51 | h_rexx.obj & 52 | h_sh.obj & 53 | h_tex.obj & 54 | h_diff.obj & 55 | h_catbs.obj & 56 | h_simple.obj & 57 | i_comp~1.obj & 58 | i_ascii.obj & 59 | i_choice.obj & 60 | i_input.obj & 61 | i_key.obj & 62 | i_search.obj & 63 | i_view.obj & 64 | i_mode~1.obj & 65 | i_oview.obj & 66 | o_bufl~1.obj & 67 | o_list.obj & 68 | o_mess~1.obj & 69 | o_model.obj & 70 | o_rout~1.obj & 71 | o_buffer.obj & 72 | o_dire~1.obj & 73 | s_files.obj & 74 | s_direct.obj & 75 | s_util.obj & 76 | view.obj & 77 | gui.obj & 78 | egui.obj & 79 | fte.obj & 80 | commands.obj & 81 | log.obj 82 | 83 | DOSP32OBJS = memicmp.obj & 84 | port.obj & 85 | portdos.obj & 86 | g_text.obj & 87 | menu_t~1.obj & 88 | con_dosx.obj & 89 | clip_no.obj & 90 | g_nodlg.obj & 91 | e_djgpp2.obj 92 | 93 | CFTE_OBJS = cfte.obj & 94 | s_files.obj & 95 | port.obj & 96 | memicmp.obj 97 | 98 | FTE_OBJS = $OBJS $DOSP32OBJS 99 | 100 | .NOCHECK 101 | build: fte.exe 102 | 103 | .NOCHECK 104 | run : fte.exe 105 | fte.exe 106 | 107 | .NOCHECK 108 | debug : fte.exe 109 | wd /swap /trap=rsi fte.exe 110 | 111 | .cpp.obj: .AUTODEPEND 112 | $(CPP) $[. /zq $(CCFLAGS) 113 | 114 | .c.obj: .AUTODEPEND 115 | $(CC) $[. /zq $(CCFLAGS) 116 | 117 | clean: .SYMBOLIC 118 | del *.obj 119 | del bin2c.exe 120 | del cfte.exe 121 | del fte.exe 122 | del defcfg.cnf 123 | del defcfg.h 124 | del cfte.lnk 125 | del fte.lnk 126 | del bin2c.lnk 127 | 128 | bin2c.exe: bin2c.cpp bin2c.lnk 129 | $(LD) $(LDFLAGS) @bin2c.lnk 130 | 131 | cfte.exe: $(CFTE_OBJS) bin2c.exe cfte.lnk 132 | $(LD) $(LDFLAGS) @cfte.lnk 133 | 134 | defcfg.cnf: defcfg.fte cfte.exe 135 | cfte defcfg.fte defcfg.cnf 136 | 137 | defcfg.h: defcfg.cnf bin2c.exe 138 | bin2c defcfg.cnf >defcfg.h 139 | 140 | c_config.obj: defcfg.h 141 | 142 | fte.exe: $(FTE_OBJS) bin2c.exe cfte.exe fte.lnk 143 | $(LD) $(LDFLAGS) @fte.lnk 144 | 145 | bin2c.lnk: bin2c.obj 146 | %create $^@ 147 | %append $^@ NAME bin2c.exe 148 | %append $^@ SYSTEM DOS4G 149 | %append $^@ OPTION QUIET 150 | %append $^@ OPTION STACK=16k 151 | %append $^@ FILE bin2c.obj 152 | 153 | cfte.lnk: $(CFTE_OBJS) 154 | %create $^@ 155 | %append $^@ NAME cfte.exe 156 | %append $^@ SYSTEM DOS4G 157 | %append $^@ OPTION QUIET 158 | %append $^@ OPTION STACK=16k 159 | @for %i in ($(CFTE_OBJS)) do %append $^@ FILE %i 160 | 161 | fte.lnk: $(FTE_OBJS) 162 | %create $^@ 163 | %append $^@ NAME fte.exe 164 | %append $^@ SYSTEM DOS4G 165 | %append $^@ OPTION QUIET 166 | %append $^@ OPTION STACK=16k 167 | @for %i in ($(FTE_OBJS)) do %append $^@ FILE %i 168 | 169 | 170 | 171 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | 2 | FTE Kit, Version 0.49.13 3 | 4 | Copyright 1994-1998 by Marko Macek. 5 | All rights reserved. 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of either: 9 | 10 | a) the GNU General Public License as published by the Free 11 | Software Foundation; either version 2, or (at your option) any 12 | later version, or 13 | 14 | b) the "Artistic License" which comes with this Kit. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either 19 | the GNU General Public License or the Artistic License for more details. 20 | 21 | You should have received a copy of the Artistic License with this 22 | Kit, in the file named "Artistic". If not, I'll be glad to provide one. 23 | 24 | You should also have received a copy of the GNU General Public License 25 | along with this program; if not, write to the Free Software 26 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 27 | 28 | ----------------------------------------------------------------------- 29 | 30 | Email: Marko.Macek@gmx.net or mark@hermes.si 31 | WWW: http://www.kiss.uni-lj.si/~k4fr0235/fte/ 32 | 33 | See file HISTORY for a list of recent changes. 34 | See file TODO for a list of possible future additions. 35 | See file FTE.HTML/FTE.INF for installation instructions. 36 | See file BUGS for a list of unresolved problems. 37 | 38 | Contributors: 39 | - F.Jalvingh 40 | NT/Win95/DOS port. 41 | - Markus F.X.J. Oberhumer 42 | DOS port (DJGPP) 43 | 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FTE: The Folding Text Editor 2 | 3 | This is a fork of the "20010819" source release [available here](http://fte.sourceforge.net). 4 | 5 | **This is NOT based on the newest FTE sources available. Please check the actual SourceForge 6 | project page for newer source updates if you're not interested in the DOS-specific changes 7 | that this Git repo is about.** 8 | 9 | Changes: 10 | 11 | * Built against Watcom C/C++ 11.0 and DOS/4GW 12 | * Fixed the `ScreenSizeX` and `ScreenSizeY` global config properties so that they are actually used under DOS. 13 | 14 | Existing `.CNF` files built for the 20010819 FTE release should all work the same and not need 15 | to be rebuilt. 16 | 17 | From the "Release" page, the ZIP file contains two pre-built CNF config files that are otherwise 18 | identical except that `FTE.CNF` sets 80x25 text mode while `FTE80x50.CNF` sets 80x50 text mode. 19 | The `config/` directory contains everything you'll need to build your own custom config via the 20 | included `CFTE.EXE`. Just make any changes you like and then run: 21 | 22 | ``` 23 | CFTE config/main.fte 24 | ``` 25 | 26 | Which will result in a new file `FTE-NEW.CNF` being built (assuming no errors). 27 | 28 | ### Background 29 | 30 | The motivation for these changes comes from the fact that I wanted a DOS build of FTE that I could 31 | use on my "retro" DOS-based PCs for writing code using Watcom C/C++ and DOS/4GW. The only DOS 32 | release of FTE that I'm aware of is compiled with DJGPP and hence uses CWSDPMI. Different DOS 33 | extenders usually don't mix well together and as I found out for myself, when trying to use FTE's 34 | Run/Compile menu options to run external Watcom tools (like wlink, wd, etc) most anything that 35 | uses DOS/4GW would crash likely due to the fact that FTE was running under CWSDPMI. 36 | 37 | After looking at the source code, it seemed that only minor changes would be needed to get a 38 | DOS/4GW-compatible build going (and indeed, _some_ of the Watcom-specific work had been done 39 | already ... I guess in the past someone else had this building with Watcom?). 40 | 41 | After I got it building I noticed that it didn't support DOS 80x50 text mode, even though from 42 | looking at the code it was clear that support for customizable screen sizes was planned from the 43 | start. I guess whoever did the original DOS porting work didn't hook up different DOS text mode 44 | support where it needed to be hooked up. 45 | 46 | For my modified source release of FTE I've cleaned out any sources and build scripts that are 47 | NOT related to Watcom/DOS support. Since this fork is based off an older version of FTE, I feel 48 | like if you're looking for support for some other OS, you're not going to be best served by 49 | starting off from here anyway. Go to the more up to date SourceForge project page instead. 50 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | Todo list (needs to be updated) 2 | ----------------------------------------------------------------------- 3 | - improve documentation 4 | - configurable smart indentation like in C/JAVA/PERL/REXX modes for any mode 5 | - fully support clipboard in every prompt 6 | - BlockPasteOver. 7 | - draw mode 8 | - piping block to program, redirection of program output to buffer 9 | - hex mode editing 10 | - shell window support 11 | - Menus should determine keybindings automatically. 12 | - CVS/RCS support. 13 | - Regexp optimizer and improved regexps. 14 | - multiple frame support for gui version. 15 | - Win32 gui version. 16 | 17 | Here are some more: 18 | - command to center the lines in block (BlockCenter) 19 | - command to wrap entire paragraph 20 | - commands to load/close desktop 21 | - remove all modal states (when getting input) (needed for kbd macros and multiframe). 22 | - fix win95 compiler execution 23 | - OS2: see if we can avoid clipserv under OS/2 using Ilya's fake-PM trick. 24 | - make configuration editor in Java (support only subset of config files?) 25 | - see if we could use java as the macro language 26 | - X11: set icons for X11 27 | - X11: set WM_COMMAND 28 | - Linux: make it run on tty. 29 | - Linux: fix the console version (capslock, numlock, ...) 30 | 31 | Comments and suggestions are appreciated! 32 | -------------------------------------------------------------------------------- /bin2c.cpp: -------------------------------------------------------------------------------- 1 | #include "sysdep.h" 2 | 3 | #define BUFLEN (64 * 1024) 4 | 5 | unsigned char buf[BUFLEN]; 6 | 7 | int main(int argc, char **argv) { 8 | int fd; 9 | int i, n = 1, len; 10 | 11 | if (argc != 2) { 12 | fprintf(stderr, "Usage: %s filename\n", argv[0]); exit(1); 13 | } 14 | 15 | if ((fd = open(argv[1], O_RDONLY | O_BINARY)) == -1) { 16 | fprintf(stderr, "Open: %s, error=%d\n", argv[1], errno); 17 | exit(1); 18 | } 19 | printf("/* do not edit */\nunsigned char DefaultConfig[] = {\n"); 20 | while ((len = read(fd, buf, BUFLEN)) > 0) { 21 | for (i = 0; i < len; i++) { 22 | printf("0x%02.02X", buf[i]); 23 | if (n++ % 10) { 24 | printf(", "); 25 | } else { 26 | printf(",\n"); 27 | } 28 | } 29 | } 30 | close(fd); 31 | printf("\n};\n"); 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /c_bind.h: -------------------------------------------------------------------------------- 1 | /* c_bind.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __BIND_H 11 | #define __BIND_H 12 | 13 | #define ABBREV_HASH 16 14 | 15 | class EMode; 16 | class EEventMap; 17 | class EKeyMap; 18 | class EKey; 19 | class EAbbrev; 20 | class EView; 21 | 22 | typedef struct { 23 | TKeyCode Mask; 24 | TKeyCode Key; 25 | } KeySel; 26 | 27 | class EMode { 28 | public: 29 | EMode *fNext; 30 | char *fName; 31 | char *MatchName; 32 | char *MatchLine; 33 | RxNode *MatchNameRx; 34 | RxNode *MatchLineRx; 35 | EBufferFlags Flags; 36 | EEventMap *fEventMap; 37 | EMode *fParent; 38 | #ifdef CONFIG_SYNTAX_HILIT 39 | EColorize *fColorize; 40 | #endif 41 | char filename[256]; 42 | 43 | EMode(EMode *aMode, EEventMap *Map, const char *aName); 44 | ~EMode(); 45 | EAbbrev *FindAbbrev(const char *string); 46 | }; 47 | 48 | class EKeyMap { 49 | public: 50 | EKeyMap *fParent; 51 | EKey *fKeys; 52 | 53 | EKeyMap(); 54 | ~EKeyMap(); 55 | 56 | void AddKey(EKey *aKey); 57 | EKey *FindKey(TKeyCode aKey); 58 | }; 59 | 60 | class EEventMap { 61 | public: 62 | EEventMap *Next; 63 | EEventMap *Parent; 64 | char *Name; 65 | 66 | EKeyMap *KeyMap; 67 | char *Menu[EM_MENUS]; // main + local 68 | 69 | EAbbrev *abbrev[ABBREV_HASH]; 70 | 71 | EEventMap(const char *AName, EEventMap *AParent); 72 | ~EEventMap(); 73 | void SetMenu(int which, const char *What); 74 | char *GetMenu(int which); 75 | #ifdef CONFIG_ABBREV 76 | int AddAbbrev(EAbbrev *ab); 77 | #endif 78 | }; 79 | 80 | #define CT_COMMAND 0 81 | #define CT_NUMBER 1 82 | #define CT_STRING 2 83 | #define CT_VARIABLE 3 84 | #define CT_CONCAT 4 /* concatenate strings */ 85 | 86 | typedef struct { 87 | int type; 88 | short repeat; 89 | short ign; 90 | union { 91 | long num; 92 | char *string; 93 | } u; 94 | } CommandType; 95 | 96 | typedef struct { 97 | char *Name; 98 | int Count; 99 | CommandType *cmds; 100 | } ExMacro; 101 | 102 | class EKey { 103 | public: 104 | KeySel fKey; 105 | int Cmd; 106 | EKeyMap *fKeyMap; 107 | EKey *fNext; 108 | 109 | EKey(char *aKey); 110 | EKey(char *aKey, EKeyMap *aKeyMap); 111 | ~EKey(); 112 | }; 113 | 114 | #ifdef CONFIG_ABBREV 115 | class EAbbrev { 116 | public: 117 | EAbbrev *next; 118 | int Cmd; 119 | char *Match; 120 | char *Replace; 121 | 122 | EAbbrev(const char *aMatch, const char *aReplace); 123 | EAbbrev(const char *aMatch, int aCmd); 124 | ~EAbbrev(); 125 | }; 126 | #endif 127 | 128 | class ExState { // state of macro execution 129 | public: 130 | int Macro; 131 | int Pos; 132 | 133 | int GetStrParam(EView *view, char *str, int buflen); 134 | int GetIntParam(EView *view, int *value); 135 | }; 136 | 137 | extern EMode *Modes; 138 | extern EEventMap *EventMaps; 139 | 140 | extern int CMacros; 141 | extern ExMacro *Macros; 142 | 143 | int GetCharFromEvent(TEvent &E, char *Ch); 144 | 145 | const char *GetCommandName(int Command); 146 | EMode *FindMode(const char *Name); 147 | EEventMap *FindEventMap(const char *Name); 148 | EEventMap *FindActiveMap(EMode *Mode); 149 | EMode *GetModeForName(const char *FileName); 150 | int CmdNum(const char *Cmd); 151 | void ExecKey(EKey *Key); 152 | EKey *SetKey(EEventMap *aMap, const char *Key); 153 | int ParseKey(const char *Key, KeySel &ks); 154 | int GetKeyName(char *Key, KeySel &ks); 155 | 156 | int NewCommand(const char *Name); 157 | int RunCommand(int Command); 158 | int AddCommand(int no, int cmd, int count, int ign); 159 | int AddString(int no, const char *Command); 160 | int AddNumber(int no, long number); 161 | int AddVariable(int no, int number); 162 | int AddConcat(int no); 163 | int HashStr(const char *str, int maxim); 164 | void SetWordChars(char *w, const char *s); 165 | 166 | #endif 167 | -------------------------------------------------------------------------------- /c_color.cpp: -------------------------------------------------------------------------------- 1 | /* c_color.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | ChColor MsgColor[3] = { 0x07, 0x0B, 0x04 }; 13 | 14 | /* Status line */ 15 | 16 | ChColor hcStatus_Normal = 0x30; 17 | ChColor hcStatus_Active = 0x70; 18 | 19 | ChColor hcEntry_Field = 0x07; 20 | ChColor hcEntry_Prompt = 0x0F; 21 | ChColor hcEntry_Selection = 0x2F; 22 | 23 | /* Plain */ 24 | 25 | ChColor hcPlain_Normal = 0x07; 26 | ChColor hcPlain_Background = 0x07; 27 | ChColor hcPlain_Selected = 0x80; 28 | ChColor hcPlain_Markers = 0x03; 29 | ChColor hcPlain_Found = 0x40; 30 | ChColor hcPlain_Keyword = 0x0F; 31 | ChColor hcPlain_Folds = 0x0A; 32 | ChColor hcPlain_HilitWord = 0x0D; 33 | 34 | /* LIST */ 35 | //ChColor hcList_Border = 0x03; 36 | ChColor hcList_Status = 0x70; 37 | ChColor hcList_Normal = 0x07; 38 | ChColor hcList_Selected = 0x1F; 39 | 40 | ChColor hcScrollBar_Arrows = 0x70; 41 | ChColor hcScrollBar_Back = 0x07; 42 | ChColor hcScrollBar_Fore = 0x07; 43 | 44 | ChColor hcAsciiChars = 0x07; 45 | 46 | ChColor hcMenu_Background = 0x70; 47 | ChColor hcMenu_ActiveItem = 0x1F; 48 | ChColor hcMenu_ActiveChar = 0x1C; 49 | ChColor hcMenu_NormalItem = 0x70; 50 | ChColor hcMenu_NormalChar = 0x74; 51 | 52 | ChColor hcChoice_Title = 0x1F; 53 | ChColor hcChoice_Param = 0x1B; 54 | ChColor hcChoice_Background = 0x17; 55 | ChColor hcChoice_ActiveItem = 0x20; 56 | ChColor hcChoice_ActiveChar = 0x2F; 57 | ChColor hcChoice_NormalItem = 0x1F; 58 | ChColor hcChoice_NormalChar = 0x1E; 59 | 60 | static const struct { 61 | const char *Name; 62 | ChColor *C; 63 | } Colors[] = 64 | { 65 | { "Status.Normal", &hcStatus_Normal }, 66 | { "Status.Active", &hcStatus_Active }, 67 | 68 | { "Message.Normal", &MsgColor[0] }, 69 | { "Message.Bold", &MsgColor[1] }, 70 | { "Message.Error", &MsgColor[2] }, 71 | 72 | { "Entry.Field", &hcEntry_Field }, 73 | { "Entry.Prompt", &hcEntry_Prompt }, 74 | { "Entry.Selection", &hcEntry_Selection }, 75 | 76 | { "LIST.Status", &hcList_Status }, 77 | { "LIST.Normal", &hcList_Normal }, 78 | { "LIST.Selected", &hcList_Selected }, 79 | 80 | { "PLAIN.Normal", &hcPlain_Normal }, 81 | { "PLAIN.Background", &hcPlain_Background }, 82 | { "PLAIN.Selected", &hcPlain_Selected }, 83 | { "PLAIN.Markers", &hcPlain_Markers }, 84 | { "PLAIN.Found", &hcPlain_Found }, 85 | { "PLAIN.Keyword", &hcPlain_Keyword }, 86 | { "PLAIN.Folds", &hcPlain_Folds }, 87 | { "PLAIN.HilitWord", &hcPlain_HilitWord }, 88 | 89 | { "ScrollBar.Arrows", &hcScrollBar_Arrows }, 90 | { "ScrollBar.Back", &hcScrollBar_Back }, 91 | { "ScrollBar.Fore", &hcScrollBar_Fore }, 92 | 93 | { "ASCII.Chars", &hcAsciiChars }, 94 | 95 | { "Menu.Background", &hcMenu_Background }, 96 | { "Menu.ActiveItem", &hcMenu_ActiveItem }, 97 | { "Menu.ActiveChar", &hcMenu_ActiveChar }, 98 | { "Menu.NormalItem", &hcMenu_NormalItem }, 99 | { "Menu.NormalChar", &hcMenu_NormalChar }, 100 | 101 | { "Choice.Title", &hcChoice_Title }, 102 | { "Choice.Param", &hcChoice_Param }, 103 | { "Choice.Background", &hcChoice_Background }, 104 | { "Choice.ActiveItem", &hcChoice_ActiveItem }, 105 | { "Choice.ActiveChar", &hcChoice_ActiveChar }, 106 | { "Choice.NormalItem", &hcChoice_NormalItem }, 107 | { "Choice.NormalChar", &hcChoice_NormalChar }, 108 | }; 109 | #define NCOLORS (sizeof(Colors)/sizeof(Colors[0])) 110 | 111 | int SetColor(const char *ColorV, const char *Value) { 112 | unsigned int Col; 113 | unsigned int ColBg, ColFg; 114 | ChColor C; 115 | 116 | if (sscanf(Value, "%1X %1X", &ColFg, &ColBg) != 2) 117 | return 0; 118 | 119 | Col = ColFg | (ColBg << 4); 120 | 121 | C = ChColor(Col); 122 | for (unsigned int i = 0; i < NCOLORS; i++) { 123 | if (strcmp(ColorV, Colors[i].Name) == 0) { 124 | *Colors[i].C = C; 125 | return 1; 126 | } 127 | } 128 | return 0; 129 | } 130 | -------------------------------------------------------------------------------- /c_color.h: -------------------------------------------------------------------------------- 1 | /* c_color.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __COLOR_H 11 | #define __COLOR_H 12 | 13 | extern ChColor hcStatus_Normal; 14 | extern ChColor hcStatus_Active; 15 | 16 | extern ChColor hcPlain_Normal; 17 | extern ChColor hcPlain_Background; 18 | extern ChColor hcPlain_Selected; 19 | extern ChColor hcPlain_Markers; 20 | extern ChColor hcPlain_Found; 21 | extern ChColor hcPlain_Keyword; 22 | extern ChColor hcPlain_Folds; 23 | extern ChColor hcPlain_HilitWord; 24 | 25 | extern ChColor hcEntry_Field; 26 | extern ChColor hcEntry_Prompt; 27 | extern ChColor hcEntry_Selection; 28 | 29 | //extern ChColor hcList_Border; 30 | extern ChColor hcList_Status; 31 | extern ChColor hcList_Normal; 32 | extern ChColor hcList_Selected; 33 | 34 | extern ChColor hcScrollBar_Arrows; 35 | extern ChColor hcScrollBar_Back; 36 | extern ChColor hcScrollBar_Fore; 37 | 38 | extern ChColor hcAsciiChars; 39 | 40 | extern ChColor hcMenu_Background; 41 | extern ChColor hcMenu_ActiveItem; 42 | extern ChColor hcMenu_ActiveChar; 43 | extern ChColor hcMenu_NormalItem; 44 | extern ChColor hcMenu_NormalChar; 45 | 46 | extern ChColor hcChoice_Title; 47 | extern ChColor hcChoice_Param; 48 | extern ChColor hcChoice_Background; 49 | extern ChColor hcChoice_ActiveItem; 50 | extern ChColor hcChoice_ActiveChar; 51 | extern ChColor hcChoice_NormalItem; 52 | extern ChColor hcChoice_NormalChar; 53 | 54 | extern ChColor MsgColor[3]; 55 | 56 | int SetColor(const char *ChColor, const char *Value); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /c_config.h: -------------------------------------------------------------------------------- 1 | /* c_config.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __CONFIG_H 11 | #define __CONFIG_H 12 | 13 | extern int ScreenSizeX; 14 | extern int ScreenSizeY; 15 | extern int CursorInsSize[2]; 16 | extern int CursorOverSize[2]; 17 | extern int SystemClipboard; 18 | extern int OpenAfterClose; 19 | extern int ShowMenuBar; 20 | extern int ShowToolBar; 21 | extern int SelectPathname; 22 | extern char DefaultModeName[32]; 23 | extern int WSStyleSearch; 24 | extern char PrintDevice[MAXPATH]; 25 | extern char CompileCommand[256]; 26 | extern int KeepHistory; 27 | extern int LoadDesktopOnEntry; 28 | extern int SaveDesktopOnExit; 29 | extern int KeepMessages; 30 | extern int ScrollBorderX; 31 | extern int ScrollBorderY; 32 | extern int ScrollJumpX; 33 | extern int ScrollJumpY; 34 | extern int GUIDialogs; 35 | extern int SevenBit; 36 | extern int WeirdScroll; 37 | extern int LoadDesktopMode; 38 | extern char HelpCommand[128]; 39 | extern char *ConfigSourcePath; 40 | extern char ConfigFileName[MAXPATH]; 41 | 42 | int LoadConfig(int argc, char **argv, char *CfgFileName); 43 | int GetIndentMode(const char *Str); 44 | int GetHilitMode(const char *Str); 45 | int UseDefaultConfig(); 46 | int AddCRegexp(int file, int line, int msg, const char *regexp); 47 | int LoadFile(char *WhereName, char *CfgName); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /c_desktop.cpp: -------------------------------------------------------------------------------- 1 | /* c_desktop.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | #ifdef CONFIG_DESKTOP 13 | 14 | #define DESKTOP_VER "FTE Desktop 2\n" 15 | #define DESKTOP_VER1 "FTE Desktop 1\n" 16 | 17 | char DesktopFileName[256] = ""; 18 | 19 | int SaveDesktop(char *FileName) { 20 | FILE *fp; 21 | EModel *M; 22 | 23 | fp = fopen(FileName, "w"); 24 | if (fp == 0) 25 | return 0; 26 | 27 | setvbuf(fp, FileBuffer, _IOFBF, sizeof(FileBuffer)); 28 | 29 | fprintf(fp, DESKTOP_VER); 30 | 31 | M = ActiveModel; 32 | while (M) { 33 | switch(M->GetContext()) { 34 | case CONTEXT_FILE: 35 | { 36 | EBuffer *B = (EBuffer *)M; 37 | fprintf(fp, "F|%d|%s\n", B->ModelNo, B->FileName); 38 | } 39 | break; 40 | #ifdef CONFIG_OBJ_DIRECTORY 41 | case CONTEXT_DIRECTORY: 42 | { 43 | EDirectory *D = (EDirectory *)M; 44 | fprintf(fp, "D|%d|%s\n", D->ModelNo, D->Path); 45 | } 46 | break; 47 | #endif 48 | } 49 | M = M->Next; 50 | if (M == ActiveModel) 51 | break; 52 | } 53 | #ifdef CONFIG_TAGS 54 | TagsSave(fp); 55 | #endif 56 | markIndex.saveToDesktop(fp); 57 | fclose(fp); 58 | return 1; 59 | } 60 | 61 | int LoadDesktop(char *FileName) { 62 | FILE *fp; 63 | char line[512]; 64 | char *p, *e; 65 | int FLCount = 0; 66 | 67 | #ifdef CONFIG_TAGS 68 | TagClear(); 69 | #endif 70 | 71 | fp = fopen(FileName, "r"); 72 | if (fp == 0) 73 | return 0; 74 | 75 | //setvbuf(fp, FileBuffer, _IOFBF, sizeof(FileBuffer)); 76 | 77 | if (fgets(line, sizeof(line), fp) == 0 || 78 | (strcmp(line, DESKTOP_VER) != 0 && 79 | (strcmp(line, DESKTOP_VER1) != 0))) 80 | { 81 | fclose(fp); 82 | return 0; 83 | } 84 | while (fgets(line, sizeof(line), fp) != 0) { 85 | e = strchr(line, '\n'); 86 | if (e == 0) 87 | break; 88 | *e = 0; 89 | if ((line[0] == 'D' || line[0] == 'F') && line[1] == '|') { 90 | int ModelNo = -1; 91 | p = line + 2; 92 | if (isdigit(*p)) { 93 | ModelNo = atoi(p); 94 | while (isdigit(*p)) p++; 95 | if (*p == '|') 96 | p++; 97 | } 98 | 99 | if (line[0] == 'F') { // file 100 | if (FLCount > 0) 101 | suspendLoads = 1; 102 | if (FileLoad(0, p, 0, ActiveView)) 103 | FLCount++; 104 | suspendLoads = 0; 105 | #ifdef CONFIG_OBJ_DIRECTORY 106 | } else if (line[0] == 'D') { // directory 107 | EModel *m = new EDirectory(0, &ActiveModel, p); 108 | assert(ActiveModel != 0 && m != 0); 109 | #endif 110 | } 111 | 112 | if (ActiveModel) { 113 | if (ModelNo != -1) { 114 | if (FindModelID(ActiveModel, ModelNo) == 0) 115 | ActiveModel->ModelNo = ModelNo; 116 | } 117 | 118 | if (ActiveModel != ActiveModel->Next) { 119 | suspendLoads = 1; 120 | ActiveView->SelectModel(ActiveModel->Next); 121 | suspendLoads = 0; 122 | } 123 | } 124 | } else { 125 | #ifdef CONFIG_TAGS 126 | if (line[0] == 'T' && line[1] == '|') { // tag file 127 | TagsAdd(line + 2); 128 | #endif 129 | } else if (line[0] == 'M' && line[1] == '|') { // mark 130 | char *name; 131 | char *file; 132 | EPoint P; 133 | //long l; 134 | char *e; 135 | 136 | p = line + 2; 137 | P.Row = strtol(p, &e, 10); 138 | if (*e != '|') 139 | break; 140 | p = e + 1; 141 | P.Col = strtol(p, &e, 10); 142 | if (*e != '|') 143 | break; 144 | p = e + 1; 145 | name = p; 146 | while (*p && *p != '|') 147 | p++; 148 | if (*p == '|') 149 | *p++ = 0; 150 | else 151 | break; 152 | file = p; 153 | 154 | markIndex.insert(name, file, P); 155 | } 156 | } 157 | } 158 | fclose(fp); 159 | return 1; 160 | } 161 | 162 | #endif 163 | -------------------------------------------------------------------------------- /c_desktop.h: -------------------------------------------------------------------------------- 1 | /* c_desktop.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __DESKTOP_H__ 11 | #define __DESKTOP_H__ 12 | 13 | #ifdef CONFIG_DESKTOP 14 | 15 | #ifdef UNIX 16 | # define DESKTOP_NAME ".fte-desktop" 17 | #else 18 | # define DESKTOP_NAME "fte.dsk" 19 | #endif 20 | 21 | extern char DesktopFileName[256]; 22 | 23 | int SaveDesktop(char *FileName); 24 | int LoadDesktop(char *FileName); 25 | 26 | #endif 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /c_fconfig.h: -------------------------------------------------------------------------------- 1 | /* c_fconfig.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __FCONFIG_H__ 11 | #define __FCONFIG_H__ 12 | 13 | #define CF_STRING 1 14 | #define CF_INT 2 15 | #define CF_REGEXP 3 16 | 17 | #define CF_END 100 18 | #define CF_SUB 101 19 | #define CF_MENU 102 20 | #define CF_OBJECT 103 21 | #define CF_COMMAND 104 22 | #define CF_ITEM 105 23 | #define CF_SUBMENU 106 24 | #define CF_MENUSUB 107 25 | #define CF_MODE 108 26 | #define CF_PARENT 109 27 | #define CF_KEYSUB 110 28 | #define CF_KEY 111 29 | #define CF_COLOR 112 30 | #define CF_KEYWORD 113 31 | #define CF_SETVAR 114 32 | #define CF_COMPRX 115 33 | #define CF_EVENTMAP 116 34 | #define CF_COLORIZE 117 35 | #define CF_ABBREV 118 36 | #define CF_HSTATE 119 37 | #define CF_HTRANS 120 38 | #define CF_HWORDS 121 39 | #define CF_SUBMENUCOND 122 40 | #define CF_HWTYPE 123 41 | #define CF_VARIABLE 124 42 | #define CF_CONCAT 125 43 | 44 | #define CF_EOF 254 45 | 46 | #define CONFIG_ID 0x1A1D70E1 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /c_hilit.h: -------------------------------------------------------------------------------- 1 | /* c_hilit.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __HILIT_H__ 11 | #define __HILIT_H__ 12 | 13 | typedef unsigned short hlState; 14 | typedef unsigned char hsState; 15 | 16 | class EBuffer; 17 | class ELine; 18 | 19 | #define HILIT_P(proc) \ 20 | int proc(EBuffer *BF, int LN, PCell B, int Pos, int Width, ELine *Line, hlState &State, hsState *StateMap, int *ECol) 21 | 22 | //typedef int (*SyntaxProc)(EBuffer *BF, int LN, PCell B, int Pos, int Width, ELine *Line, hlState &State, hsState *StateMap); 23 | typedef HILIT_P((*SyntaxProc)); 24 | 25 | 26 | int Indent_Plain(EBuffer *B, int Line, int PosCursor); 27 | HILIT_P(Hilit_Plain); 28 | 29 | #ifdef CONFIG_SYNTAX_HILIT 30 | /* highlighting state */ 31 | 32 | #ifdef CONFIG_HILIT_C 33 | HILIT_P(Hilit_C); 34 | #endif 35 | #ifdef CONFIG_HILIT_HTML 36 | HILIT_P(Hilit_HTML); 37 | #endif 38 | #ifdef CONFIG_HILIT_PERL 39 | HILIT_P(Hilit_PERL); 40 | #endif 41 | #ifdef CONFIG_HILIT_MAKE 42 | HILIT_P(Hilit_MAKE); 43 | #endif 44 | #ifdef CONFIG_HILIT_REXX 45 | HILIT_P(Hilit_REXX); 46 | #endif 47 | #ifdef CONFIG_HILIT_DIFF 48 | HILIT_P(Hilit_DIFF); 49 | #endif 50 | #ifdef CONFIG_HILIT_MERGE 51 | HILIT_P(Hilit_MERGE); 52 | #endif 53 | #ifdef CONFIG_HILIT_IPF 54 | HILIT_P(Hilit_IPF); 55 | #endif 56 | #ifdef CONFIG_HILIT_ADA 57 | HILIT_P(Hilit_ADA); 58 | #endif 59 | #ifdef CONFIG_HILIT_MSG 60 | HILIT_P(Hilit_MSG); 61 | #endif 62 | #ifdef CONFIG_HILIT_SH 63 | HILIT_P(Hilit_SH); 64 | #endif 65 | #ifdef CONFIG_HILIT_PASCAL 66 | HILIT_P(Hilit_PASCAL); 67 | #endif 68 | #ifdef CONFIG_HILIT_TEX 69 | HILIT_P(Hilit_TEX); 70 | #endif 71 | #ifdef CONFIG_HILIT_FTE 72 | HILIT_P(Hilit_FTE); 73 | #endif 74 | #ifdef CONFIG_HILIT_CATBS 75 | HILIT_P(Hilit_CATBS); 76 | #endif 77 | #ifdef CONFIG_HILIT_SIMPLE 78 | HILIT_P(Hilit_SIMPLE); 79 | #endif 80 | 81 | #ifdef CONFIG_INDENT_C 82 | int Indent_C(EBuffer *B, int Line, int PosCursor); 83 | #endif 84 | #ifdef CONFIG_INDENT_REXX 85 | int Indent_REXX(EBuffer *B, int Line, int PosCursor); 86 | #endif 87 | #ifdef CONFIG_INDENT_SIMPLE 88 | int Indent_SIMPLE(EBuffer *B, int Line, int PosCursor); 89 | #endif 90 | 91 | /* 92 | * NT has 2-byte charcode and attribute... Following is not portable to non- 93 | * intel; should be replaced by formal TCell definition' usage instead of 94 | * assumed array.. (Jal) 95 | */ 96 | #ifdef NTCONSOLE 97 | # define PCLI unsigned short 98 | #else 99 | # define PCLI unsigned char 100 | #endif 101 | 102 | #define ColorChar() \ 103 | do {\ 104 | BPos = C - Pos; \ 105 | if (B) \ 106 | if (BPos >= 0 && BPos < Width) { \ 107 | BPtr = (PCLI *) (B + BPos); \ 108 | BPtr[0] = *p; \ 109 | BPtr[1] = Color; \ 110 | } \ 111 | if (StateMap) StateMap[i] = (hsState)(State & 0xFF); \ 112 | } while (0) 113 | 114 | // MoveChar(B, C - Pos, Width, *p, Color, 1); 115 | // if (StateMap) StateMap[i] = State; } 116 | 117 | #define NextChar() do { i++; p++; len--; C++; } while (0) 118 | #define ColorNext() do { ColorChar(); NextChar(); } while (0) 119 | 120 | #define HILIT_VARS(ColorNormal, Line) \ 121 | PCLI *BPtr; \ 122 | int BPos; \ 123 | ChColor Color = ColorNormal; \ 124 | int i; \ 125 | int len = Line->Count; \ 126 | char *p = Line->Chars; \ 127 | int NC = 0, C = 0; \ 128 | int TabSize = BFI(BF, BFI_TabSize); \ 129 | int ExpandTabs = BFI(BF, BFI_ExpandTabs); 130 | 131 | //#define HILIT_VARS2() 132 | // int len1 = len; 133 | // char *last = p + len1 - 1; 134 | 135 | #define IF_TAB() \ 136 | if (*p == '\t' && ExpandTabs) { \ 137 | NC = NextTab(C, TabSize); \ 138 | if (StateMap) StateMap[i] = hsState(State);\ 139 | if (B) MoveChar(B, C - Pos, Width, ' ', Color, NC - C);\ 140 | if (BFI(BF, BFI_ShowTabs)) ColorChar();\ 141 | i++,len--,p++;\ 142 | C = NC;\ 143 | continue;\ 144 | } 145 | 146 | #define CK_MAXLEN 32 147 | 148 | typedef struct { 149 | int TotalCount; 150 | int count[CK_MAXLEN]; 151 | char *key[CK_MAXLEN]; 152 | } ColorKeywords; 153 | 154 | struct HTrans { 155 | char *match; 156 | int matchLen; 157 | long matchFlags; 158 | int nextState; 159 | int color; 160 | 161 | void InitTrans(); 162 | }; 163 | 164 | struct HState { 165 | int transCount; 166 | int firstTrans; 167 | int color; 168 | 169 | ColorKeywords keywords; 170 | char *wordChars; 171 | long options; 172 | int nextKwdMatchedState; 173 | int nextKwdNotMatchedState; 174 | int nextKwdNoCharState; 175 | 176 | void InitState(); 177 | int GetHilitWord(int len, char *str, ChColor &clr); 178 | }; 179 | 180 | class HMachine { 181 | public: 182 | int stateCount; 183 | int transCount; 184 | HState *state; 185 | HTrans *trans; 186 | 187 | HMachine(); 188 | ~HMachine(); 189 | void AddState(HState &aState); 190 | void AddTrans(HTrans &aTrans); 191 | 192 | HState *LastState() { return state + stateCount - 1; } 193 | }; 194 | 195 | class EColorize { 196 | public: 197 | char *Name; 198 | EColorize *Next; 199 | EColorize *Parent; 200 | int SyntaxParser; 201 | ColorKeywords Keywords; // keywords to highlight 202 | HMachine *hm; 203 | ChColor Colors[COUNT_CLR]; 204 | 205 | EColorize(const char *AName, const char *AParent); 206 | ~EColorize(); 207 | 208 | int SetColor(int clr, const char *value); 209 | }; 210 | 211 | extern EColorize *Colorizers; 212 | EColorize *FindColorizer(const char *AName); 213 | 214 | SyntaxProc GetHilitProc(int id); 215 | 216 | int IsState(hsState *Buf, hsState State, int Len); 217 | int LookAt(EBuffer *B, int Row, unsigned int Pos, const char *What, hsState State, int NoWord = 1, int CaseInsensitive = 0); 218 | inline int LookAtNoCase(EBuffer *B, int Row, unsigned int Pos, const char *What, hsState State, int NoWord = 1) 219 | { return LookAt(B, Row, Pos, What, State, NoWord, 1); } 220 | 221 | #endif 222 | 223 | #endif 224 | -------------------------------------------------------------------------------- /c_history.h: -------------------------------------------------------------------------------- 1 | /* c_history.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __FPOSHIST_H__ 11 | #define __FPOSHIST_H__ 12 | 13 | #ifdef CONFIG_HISTORY 14 | 15 | #ifdef UNIX 16 | #define HISTORY_NAME ".fte-history" 17 | #else 18 | #define HISTORY_NAME "fte.his" 19 | #endif 20 | 21 | typedef struct { 22 | char *FileName; 23 | int Row, Col; 24 | } FPosHistory; 25 | 26 | #define MAX_INPUT_HIST 128 27 | 28 | typedef struct { 29 | int Count; 30 | char **Line; 31 | int *Id; 32 | } InputHistory; 33 | 34 | extern char HistoryFileName[256]; 35 | 36 | 37 | void ClearHistory(); 38 | int SaveHistory(char *FileName); 39 | int LoadHistory(char *FileName); 40 | 41 | int UpdateFPos(char *FileName, int Row, int Col); 42 | int RetrieveFPos(char *FileName, int &Row, int &Col); 43 | 44 | int AddInputHistory(int Id, char *String); 45 | int CountInputHistory(int Id); 46 | int GetInputHistory(int Id, char *String, int maxlen, int Nth); 47 | 48 | /* history values */ 49 | #define HIST_DEFAULT 0 50 | #define HIST_PATH 1 51 | #define HIST_SEARCH 2 52 | #define HIST_POSITION 3 53 | #define HIST_SETUP 4 54 | #define HIST_SHELL 5 55 | #define HIST_COMPILE 6 56 | #define HIST_SEARCHOPT 7 57 | #define HIST_BOOKMARK 8 58 | #define HIST_REGEXP 9 59 | #define HIST_TRANS 10 60 | #define HIST_TAGFILES 11 61 | 62 | #endif 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /c_mode.cpp: -------------------------------------------------------------------------------- 1 | /* c_mode.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | EBufferFlags DefaultBufferFlags = { 13 | { 14 | 1, // AutoIndent 15 | 1, // InsertOn 16 | 0, // DrawOn 17 | 1, // HilitOn 18 | 1, // ExpandTabs 19 | 0, // Trim 20 | 8, // TabSize 21 | HILIT_PLAIN, // HilitMode 22 | INDENT_PLAIN, // IndentMode 23 | 0, // ShowTab 24 | 10, // LineChar 25 | #if !defined(UNIX) 26 | 13, // StripChar 27 | #else 28 | -1, 29 | #endif 30 | 1, // AddLine 31 | #if !defined(UNIX) 32 | 1, // AddStrip 33 | #else 34 | 0, 35 | #endif 36 | 0, // ForceNewLine 37 | 0, // HardMode 38 | 1, // UndoRedo 39 | 0, // ReadOnly 40 | 0, // AutoSave 41 | 1, // KeepBackups 42 | -1, // LoadMargin 43 | 256, // Max Undo/Redo Commands 44 | 1, // MatchCase 45 | 0, // BackKillTab 46 | 0, // DelKillTab 47 | 1, // BackSpUnindent 48 | 0, // SpaceTabs 49 | 1, // IndentWTabs 50 | 1, // Wrap.LeftMargin 51 | 72, // Wrap.RightMargin 52 | 1, // See Thru Sel 53 | 0, // WordWrap 54 | 0, // ShowMarkers 55 | 1, // CursorThroughTabs 56 | 0, // Save Folds 57 | 0, // MultiLineHilit 58 | 0, // AutoHilitParen 59 | 0, // Abbreviations 60 | 0, // BackSpKillBlock 61 | 0, // DeleteKillBlock 62 | 1, // PersistentBlocks 63 | 0, // InsertKillBlock 64 | 0, // UndoMoves 65 | #ifdef UNIX 66 | 0, // DetectLineSep 67 | #else 68 | 1, 69 | #endif 70 | 0 // trim on save 71 | }, 72 | { 73 | 0, // Routine Regexp 74 | 0, // DefFindOpt 75 | 0, // DefFindReplaceOpt 76 | 0, // comment start (folds) 77 | 0, // comment end (folds) 78 | 0, // filename rx 79 | 0, // firstline rx 80 | 0 // compile command 81 | } 82 | }; 83 | 84 | EMode *GetModeForName(const char *FileName) { 85 | // char ext[10]; 86 | // char *p; 87 | int l, i; 88 | EMode *m; 89 | RxMatchRes RM; 90 | char buf[81]; 91 | int fd; 92 | 93 | m = Modes; 94 | while (m) { 95 | if (m->MatchNameRx) 96 | if (RxExec(m->MatchNameRx, 97 | FileName, strlen(FileName), FileName, 98 | &RM) == 1) 99 | return m; 100 | if (m->fNext == 0) break; 101 | m = m->fNext; 102 | } 103 | 104 | fd = open(FileName, O_RDONLY); 105 | if (fd != -1) { 106 | l = read(fd, buf, 80); 107 | close(fd); 108 | if (l > 0) { 109 | buf[l] = 0; 110 | for (i = 0; i < l; i++) { 111 | if (buf[i] == '\n') { 112 | buf[i] = 0; 113 | l = i; 114 | break; 115 | } 116 | } 117 | m = Modes; 118 | while (m) { 119 | if (m->MatchLineRx) 120 | if (RxExec(m->MatchLineRx, buf, l, buf, &RM) == 1) 121 | return m; 122 | if (m->fNext == 0) break; 123 | m = m->fNext; 124 | } 125 | } 126 | } 127 | 128 | if ((m = FindMode(DefaultModeName)) != 0) return m; 129 | 130 | m = Modes; 131 | while (m && m->fNext) m = m->fNext; 132 | return m; 133 | } 134 | -------------------------------------------------------------------------------- /clip_no.cpp: -------------------------------------------------------------------------------- 1 | /* clip_no.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | int GetPMClip() { 13 | return 0; 14 | } 15 | 16 | int PutPMClip() { 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /commands.cpp: -------------------------------------------------------------------------------- 1 | /* commands.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | int GetDefaultDirectory(EModel *M, char *Path, int MaxLen) { 13 | if (M) 14 | M->GetPath(Path, MaxLen); 15 | if (!M || Path[0] == 0) 16 | if (ExpandPath(".", Path) == -1) 17 | return 0; 18 | SlashDir(Path); 19 | return 1; 20 | } 21 | 22 | int SetDefaultDirectory(EModel *M) { 23 | char Path[MAXPATH]; 24 | 25 | if (GetDefaultDirectory(M, Path, sizeof(Path)) == 0) 26 | return 0; 27 | if (ChangeDir(Path) == -1) 28 | return 0; 29 | return 1; 30 | } 31 | -------------------------------------------------------------------------------- /con_dosx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gered/fte/972be491c31c9c5a465ac1aa4e0d84e4e0667fc6/con_dosx.cpp -------------------------------------------------------------------------------- /conkbd.h: -------------------------------------------------------------------------------- 1 | /* conkbd.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __CONKBD_H__ 11 | #define __CONKBD_H__ 12 | 13 | #define kfAltXXX 0x01000000L 14 | #define kfModifier 0x02000000L 15 | #define kfSpecial 0x00010000L 16 | #define kfAlt 0x00100000L 17 | #define kfCtrl 0x00200000L 18 | #define kfShift 0x00400000L 19 | #define kfGray 0x00800000L 20 | #define kfKeyUp 0x10000000L 21 | #define kfAll 0x00F00000L 22 | 23 | #define isAltXXX(x) (((x) & (kfAltXXX)) != 0) 24 | #define isAlt(x) (((x) & kfAlt) != 0) 25 | #define isCtrl(x) (((x) & kfCtrl) != 0) 26 | #define isShift(x) (((x) & kfShift) != 0) 27 | #define isGray(x) (((x) & kfGray) != 0) 28 | #define keyType(x) ((x) & kfAll) 29 | #define keyCode(x) ((x) & 0x000FFFFF) 30 | #define kbCode(x) (((x) & 0x0FFFFFFF) & ~(kfGray | kfAltXXX)) 31 | #define isAscii(x) ((((x) & (kfAlt | kfCtrl)) == 0) && (keyCode(x) < 256)) 32 | 33 | #define kbF1 (kfSpecial | 0x101) 34 | #define kbF2 (kfSpecial | 0x102) 35 | #define kbF3 (kfSpecial | 0x103) 36 | #define kbF4 (kfSpecial | 0x104) 37 | #define kbF5 (kfSpecial | 0x105) 38 | #define kbF6 (kfSpecial | 0x106) 39 | #define kbF7 (kfSpecial | 0x107) 40 | #define kbF8 (kfSpecial | 0x108) 41 | #define kbF9 (kfSpecial | 0x109) 42 | #define kbF10 (kfSpecial | 0x110) 43 | #define kbF11 (kfSpecial | 0x111) 44 | #define kbF12 (kfSpecial | 0x112) 45 | 46 | #define kbUp (kfSpecial | 0x201) 47 | #define kbDown (kfSpecial | 0x202) 48 | #define kbLeft (kfSpecial | 0x203) 49 | #define kbCenter (kfSpecial | 0x204) 50 | #define kbRight (kfSpecial | 0x205) 51 | #define kbHome (kfSpecial | 0x206) 52 | #define kbEnd (kfSpecial | 0x207) 53 | #define kbPgUp (kfSpecial | 0x208) 54 | #define kbPgDn (kfSpecial | 0x209) 55 | #define kbIns (kfSpecial | 0x210) 56 | #define kbDel (kfSpecial | 0x211) 57 | 58 | #define kbSpace 32 59 | 60 | #define kbBackSp (kfSpecial | 8) 61 | #define kbTab (kfSpecial | 9) 62 | #define kbEnter (kfSpecial | 13) 63 | #define kbEsc (kfSpecial | 27) 64 | 65 | #define kbAlt (kfModifier | 0x301) 66 | #define kbCtrl (kfModifier | 0x302) 67 | #define kbShift (kfModifier | 0x303) 68 | #define kbCapsLock (kfModifier | 0x304) 69 | #define kbNumLock (kfModifier | 0x305) 70 | #define kbScrollLock (kfModifier | 0x306) 71 | 72 | #define kbPause (kfSpecial | 0x401) 73 | #define kbPrtScr (kfSpecial | 0x402) 74 | #define kbSysReq (kfSpecial | 0x403) 75 | #define kbBreak (kfSpecial | 0x404) 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /console.h: -------------------------------------------------------------------------------- 1 | /* console.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __CONSOLE_H__ 11 | #define __CONSOLE_H__ 12 | 13 | /* don't change these, used as index */ 14 | #define DCH_C1 0 15 | #define DCH_C2 1 16 | #define DCH_C3 2 17 | #define DCH_C4 3 18 | #define DCH_H 4 19 | #define DCH_V 5 20 | #define DCH_M1 6 21 | #define DCH_M2 7 22 | #define DCH_M3 8 23 | #define DCH_M4 9 24 | #define DCH_X 10 25 | #define DCH_RPTR 11 26 | #define DCH_EOL 12 27 | #define DCH_EOF 13 28 | #define DCH_END 14 29 | #define DCH_AUP 15 30 | #define DCH_ADOWN 16 31 | #define DCH_HFORE 17 32 | #define DCH_HBACK 18 33 | #define DCH_ALEFT 19 34 | #define DCH_ARIGHT 20 35 | 36 | #define ConMaxCols 256 37 | #define ConMaxRows 128 38 | 39 | #define csUp 0 40 | #define csDown 1 41 | #define csLeft 2 42 | #define csRight 3 43 | 44 | #define evNone 0 45 | #define evKeyDown 0x0001 46 | #define evKeyUp 0x0002 47 | #define evMouseDown 0x0010 48 | #define evMouseUp 0x0020 49 | #define evMouseMove 0x0040 50 | #define evMouseAuto 0x0080 51 | #define evCommand 0x0100 52 | #define evBroadcast 0x0200 53 | #define evNotify 0x0400 54 | 55 | #define evKeyboard (evKeyDown | evKeyUp) 56 | #define evMouse (evMouseDown | evMouseUp | evMouseMove | evMouseAuto) 57 | #define evMessage (evCommand | evBroadcast) 58 | 59 | #include "conkbd.h" 60 | 61 | #define cmRefresh 1 62 | #define cmResize 2 63 | #define cmClose 3 64 | #define cmPipeRead 4 65 | #define cmMainMenu 5 66 | #define cmPopupMenu 6 67 | 68 | /* vertical scroll */ 69 | 70 | #define cmVScrollUp 10 71 | #define cmVScrollDown 11 72 | #define cmVScrollPgUp 12 73 | #define cmVScrollPgDn 13 74 | #define cmVScrollMove 14 75 | 76 | /* horizontal scroll */ 77 | 78 | #define cmHScrollLeft 15 79 | #define cmHScrollRight 16 80 | #define cmHScrollPgLt 17 81 | #define cmHScrollPgRt 18 82 | #define cmHScrollMove 19 83 | 84 | #define cmDroppedFile 30 85 | #define cmRenameFile 31 /* TODO: in-place editing of titlebar */ 86 | 87 | typedef unsigned char TAttr; 88 | typedef TAttr *PAttr; 89 | 90 | #ifdef NTCONSOLE 91 | typedef unsigned long TCell; 92 | #else 93 | typedef unsigned short TCell; 94 | #endif 95 | 96 | typedef TCell *PCell; 97 | typedef TCell TDrawBuffer[ConMaxCols]; 98 | typedef TDrawBuffer *PDrawBuffer; 99 | typedef unsigned long TEventMask; 100 | typedef unsigned long TKeyCode; 101 | typedef unsigned long TCommand; 102 | 103 | class EModel; // forward 104 | class GView; 105 | 106 | typedef struct { 107 | TEventMask What; 108 | GView *View; 109 | TKeyCode Code; 110 | } TKeyEvent; 111 | 112 | typedef struct { 113 | TEventMask What; 114 | GView *View; 115 | long X; 116 | long Y; 117 | unsigned short Buttons; 118 | unsigned short Count; 119 | TKeyCode KeyMask; 120 | } TMouseEvent; 121 | 122 | typedef struct { 123 | TEventMask What; 124 | GView *View; 125 | EModel *Model; 126 | TCommand Command; 127 | long Param1; 128 | void *Param2; 129 | } TMsgEvent; 130 | 131 | typedef union { 132 | TEventMask What; 133 | TKeyEvent Key; 134 | TMouseEvent Mouse; 135 | TMsgEvent Msg; 136 | char fill[32]; 137 | } TEvent; 138 | 139 | #define SUBMENU_NORMAL (-1) 140 | #define SUBMENU_CONDITIONAL (-2) 141 | 142 | typedef struct _mItem { 143 | char *Name; 144 | char *Arg; 145 | int SubMenu; 146 | int Cmd; 147 | } mItem; 148 | 149 | typedef struct _mMenu { 150 | char *Name; 151 | int Count; 152 | mItem *Items; 153 | } mMenu; 154 | 155 | extern int MenuCount; 156 | extern mMenu *Menus; 157 | 158 | int ConInit(int XSize, int YSize); 159 | int ConDone(); 160 | int ConSuspend(); 161 | int ConContinue(); 162 | int ConSetTitle(char *Title, char *STitle); 163 | int ConGetTitle(char *Title, int MaxLen, char *STitle, int SMaxLen); 164 | 165 | int ConClear(); 166 | int ConPutBox(int X, int Y, int W, int H, PCell Cell); 167 | int ConGetBox(int X, int Y, int W, int H, PCell Cell); 168 | int ConPutLine(int X, int Y, int W, int H, PCell Cell); 169 | int ConSetBox(int X, int Y, int W, int H, TCell Cell); 170 | int ConScroll(int Way, int X, int Y, int W, int H, TAttr Fill, int Count); 171 | 172 | int ConSetSize(int X, int Y); 173 | int ConQuerySize(int *X, int *Y); 174 | 175 | int ConSetCursorPos(int X, int Y); 176 | int ConQueryCursorPos(int *X, int *Y); 177 | int ConShowCursor(); 178 | int ConHideCursor(); 179 | int ConCursorVisible(); 180 | int ConSetCursorSize(int Start, int End); 181 | 182 | int ConSetMousePos(int X, int Y); 183 | int ConQueryMousePos(int *X, int *Y); 184 | int ConShowMouse(); 185 | int ConHideMouse(); 186 | int ConMouseVisible(); 187 | int ConQueryMouseButtons(int *ButtonCount); 188 | 189 | int ConGetEvent(TEventMask EventMask, TEvent *Event, int WaitTime, int Delete); 190 | int ConPutEvent(TEvent Event); 191 | 192 | void MoveCh(PCell B, char Ch, TAttr Attr, int Count); 193 | void MoveChar(PCell B, int Pos, int Width, const char Ch, TAttr Attr, int Count); 194 | void MoveMem(PCell B, int Pos, int Width, const char* Ch, TAttr Attr, int Count); 195 | void MoveStr(PCell B, int Pos, int Width, const char* Ch, TAttr Attr, int MaxCount); 196 | void MoveCStr(PCell B, int Pos, int Width, const char* Ch, TAttr A0, TAttr A1, int MaxCount); 197 | void MoveAttr(PCell B, int Pos, int Width, TAttr Attr, int Count); 198 | void MoveBgAttr(PCell B, int Pos, int Width, TAttr Attr, int Count); 199 | 200 | int CStrLen(const char *s); 201 | 202 | int NewMenu(const char *Name); 203 | int NewItem(int menu, const char *Name); 204 | int NewSubMenu(int menu, const char *Name, int submenu, int type); 205 | int GetMenuId(const char *Name); 206 | 207 | char ConGetDrawChar(int index); 208 | 209 | extern char WindowFont[64]; 210 | 211 | #endif 212 | -------------------------------------------------------------------------------- /e_djgpp2.cpp: -------------------------------------------------------------------------------- 1 | /* e_djgpp2.cpp 2 | * 3 | * Copyright (c) 1997, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | * Contributed by Markus F.X.J. Oberhumer 9 | */ 10 | 11 | // djgpp2 specific routines 12 | 13 | #include "fte.h" 14 | 15 | int EView::SysShowHelp(ExState &State, const char *word) { 16 | Msg(S_ERROR, "Not yet implemented"); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /e_file.cpp: -------------------------------------------------------------------------------- 1 | /* e_file.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | EBuffer *FindFile(char *FileName) { 13 | EModel *M; 14 | EBuffer *B; 15 | 16 | M = ActiveModel; 17 | while (M) { 18 | if (M->GetContext() == CONTEXT_FILE) { 19 | B = (EBuffer *)M; 20 | if (filecmp(B->FileName, FileName) == 0) { return B; } 21 | } 22 | M = M->Next; 23 | if (M == ActiveModel) break; 24 | } 25 | return 0; 26 | } 27 | 28 | #if 0 29 | static void SwitchModel(EModel *AModel) { 30 | if (AModel != AcgiveModel && MM && AModel) { 31 | AModel->Prev->Next = AModel->Next; 32 | AModel->Next->Prev = AModel->Prev; 33 | 34 | AModel->Next = MM; 35 | AModel->Prev = MM->Prev; 36 | AModel->Prev->Next = AModel; 37 | MM->Prev = AModel; 38 | MM = AModel; 39 | } 40 | } 41 | #endif 42 | 43 | int FileLoad(int createFlags, const char *FileName, const char *Mode, EView *View) { 44 | char Name[MAXPATH]; 45 | EBuffer *B; 46 | 47 | assert(View != 0); 48 | 49 | if (ExpandPath(FileName, Name) == -1) { 50 | View->MView->Win->Choice(GPC_ERROR, "Error", 1, "O&K", "Invalid path: %s.", FileName); 51 | return 0; 52 | } 53 | B = FindFile(Name); 54 | if (B) { 55 | if (Mode != 0) 56 | B->SetFileName(Name, Mode); 57 | View->SwitchToModel(B); 58 | return 1; 59 | } 60 | B = new EBuffer(createFlags, &ActiveModel, Name); 61 | B->SetFileName(Name, Mode); 62 | 63 | View->SwitchToModel(B); 64 | return 1; 65 | } 66 | 67 | int MultiFileLoad(int createFlags, const char *FileName, const char *Mode, EView *View) { 68 | char fX[MAXPATH]; 69 | int count = 0; 70 | char FPath[MAXPATH]; 71 | char FName[MAXPATH]; 72 | FileFind *ff; 73 | FileInfo *fi; 74 | int rc; 75 | 76 | assert(View != 0); 77 | 78 | JustDirectory(FileName, fX); 79 | if (fX[0] == 0) strcpy(fX, "."); 80 | JustFileName(FileName, FName); 81 | if (ExpandPath(fX, FPath) == -1) return 0; 82 | Slash(FPath, 1); 83 | 84 | ff = new FileFind(FPath, FName, ffHIDDEN | ffFULLPATH); 85 | if (ff == 0) 86 | return 0; 87 | rc = ff->FindFirst(&fi); 88 | while (rc == 0) { 89 | count++; 90 | if (FileLoad(createFlags, fi->Name(), Mode, View) == 0) { 91 | delete fi; 92 | delete ff; 93 | return 0; 94 | } 95 | delete fi; 96 | rc = ff->FindNext(&fi); 97 | } 98 | delete ff; 99 | if (count == 0) 100 | return FileLoad(createFlags, FileName, Mode, View); 101 | return 1; 102 | } 103 | -------------------------------------------------------------------------------- /e_line.cpp: -------------------------------------------------------------------------------- 1 | /* e_line.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | ELine::ELine(int ACount, char *AChars) { 13 | Chars = NULL; 14 | Count = ACount; 15 | Allocate(Count); 16 | #ifdef CONFIG_SYNTAX_HILIT 17 | StateE = 0; 18 | #endif 19 | if (AChars) 20 | memcpy(Chars, AChars, Count); 21 | else 22 | memset(Chars, ' ', Count); 23 | } 24 | 25 | ELine::ELine(char *AChars, int ACount) { 26 | Chars = AChars; 27 | Count = ACount; 28 | #ifdef CONFIG_SYNTAX_HILIT 29 | StateE = 0; 30 | #endif 31 | } 32 | 33 | ELine::~ELine() { 34 | if (Chars) 35 | free(Chars); 36 | } 37 | 38 | int ELine::Allocate(unsigned int Bytes) { 39 | unsigned int Allocated; 40 | 41 | Allocated = (Bytes | CHAR_TRESHOLD); 42 | if (Chars) 43 | Chars = (char *) realloc(Chars, Allocated); 44 | else 45 | Chars = (char *) malloc(Allocated); 46 | if (Chars == NULL) 47 | return 0; 48 | return 1; 49 | } 50 | 51 | int EBuffer::ScreenPos(ELine *L, int Offset) { 52 | int ExpandTabs = BFI(this, BFI_ExpandTabs); 53 | int TabSize = BFI(this, BFI_TabSize); 54 | 55 | if (!ExpandTabs) { 56 | return Offset; 57 | } else { 58 | char *p = L->Chars; 59 | int Len = L->Count; 60 | int Pos = 0; 61 | int Ofs = Offset; 62 | 63 | if (Ofs > Len) { 64 | while (Len > 0) { 65 | if (*p++ != '\t') 66 | Pos++; 67 | else 68 | Pos = NextTab(Pos, TabSize); 69 | Len--; 70 | } 71 | Pos += Ofs - L->Count; 72 | } else { 73 | while (Ofs > 0) { 74 | if (*p++ != '\t') 75 | Pos++; 76 | else 77 | Pos = NextTab(Pos, TabSize); 78 | Ofs--; 79 | } 80 | } 81 | return Pos; 82 | } 83 | } 84 | 85 | int EBuffer::CharOffset(ELine *L, int ScreenPos) { 86 | int ExpandTabs = BFI(this, BFI_ExpandTabs); 87 | int TabSize = BFI(this, BFI_TabSize); 88 | 89 | if (!ExpandTabs) { 90 | return ScreenPos; 91 | } else { 92 | int Pos = 0; 93 | int Ofs = 0; 94 | char *p = L->Chars; 95 | int Len = L->Count; 96 | 97 | while (Len > 0) { 98 | if (*p++ != '\t') 99 | Pos++; 100 | else 101 | Pos = NextTab(Pos, TabSize); 102 | if (Pos > ScreenPos) 103 | return Ofs; 104 | Ofs++; 105 | Len--; 106 | } 107 | return Ofs + ScreenPos - Pos; 108 | } 109 | } 110 | 111 | int EBuffer::Allocate(int ACount) { 112 | PELine *L; 113 | 114 | L = (PELine *) realloc(LL, sizeof(PELine) * (ACount + 1)); 115 | if (L == 0 && ACount != 0) 116 | return 0; 117 | RAllocated = ACount; 118 | LL = L; 119 | return 1; 120 | } 121 | 122 | int EBuffer::MoveRGap(int RPos) { 123 | int GapSize = RAllocated - RCount; 124 | 125 | if (RGap == RPos) return 1; 126 | if (RPos < 0 || RPos > RCount) return 0; 127 | 128 | if (RGap < RPos) { 129 | if (RPos - RGap == 1) { 130 | LL[RGap] = LL[RGap + GapSize]; 131 | } else { 132 | memmove(LL + RGap, 133 | LL + RGap + GapSize, 134 | sizeof(PELine) * (RPos - RGap)); 135 | } 136 | } else { 137 | if (RGap - RPos == 1) { 138 | LL[RPos + GapSize] = LL[RPos]; 139 | } else { 140 | memmove(LL + RPos + GapSize, 141 | LL + RPos, 142 | sizeof(PELine) * (RGap - RPos)); 143 | } 144 | } 145 | RGap = RPos; 146 | return 1; 147 | } 148 | 149 | int EBuffer::AllocVis(int ACount) { 150 | int *V; 151 | 152 | V = (int *) realloc(VV, sizeof(int) * (ACount + 1)); 153 | if (V == 0 && ACount != 0) return 0; 154 | VAllocated = ACount; 155 | VV = V; 156 | return 1; 157 | } 158 | 159 | int EBuffer::MoveVGap(int VPos) { 160 | int GapSize = VAllocated - VCount; 161 | 162 | if (VGap == VPos) return 1; 163 | if (VPos < 0 || VPos > VCount) return 0; 164 | 165 | if (VGap < VPos) { 166 | if (VPos - VGap == 1) { 167 | VV[VGap] = VV[VGap + GapSize]; 168 | } else { 169 | memmove(VV + VGap, 170 | VV + VGap + GapSize, 171 | sizeof(VV[0]) * (VPos - VGap)); 172 | } 173 | } else { 174 | if (VGap - VPos == 1) { 175 | VV[VPos + GapSize] = VV[VPos]; 176 | } else { 177 | memmove(VV + VPos + GapSize, 178 | VV + VPos, 179 | sizeof(VV[0]) * (VGap - VPos)); 180 | } 181 | } 182 | VGap = VPos; 183 | return 1; 184 | } 185 | 186 | int EBuffer::RToV(int No) { 187 | int L = 0, R = VCount, M, V; 188 | 189 | if (No > Vis(VCount - 1) + VCount - 1) // beyond end 190 | return -1; 191 | if (No < VCount) // no folds before (direct match) 192 | if (Vis(No) == 0) return No; 193 | 194 | while (L < R) { 195 | M = (L + R) >> 1; 196 | V = Vis(M) + M; 197 | if (V == No) 198 | return M; 199 | else if (V > No) 200 | R = M; 201 | else 202 | L = M + 1; 203 | } 204 | return -1; 205 | } 206 | 207 | int EBuffer::RToVN(int No) { 208 | int L = 0, R = VCount, M, V; 209 | 210 | if (No == RCount) 211 | return VCount; 212 | if (No > Vis(VCount - 1) + VCount - 1) 213 | return VCount - 1; 214 | if (No < VCount) 215 | if (Vis(No) == 0) return No; 216 | 217 | while (L < R) { 218 | M = (L + R) >> 1; 219 | V = Vis(M) + M; 220 | if (V == No) 221 | return M; 222 | else if (V > No) 223 | R = M; 224 | else { 225 | if (M == VCount - 1) 226 | return M; 227 | else if (Vis(M + 1) + M + 1 > No) 228 | return M; 229 | L = M + 1; 230 | } 231 | } 232 | return R; 233 | } 234 | -------------------------------------------------------------------------------- /e_mark.h: -------------------------------------------------------------------------------- 1 | #ifndef __EMARK_H 2 | #define __EMARK_H 3 | 4 | class EMark { 5 | public: 6 | EMark(char *aName, char *aFileName, EPoint aPoint, EBuffer *aBuffer = 0); 7 | ~EMark(); 8 | 9 | int setBuffer(EBuffer *aBuffer); 10 | int removeBuffer(EBuffer *aBuffer); 11 | 12 | char *getName() { return Name; } 13 | char *getFileName() { return FileName; } 14 | EPoint &getPoint(); 15 | EBuffer *getBuffer() { return Buffer; } 16 | private: 17 | /* bookmark */ 18 | char *Name; 19 | EPoint Point; 20 | char *FileName; 21 | 22 | /* bookmark in file */ 23 | EBuffer *Buffer; 24 | }; 25 | 26 | class EMarkIndex { 27 | public: 28 | EMarkIndex(); 29 | ~EMarkIndex(); 30 | 31 | EMark *insert(char *aName, char *aFileName, EPoint aPoint, EBuffer *aBuffer = 0); 32 | EMark *insert(char *aName, EBuffer *aBuffer, EPoint aPoint); 33 | EMark *locate(char *aName); 34 | int remove(char *aName); 35 | int view(EView *aView, char *aName); 36 | 37 | // int MarkPush(EBuffer *B, EPoint P); 38 | // int MarkPop(EView *V); 39 | // int MarkSwap(EView *V, EBuffer *B, EPoint P); 40 | // int MarkNext(EView *V); 41 | // int MarkPrev(EView *V); 42 | EMark *pushMark(EBuffer *aBuffer, EPoint P); 43 | int popMark(EView *aView); 44 | 45 | int retrieveForBuffer(EBuffer *aBuffer); 46 | int storeForBuffer(EBuffer *aBuffer); 47 | 48 | int saveToDesktop(FILE *fp); 49 | 50 | private: 51 | int markCount; 52 | EMark **marks; 53 | }; 54 | 55 | extern EMarkIndex markIndex; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /e_print.cpp: -------------------------------------------------------------------------------- 1 | /* e_print.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | int EBuffer::BlockPrint() { 13 | static char cr = 13; 14 | static char lf = 10; 15 | EPoint B, E; 16 | int L; 17 | int A, Z; 18 | PELine LL; 19 | FILE *fp; 20 | int bc = 0, lc = 0; 21 | int error = 0; 22 | 23 | AutoExtend = 0; 24 | if (CheckBlock() == 0) return 0; 25 | if (RCount == 0) return 0; 26 | B = BB; 27 | E = BE; 28 | Msg(S_INFO, "Printing to %s...", PrintDevice); 29 | #if !defined(__IBMCPP__) && !defined(__WATCOMC__) 30 | if (PrintDevice[0] == '|') 31 | fp = popen(PrintDevice + 1, "w"); 32 | else 33 | #endif 34 | fp = fopen(PrintDevice, "w"); 35 | if (fp == NULL) { 36 | Msg(S_INFO, "Failed to write to %s", PrintDevice); 37 | return 0; 38 | } 39 | for (L = B.Row; L <= E.Row; L++) { 40 | A = -1; 41 | Z = -1; 42 | LL = RLine(L); 43 | switch (BlockMode) { 44 | case bmLine: 45 | if (L < E.Row) { 46 | A = 0; 47 | Z = LL->Count; 48 | } 49 | break; 50 | case bmColumn: 51 | if (L < E.Row) { 52 | A = CharOffset(LL, B.Col); 53 | Z = CharOffset(LL, E.Col); 54 | } 55 | break; 56 | case bmStream: 57 | if (B.Row == E.Row) { 58 | A = CharOffset(LL, B.Col); 59 | Z = CharOffset(LL, E.Col); 60 | } else if (L == B.Row) { 61 | A = CharOffset(LL, B.Col); 62 | Z = LL->Count; 63 | } else if (L < E.Row) { 64 | A = 0; 65 | Z = LL->Count; 66 | } else if (L == E.Row) { 67 | A = 0; 68 | Z = CharOffset(LL, E.Col); 69 | } 70 | break; 71 | } 72 | if (A != -1 && Z != -1) { 73 | if (A < LL->Count) { 74 | if (Z > LL->Count) 75 | Z = LL->Count; 76 | if (Z > A) { 77 | if ((int)(fwrite(LL->Chars + A, 1, Z - A, fp)) != Z - A) { 78 | error++; 79 | break; 80 | } else 81 | bc += Z - A; 82 | } 83 | } 84 | if (BFI(this, BFI_AddCR) == 1) 85 | if (fwrite(&cr, 1, 1, fp) != 1) { 86 | error++; 87 | break; 88 | } else 89 | bc++; 90 | if (BFI(this, BFI_AddLF) == 1) 91 | if (fwrite(&lf, 1, 1, fp) != 1) { 92 | error++; 93 | break; 94 | } else { 95 | bc++; 96 | lc++; 97 | } 98 | if ((lc % 200) == 0) 99 | Msg(S_INFO, "Printing, %d lines, %d bytes.", lc, bc); 100 | 101 | } 102 | } 103 | if (!error) { 104 | fwrite("\f\n", 2, 1, fp); 105 | #if !defined(__IBMCPP__) && !defined(__WATCOMC__) 106 | if (PrintDevice[0] == '|') 107 | pclose(fp); 108 | else 109 | #endif 110 | fclose(fp); 111 | Msg(S_INFO, "Printing %d lines, %d bytes.", lc, bc); 112 | return 1; 113 | } 114 | #if !defined(__IBMCPP__) && !defined(__WATCOMC__) 115 | if (PrintDevice[0] == '|') 116 | pclose(fp); 117 | else 118 | #endif 119 | fclose(fp); 120 | Msg(S_INFO, "Failed to write to %s", PrintDevice); 121 | return 0; 122 | } 123 | 124 | 125 | int EBuffer::FilePrint() { 126 | static char cr = 13; 127 | static char lf = 10; 128 | int l; 129 | FILE *fp; 130 | unsigned long ByteCount = 0; 131 | int BChars; 132 | 133 | Msg(S_INFO, "Printing %s to %s...", FileName, PrintDevice); 134 | #if !defined(__IBMCPP__) && !defined(__WATCOMC__) 135 | if (PrintDevice[0] == '|') 136 | fp = popen(PrintDevice + 1, "w"); 137 | else 138 | #endif 139 | fp = fopen(PrintDevice, "w"); 140 | if (fp == NULL) { 141 | Msg(S_ERROR, "Error printing %s to %s.", FileName, PrintDevice); 142 | return 0; 143 | } 144 | BChars = 0; 145 | for (l = 0; l < RCount; l++) { 146 | if ((int) sizeof(FileBuffer) - (BChars + 2) < RLine(l)->Count) { 147 | if (BChars) { 148 | ByteCount += BChars; 149 | Msg(S_INFO, "Printing: %d lines, %d bytes.", l, ByteCount); 150 | if ((int)(fwrite(FileBuffer, 1, BChars, fp)) != BChars) goto fail; 151 | BChars = 0; 152 | } 153 | } 154 | if (RLine(l)->Count > int(sizeof(FileBuffer)) - 2) { 155 | assert(BChars == 0); 156 | ByteCount += RLine(l)->Count; 157 | Msg(S_INFO, "Printing: %d lines, %d bytes.", l, ByteCount); 158 | if (int(fwrite(RLine(l)->Chars, 1, RLine(l)->Count, fp)) != RLine(l)->Count) goto fail; 159 | } else { 160 | memcpy(FileBuffer + BChars, RLine(l)->Chars, RLine(l)->Count); 161 | BChars += RLine(l)->Count; 162 | } 163 | if ((l < RCount - 1) || BFI(this, BFI_ForceNewLine)) { 164 | assert(int(sizeof(FileBuffer)) >= BChars + 2); 165 | if (BFI(this, BFI_AddCR) == 1) FileBuffer[BChars++] = cr; 166 | if (BFI(this, BFI_AddLF) == 1) FileBuffer[BChars++] = lf; 167 | } 168 | } 169 | if (BChars) { 170 | ByteCount += BChars; 171 | Msg(S_INFO, "Printing: %d lines, %d bytes.", l, ByteCount); 172 | if ((int)(fwrite(FileBuffer, 1, BChars, fp)) != BChars) goto fail; 173 | } 174 | BChars = 0; 175 | #if !defined(__IBMCPP__) && !defined(__WATCOMC__) 176 | if (PrintDevice[0] == '|') 177 | pclose(fp); 178 | else 179 | #endif 180 | fclose(fp); 181 | Msg(S_INFO, "Printed %s.", FileName); 182 | return 1; 183 | fail: 184 | if (fp != NULL) { 185 | #if !defined(__IBMCPP__) && !defined(__WATCOMC__) 186 | if (PrintDevice[0] == '|') 187 | pclose(fp); 188 | else 189 | #endif 190 | fclose(fp); 191 | } 192 | Msg(S_ERROR, "Error printing %s to %s.", FileName, PrintDevice); 193 | return 0; 194 | } 195 | -------------------------------------------------------------------------------- /e_regex.h: -------------------------------------------------------------------------------- 1 | /* e_regex.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __REGEX_H 11 | #define __REGEX_H 12 | 13 | /* 14 | * Operator: 15 | * 16 | * ^ Match the beginning of line 17 | * $ Match the end of line 18 | * . Match any character 19 | * [ ] Match characters in set 20 | * [^ ] Match characters not in set 21 | * ? Match previous pattern 0 or 1 times (greedy) 22 | * | Match previous or next pattern 23 | * @ Match previous pattern 0 or more times (non-greedy) 24 | * # Match previous pattern 1 or more times (non-greedy) 25 | * * Match previous pattern 0 or more times (greedy) 26 | * + Match previous pattern 1 or more times (greedy) 27 | * { } Group characters to form one pattern 28 | * ( ) Group and remember 29 | * \ Quote next character (only of not a-z) 30 | * < Match beginning of a word 31 | * > Match end of a word 32 | * \x## Match character with ASCII code ## (hex) 33 | * \N### Match ascii code ### (dec) 34 | * \o### Match ascii code 35 | * \a Match \a \r Match 0x13 (cr) 36 | * \b Match \b \t Match 0x09 (tab) 37 | * \f Match \f \v Match \v 38 | * \n Match 0x10 (lf) \e Match escape (^E) 39 | * \s Match whitespace (cr/lf/tab/space) 40 | * \S Match nonwhitespace (!\S) 41 | * \w Match word character 42 | * \W Match non-word character 43 | * \d Match digit character 44 | * \D Match non-digit character 45 | * \U Match uppercase 46 | * \L Match lowercase 47 | * \C Match case sensitively from here on 48 | * \c Match case ingnore from here on 49 | */ 50 | 51 | #define RE_NOTHING 0 // nothing 52 | #define RE_JUMP 1 // jump to 53 | #define RE_BREAK 2 // break | 54 | #define RE_ATBOL 3 // match at beginning of line 55 | #define RE_ATEOL 4 // match at end of line 56 | #define RE_ATBOW 5 // match beginning of word 57 | #define RE_ATEOW 6 // match end of word 58 | #define RE_CASE 7 // match case sensitively from here 59 | #define RE_NCASE 8 // ignore case from here. 60 | #define RE_END 31 // end of regexp 61 | 62 | #define RE_ANY (32 + 1) // match any character 63 | #define RE_INSET (32 + 2) // match if in set 64 | #define RE_NOTINSET (32 + 3) // match if not in set 65 | #define RE_CHAR (32 + 4) // match character string 66 | #define RE_WSPACE (32 + 5) // match whitespace 67 | #define RE_NWSPACE (32 + 6) // match whitespace 68 | #define RE_UPPER (32 + 7) // match uppercase 69 | #define RE_LOWER (32 + 8) // match lowercase 70 | #define RE_DIGIT (32 + 9) // match digit 71 | #define RE_NDIGIT (32 + 10) // match non-digit 72 | #define RE_WORD (32 + 11) // match word 73 | #define RE_NWORD (32 + 12) // match non-word 74 | 75 | #define RE_GROUP 256 // grouping 76 | #define RE_OPEN 512 // open ( 77 | #define RE_CLOSE 1024 // close ) 78 | #define RE_MEM 2048 // store () match 79 | 80 | #define RE_BRANCH 4096 81 | #define RE_GREEDY 2048 // do a greedy match (as much as possible) 82 | 83 | #define NSEXPS 64 // for replace only 0-9 84 | 85 | #define RX_CASE 1 // matchcase 86 | 87 | typedef struct _RxNode RxNode; 88 | 89 | struct _RxNode { 90 | short fWhat; 91 | short fLen; 92 | RxNode *fPrev; 93 | RxNode *fNext; 94 | union { 95 | char *fChar; 96 | RxNode *fPtr; 97 | }; 98 | }; 99 | 100 | typedef struct { 101 | int Open[NSEXPS]; // -1 = not matched 102 | int Close[NSEXPS]; 103 | } RxMatchRes; 104 | 105 | RxNode *RxCompile(const char *Regexp); 106 | int RxExec(RxNode *Regexp, const char *Data, int Len, const char *Start, RxMatchRes *Match, unsigned int RxOpt = RX_CASE); 107 | int RxReplace(const char *rep, const char *Src, int len, RxMatchRes match, char **Dest, int *Dlen); 108 | void RxFree(RxNode *Node); 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /e_tags.h: -------------------------------------------------------------------------------- 1 | /* e_tags.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __TAGS_H 11 | #define __TAGS_H 12 | 13 | #ifdef CONFIG_TAGS 14 | 15 | int TagsAdd(char *FileName); 16 | int TagsSave(FILE *fp); 17 | int TagsLoad(int id); 18 | 19 | int TagLoad(char *FileName); 20 | void TagClear(); 21 | int TagGoto(EView *V, char *Tag); 22 | int TagDefined(char *Tag); 23 | int TagFind(EBuffer *B, EView *V, char *Tag); 24 | int TagComplete(char **Words, int *WordsPos, int WordsMax, char *Tag); 25 | int TagNext(EView *V); 26 | int TagPrev(EView *V); 27 | int TagPop(EView *V); 28 | 29 | #endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /e_undo.h: -------------------------------------------------------------------------------- 1 | /* e_undo.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __UNDO_H__ 11 | #define __UNDO_H__ 12 | 13 | /* 14 | * only core operations can be directly undone 15 | * - Insert # of Lines 16 | * - Delete # of Lines 17 | * - Insert # Line 18 | * - Delete Line Text 19 | * - Insert Line Text 20 | * - Positioning 21 | * - Block marking 22 | */ 23 | 24 | #define ucInsLine 1 25 | #define ucDelLine 2 26 | #define ucInsChars 3 27 | #define ucDelChars 4 28 | 29 | #define ucJoinLine 5 30 | #define ucSplitLine 6 31 | 32 | #define ucPosition 7 33 | #define ucBlock 8 34 | #define ucModified 9 35 | 36 | #define ucFoldCreate 11 37 | #define ucFoldDestroy 12 38 | #define ucFoldPromote 13 39 | #define ucFoldDemote 14 40 | #define ucFoldOpen 15 41 | #define ucFoldClose 16 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /egui.h: -------------------------------------------------------------------------------- 1 | /* egui.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __EGUI_H__ 11 | #define __EGUI_H__ 12 | 13 | class EFrame: public GFrame { 14 | public: 15 | EEventMap *CMap; 16 | EModel *CModel; 17 | 18 | EFrame(int XSize, int YSize); 19 | virtual ~EFrame(); 20 | 21 | virtual void Update(); 22 | virtual void UpdateMenu(); 23 | }; 24 | 25 | class EGUI: public GUI { 26 | public: 27 | EKeyMap *ActiveMap; 28 | EKeyMap *OverrideMap; 29 | char CharMap[32]; 30 | 31 | EGUI(int &argc, char **argv, int XSize, int YSize); 32 | virtual ~EGUI(); 33 | 34 | virtual int ExecCommand(GxView *view, int Command, ExState &State); 35 | virtual int ExecMacro(GxView *view, int Macro); 36 | virtual int BeginMacro(GxView *view); 37 | 38 | void SetMsg(char *Msg); 39 | void SetOverrideMap(EKeyMap *aMap, char *ModeName); 40 | void SetMap(EKeyMap *aMap, KeySel *ks); 41 | // void CharEvent(TEvent &Event, char Ch); 42 | 43 | void DispatchKey(GxView *view, TEvent &Event); 44 | void DispatchCommand(GxView *view, TEvent &Event); 45 | 46 | virtual void DispatchEvent(GFrame *frame, GView *view, TEvent &Event); 47 | 48 | int FileCloseX(EView *View, int CreateNew, int XClose = 0); 49 | int FileClose(EView *View, ExState &State); 50 | int FileCloseAll(EView *View, ExState &State); 51 | 52 | int WinNext(GxView *view); 53 | int WinPrev(GxView *view); 54 | 55 | int WinHSplit(GxView *View); 56 | int WinClose(GxView *View); 57 | int WinZoom(GxView *View); 58 | int WinResize(ExState &State, GxView *View); 59 | int ExitEditor(EView *View); 60 | 61 | int FrameNew(); 62 | int FrameClose(GxView *View); 63 | int FrameNext(GxView *View); 64 | int FramePrev(GxView *View); 65 | 66 | int ShowEntryScreen(); 67 | int RunProgram(ExState &State, GxView *view); 68 | int RunProgramAsync(ExState &State, GxView *view); 69 | 70 | int MainMenu(ExState &State, GxView *View); 71 | int ShowMenu(ExState &State, GxView *View); 72 | int LocalMenu(GxView *View); 73 | 74 | int DesktopSaveAs(ExState &State, GxView *View); 75 | 76 | int findDesktop(char *argv[]); 77 | void DoLoadDesktopOnEntry(int &argc, char **argv); 78 | void EditorInit(); 79 | int CmdLoadFiles(int &argc, char **argv); 80 | int InterfaceInit(int &argc, char **argv); 81 | void DoLoadHistoryOnEntry(int &argc, char **argv); 82 | void DoSaveHistoryOnExit(); 83 | 84 | void EditorCleanup(); 85 | void InterfaceCleanup(); 86 | 87 | virtual int Start(int &argc, char **argv); 88 | virtual void Stop(); 89 | }; 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /feature.h: -------------------------------------------------------------------------------- 1 | /* feature.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | /* some stuff does not yet work */ 11 | 12 | #ifndef __FEATURE_H__ 13 | #define __FEATURE_H__ 14 | 15 | #undef CONFIG_EMULATE_VI // todo 16 | 17 | #define CONFIG_CONFIGURABLE 18 | #define CONFIG_MOUSE 19 | #define CONFIG_CLIPBOARD 20 | #define CONFIG_SHELL 21 | 22 | #define CONFIG_MFRAMES 23 | #define CONFIG_MWINDOWS 24 | #define CONFIG_MBUFFERS 25 | #define CONFIG_MENUS 26 | #define CONFIG_SCROLLBARS 27 | #define CONFIG_I_SEARCH 28 | #define CONFIG_I_ASCII 29 | #define CONFIG_HISTORY 30 | #define CONFIG_DESKTOP 31 | 32 | #define CONFIG_BLOCK_STREAM 33 | #define CONFIG_BLOCK_COLUMN 34 | #define CONFIG_BLOCK_LINE 35 | #define CONFIG_IOBLOCKS 36 | #define CONFIG_PRINTING 37 | #define CONFIG_BOOKMARKS 38 | #define CONFIG_WORDWRAP 39 | #define CONFIG_ABBREV 40 | #define CONFIG_TAGS 41 | 42 | #define CONFIG_UNDOREDO 43 | #define CONFIG_REGEXPS 44 | #define CONFIG_FOLDS 45 | 46 | #undef CONFIG_OBJ_HEXEDIT // todo 47 | #undef CONFIG_OBJ_VIEWER // todo 48 | #define CONFIG_OBJ_LIST 49 | #define CONFIG_OBJ_FILE 50 | 51 | #ifdef CONFIG_OBJ_LIST 52 | #define CONFIG_OBJ_DIRECTORY 53 | #define CONFIG_OBJ_ROUTINE 54 | #define CONFIG_OBJ_BUFFERS 55 | #define CONFIG_OBJ_MESSAGES 56 | #endif 57 | 58 | #define CONFIG_SYNTAX_HILIT 59 | #define CONFIG_WORD_HILIT 60 | 61 | #ifdef CONFIG_SYNTAX_HILIT 62 | #define CONFIG_HILIT_C 63 | #define CONFIG_HILIT_REXX 64 | #define CONFIG_HILIT_HTML 65 | #define CONFIG_HILIT_PERL 66 | #define CONFIG_HILIT_ADA 67 | #define CONFIG_HILIT_MAKE 68 | #define CONFIG_HILIT_DIFF 69 | #define CONFIG_HILIT_MERGE 70 | #define CONFIG_HILIT_IPF 71 | #define CONFIG_HILIT_MSG 72 | #define CONFIG_HILIT_SH 73 | #define CONFIG_HILIT_PASCAL 74 | #define CONFIG_HILIT_TEX 75 | #define CONFIG_HILIT_FTE 76 | #define CONFIG_HILIT_CATBS 77 | #define CONFIG_HILIT_SIMPLE 78 | #endif 79 | 80 | #if defined(CONFIG_HILIT_C) 81 | #define CONFIG_INDENT_C 82 | #endif 83 | 84 | #if defined(CONFIG_HILIT_SIMPLE) 85 | #define CONFIG_INDENT_SIMPLE 86 | #endif 87 | 88 | #if defined(CONFIG_HILIT_REXX) 89 | #define CONFIG_INDENT_REXX 90 | #endif 91 | 92 | #define CONFIG_I_COMPLETE 93 | #endif 94 | -------------------------------------------------------------------------------- /file_id.diz: -------------------------------------------------------------------------------- 1 | Text Mode text editor. Version 0.49.13 2 | Color syntax highlighting for C/C++, 3 | REXX, HTML, IPF, PERL, Ada, Pascal, TEX 4 | Multiple file/window editing, Column 5 | blocks, configurable menus and keyboard 6 | bindings, mouse support, undo/redo, 7 | regular expression search and replace, 8 | folding, background compiler execution. 9 | -------------------------------------------------------------------------------- /fte.cnf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gered/fte/972be491c31c9c5a465ac1aa4e0d84e4e0667fc6/fte.cnf -------------------------------------------------------------------------------- /fte.h: -------------------------------------------------------------------------------- 1 | /* fte.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __FTE_H 11 | #define __FTE_H 12 | 13 | #include "ftever.h" 14 | #include "feature.h" 15 | #include "sysdep.h" 16 | 17 | #ifdef NEED_LOG_H 18 | #include "log.h" 19 | #endif // NEED_LOG_H 20 | #include "console.h" 21 | #include "gui.h" 22 | #include "c_desk~1.h" 23 | #include "e_regex.h" 24 | #include "c_mode.h" 25 | #include "c_hilit.h" 26 | #include "c_bind.h" 27 | #include "e_undo.h" 28 | #include "c_color.h" 29 | #include "s_files.h" 30 | #include "s_direct.h" 31 | #include "c_config.h" 32 | #include "c_fcon~1.h" 33 | #include "i_oview.h" 34 | #include "i_input.h" 35 | #include "i_key.h" 36 | #include "i_choice.h" 37 | #include "i_ascii.h" 38 | #include "i_view.h" 39 | #include "i_mode~1.h" 40 | #include "egui.h" 41 | #include "o_model.h" 42 | #include "e_buffer.h" 43 | #include "e_mark.h" 44 | #include "o_list.h" 45 | #include "e_tags.h" 46 | #include "s_util.h" 47 | #include "i_search.h" 48 | #include "i_comp~1.h" 49 | #include "o_dire~1.h" 50 | #include "o_mess~1.h" 51 | #include "o_bufl~1.h" 52 | #include "o_rout~1.h" 53 | #include "o_mode~1.h" 54 | #include "c_comm~1.h" 55 | #include "c_hist~1.h" 56 | 57 | #if defined(_DEBUG) && defined(MSVC) && defined(MSVCDEBUG) 58 | #include 59 | 60 | #define new new( _CLIENT_BLOCK, __FILE__, __LINE__) 61 | 62 | #endif //_DEBUG && MSVC && MSVCDEBUG 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /ftever.h: -------------------------------------------------------------------------------- 1 | #ifndef __FTEVER_H 2 | #define __FTEVER_H 3 | 4 | #define PROG_FTE "fte" 5 | #define PROG_CFTE "cfte" 6 | #define PROGRAM PROG_FTE 7 | #define VERSION "0.49.13" 8 | #define VERNUM 0x00490400UL 9 | #define COPYRIGHT "Copyright (c) 1994-1998 Marko Macek\n" \ 10 | "Copyright (c) 2000-2001 Others" 11 | #endif 12 | -------------------------------------------------------------------------------- /g_menu.cpp: -------------------------------------------------------------------------------- 1 | /* g_menu.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include "console.h" 17 | #include "gui.h" 18 | 19 | int MenuCount = 0; 20 | mMenu *Menus = 0; 21 | 22 | int NewMenu(const char *Name) { 23 | int n; 24 | 25 | Menus = (mMenu *) realloc((void *) Menus, 26 | sizeof(mMenu) * (MenuCount + 1)); 27 | n = MenuCount; 28 | 29 | Menus[n].Name = strdup(Name); 30 | Menus[n].Count = 0; 31 | Menus[n].Items = 0; 32 | 33 | MenuCount++; 34 | return n; 35 | } 36 | 37 | int NewItem(int menu, const char *Name) { 38 | int n; 39 | 40 | assert (menu < MenuCount); 41 | 42 | Menus[menu].Items = (mItem *) realloc(Menus[menu].Items, 43 | sizeof(mItem) * (Menus[menu].Count + 1)); 44 | n = Menus[menu].Count; 45 | 46 | Menus[menu].Items[n].SubMenu = -1; 47 | Menus[menu].Items[n].Name = Name ? strdup(Name) : 0; 48 | Menus[menu].Items[n].Arg = 0; 49 | Menus[menu].Items[n].Cmd = -1; 50 | 51 | Menus[menu].Count++; 52 | return n; 53 | } 54 | 55 | int NewSubMenu(int menu, const char *Name, int submenu, int Type) { 56 | int n; 57 | 58 | assert (menu < MenuCount); 59 | 60 | Menus[menu].Items = (mItem *) realloc(Menus[menu].Items, 61 | sizeof(mItem) * (Menus[menu].Count + 1)); 62 | n = Menus[menu].Count; 63 | 64 | Menus[menu].Items[n].SubMenu = submenu; 65 | Menus[menu].Items[n].Name = Name ? strdup(Name) : 0; 66 | Menus[menu].Items[n].Arg = 0; 67 | Menus[menu].Items[n].Cmd = Type; 68 | 69 | Menus[menu].Count++; 70 | return n; 71 | } 72 | 73 | int GetMenuId(const char *Name) { 74 | if (Name) 75 | for (int i = 0; i < MenuCount; i++) 76 | if (strcmp(Name, Menus[i].Name) == 0) 77 | return i; 78 | return -1; 79 | } 80 | 81 | -------------------------------------------------------------------------------- /g_nodlg.cpp: -------------------------------------------------------------------------------- 1 | // used in text mode versions, should never be called (just for linking) 2 | 3 | #include 4 | #include 5 | #include "console.h" 6 | #include "gui.h" 7 | 8 | int DLGGetFile(GView *v, const char *Prompt, unsigned int BufLen, char *FileName, int Flags) { 9 | assert(1==0); 10 | return 0; 11 | } 12 | 13 | int DLGPickChoice(GView *v, const char *ATitle, int NSel, va_list ap, int Flags) { 14 | assert(1==0); 15 | return 0; 16 | } 17 | 18 | int DLGGetFind(GView *View, SearchReplaceOptions &sr) { 19 | assert(1==0); 20 | return 0; 21 | } 22 | 23 | int DLGGetFindReplace(GView *View, SearchReplaceOptions &sr) { 24 | assert(1==0); 25 | return 0; 26 | } 27 | 28 | int DLGGetStr(GView *View, const char *Prompt, unsigned int BufLen, char *Str, int HistId, int Flags) { 29 | assert(1 == 0); 30 | return 0; 31 | } 32 | 33 | -------------------------------------------------------------------------------- /gui.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "console.h" 8 | #include "gui.h" 9 | 10 | int GFrame::isLastFrame() { 11 | if (this == Next && frames == this) 12 | return 1; 13 | else 14 | return 0; 15 | } 16 | 17 | void GUI::deleteFrame(GFrame *frame) { 18 | if (frame->isLastFrame()) { 19 | delete frame; 20 | frames = 0; 21 | } else { 22 | //frame->Prev->Next = frame->Next; 23 | //frame->Next->Prev = frame->Prev; 24 | //if (frames == frame) 25 | // frames = frame->Next; 26 | 27 | //frames->Activate(); 28 | delete frame; 29 | } 30 | } 31 | 32 | int GUI::Start(int &/*argc*/, char ** /*argv*/) { 33 | return 0; 34 | } 35 | 36 | void GUI::Stop() { 37 | } 38 | 39 | void GUI::StopLoop() { 40 | doLoop = 0; 41 | } 42 | -------------------------------------------------------------------------------- /h_ada.cpp: -------------------------------------------------------------------------------- 1 | /* h_ada.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | #ifdef CONFIG_HILIT_ADA 13 | 14 | #define hsAda_Normal 0 15 | #define hsAda_Comment 1 16 | #define hsAda_CommentL 2 17 | #define hsAda_Keyword 4 18 | #define hsAda_String1 10 19 | #define hsAda_String2 11 20 | 21 | int Hilit_ADA(EBuffer *BF, int /*LN*/, PCell B, int Pos, int Width, ELine *Line, hlState &State, hsState *StateMap, int *ECol) { 22 | ChColor *Colors = BF->Mode->fColorize->Colors; 23 | int j = 0; 24 | int firstnw = 0; 25 | HILIT_VARS(Colors[CLR_Normal], Line); 26 | int len1 = len; 27 | // char *last = p + len1 - 1; 28 | 29 | C = 0; 30 | NC = 0; 31 | for(i = 0; i < Line->Count;) { 32 | if (*p != ' ' && *p != 9) firstnw++; 33 | IF_TAB() else { 34 | switch (State) { 35 | default: 36 | case hsAda_Normal: 37 | if (isalpha(*p) || *p == '_') { 38 | j = 0; 39 | while (((i + j) < Line->Count) && 40 | (isalnum(Line->Chars[i+j]) || 41 | (Line->Chars[i + j] == '_') || 42 | (Line->Chars[i + j] == '\'')) 43 | ) j++; 44 | if (BF->GetHilitWord(j, &Line->Chars[i], Color, 1)) { 45 | State = hsAda_Keyword; 46 | } else { 47 | int x; 48 | x = i + j; 49 | while ((x < Line->Count) && 50 | ((Line->Chars[x] == ' ') || (Line->Chars[x] == 9))) x++; 51 | if ((x < Line->Count) && (Line->Chars[x] == '(')) { 52 | Color = Colors[CLR_Function]; 53 | } else { 54 | Color = Colors[CLR_Normal]; 55 | } 56 | State = hsAda_Normal; 57 | } 58 | if (StateMap) 59 | memset(StateMap + i, State, j); 60 | if (B) 61 | MoveMem(B, C - Pos, Width, Line->Chars + i, Color, j); 62 | i += j; 63 | len -= j; 64 | p += j; 65 | C += j; 66 | State = hsAda_Normal; 67 | continue; 68 | } else if ((len >= 2) && (*p == '-') && (*(p+1) == '-')) { 69 | State = hsAda_CommentL; 70 | Color = Colors[CLR_Comment]; 71 | //hilit2: 72 | ColorNext(); 73 | hilit: 74 | ColorNext(); 75 | continue; 76 | } else if (isdigit(*p)) { 77 | Color = Colors[CLR_Number]; 78 | ColorNext(); 79 | while (len && (isdigit(*p) || *p == 'e' || *p == 'E' || *p == '.' || *p == '_')) ColorNext(); 80 | continue; 81 | } else if (*p == '\'') { 82 | State = hsAda_String1; 83 | Color = Colors[CLR_String]; 84 | goto hilit; 85 | } else if (*p == '"') { 86 | State = hsAda_String2; 87 | Color = Colors[CLR_String]; 88 | goto hilit; 89 | } else if (ispunct(*p) && *p != '_') { 90 | Color = Colors[CLR_Punctuation]; 91 | goto hilit; 92 | } 93 | Color = Colors[CLR_Normal]; 94 | goto hilit; 95 | case hsAda_CommentL: 96 | Color = Colors[CLR_Comment]; 97 | goto hilit; 98 | case hsAda_String1: 99 | Color = Colors[CLR_String]; 100 | if (*p == '\'') { 101 | ColorNext(); 102 | State = hsAda_Normal; 103 | continue; 104 | } 105 | goto hilit; 106 | case hsAda_String2: 107 | Color = Colors[CLR_String]; 108 | if (*p == '"') { 109 | ColorNext(); 110 | State = hsAda_Normal; 111 | continue; 112 | } 113 | goto hilit; 114 | } 115 | } 116 | } 117 | if (State == hsAda_CommentL) 118 | State = hsAda_Normal; 119 | if ((len1 == 0)) { 120 | switch (State) { 121 | case hsAda_String1: 122 | case hsAda_String2: 123 | State = hsAda_Normal; 124 | break; 125 | } 126 | } 127 | *ECol = C; 128 | return 0; 129 | } 130 | #endif 131 | -------------------------------------------------------------------------------- /h_catbs.cpp: -------------------------------------------------------------------------------- 1 | /* h_catbs.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | #ifdef CONFIG_HILIT_CATBS 13 | 14 | #define hsBS_Normal 1 15 | 16 | // this is for viewing only, do not try to edit or anything. 17 | 18 | int Hilit_CATBS(EBuffer *BF, int /*LN*/, PCell B, int Pos, int Width, ELine *Line, hlState &State, hsState *StateMap, int *ECol) { 19 | ChColor *Colors = BF->Mode->fColorize->Colors; 20 | HILIT_VARS(Colors[CLR_Normal], Line); 21 | int CL = 0; //(LN == BF->VToR(BF->CP.Row)) ? 1 : 0; 22 | 23 | for (i = 0; i < Line->Count;) { 24 | IF_TAB() else { 25 | switch (State) { 26 | default: 27 | case hsBS_Normal: 28 | Color = Colors[CLR_Normal]; 29 | while (!CL && len >= 2 && p[1] == '\b') { 30 | if (len > 2 && p[0] == p[2]) { // bold 31 | Color = Colors[CLR_Keyword]; 32 | NextChar(); 33 | NextChar(); 34 | C -= 2; 35 | } else if (p[0] == '_') { // underline 36 | Color = Colors[CLR_Symbol]; 37 | NextChar(); 38 | NextChar(); 39 | C -= 2; 40 | break; 41 | } else 42 | break; 43 | } 44 | ColorNext(); 45 | continue; 46 | } 47 | } 48 | } 49 | *ECol = C; 50 | return 0; 51 | } 52 | #endif 53 | -------------------------------------------------------------------------------- /h_diff.cpp: -------------------------------------------------------------------------------- 1 | /* h_diff.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | #ifdef CONFIG_HILIT_DIFF 13 | 14 | int Hilit_DIFF(EBuffer *BF, int /*LN*/, PCell B, int Pos, int Width, ELine* Line, hlState& State, hsState *StateMap, int *ECol) { 15 | ChColor *Colors = BF->Mode->fColorize->Colors; 16 | HILIT_VARS(Colors[CLR_Normal], Line); 17 | 18 | if (Line->Count > 0) { 19 | switch (Line->Chars[0]) { 20 | case '>': 21 | case '+': Color = Colors[CLR_New]; break; 22 | case '<': 23 | case '-': Color = Colors[CLR_Old]; break; 24 | case '!': Color = Colors[CLR_Changed]; break; 25 | default: Color = Colors[CLR_Normal]; break; 26 | } 27 | } 28 | 29 | if (ExpandTabs) { /* use slow mode */ 30 | for (i = 0; i < Line->Count;) { 31 | IF_TAB() else { 32 | ColorNext(); 33 | } 34 | } 35 | } else { /* fast mode */ 36 | if (Pos < Line->Count) { 37 | if (Pos + Width < Line->Count) { 38 | if (B) 39 | MoveMem(B, 0, Width, Line->Chars + Pos, Color, Width); 40 | if (StateMap) 41 | memset(StateMap, State, Line->Count); 42 | } else { 43 | if (B) 44 | MoveMem(B, 0, Width, Line->Chars + Pos, Color, Line->Count - Pos); 45 | if (StateMap) 46 | memset(StateMap, State, Line->Count); 47 | } 48 | } 49 | C = Line->Count; 50 | } 51 | State = 0; 52 | *ECol = C; 53 | return 0; 54 | } 55 | #endif 56 | -------------------------------------------------------------------------------- /h_fte.cpp: -------------------------------------------------------------------------------- 1 | /* h_fte.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | #ifdef CONFIG_HILIT_FTE 13 | 14 | #define hsFTE_Normal 0 15 | #define hsFTE_Comment 1 16 | #define hsFTE_Keyword 4 17 | #define hsFTE_String1 10 18 | #define hsFTE_String2 11 19 | #define hsFTE_CPP 12 20 | #define hsFTE_Regexp 15 21 | #define hsFTE_KeySpec 16 22 | 23 | int Hilit_FTE(EBuffer *BF, int /*LN*/, PCell B, int Pos, int Width, ELine *Line, hlState &State, hsState *StateMap, int *ECol) { 24 | ChColor *Colors = BF->Mode->fColorize->Colors; 25 | int j = 0; 26 | HILIT_VARS(Colors[CLR_Normal], Line); 27 | int len1 = len; 28 | char *last = p + len1 - 1; 29 | 30 | C = 0; 31 | NC = 0; 32 | 33 | for (i = 0; i < Line->Count;) { 34 | IF_TAB() else { 35 | switch(State) { 36 | default: 37 | case hsFTE_Normal: 38 | if (isalpha(*p) || *p == '_') { 39 | j = 0; 40 | while (((i + j) < Line->Count) && 41 | (isalnum(Line->Chars[i+j]) || 42 | (Line->Chars[i + j] == '_')) 43 | ) j++; 44 | if (BF->GetHilitWord(j, &Line->Chars[i], Color)) { 45 | State = hsFTE_Keyword; 46 | } else { 47 | Color = Colors[CLR_Normal]; 48 | State = hsFTE_Normal; 49 | } 50 | if (StateMap) 51 | memset(StateMap + i, State, j); 52 | if (B) 53 | MoveMem(B, C - Pos, Width, Line->Chars + i, Color, j); 54 | i += j; 55 | len -= j; 56 | p += j; 57 | C += j; 58 | State = hsFTE_Normal; 59 | continue; 60 | } else if (*p == '#') { 61 | State = hsFTE_Comment; 62 | Color = Colors[CLR_Comment]; 63 | goto hilit; 64 | } else if (*p == '%') { 65 | State = hsFTE_CPP; 66 | Color = Colors[CLR_CPreprocessor]; 67 | goto hilit; 68 | } else if (isdigit(*p)) { 69 | Color = Colors[CLR_Number]; 70 | ColorNext(); 71 | while (len && (isdigit(*p) || *p == 'e' || *p == 'E' || *p == '.')) ColorNext(); 72 | if (len && (toupper(*p) == 'U')) ColorNext(); 73 | if (len && (toupper(*p) == 'L')) ColorNext(); 74 | continue; 75 | } else if (*p == '\'') { 76 | State = hsFTE_String1; 77 | Color = Colors[CLR_String]; 78 | goto hilit; 79 | } else if (*p == '[') { 80 | State = hsFTE_KeySpec; 81 | Color = Colors[CLR_Command]; 82 | goto hilit; 83 | } else if (*p == '"') { 84 | State = hsFTE_String2; 85 | Color = Colors[CLR_String]; 86 | goto hilit; 87 | } else if (*p == '/') { 88 | State = hsFTE_Regexp; 89 | Color = Colors[CLR_Regexp]; 90 | goto hilit; 91 | } else if (ispunct(*p)) { 92 | Color = Colors[CLR_Punctuation]; 93 | ColorNext(); 94 | continue; 95 | } 96 | Color = Colors[CLR_Normal]; 97 | ColorNext(); 98 | continue; 99 | case hsFTE_Comment: 100 | Color = Colors[CLR_Comment]; 101 | goto hilit; 102 | case hsFTE_CPP: 103 | Color = Colors[CLR_CPreprocessor]; 104 | goto hilit; 105 | case hsFTE_String1: 106 | Color = Colors[CLR_String]; 107 | if ((len >= 2) && (*p == '\\')) { 108 | hilit2: 109 | ColorNext(); 110 | hilit: 111 | ColorNext(); 112 | continue; 113 | } else if (*p == '\'') { 114 | ColorNext(); 115 | State = hsFTE_Normal; 116 | continue; 117 | } 118 | goto hilit; 119 | case hsFTE_String2: 120 | Color = Colors[CLR_String]; 121 | if ((len >= 2) && (*p == '\\')) { 122 | goto hilit2; 123 | } else if (*p == '"') { 124 | ColorNext(); 125 | State = hsFTE_Normal; 126 | continue; 127 | } 128 | goto hilit; 129 | case hsFTE_KeySpec: 130 | Color = Colors[CLR_Command]; 131 | if ((len >= 2) && (*p == '\\')) { 132 | goto hilit2; 133 | } else if (*p == ']') { 134 | ColorNext(); 135 | State = hsFTE_Normal; 136 | continue; 137 | } 138 | goto hilit; 139 | case hsFTE_Regexp: 140 | Color = Colors[CLR_Regexp]; 141 | if ((len >= 2) && (*p == '\\')) { 142 | goto hilit2; 143 | } else if (*p == '/') { 144 | ColorNext(); 145 | State = hsFTE_Normal; 146 | continue; 147 | } 148 | goto hilit; 149 | } 150 | } 151 | } 152 | 153 | if (State == hsFTE_Comment) 154 | State = hsFTE_Normal; 155 | 156 | if ((len1 == 0) || (*last != '\\')) { 157 | switch(State) { 158 | case hsFTE_CPP: 159 | case hsFTE_String1: 160 | case hsFTE_String2: 161 | case hsFTE_KeySpec: 162 | case hsFTE_Regexp: 163 | State = hsFTE_Normal; 164 | break; 165 | } 166 | } 167 | *ECol = C; 168 | return 0; 169 | } 170 | #endif 171 | -------------------------------------------------------------------------------- /h_html.cpp: -------------------------------------------------------------------------------- 1 | /* h_html.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | #ifdef CONFIG_HILIT_HTML 13 | 14 | #define hsHTML_Normal 0 15 | #define hsHTML_Command 1 16 | #define hsHTML_String1 2 17 | #define hsHTML_String2 3 18 | #define hsHTML_Char 4 19 | #define hsHTML_Slashed 5 20 | #define hsHTML_Comment 6 21 | 22 | int Hilit_HTML(EBuffer *BF, int /*LN*/, PCell B, int Pos, int Width, ELine *Line, hlState &State, hsState *StateMap, int *ECol) { 23 | ChColor *Colors = BF->Mode->fColorize->Colors; 24 | HILIT_VARS(Colors[CLR_Normal], Line); 25 | int j; 26 | 27 | for (i = 0; i < Line->Count;) { 28 | IF_TAB() else { 29 | switch (State) { 30 | case hsHTML_Normal: 31 | Color = Colors[CLR_Normal]; 32 | if (*p == '<') { 33 | State = hsHTML_Command; 34 | Color = Colors[CLR_Command]; 35 | ColorNext(); 36 | if ((len > 0) && (*p == '/')) ColorNext(); 37 | continue; 38 | } else if (*p == '&') { 39 | State = hsHTML_Char; 40 | Color = Colors[CLR_Symbol]; 41 | } 42 | goto hilit; 43 | case hsHTML_Slashed: 44 | Color = Colors[CLR_Tag]; 45 | if (*p == '/') { 46 | Color = Colors[CLR_Command]; 47 | ColorNext(); 48 | State = hsHTML_Normal; 49 | continue; 50 | } 51 | goto hilit; 52 | case hsHTML_Command: 53 | Color = Colors[CLR_Command]; 54 | if (isalpha(*p) || *p == '_') { 55 | j = 0; 56 | while (((i + j) < Line->Count) && 57 | (isalnum(Line->Chars[i+j]) || 58 | (Line->Chars[i + j] == '_')) 59 | ) j++; 60 | if (BF->GetHilitWord(j, &Line->Chars[i], Color, 1)) { 61 | } 62 | if (StateMap) 63 | memset(StateMap + i, State, j); 64 | if (B) 65 | MoveMem(B, C - Pos, Width, Line->Chars + i, Color, j); 66 | i += j; 67 | len -= j; 68 | p += j; 69 | C += j; 70 | Color = Colors[CLR_Command]; 71 | continue; 72 | } else if (*p == '-' && len > 1 && p[1] == '-') { 73 | State = hsHTML_Comment; 74 | Color = Colors[CLR_Comment]; 75 | ColorNext(); 76 | goto hilit; 77 | } else if (*p == '"') { 78 | State = hsHTML_String2; 79 | Color = Colors[CLR_String]; 80 | goto hilit; 81 | } else if (*p == '\'') { 82 | State = hsHTML_String1; 83 | Color = Colors[CLR_String]; 84 | goto hilit; 85 | } else if (*p == '>') { 86 | ColorNext(); 87 | State = hsHTML_Normal; 88 | continue; 89 | } else if (*p == '/') { 90 | ColorNext(); 91 | State = hsHTML_Slashed; 92 | continue; 93 | } 94 | goto hilit; 95 | case hsHTML_String2: 96 | Color = Colors[CLR_String]; 97 | if (*p == '"') { 98 | ColorNext(); 99 | State = hsHTML_Command; 100 | continue; 101 | } 102 | goto hilit; 103 | case hsHTML_String1: 104 | Color = Colors[CLR_String]; 105 | if (*p == '\'') { 106 | ColorNext(); 107 | State = hsHTML_Command; 108 | continue; 109 | } 110 | goto hilit; 111 | case hsHTML_Char: 112 | Color = Colors[CLR_Symbol]; 113 | if (*p == ';' || *p == ' ' || *p == '<') { 114 | ColorNext(); 115 | State = hsHTML_Normal; 116 | continue; 117 | } 118 | goto hilit; 119 | case hsHTML_Comment: 120 | Color = Colors[CLR_Comment]; 121 | if (*p == '-' && len > 1 && p[1] == '-') { 122 | ColorNext(); 123 | ColorNext(); 124 | State = hsHTML_Command; 125 | continue; 126 | } 127 | goto hilit; 128 | default: 129 | State = hsHTML_Normal; 130 | Color = Colors[CLR_Normal]; 131 | hilit: 132 | ColorNext(); 133 | continue; 134 | } 135 | } 136 | } 137 | if (State == hsHTML_Char) 138 | State = hsHTML_Normal; 139 | *ECol = C; 140 | return 0; 141 | } 142 | 143 | #endif 144 | -------------------------------------------------------------------------------- /h_ipf.cpp: -------------------------------------------------------------------------------- 1 | /* h_ipf.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | #ifdef CONFIG_HILIT_IPF 13 | 14 | #define hsIPF_Normal 0 15 | #define hsIPF_Symbol 1 16 | #define hsIPF_Tag 2 17 | #define hsIPF_Control 3 18 | #define hsIPF_String 4 19 | 20 | int Hilit_IPF(EBuffer *BF, int /*LN*/, PCell B, int Pos, int Width, ELine *Line, hlState &State, hsState *StateMap, int *ECol) { 21 | ChColor *Colors = BF->Mode->fColorize->Colors; 22 | HILIT_VARS(Colors[CLR_Normal], Line); 23 | int j; 24 | 25 | C = 0; 26 | NC = 0; 27 | for (i = 0; i < Line->Count;) { 28 | IF_TAB() else { 29 | switch (State) { 30 | case hsIPF_Normal: 31 | Color = Colors[CLR_Normal]; 32 | if (i == 0 && *p == '.') { 33 | State = hsIPF_Control; 34 | Color = Colors[CLR_Control]; 35 | } else if (*p == ':') { 36 | State = hsIPF_Tag; 37 | Color = Colors[CLR_Tag]; 38 | } else if (*p == '&') { 39 | State = hsIPF_Symbol; 40 | Color = Colors[CLR_Symbol]; 41 | } 42 | goto hilit; 43 | case hsIPF_Tag: 44 | Color = Colors[CLR_Tag]; 45 | if (isalpha(*p) || *p == '_') { 46 | j = 0; 47 | while (((i + j) < Line->Count) && 48 | (isalnum(Line->Chars[i+j]) || 49 | (Line->Chars[i + j] == '_')) 50 | ) j++; 51 | if (BF->GetHilitWord(j, &Line->Chars[i], Color, 1)) { 52 | } 53 | if (StateMap) 54 | memset(StateMap + i, State, j); 55 | if (B) 56 | MoveMem(B, C - Pos, Width, Line->Chars + i, Color, j); 57 | i += j; 58 | len -= j; 59 | p += j; 60 | C += j; 61 | Color = Colors[CLR_Tag]; 62 | continue; 63 | } else if (*p == '\'') { 64 | State = hsIPF_String; 65 | Color = Colors[CLR_String]; 66 | goto hilit; 67 | } else if (*p == '.') { 68 | ColorNext(); 69 | State = hsIPF_Normal; 70 | continue; 71 | } 72 | goto hilit; 73 | case hsIPF_String: 74 | Color = Colors[CLR_String]; 75 | if (*p == '\'') { 76 | ColorNext(); 77 | State = hsIPF_Tag; 78 | continue; 79 | } 80 | goto hilit; 81 | case hsIPF_Symbol: 82 | Color = Colors[CLR_Symbol]; 83 | if (*p == '.') { 84 | ColorNext(); 85 | State = hsIPF_Normal; 86 | continue; 87 | } 88 | goto hilit; 89 | case hsIPF_Control: 90 | State = hsIPF_Control; 91 | Color = Colors[CLR_Control]; 92 | goto hilit; 93 | default: 94 | State = hsIPF_Normal; 95 | Color = Colors[CLR_Normal]; 96 | hilit: 97 | ColorNext(); 98 | continue; 99 | } 100 | } 101 | } 102 | if (State == hsIPF_Symbol || State == hsIPF_Control || State == hsIPF_String) 103 | State = hsIPF_Normal; 104 | *ECol = C; 105 | return 0; 106 | } 107 | #endif 108 | -------------------------------------------------------------------------------- /h_make.cpp: -------------------------------------------------------------------------------- 1 | /* h_make.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | #ifdef CONFIG_HILIT_MAKE 13 | 14 | #define hsMAKE_Normal 0 15 | #define hsMAKE_Comment 1 16 | #define hsMAKE_DotCmd 2 17 | #define hsMAKE_Command 3 18 | 19 | int Hilit_MAKE(EBuffer *BF, int /*LN*/, PCell B, int Pos, int Width, ELine *Line, hlState &State, hsState *StateMap, int *ECol) { 20 | ChColor *Colors = BF->Mode->fColorize->Colors; 21 | HILIT_VARS(Colors[CLR_Normal], Line); 22 | int len1 = len; 23 | char *last = p + len1 - 1; 24 | 25 | for(i = 0; i < Line->Count;) { 26 | if (i == 0 && *p == 9) { 27 | State = hsMAKE_Command; 28 | Color = Colors[CLR_Command]; 29 | } 30 | IF_TAB() else { 31 | if (i == 0) { 32 | if (*p == '.') { 33 | State = hsMAKE_DotCmd; 34 | Color = Colors[CLR_Directive]; 35 | goto hilit; 36 | } else if (*p == '#') { 37 | State = hsMAKE_Comment; 38 | Color = Colors[CLR_Comment]; 39 | goto hilit; 40 | } 41 | } 42 | switch(State) { 43 | case hsMAKE_Comment: 44 | Color = Colors[CLR_Comment]; 45 | goto hilit; 46 | 47 | case hsMAKE_DotCmd: 48 | Color = Colors[CLR_Directive]; 49 | goto hilit; 50 | 51 | case hsMAKE_Command: 52 | Color = Colors[CLR_Command]; 53 | goto hilit; 54 | 55 | default: 56 | State = hsMAKE_Normal; 57 | Color = Colors[CLR_Normal]; 58 | hilit: 59 | ColorNext(); 60 | continue; 61 | } 62 | } 63 | } 64 | if((len1 == 0) || (*last != '\\')) { 65 | if (State == hsMAKE_Comment || State == hsMAKE_DotCmd || State == hsMAKE_Command) 66 | State = hsMAKE_Normal; 67 | } 68 | *ECol = C; 69 | return 0; 70 | } 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /h_merge.cpp: -------------------------------------------------------------------------------- 1 | /* h_merge.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | #ifdef CONFIG_HILIT_MERGE 13 | 14 | #define hsMERGE_Normal 0 15 | #define hsMERGE_Modified 1 16 | #define hsMERGE_Original 2 17 | #define hsMERGE_New 3 18 | #define hsMERGE_Control 4 19 | 20 | int Hilit_MERGE(EBuffer *BF, int /*LN*/, PCell B, int Pos, int Width, ELine* Line, hlState& State, hsState *StateMap, int *ECol) { 21 | ChColor *Colors = BF->Mode->fColorize->Colors; 22 | HILIT_VARS(Colors[CLR_Normal], Line); 23 | hlState StateO = State; 24 | hlState StateN = State; 25 | 26 | if (Line->Count >= 7) { 27 | State = hsMERGE_Control; 28 | if (memcmp(Line->Chars, "<<<<<<<", 7) == 0) 29 | StateN = hsMERGE_Modified; 30 | else if (memcmp(Line->Chars, "|||||||", 7) == 0) 31 | StateN = hsMERGE_Original; 32 | else if (memcmp(Line->Chars, "=======", 7) == 0) 33 | StateN = hsMERGE_New; 34 | else if (memcmp(Line->Chars, ">>>>>>>", 7) == 0) 35 | StateN = hsMERGE_Normal; 36 | else 37 | State = StateO; 38 | } 39 | 40 | for (i = 0; i < Line->Count; ) { 41 | IF_TAB() else { 42 | switch(State) { 43 | case hsMERGE_Control: Color = Colors[CLR_Control]; break; 44 | case hsMERGE_Modified: Color = Colors[CLR_Changed]; break; 45 | case hsMERGE_Original: Color = Colors[CLR_Old]; break; 46 | case hsMERGE_New: Color = Colors[CLR_New]; break; 47 | default: Color = Colors[CLR_Normal]; break; 48 | 49 | } 50 | ColorNext(); 51 | continue; 52 | } 53 | } 54 | State = StateN; 55 | *ECol = C; 56 | return 0; 57 | } 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /h_msg.cpp: -------------------------------------------------------------------------------- 1 | /* h_msg.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | #ifdef CONFIG_HILIT_MSG 13 | 14 | #define hsMSG_Normal 0 15 | #define hsMSG_Header 1 16 | #define hsMSG_Quote 2 17 | #define hsMSG_Tag 3 18 | #define hsMSG_Control 4 19 | 20 | int Hilit_MSG(EBuffer *BF, int /*LN*/, PCell B, int Pos, int Width, ELine* Line, hlState& State, hsState *StateMap, int *ECol) { 21 | ChColor *Colors = BF->Mode->fColorize->Colors; 22 | HILIT_VARS(Colors[CLR_Normal], Line); 23 | int is_head = 0, is_quote = 0, is_space = 0, is_tag = 0, is_control = 0; 24 | 25 | if (Line->Count > 0) { 26 | if (State == hsMSG_Header) { 27 | if (Line->Chars[0] == ' ' || Line->Chars[0] == '\t') is_head = 1; 28 | else 29 | State = hsMSG_Normal; 30 | } 31 | if (State == hsMSG_Normal) { 32 | if (Line->Count >= 2 && 33 | Line->Chars[0] == '-' && 34 | Line->Chars[1] == '-' && 35 | (Line->Count == 2 || Line->Chars[2] == ' ')) 36 | is_tag = 1; 37 | else if (Line->Count >= 2 && 38 | Line->Chars[0] == '.' && 39 | Line->Chars[1] == '.' && 40 | (Line->Count == 2 || Line->Chars[2] == ' ')) 41 | is_tag = 1; 42 | else if (Line->Count >= 3 && 43 | Line->Chars[0] == '-' && 44 | Line->Chars[1] == '-' && 45 | Line->Chars[2] == '-' && 46 | (Line->Count == 3 || Line->Chars[3] == ' ')) 47 | is_tag = 1; 48 | else if (Line->Count >= 3 && 49 | Line->Chars[0] == '.' && 50 | Line->Chars[1] == '.' && 51 | Line->Chars[2] == '.' && 52 | (Line->Count == 3 || Line->Chars[3] == ' ')) 53 | is_tag = 1; 54 | else if (Line->Count > 10 && memcmp(Line->Chars, " * Origin:", 10) == 0) 55 | is_control = 1; 56 | else if (Line->Count > 0 && Line->Chars[0] == '\x01') 57 | is_control = 1; 58 | else for (i = 0; i < Line->Count; i++) { 59 | if (i < 30 && Line->Chars[i] == ':' && i < Line->Count - 1 && Line->Chars[i+1] == ' ' && !is_space) { is_head = 1; break; } 60 | else if (i < 5 && Line->Chars[i] == '>') { is_quote = 1; break; } 61 | else if (Line->Chars[i] == '<' || 62 | (Line->Chars[i] == ' ' && i > 0) || 63 | Line->Chars[i] == '\t') break; 64 | else if (Line->Chars[i] == ' ' || Line->Chars[i] == '\t') 65 | is_space = 0; 66 | } 67 | } 68 | } 69 | if (is_head) { 70 | State = hsMSG_Header; 71 | Color = Colors[CLR_Header]; 72 | } else if (is_quote) { 73 | State = hsMSG_Quote; 74 | Color = Colors[CLR_Quotes]; 75 | } else if (is_tag) { 76 | State = hsMSG_Tag; 77 | Color = Colors[CLR_Tag]; 78 | } else if (is_control) { 79 | State = hsMSG_Control; 80 | Color = Colors[CLR_Control]; 81 | } else { 82 | State = hsMSG_Normal; 83 | Color = Colors[CLR_Normal]; 84 | } 85 | 86 | ChColor DefColor = Color; 87 | #ifdef CONFIG_WORD_HILIT 88 | int j = 0; 89 | 90 | if (BF->Mode->fColorize->Keywords.TotalCount > 0 || 91 | BF->WordCount > 0) 92 | { /* words have to be hilited, go slow */ 93 | for(i = 0; i < Line->Count;) { 94 | IF_TAB() else { 95 | if (isalpha(*p) || (*p == '_')) { 96 | j = 0; 97 | while (((i + j) < Line->Count) && 98 | (isalnum(Line->Chars[i+j]) || 99 | (Line->Chars[i + j] == '_')) 100 | ) j++; 101 | if (BF->GetHilitWord(j, Line->Chars + i, Color, 1)) ; 102 | else { 103 | Color = DefColor; 104 | } 105 | if (StateMap) 106 | memset(StateMap + i, State, j); 107 | if (B) 108 | MoveMem(B, C - Pos, Width, Line->Chars + i, Color, j); 109 | i += j; 110 | len -= j; 111 | p += j; 112 | C += j; 113 | Color = DefColor; 114 | continue; 115 | } 116 | ColorNext(); 117 | continue; 118 | } 119 | } 120 | } else 121 | #endif 122 | if (ExpandTabs) { /* use slow mode */ 123 | for (i = 0; i < Line->Count;) { 124 | IF_TAB() else { 125 | ColorNext(); 126 | } 127 | } 128 | } else { /* fast mode */ 129 | if (Pos < Line->Count) { 130 | if (Pos + Width < Line->Count) { 131 | if (B) 132 | MoveMem(B, 0, Width, Line->Chars + Pos, Color, Width); 133 | if (StateMap) 134 | memset(StateMap, State, Line->Count); 135 | } else { 136 | if (B) 137 | MoveMem(B, 0, Width, Line->Chars + Pos, Color, Line->Count - Pos); 138 | if (StateMap) 139 | memset(StateMap, State, Line->Count); 140 | } 141 | } 142 | C = Line->Count; 143 | } 144 | if (State != hsMSG_Header) 145 | State = hsMSG_Normal; 146 | *ECol = C; 147 | return 0; 148 | } 149 | 150 | #endif 151 | -------------------------------------------------------------------------------- /h_pascal.cpp: -------------------------------------------------------------------------------- 1 | /* h_pascal.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | #ifdef CONFIG_HILIT_PASCAL 13 | 14 | #define hsPas_Normal 0 15 | #define hsPas_Comment1 1 16 | #define hsPas_Comment2 2 17 | #define hsPas_Keyword 3 18 | #define hsPas_String1 4 19 | #define hsPas_String2 5 20 | 21 | int Hilit_PASCAL(EBuffer *BF, int /*LN*/, PCell B, int Pos, int Width, ELine *Line, hlState &State, hsState *StateMap, int *ECol) { 22 | ChColor *Colors = BF->Mode->fColorize->Colors; 23 | int j = 0; 24 | int firstnw = 0; 25 | HILIT_VARS(Colors[CLR_Normal], Line); 26 | 27 | C = 0; 28 | NC = 0; 29 | for(i = 0; i < Line->Count;) { 30 | if (*p != ' ' && *p != 9) firstnw++; 31 | IF_TAB() else { 32 | switch(State) { 33 | default: 34 | case hsPas_Normal: 35 | if (isalpha(*p) || *p == '_') { 36 | j = 0; 37 | while (((i + j) < Line->Count) && 38 | (isalnum(Line->Chars[i+j]) || 39 | (Line->Chars[i + j] == '_')) 40 | ) j++; 41 | if (BF->GetHilitWord(j, &Line->Chars[i], Color, 1)) { 42 | // Color = hcC_Keyword; 43 | State = hsPas_Keyword; 44 | } else { 45 | Color = Colors[CLR_Normal]; 46 | State = hsPas_Normal; 47 | } 48 | if (StateMap) 49 | memset(StateMap + i, State, j); 50 | if (B) 51 | MoveMem(B, C - Pos, Width, Line->Chars + i, Color, j); 52 | i += j; 53 | len -= j; 54 | p += j; 55 | C += j; 56 | State = hsPas_Normal; 57 | continue; 58 | } else if ((len >= 2) && (*p == '(') && (*(p+1) == '*')) { 59 | State = hsPas_Comment1; 60 | Color = Colors[CLR_Comment]; 61 | ColorNext(); 62 | goto hilit; 63 | } else if (*p == '{') { 64 | State = hsPas_Comment2; 65 | Color = Colors[CLR_Comment]; 66 | goto hilit; 67 | } else if (*p == '$') { 68 | Color = Colors[CLR_HexNumber]; 69 | ColorNext(); 70 | ColorNext(); 71 | while (len && isxdigit(*p)) ColorNext(); 72 | continue; 73 | } else if (isdigit(*p)) { 74 | Color = Colors[CLR_Number]; 75 | ColorNext(); 76 | while (len && (isdigit(*p) || *p == 'e' || *p == 'E' || *p == '.')) ColorNext(); 77 | continue; 78 | } else if (*p == '\'') { 79 | State = hsPas_String1; 80 | Color = Colors[CLR_String]; 81 | goto hilit; 82 | } else if (*p == '"') { 83 | State = hsPas_String2; 84 | Color = Colors[CLR_String]; 85 | goto hilit; 86 | } else if (ispunct(*p) && *p != '_') { 87 | Color = Colors[CLR_Punctuation]; 88 | goto hilit; 89 | } 90 | Color = Colors[CLR_Normal]; 91 | goto hilit; 92 | case hsPas_Comment1: 93 | Color = Colors[CLR_Comment]; 94 | if ((len >= 2) && (*p == '*') && (*(p+1) == ')')) { 95 | ColorNext(); 96 | ColorNext(); 97 | State = hsPas_Normal; 98 | continue; 99 | } 100 | goto hilit; 101 | case hsPas_Comment2: 102 | Color = Colors[CLR_Comment]; 103 | if (*p == '}') { 104 | ColorNext(); 105 | State = hsPas_Normal; 106 | continue; 107 | } 108 | goto hilit; 109 | case hsPas_String1: 110 | Color = Colors[CLR_String]; 111 | if (*p == '\'') { 112 | ColorNext(); 113 | State = hsPas_Normal; 114 | continue; 115 | } 116 | goto hilit; 117 | case hsPas_String2: 118 | Color = Colors[CLR_String]; 119 | if (*p == '"') { 120 | ColorNext(); 121 | State = hsPas_Normal; 122 | continue; 123 | } 124 | hilit: 125 | ColorNext(); 126 | continue; 127 | } 128 | } 129 | } 130 | switch(State) { 131 | case hsPas_String1: 132 | case hsPas_String2: 133 | State = hsPas_Normal; 134 | break; 135 | } 136 | *ECol = C; 137 | return 0; 138 | } 139 | #endif 140 | -------------------------------------------------------------------------------- /h_plain.cpp: -------------------------------------------------------------------------------- 1 | /* h_plain.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | #define hsPLAIN_Normal 0 13 | 14 | int Hilit_Plain(EBuffer *BF, int /*LN*/, PCell B, int Pos, int Width, ELine* Line, hlState& State, hsState *StateMap, int *ECol) { 15 | ChColor *Colors = BF->Mode->fColorize->Colors; 16 | HILIT_VARS(Colors[CLR_Normal], Line); 17 | 18 | #ifdef CONFIG_WORD_HILIT 19 | int j = 0; 20 | 21 | if (BF->Mode->fColorize->Keywords.TotalCount > 0 || 22 | BF->WordCount > 0) 23 | { /* words have to be hilited, go slow */ 24 | for(i = 0; i < Line->Count;) { 25 | IF_TAB() else { 26 | if (isalpha(*p) || (*p == '_')) { 27 | j = 0; 28 | while (((i + j) < Line->Count) && 29 | (isalnum(Line->Chars[i+j]) || 30 | (Line->Chars[i + j] == '_')) 31 | ) j++; 32 | if (BF->GetHilitWord(j, Line->Chars + i, Color, 1)) ; 33 | else { 34 | Color = Colors[CLR_Normal]; 35 | State = hsPLAIN_Normal; 36 | } 37 | if (StateMap) 38 | memset(StateMap + i, State, j); 39 | if (B) 40 | MoveMem(B, C - Pos, Width, Line->Chars + i, Color, j); 41 | i += j; 42 | len -= j; 43 | p += j; 44 | C += j; 45 | State = hsPLAIN_Normal; 46 | Color = Colors[CLR_Normal]; 47 | continue; 48 | } 49 | ColorNext(); 50 | continue; 51 | } 52 | } 53 | } else 54 | #endif 55 | if (ExpandTabs) { /* use slow mode */ 56 | for (i = 0; i < Line->Count;) { 57 | IF_TAB() else { 58 | ColorNext(); 59 | } 60 | } 61 | } else { /* fast mode */ 62 | if (Pos < Line->Count) { 63 | if (Pos + Width < Line->Count) { 64 | if (B) 65 | MoveMem(B, 0, Width, Line->Chars + Pos, Color, Width); 66 | if (StateMap) 67 | memset(StateMap, State, Line->Count); 68 | } else { 69 | if (B) 70 | MoveMem(B, 0, Width, Line->Chars + Pos, Color, Line->Count - Pos); 71 | if (StateMap) 72 | memset(StateMap, State, Line->Count); 73 | } 74 | } 75 | C = Line->Count; 76 | } 77 | *ECol = C; 78 | State = 0; 79 | return 0; 80 | } 81 | 82 | int Indent_Plain(EBuffer *B, int Line, int PosCursor) { 83 | int OI = B->LineIndented(Line); 84 | B->IndentLine(Line, B->LineIndented(Line - 1)); 85 | if (PosCursor) { 86 | int I = B->LineIndented(Line); 87 | int X = B->CP.Col; 88 | 89 | X = X - OI + I; 90 | if (X < I) X = I; 91 | if (X < 0) X = 0; 92 | B->SetPosR(X, Line); 93 | } 94 | return 1; 95 | } 96 | -------------------------------------------------------------------------------- /h_tex.cpp: -------------------------------------------------------------------------------- 1 | /* h_tex.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | #ifdef CONFIG_HILIT_TEX 13 | 14 | #define hsTEX_Normal 0 15 | #define hsTEX_Tag 1 16 | #define hsTEX_Comment 2 17 | #define hsTEX_Special 3 18 | 19 | int Hilit_TEX(EBuffer *BF, int /*LN*/, PCell B, int Pos, int Width, ELine *Line, hlState &State, hsState *StateMap, int *ECol) { 20 | ChColor *Colors = BF->Mode->fColorize->Colors; 21 | HILIT_VARS(Colors[CLR_Normal], Line); 22 | int j; 23 | 24 | for (i = 0; i < Line->Count;) { 25 | IF_TAB() else { 26 | switch (State) { 27 | case hsTEX_Normal: 28 | Color = Colors[CLR_Normal]; 29 | if (*p == '%') { 30 | State = hsTEX_Comment; 31 | Color = Colors[CLR_Comment]; 32 | goto hilit; 33 | } else if (*p == '\\') { 34 | State = hsTEX_Tag; 35 | Color = Colors[CLR_Tag]; 36 | ColorNext(); 37 | continue; 38 | } else if (*p == '{' || *p == '}' || *p == '$' || *p == '&' || *p == '|') { 39 | State = hsTEX_Special; 40 | Color = Colors[CLR_Special]; 41 | ColorNext(); 42 | State = hsTEX_Normal; 43 | continue; 44 | } 45 | goto hilit; 46 | case hsTEX_Tag: 47 | Color = Colors[CLR_Tag]; 48 | if (isalpha(*p)) { 49 | j = 0; 50 | while (((i + j) < Line->Count) && 51 | (isalnum(Line->Chars[i+j])/* || 52 | (Line->Chars[i + j] == '_')*/) 53 | ) j++; 54 | if (BF->GetHilitWord(j, &Line->Chars[i], Color, 0)) { 55 | } 56 | if (StateMap) 57 | memset(StateMap + i, State, j); 58 | if (B) 59 | MoveMem(B, C - Pos, Width, Line->Chars + i, Color, j); 60 | i += j; 61 | len -= j; 62 | p += j; 63 | C += j; 64 | Color = Colors[CLR_Normal]; 65 | State = hsTEX_Normal; 66 | continue; 67 | } 68 | ColorNext(); 69 | Color = Colors[CLR_Normal]; 70 | State = hsTEX_Normal; 71 | continue; 72 | case hsTEX_Comment: 73 | Color = Colors[CLR_Comment]; 74 | goto hilit; 75 | default: 76 | State = hsTEX_Normal; 77 | Color = Colors[CLR_Normal]; 78 | hilit: 79 | ColorNext(); 80 | continue; 81 | } 82 | } 83 | } 84 | if (State == hsTEX_Comment) 85 | State = hsTEX_Normal; 86 | *ECol = C; 87 | return 0; 88 | } 89 | #endif 90 | -------------------------------------------------------------------------------- /i_ascii.cpp: -------------------------------------------------------------------------------- 1 | /* i_ascii.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | #ifdef CONFIG_I_ASCII 13 | 14 | static int SPos = 0; 15 | static int SLPos = 0; 16 | 17 | ExASCII::ExASCII(): ExView() { 18 | Pos = SPos; 19 | LPos = SLPos; 20 | } 21 | 22 | ExASCII::~ExASCII() { 23 | SPos = Pos; 24 | SLPos = LPos; 25 | } 26 | 27 | void ExASCII::Activate(int gotfocus) { 28 | ExView::Activate(gotfocus); 29 | } 30 | 31 | int ExASCII::BeginMacro() { 32 | return 1; 33 | } 34 | 35 | void ExASCII::HandleEvent(TEvent &Event) { 36 | int W, H; 37 | 38 | ConQuerySize(&W, &H); 39 | 40 | switch (Event.What) { 41 | case evKeyDown: 42 | switch(kbCode(Event.Key.Code)) { 43 | case kbLeft: Pos--; Event.What = evNone; break; 44 | case kbRight: Pos++; Event.What = evNone; break; 45 | case kbHome: Pos = 0; Event.What = evNone; break; 46 | case kbEnd: Pos = 255; Event.What = evNone; break; 47 | case kbLeft + kfCtrl: Pos -= 16; Event.What = evNone; break; 48 | case kbRight + kfCtrl: Pos += 16; Event.What = evNone; break; 49 | case kbUp: Pos -= W; LPos -= W; Event.What = evNone; break; 50 | case kbDown: Pos += W; LPos += W; Event.What = evNone; break; 51 | case kbEsc: EndExec(-1); Event.What = evNone; break; 52 | case kbEnter: EndExec(Pos); Event.What = evNone; break; 53 | } 54 | break; 55 | #if 0 56 | case evMouseDown: 57 | if (E.Mouse.X < XPos || E.Mouse.X >= XPos + 34 || 58 | E.Mouse.Y < YPos || E.Mouse.Y >= YPos + 10) 59 | { 60 | abort = 2; 61 | break; 62 | } 63 | 64 | do { 65 | x = E.Mouse.X - XPos - 1; 66 | y = E.Mouse.Y - YPos - 1; 67 | if (x >= 0 && x < 32 && 68 | y >= 0 && y < 8) 69 | { 70 | X = x; 71 | Y = y; 72 | if (X >= 32) X = 31; 73 | if (Y >= 8) Y = 7; 74 | if (X < 0) X = 0; 75 | if (Y < 0) Y = 0; 76 | frames->ConSetCursorPos(X + XPos + 1, Y + YPos + 1); 77 | sprintf(s, "0%03o %03d 0x%02X", 78 | X + Y * 32, X + Y * 32, X + Y * 32); 79 | MoveStr(B, 0, 13, s, hcAsciiStatus, 13); 80 | frames->ConPutBox(XPos + 2, YPos + 9, 13, 1, B); 81 | } 82 | if (E.Mouse.Count == 2) { 83 | abort = 1; 84 | break; 85 | } 86 | gui->ConGetEvent(evMouse, &E, -1, 1); 87 | if (E.What == evMouseUp) break; 88 | } while (1); 89 | break; 90 | #endif 91 | } 92 | } 93 | 94 | void ExASCII::UpdateView() { 95 | if (Next) { 96 | Next->UpdateView(); 97 | } 98 | } 99 | 100 | void ExASCII::RepaintView() { 101 | if (Next) { 102 | Next->RepaintView(); 103 | } 104 | } 105 | 106 | void ExASCII::UpdateStatus() { 107 | RepaintStatus(); 108 | } 109 | 110 | void ExASCII::RepaintStatus() { 111 | TDrawBuffer B; 112 | int W, H; 113 | 114 | ConQuerySize(&W, &H); 115 | 116 | if (Pos > 255) Pos = 255; 117 | if (Pos < 0) Pos = 0; 118 | if (LPos + W < Pos) LPos = Pos - W + 1; 119 | if (LPos > 255 - W) LPos = 255 - W + 1; 120 | if (LPos > Pos) LPos = Pos; 121 | if (LPos < 0) LPos = 0; 122 | 123 | for (int i = 0; i < W; i++) 124 | MoveCh(B + i, char(i + LPos), hcAsciiChars, 1); 125 | ConSetCursorPos(Pos - LPos, H - 1); 126 | ConShowCursor(); 127 | ConPutBox(0, H - 1, W, 1, B); 128 | } 129 | #endif 130 | -------------------------------------------------------------------------------- /i_ascii.h: -------------------------------------------------------------------------------- 1 | /* i_ascii.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __EXASCII_H 11 | #define __EXASCII_H 12 | 13 | class ExASCII: public ExView { 14 | public: 15 | int Pos, LPos; 16 | 17 | ExASCII(); 18 | virtual ~ExASCII(); 19 | virtual void Activate(int gotfocus); 20 | 21 | virtual ExView* GetViewContext() { return Next; } 22 | virtual int BeginMacro(); 23 | virtual void HandleEvent(TEvent &Event); 24 | virtual void UpdateView(); 25 | virtual void RepaintView(); 26 | virtual void UpdateStatus(); 27 | virtual void RepaintStatus(); 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /i_choice.cpp: -------------------------------------------------------------------------------- 1 | /* i_choice.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | ExChoice::ExChoice(const char *ATitle, int NSel, va_list ap): ExView() { 13 | char msg[1024]; 14 | int i; 15 | char *fmt; 16 | 17 | Cur = 0; 18 | MouseCaptured = 0; 19 | 20 | Title = strdup(ATitle); 21 | lTitle = strlen(Title); 22 | NOpt = NSel; 23 | lChoice = 0; 24 | 25 | for (i = 0; i < NSel; i++) { 26 | SOpt[i] = strdup(va_arg(ap, char *)); 27 | lChoice += CStrLen(SOpt[i]) + 1; 28 | } 29 | fmt = va_arg(ap, char *); 30 | vsprintf(msg, fmt, ap); 31 | strncpy(Prompt, msg, sizeof(Prompt)); 32 | Prompt[sizeof(Prompt) - 1] = 0; 33 | } 34 | 35 | ExChoice::~ExChoice() { 36 | free(Title); 37 | for (int i = 0; i < NOpt; i++) 38 | free(SOpt[i]); 39 | } 40 | 41 | void ExChoice::Activate(int gotfocus) { 42 | ExView::Activate(gotfocus); 43 | } 44 | 45 | int ExChoice::BeginMacro() { 46 | return 1; 47 | } 48 | 49 | int ExChoice::FindChoiceByPoint(int x, int y) { 50 | int pos, i; 51 | int W, H; 52 | 53 | Win->ConQuerySize(&W, &H); 54 | 55 | if (y != H - 1) 56 | return -1; 57 | 58 | pos = W - lChoice; 59 | if (x < pos) 60 | return -1; 61 | 62 | for (i = 0; i < NOpt; i++) { 63 | int clen = CStrLen(SOpt[i]); 64 | 65 | if (x > pos && x <= pos + clen) 66 | return i; 67 | pos += clen + 1; 68 | } 69 | return -1; 70 | } 71 | 72 | void ExChoice::HandleEvent(TEvent &Event) { 73 | int i; 74 | 75 | switch (Event.What) { 76 | case evKeyDown: 77 | switch (kbCode(Event.Key.Code)) { 78 | case kbTab | kfShift: 79 | case kbLeft: if (Cur == -1) Cur = 0; Cur--; if (Cur < 0) Cur = NOpt - 1; Event.What = evNone; break; 80 | case kbTab: 81 | case kbRight: if (Cur == -1) Cur = 0; Cur++; if (Cur >= NOpt) Cur = 0; Event.What = evNone; break; 82 | case kbHome: Cur = 0; Event.What = evNone; break; 83 | case kbEnd: Cur = NOpt - 1; Event.What = evNone; break; 84 | case kbEnter: if (Cur >= 0 && NOpt > 0) EndExec(Cur); Event.What = evNone; break; 85 | case kbEsc: EndExec(-1); Event.What = evNone; break; 86 | default: 87 | if (isAscii(Event.Key.Code)) { 88 | char c = char(Event.Key.Code & 0xFF); 89 | char s[3]; 90 | 91 | s[0] = '&'; 92 | s[1] = (char)(toupper((char)c) & 0xFF); 93 | s[2] = 0; 94 | 95 | for (i = 0; i < NOpt; i++) { 96 | if (strstr(SOpt[i], s) != 0) { 97 | Win->EndExec(i); 98 | break; 99 | } 100 | } 101 | Event.What = evNone; 102 | } 103 | break; 104 | } 105 | break; 106 | case evMouseDown: 107 | if (Win->CaptureMouse(1)) 108 | MouseCaptured = 1; 109 | else 110 | break; 111 | Cur = FindChoiceByPoint(Event.Mouse.X, Event.Mouse.Y); 112 | Event.What = evNone; 113 | break; 114 | case evMouseMove: 115 | if (MouseCaptured) 116 | Cur = FindChoiceByPoint(Event.Mouse.X, Event.Mouse.Y); 117 | Event.What = evNone; 118 | break; 119 | case evMouseUp: 120 | if (MouseCaptured) 121 | Win->CaptureMouse(0); 122 | else 123 | break; 124 | MouseCaptured = 0; 125 | Cur = FindChoiceByPoint(Event.Mouse.X, Event.Mouse.Y); 126 | Event.What = evNone; 127 | if (Cur >= 0 && Cur < NOpt && NOpt > 0) 128 | EndExec(Cur); 129 | else 130 | Cur = 0; 131 | break; 132 | } 133 | } 134 | 135 | void ExChoice::UpdateView() { 136 | if (Next) { 137 | Next->UpdateView(); 138 | } 139 | } 140 | 141 | void ExChoice::RepaintView() { 142 | if (Next) { 143 | Next->RepaintView(); 144 | } 145 | } 146 | 147 | void ExChoice::UpdateStatus() { 148 | RepaintStatus(); 149 | } 150 | 151 | void ExChoice::RepaintStatus() { 152 | TDrawBuffer B; 153 | int W, H; 154 | int pos, i; 155 | TAttr color1, color2; 156 | 157 | ConQuerySize(&W, &H); 158 | 159 | 160 | if (Cur != -1) { 161 | if (Cur >= NOpt) Cur = NOpt - 1; 162 | if (Cur < 0) Cur = 0; 163 | } 164 | 165 | MoveCh(B, ' ', hcChoice_Background, W); 166 | MoveStr(B, 0, W, Title, hcChoice_Title, W); 167 | MoveChar(B, lTitle, W, ':', hcChoice_Background, 1); 168 | MoveStr(B, lTitle + 2, W, Prompt, hcChoice_Param, W); 169 | 170 | pos = W - lChoice; 171 | for (i = 0; i < NOpt; i++) { 172 | if (i == Cur) { 173 | color1 = hcChoice_ActiveItem; 174 | color2 = hcChoice_ActiveChar; 175 | } else { 176 | color1 = hcChoice_NormalItem; 177 | color2 = hcChoice_NormalChar; 178 | } 179 | if (i == Cur) 180 | ConSetCursorPos(pos + 1, H - 1); 181 | MoveChar(B, pos, W, ConGetDrawChar(DCH_V), hcChoice_Background, 1); 182 | MoveCStr(B, pos + 1, W, SOpt[i], color1, color2, W); 183 | pos += CStrLen(SOpt[i]) + 1; 184 | } 185 | ConPutBox(0, H - 1, W, 1, B); 186 | } 187 | -------------------------------------------------------------------------------- /i_choice.h: -------------------------------------------------------------------------------- 1 | /* i_choice.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __EXCHOICE_H 11 | #define __EXCHOICE_H 12 | 13 | class ExChoice: public ExView { 14 | public: 15 | char *Title; 16 | char Prompt[160]; 17 | int NOpt; 18 | char *SOpt[10]; 19 | int Cur; 20 | int lTitle; 21 | int lChoice; 22 | int MouseCaptured; 23 | 24 | ExChoice(const char *ATitle, int NSel, va_list ap /* choices, format, args */); 25 | virtual ~ExChoice(); 26 | virtual void Activate(int gotfocus); 27 | 28 | virtual ExView* GetViewContext() { return Next; } 29 | virtual int BeginMacro(); 30 | int FindChoiceByPoint(int x, int y); 31 | virtual void HandleEvent(TEvent &Event); 32 | virtual void UpdateView(); 33 | virtual void RepaintView(); 34 | virtual void UpdateStatus(); 35 | virtual void RepaintStatus(); 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /i_complete.h: -------------------------------------------------------------------------------- 1 | /* i_ascii.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __EXCOMPLETE_H 11 | #define __EXCOMPLETE_H 12 | 13 | // maximum words which will be presented to the user 14 | #define MAXCOMPLETEWORDS 300 15 | 16 | class ExComplete: public ExView { 17 | EPoint Orig; 18 | EBuffer *Buffer; 19 | int WordsLast; 20 | char **Words; 21 | char *WordBegin; 22 | char *WordContinue; 23 | int WordPos; 24 | size_t WordFixed; 25 | size_t WordFixedCount; 26 | 27 | int RefreshComplete(); 28 | inline int CheckASCII(int c) { 29 | return ((c < 256) 30 | && (isalnum(c) || (c == '_') || (c == '.'))) ? 1 : 0; 31 | } 32 | void FixedUpdate(int add); 33 | 34 | public: 35 | 36 | ExComplete(EBuffer *B); 37 | virtual ~ExComplete(); 38 | virtual void Activate(int gotfocus); 39 | virtual ExView* GetViewContext() { return Next; } 40 | virtual int BeginMacro(); 41 | virtual void HandleEvent(TEvent &Event); 42 | virtual void UpdateView(); 43 | virtual void RepaintView(); 44 | virtual void UpdateStatus(); 45 | virtual void RepaintStatus(); 46 | }; 47 | #endif 48 | -------------------------------------------------------------------------------- /i_input.h: -------------------------------------------------------------------------------- 1 | /* i_input.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __EXINPUT_H 11 | #define __EXINPUT_H 12 | 13 | typedef int (*Completer)(const char *Name, char *Completed, int Num); 14 | 15 | class ExInput: public ExView { 16 | public: 17 | char *Prompt; 18 | char *Line; 19 | char *MatchStr; 20 | char *CurStr; 21 | unsigned int Pos; 22 | unsigned int LPos; 23 | unsigned int MaxLen; 24 | Completer Comp; 25 | int TabCount; 26 | int HistId; 27 | int CurItem; 28 | unsigned int SelStart; 29 | unsigned int SelEnd; 30 | 31 | ExInput(const char *APrompt, char *ALine, unsigned int AMaxLen, Completer AComp, int Select, int AHistId); 32 | virtual ~ExInput(); 33 | virtual void Activate(int gotfocus); 34 | 35 | virtual ExView *GetViewContext() { return Next; } 36 | virtual int BeginMacro(); 37 | virtual void HandleEvent(TEvent &Event); 38 | virtual void UpdateView(); 39 | virtual void RepaintView(); 40 | virtual void UpdateStatus(); 41 | virtual void RepaintStatus(); 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /i_key.cpp: -------------------------------------------------------------------------------- 1 | /* i_key.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | ExKey::ExKey(const char *APrompt): ExView() { 13 | if (APrompt) 14 | Prompt = strdup(APrompt); 15 | else 16 | Prompt = 0; 17 | } 18 | 19 | ExKey::~ExKey() { 20 | free(Prompt); 21 | } 22 | 23 | void ExKey::Activate(int gotfocus) { 24 | ExView::Activate(gotfocus); 25 | } 26 | 27 | int ExKey::BeginMacro() { 28 | return 1; 29 | } 30 | 31 | void ExKey::HandleEvent(TEvent &Event) { 32 | switch (Event.What) { 33 | case evKeyDown: 34 | Key = Event.Key.Code; 35 | if (!(Key & kfModifier)) // not ctrl,alt,shift, .... 36 | EndExec(1); 37 | Event.What = evNone; 38 | break; 39 | } 40 | } 41 | 42 | void ExKey::UpdateView() { 43 | if (Next) { 44 | Next->UpdateView(); 45 | } 46 | } 47 | 48 | void ExKey::RepaintView() { 49 | if (Next) { 50 | Next->RepaintView(); 51 | } 52 | } 53 | 54 | void ExKey::UpdateStatus() { 55 | RepaintStatus(); 56 | } 57 | 58 | void ExKey::RepaintStatus() { 59 | TDrawBuffer B; 60 | int W, H; 61 | 62 | ConQuerySize(&W, &H); 63 | 64 | MoveCh(B, ' ', 0x17, W); 65 | ConPutBox(0, H - 1, W, 1, B); 66 | } 67 | -------------------------------------------------------------------------------- /i_key.h: -------------------------------------------------------------------------------- 1 | /* i_key.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __EXKEY_H 11 | #define __EXKEY_H 12 | 13 | class ExKey: public ExView { 14 | public: 15 | char *Prompt; 16 | TKeyCode Key; 17 | char ch; 18 | 19 | ExKey(const char *APrompt); 20 | virtual ~ExKey(); 21 | virtual void Activate(int gotfocus); 22 | 23 | virtual ExView* GetViewContext() { return Next; } 24 | virtual int BeginMacro(); 25 | virtual void HandleEvent(TEvent &Event); 26 | virtual void UpdateView(); 27 | virtual void RepaintView(); 28 | virtual void UpdateStatus(); 29 | virtual void RepaintStatus(); 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /i_modelview.cpp: -------------------------------------------------------------------------------- 1 | /* i_modelview.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | ExModelView::ExModelView(EView *AView): ExView() { 13 | View = AView; 14 | View->MView = this; 15 | MouseCaptured = 0; 16 | MouseMoved = 0; 17 | } 18 | 19 | ExModelView::~ExModelView() { 20 | if (View) { // close it 21 | delete View; 22 | View = 0; 23 | } 24 | } 25 | 26 | int ExModelView::GetContext() { 27 | return View->GetContext(); 28 | } 29 | 30 | void ExModelView::Activate(int gotfocus) { 31 | ExView::Activate(gotfocus); 32 | View->Activate(gotfocus); 33 | } 34 | 35 | EEventMap *ExModelView::GetEventMap() { 36 | return View->GetEventMap(); 37 | } 38 | 39 | int ExModelView::ExecCommand(int Command, ExState &State) { 40 | return View->ExecCommand(Command, State); 41 | } 42 | 43 | int ExModelView::BeginMacro() { 44 | return View->BeginMacro(); 45 | } 46 | 47 | void ExModelView::HandleEvent(TEvent &Event) { 48 | ExView::HandleEvent(Event); 49 | View->HandleEvent(Event); 50 | } 51 | 52 | void ExModelView::UpdateView() { 53 | View->UpdateView(); 54 | } 55 | 56 | void ExModelView::RepaintView() { 57 | View->RepaintView(); 58 | } 59 | 60 | void ExModelView::RepaintStatus() { 61 | View->RepaintStatus(); 62 | } 63 | 64 | void ExModelView::UpdateStatus() { 65 | View->UpdateStatus(); 66 | } 67 | 68 | void ExModelView::Resize(int width, int height) { 69 | View->Resize(width, height); 70 | } 71 | 72 | void ExModelView::WnSwitchBuffer(EModel *B) { 73 | if (View) 74 | View->SwitchToModel(B); 75 | } 76 | -------------------------------------------------------------------------------- /i_modelview.h: -------------------------------------------------------------------------------- 1 | /* i_modelview.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __EXEDIT_H 11 | #define __EXEDIT_H 12 | 13 | class EView; 14 | 15 | class ExModelView: public ExView { 16 | public: 17 | EView *View; 18 | int MouseCaptured; 19 | int MouseMoved; 20 | 21 | ExModelView(EView *AView); 22 | virtual ~ExModelView(); 23 | virtual void Activate(int gotfocus); 24 | 25 | virtual EEventMap *GetEventMap(); 26 | virtual int ExecCommand(int Command, ExState &State); 27 | 28 | virtual int GetContext(); 29 | virtual int BeginMacro(); 30 | virtual void HandleEvent(TEvent &Event); 31 | virtual void UpdateView(); 32 | virtual void RepaintView(); 33 | virtual void UpdateStatus(); 34 | virtual void RepaintStatus(); 35 | virtual void Resize(int width, int height); 36 | virtual void WnSwitchBuffer(EModel *M); 37 | virtual int IsModelView() { return 1; } 38 | }; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /i_oview.cpp: -------------------------------------------------------------------------------- 1 | /* i_oview.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | ExView::ExView() { 13 | } 14 | 15 | ExView::~ExView() { 16 | } 17 | 18 | void ExView::Activate(int /*gotfocus*/) { 19 | } 20 | 21 | int ExView::IsActive() { 22 | if (Win) 23 | return Win->IsActive(); 24 | return 0; 25 | } 26 | 27 | EEventMap *ExView::GetEventMap() { return 0; } 28 | 29 | int ExView::ExecCommand(int /*Command*/, ExState &/*State*/) { return ErFAIL; } 30 | 31 | int ExView::BeginMacro() { 32 | return 1; 33 | } 34 | 35 | void ExView::HandleEvent(TEvent &Event) { 36 | if (Event.What == evKeyDown && kbCode(Event.Key.Code) == kbF12) 37 | Win->Parent->SelectNext(0); 38 | } 39 | 40 | void ExView::EndExec(int NewResult) { 41 | if (Win->Result == -2) { // hack 42 | Win->EndExec(NewResult); 43 | } else { 44 | if (Next) { 45 | delete Win->PopView(); // self 46 | } 47 | } 48 | } 49 | 50 | void ExView::UpdateView() { 51 | } 52 | 53 | void ExView::UpdateStatus() { 54 | } 55 | 56 | void ExView::RepaintView() { 57 | } 58 | 59 | void ExView::RepaintStatus() { 60 | } 61 | 62 | void ExView::Resize(int /*width*/, int /*height*/) { 63 | Repaint(); 64 | } 65 | 66 | int ExView::ConPutBox(int X, int Y, int W, int H, PCell Cell) { 67 | if (Win) 68 | return Win->ConPutBox(X, Y, W, H, Cell); 69 | return -1; 70 | } 71 | 72 | int ExView::ConScroll(int Way, int X, int Y, int W, int H, TAttr Fill, int Count) { 73 | if (Win) 74 | return Win->ConScroll(Way, X, Y, W, H, Fill, Count); 75 | return -1; 76 | } 77 | 78 | int ExView::ConQuerySize(int *X, int *Y) { 79 | if (Win) 80 | return Win->ConQuerySize(X, Y); 81 | return -1; 82 | } 83 | 84 | int ExView::ConSetCursorPos(int X, int Y) { 85 | if (Win) 86 | return Win->ConSetCursorPos(X, Y); 87 | return -1; 88 | } 89 | 90 | int ExView::ConShowCursor() { 91 | if (Win) 92 | return Win->ConShowCursor(); 93 | return -1; 94 | } 95 | 96 | int ExView::ConHideCursor() { 97 | if (Win) 98 | return Win->ConHideCursor(); 99 | return -1; 100 | } 101 | 102 | int ExView::ConSetCursorSize(int Start, int End) { 103 | if (Win) 104 | return Win->ConSetCursorSize(Start, End); 105 | return -1; 106 | } 107 | -------------------------------------------------------------------------------- /i_oview.h: -------------------------------------------------------------------------------- 1 | /* i_oview.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __IOVIEW_H 11 | #define __IOVIEW_H 12 | 13 | class GxView; 14 | class EBuffer; 15 | class EWindow; 16 | 17 | class ExView { 18 | public: 19 | GxView *Win; 20 | ExView *Next; 21 | 22 | ExView(); 23 | virtual ~ExView(); 24 | 25 | virtual EEventMap *GetEventMap(); 26 | virtual int ExecCommand(int Command, ExState &State); 27 | 28 | virtual void Activate(int gotfocus); 29 | virtual int GetContext() { return CONTEXT_NONE; } 30 | virtual ExView *GetViewContext() { return this; } 31 | virtual ExView *GetStatusContext() { return this; } 32 | virtual int BeginMacro(); 33 | virtual void HandleEvent(TEvent &Event); 34 | virtual void UpdateView(); 35 | virtual void UpdateStatus(); 36 | virtual void RepaintView(); 37 | virtual void RepaintStatus(); 38 | virtual void Resize(int width, int height); 39 | virtual void EndExec(int NewResult); 40 | int IsActive(); 41 | 42 | void Repaint() { RepaintStatus(); RepaintView(); } 43 | void Update() { UpdateStatus(); UpdateView(); } 44 | 45 | int ConPutBox(int X, int Y, int W, int H, PCell Cell); 46 | int ConScroll(int Way, int X, int Y, int W, int H, TAttr Fill, int Count); 47 | int ConQuerySize(int *X, int *Y); 48 | int ConSetCursorPos(int X, int Y); 49 | int ConShowCursor(); 50 | int ConHideCursor(); 51 | int ConSetCursorSize(int Start, int End); 52 | 53 | virtual int IsModelView() { return 0; } 54 | virtual void WnSwitchBuffer(EModel *M) { Next->WnSwitchBuffer(M); } 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /i_search.cpp: -------------------------------------------------------------------------------- 1 | /* i_search.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | #ifdef CONFIG_I_SEARCH 13 | 14 | static char PrevISearch[MAXISEARCH] = ""; 15 | 16 | ExISearch::ExISearch(EBuffer *B) { 17 | Buffer = B; 18 | strcpy(ISearchStr, ""); 19 | len = 0; 20 | stacklen = 0; 21 | Orig = Buffer->CP; // ? 22 | Direction = 0; 23 | state = INoMatch; 24 | } 25 | 26 | ExISearch::~ExISearch() { 27 | if (ISearchStr[0] != 0) 28 | strcpy(PrevISearch, ISearchStr); 29 | } 30 | 31 | void ExISearch::Activate(int gotfocus) { 32 | ExView::Activate(gotfocus); 33 | } 34 | 35 | int ExISearch::BeginMacro() { return 1; } 36 | 37 | void ExISearch::HandleEvent(TEvent &Event) { 38 | int Case = BFI(Buffer, BFI_MatchCase) ? 0 : SEARCH_NCASE; 39 | 40 | ExView::HandleEvent(Event); 41 | switch (Event.What) { 42 | case evKeyDown: 43 | SetState(IOk); 44 | switch (kbCode(Event.Key.Code)) { 45 | case kbEsc: 46 | Buffer->SetPos(Orig.Col, Orig.Row); 47 | EndExec(0); 48 | break; 49 | case kbEnter: EndExec(1); break; 50 | case kbBackSp: 51 | if (len > 0) { 52 | if (stacklen > 0) { 53 | stacklen--; 54 | if (Buffer->CenterPos(stack[stacklen].Col, stack[stacklen].Row) == 0) return; 55 | } 56 | len--; 57 | ISearchStr[len] = 0; 58 | if (len > 0 && Buffer->FindStr(ISearchStr, len, Case | Direction) == 0) { 59 | SetState(INoMatch); 60 | } 61 | } else { 62 | if (Buffer->CenterPos(Orig.Col, Orig.Row) == 0) return; 63 | } 64 | break; 65 | case kbUp: 66 | Buffer->ScrollDown(1); 67 | break; 68 | case kbDown: 69 | Buffer->ScrollUp(1); 70 | break; 71 | case kbLeft: 72 | Buffer->ScrollRight(8); 73 | break; 74 | case kbRight: 75 | Buffer->ScrollLeft(8); 76 | break; 77 | case kbPgDn: 78 | Buffer->MovePageDown(); 79 | break; 80 | case kbPgUp: 81 | Buffer->MovePageUp(); 82 | break; 83 | case kbPgUp | kfCtrl: 84 | Buffer->MoveFileStart(); 85 | break; 86 | case kbPgDn | kfCtrl: 87 | Buffer->MoveFileEnd(); 88 | break; 89 | case kbHome: 90 | Buffer->MoveLineStart(); 91 | break; 92 | case kbEnd: 93 | Buffer->MoveLineEnd(); 94 | break; 95 | case kbTab | kfShift: 96 | Direction = SEARCH_BACK; 97 | if (len == 0) { 98 | strcpy(ISearchStr, PrevISearch); 99 | len = strlen(ISearchStr); 100 | if (len == 0) 101 | break; 102 | } 103 | if (Buffer->FindStr(ISearchStr, len, Case | Direction | SEARCH_NEXT) == 0) { 104 | Buffer->FindStr(ISearchStr, len, Case); 105 | SetState(INoPrev); 106 | } 107 | break; 108 | case kbTab: 109 | Direction = 0; 110 | if (len == 0) { 111 | strcpy(ISearchStr, PrevISearch); 112 | len = strlen(ISearchStr); 113 | if (len == 0) 114 | break; 115 | } 116 | if (Buffer->FindStr(ISearchStr, len, Case | Direction | SEARCH_NEXT) == 0) { 117 | Buffer->FindStr(ISearchStr, len, Case); 118 | SetState(INoNext); 119 | } 120 | break; 121 | case 'Q' | kfCtrl: 122 | Event.What = evKeyDown; 123 | Event.Key.Code = Win->GetChar(0); 124 | default: 125 | if (isAscii(Event.Key.Code) && (len < MAXISEARCH)) { 126 | char Ch = (char) Event.Key.Code; 127 | 128 | stack[stacklen] = Buffer->CP; 129 | ISearchStr[len++] = Ch; 130 | ISearchStr[len] = 0; 131 | if (Buffer->FindStr(ISearchStr, len, Case | Direction) == 0) { 132 | SetState(INoMatch); 133 | len--; 134 | stacklen--; 135 | ISearchStr[len] = 0; 136 | Buffer->FindStr(ISearchStr, len, Case | Direction); 137 | } else { 138 | } 139 | } 140 | break; 141 | } 142 | } 143 | } 144 | 145 | void ExISearch::UpdateView() { 146 | if (Next) { 147 | Next->UpdateView(); 148 | } 149 | } 150 | 151 | void ExISearch::RepaintView() { 152 | if (Next) { 153 | Next->RepaintView(); 154 | } 155 | } 156 | 157 | void ExISearch::UpdateStatus() { 158 | RepaintStatus(); 159 | } 160 | 161 | void ExISearch::RepaintStatus() { 162 | TDrawBuffer B; 163 | char s[MAXISEARCH + 1]; 164 | const char *p; 165 | int W, H; 166 | 167 | ConQuerySize(&W, &H); 168 | 169 | switch (state) { 170 | case INoMatch: p = " No Match. "; break; 171 | case INoPrev: p = " No Prev Match. "; break; 172 | case INoNext: p = " No Next Match. "; break; 173 | case IOk: default: p = ""; break; 174 | } 175 | 176 | sprintf(s, "ISearch [%s]%s", ISearchStr, p); 177 | MoveCh(B, ' ', 0x17, W); 178 | MoveStr(B, 0, W, s, 0x17, W); 179 | ConPutBox(0, H - 1, W, 1, B); 180 | ConSetCursorPos(strlen(s) - 1, H - 1); 181 | ConShowCursor(); 182 | } 183 | 184 | void ExISearch::SetState(IState s) { 185 | state = s; 186 | RepaintView(); 187 | } 188 | #endif 189 | -------------------------------------------------------------------------------- /i_search.h: -------------------------------------------------------------------------------- 1 | /* i_search.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __ISEARCH_H 11 | #define __ISEARCH_H 12 | 13 | #define MAXISEARCH 256 14 | 15 | class ExISearch: public ExView { 16 | public: 17 | typedef enum { IOk, INoMatch, INoPrev, INoNext } IState; 18 | 19 | char ISearchStr[MAXISEARCH + 1]; 20 | EPoint Orig; 21 | EPoint stack[MAXISEARCH]; 22 | int len; 23 | int stacklen; 24 | EBuffer *Buffer; 25 | IState state; 26 | int Direction; 27 | 28 | ExISearch(EBuffer *B); 29 | virtual ~ExISearch(); 30 | virtual void Activate(int gotfocus); 31 | 32 | virtual ExView *GetViewContext() { return Next; } 33 | virtual int BeginMacro(); 34 | virtual void HandleEvent(TEvent &Event); 35 | virtual void UpdateView(); 36 | virtual void RepaintView(); 37 | virtual void UpdateStatus(); 38 | virtual void RepaintStatus(); 39 | 40 | void SetState(IState state); 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /i_view.h: -------------------------------------------------------------------------------- 1 | /* i_view.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | class EView; 11 | 12 | class GxView: public GView { 13 | public: 14 | ExView *Top; 15 | ExView *Bottom; 16 | int MouseCaptured; 17 | 18 | GxView(GFrame *Parent); 19 | virtual ~GxView(); 20 | 21 | void PushView(ExView *view); 22 | ExView *PopView(); 23 | void NewView(ExView *view); 24 | 25 | EEventMap *GetEventMap(); 26 | int ExecCommand(int Command, ExState &State); 27 | 28 | virtual int GetContext(); 29 | virtual ExView* GetStatusContext() { if (Top) return Top->GetStatusContext(); else return 0; } 30 | virtual ExView* GetViewContext() { if (Top) return Top->GetViewContext(); else return 0; } 31 | virtual int BeginMacro(); 32 | virtual void HandleEvent(TEvent &Event); 33 | virtual void Update(); 34 | virtual void Repaint(); 35 | virtual void Activate(int gotfocus); 36 | virtual void Resize(int width, int height); 37 | 38 | void UpdateTitle(char *Title, char *STitle); 39 | 40 | int ReadStr(const char *Prompt, unsigned int BufLen, char *Str, Completer Comp, int Select, int HistId); 41 | int Choice(unsigned long Flags, const char *Title, int NSel, ... /* choices, format, args */); 42 | TKeyCode GetChar(const char *Prompt); 43 | #ifdef CONFIG_I_SEARCH 44 | int IncrementalSearch(EView *V); 45 | #endif 46 | #ifdef CONFIG_I_ASCII 47 | int PickASCII(); 48 | #endif 49 | #ifdef CONFIG_I_COMPLETE 50 | int ICompleteWord(EView *View); 51 | #endif 52 | 53 | int GetStr(const char *Prompt, unsigned int BufLen, char *Str, int HistId); 54 | int GetFile(const char *Prompt, unsigned int BufLen, char *Str, int HistId, int Flags); 55 | 56 | int IsModelView() { return Top ? Top->IsModelView() : 0; } 57 | }; 58 | -------------------------------------------------------------------------------- /indent.cpp: -------------------------------------------------------------------------------- 1 | /* indent.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | #ifdef CONFIG_INDENT_SIMPLE 13 | 14 | /* place holder */ 15 | 16 | int Indent_SIMPLE(EBuffer *B, int Line, int PosCursor) { 17 | int Pos, Old; 18 | 19 | if (Line == 0) { 20 | Pos = 0; 21 | } else { 22 | if (B->RLine(Line - 1)->StateE == 0) { 23 | Pos = B->LineIndented(Line - 1); 24 | } else { // for comments, strings, etc, use same as prev line. 25 | Pos = B->LineIndented(Line - 1); 26 | } 27 | } 28 | 29 | Old = B->LineIndented(Line); 30 | if (Pos < 0) 31 | Pos = 0; 32 | if (Pos != Old) 33 | if (B->IndentLine(Line, Pos) == 0) 34 | return 0;; 35 | return 1; 36 | } 37 | #endif 38 | -------------------------------------------------------------------------------- /log.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | The author, Darin McBride, explicitly places this module under the 4 | LGPL license. This module must remain free for use, but will not 5 | cause software that uses it to be required to be under the GPL or 6 | any of its derivitives. 7 | 8 | ********************************************************************/ 9 | 10 | #include 11 | #include 12 | #include "sysdep.h" 13 | #include "log.h" 14 | 15 | #if defined(NO_NEW_CPP_FEATURES) 16 | #include 17 | #include 18 | #else 19 | #include 20 | #include 21 | 22 | using namespace std; 23 | #endif 24 | 25 | #ifndef FTE_NO_LOGGING 26 | 27 | /********************************************************************* 28 | * 29 | * Required variables: 30 | * 31 | *********************************************************************/ 32 | 33 | GlobalLog globalLog; 34 | 35 | bool GlobalLog::OpenLogFile() 36 | { 37 | if (!m_bOpened && m_strLogFile != NULL) 38 | { 39 | m_ofsLog.open(m_strLogFile, ios::out /*| ios::text*/ | ios::app /*append*/); 40 | if (!m_ofsLog) 41 | { 42 | m_strLogFile = NULL; 43 | m_bOpened = false; 44 | } 45 | else 46 | { 47 | m_bOpened = true; 48 | //no way with gcc3.0 m_ofsLog.setbuf(NULL, 0); 49 | } 50 | } 51 | return m_bOpened; 52 | } 53 | 54 | // 55 | // Operator(): 56 | // 57 | 58 | // useful variable for returning an invalid ofstream to kill off any 59 | // output to the logfile with wrong loglevel. 60 | static ofstream ofsInvalid; 61 | 62 | ostream& GlobalLog::operator()() 63 | { 64 | // Ensure the current file is open: 65 | if (!OpenLogFile()) // if it can't be opened, shortcut everything: 66 | return ofsInvalid; 67 | 68 | time_t tNow = time(NULL); 69 | struct tm* ptm = localtime(&tNow); 70 | 71 | char cOldFill = m_ofsLog.fill('0'); 72 | m_ofsLog << setw(4) << ptm->tm_year + 1900 << '-' 73 | << setw(2) << ptm->tm_mon << '-' 74 | << setw(2) << ptm->tm_mday << ' ' 75 | << setw(2) << ptm->tm_hour << ':' 76 | << setw(2) << ptm->tm_min << ':' 77 | << setw(2) << ptm->tm_sec << ' ' 78 | << "FTE" << ' '; 79 | m_ofsLog.fill(cOldFill); 80 | return m_ofsLog; 81 | } 82 | 83 | FunctionLog::FunctionLog(GlobalLog& gl, const char* funcName, unsigned long line) 84 | : log(gl), func(funcName), myIndentLevel(++log.indent), indentChar('+') 85 | { 86 | OutputLine(line) << "Entered function" << ENDLINE; 87 | } 88 | 89 | FunctionLog::~FunctionLog() 90 | { 91 | indentChar = '+'; 92 | OutputLine() << "Exited function" << ENDLINE; 93 | --log.indent; 94 | } 95 | 96 | ostream& FunctionLog::RC(unsigned long line) 97 | { 98 | indentChar = '!'; 99 | return OutputLine() << "{" << line << "} Returning rc = "; 100 | } 101 | 102 | ostream& FunctionLog::OutputIndent(ostream& os) 103 | { 104 | os << FillChar('|', myIndentLevel - 1); 105 | //for (int i = 1; i < myIndentLevel; ++i) 106 | // os << '|'; 107 | os << indentChar << ' '; 108 | indentChar = '|'; // reset it to |'s. 109 | return os; 110 | } 111 | 112 | ostream& Log__osBinChar(ostream& os, char const& c) 113 | { 114 | char const cOldFill = os.fill('0'); 115 | os << (isprint(c) ? c : '.') << 116 | " [0x" << hex << (int)c << dec << "]"; 117 | os.fill(cOldFill); 118 | return os; 119 | } 120 | 121 | ostream& Log__osFillChar(ostream& os, char const& c, size_t const& len) 122 | { 123 | for (size_t i = 0; i < len; ++i) 124 | os << c; 125 | return os; 126 | } 127 | 128 | #define LINE_LENGTH 8 129 | void Log__BinaryData(FunctionLog& LOGOBJNAME, void* bin_data, size_t len, unsigned long line) 130 | { 131 | for (size_t i = 0; i < len; i += LINE_LENGTH) 132 | { 133 | ostream& os = LOGOBJNAME.OutputLine(line); 134 | size_t j; 135 | 136 | // as characters 137 | for (j = i; j < i + LINE_LENGTH; ++j) 138 | { 139 | if (j < len) 140 | { 141 | char const c = ((char*)bin_data)[i+j]; 142 | os << (isprint(c) ? c : '.'); 143 | } 144 | else 145 | { 146 | os << ' '; 147 | } 148 | } 149 | os << " ["; 150 | // as hex values 151 | char const cOldFill = os.fill('0'); 152 | for (j = i; j < i + LINE_LENGTH; ++j) 153 | { 154 | if (j < len) 155 | { 156 | int const c = ((char*)bin_data)[i+j]; 157 | if (j != i) os << ','; 158 | os << hex << setw(2) << c << dec; 159 | } 160 | else 161 | { 162 | os << " "; 163 | } 164 | } 165 | os.fill(cOldFill); 166 | os << ']' << ENDLINE; 167 | } 168 | } 169 | 170 | #endif // FTE_NO_LOGGING 171 | -------------------------------------------------------------------------------- /memicmp.cpp: -------------------------------------------------------------------------------- 1 | // Contributed by Markus F.X.J. Oberhumer 2 | 3 | #include 4 | #include 5 | 6 | #if defined(__DJGPP__) || defined(UNIX) || defined(WATCOM) 7 | 8 | #ifdef __cplusplus 9 | extern "C" 10 | #endif 11 | int memicmp(const void *s1, const void *s2, size_t n) 12 | { 13 | if (n != 0) 14 | { 15 | const unsigned char *p1 = (const unsigned char *) s1; 16 | const unsigned char *p2 = (const unsigned char *) s2; 17 | 18 | do { 19 | if (*p1 != *p2) 20 | { 21 | int c = toupper(*p1) - toupper(*p2); 22 | if (c) 23 | return c; 24 | } 25 | p1++; p2++; 26 | } while (--n != 0); 27 | } 28 | return 0; 29 | } 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /o_buflist.cpp: -------------------------------------------------------------------------------- 1 | /* o_buflist.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | BufferView *BufferList = 0; 13 | 14 | BufferView::BufferView(int createFlags, EModel **ARoot): EList(createFlags, ARoot, "Buffers") { 15 | ModelNo = 0; // trick 16 | BList = 0; 17 | BCount = 0; 18 | } 19 | 20 | BufferView::~BufferView() { 21 | if (BList) { 22 | for (int i = 0; i < BCount; i++) 23 | if (BList[i]) 24 | free(BList[i]); 25 | free(BList); 26 | } 27 | BufferList = 0; 28 | } 29 | 30 | EEventMap *BufferView::GetEventMap() { 31 | return FindEventMap("BUFFERS"); 32 | } 33 | 34 | int BufferView::GetContext() { 35 | return CONTEXT_BUFFERS; 36 | } 37 | 38 | void BufferView::DrawLine(PCell B, int Line, int Col, ChColor color, int Width) { 39 | if (Line < BCount) 40 | if (Col < int(strlen(BList[Line]))) 41 | MoveStr(B, 0, Width, BList[Line] + Col, color, Width); 42 | } 43 | 44 | char* BufferView::FormatLine(int Line) { 45 | return strdup(BList[Line]); 46 | } 47 | 48 | void BufferView::UpdateList() { 49 | EModel *B = ActiveModel; 50 | int No; 51 | char s[512] = ""; 52 | 53 | if (BList) { 54 | for (int i = 0; i < BCount; i++) 55 | if (BList[i]) 56 | free(BList[i]); 57 | free(BList); 58 | } 59 | BList = 0; 60 | BCount = 0; 61 | while (B) { 62 | BCount++; 63 | B = B->Next; 64 | if (B == ActiveModel) break; 65 | } 66 | BList = (char **) malloc(sizeof(char *) * BCount); 67 | assert(BList != 0); 68 | B = ActiveModel; 69 | No = 0; 70 | while (B) { 71 | B->GetInfo(s, sizeof(s) - 1); 72 | BList[No++] = strdup(s); 73 | B = B->Next; 74 | if (B == ActiveModel) break; 75 | if (No >= BCount) break; 76 | } 77 | Count = BCount; 78 | NeedsUpdate = 1; 79 | } 80 | 81 | EModel *BufferView::GetBufferById(int No) { 82 | EModel *B; 83 | 84 | B = ActiveModel; 85 | while (B) { 86 | if (No == 0) { 87 | return B; 88 | } 89 | No--; 90 | B = B->Next; 91 | if (B == ActiveModel) break; 92 | } 93 | return 0; 94 | } 95 | 96 | int BufferView::ExecCommand(int Command, ExState &State) { 97 | switch (Command) { 98 | case ExCloseActivate: 99 | { 100 | EModel *B; 101 | 102 | B = GetBufferById(Row); 103 | if (B && B != this) { 104 | View->SwitchToModel(B); 105 | delete this; 106 | return ErOK; 107 | } 108 | } 109 | return ErFAIL; 110 | case ExBufListFileClose: 111 | { 112 | EModel *B = GetBufferById(Row); 113 | 114 | if (B && B != this && Count > 1) { 115 | if (B->ConfQuit(View->MView->Win)) { 116 | View->DeleteModel(B); 117 | } 118 | UpdateList(); 119 | return ErOK; 120 | } 121 | } 122 | return ErFAIL; 123 | case ExBufListFileSave: 124 | { 125 | EModel *B = GetBufferById(Row); 126 | 127 | if (B && B->GetContext() == CONTEXT_FILE) 128 | if (((EBuffer *)B)->Save()) 129 | return ErOK; 130 | } 131 | return ErFAIL; 132 | 133 | case ExActivateInOtherWindow: 134 | { 135 | EModel *B = GetBufferById(Row); 136 | 137 | if (B) { 138 | View->Next->SwitchToModel(B); 139 | return ErOK; 140 | } 141 | } 142 | return ErFAIL; 143 | } 144 | return EList::ExecCommand(Command, State); 145 | } 146 | 147 | int BufferView::Activate(int No) { 148 | EModel *B; 149 | 150 | B = GetBufferById(No); 151 | if (B) { 152 | View->SwitchToModel(B); 153 | return 1; 154 | } 155 | return 0; 156 | } 157 | 158 | void BufferView::GetInfo(char *AInfo, int MaxLen) { 159 | sprintf(AInfo, "%2d %04d/%03d Buffers", ModelNo, Row + 1, Count); 160 | } 161 | 162 | void BufferView::GetTitle(char *ATitle, int MaxLen, char *ASTitle, int SMaxLen) { 163 | strncpy(ATitle, "Buffers", MaxLen); 164 | ATitle[MaxLen - 1] = 0; 165 | strncpy(ASTitle, "Buffers", SMaxLen); 166 | ASTitle[SMaxLen - 1] = 0; 167 | } 168 | -------------------------------------------------------------------------------- /o_buflist.h: -------------------------------------------------------------------------------- 1 | /* o_buflist.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __BUFLIST_H 11 | #define __BUFLIST_H 12 | 13 | class BufferView: public EList { 14 | public: 15 | char **BList; 16 | int BCount; 17 | 18 | BufferView(int createFlags, EModel **ARoot); 19 | virtual ~BufferView(); 20 | virtual EEventMap *GetEventMap(); 21 | virtual int GetContext(); 22 | virtual void DrawLine(PCell B, int Line, int Col, ChColor color, int Width); 23 | virtual char* FormatLine(int Line); 24 | virtual void UpdateList(); 25 | EModel *GetBufferById(int No); 26 | virtual int ExecCommand(int Command, ExState &State); 27 | virtual int Activate(int No); 28 | virtual void GetInfo(char *AInfo, int MaxLen); 29 | virtual void GetTitle(char *ATitle, int MaxLen, char *ASTitle, int SMaxLen); 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /o_directory.h: -------------------------------------------------------------------------------- 1 | /* o_directory.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __ODIRECTORY_H 11 | #define __ODIRECTORY_H 12 | 13 | #ifdef CONFIG_OBJ_DIRECTORY 14 | 15 | class EDirectory: public EList { 16 | public: 17 | char *Path; 18 | FileInfo **Files; 19 | int FCount; 20 | int SearchLen; 21 | char SearchName[MAXISEARCH]; 22 | int SearchPos[MAXISEARCH]; 23 | 24 | EDirectory(int createFlags, EModel **ARoot, char *aPath); 25 | virtual ~EDirectory(); 26 | 27 | virtual int GetContext(); 28 | virtual EEventMap *GetEventMap(); 29 | virtual int ExecCommand(int Command, ExState &State); 30 | virtual void HandleEvent(TEvent &Event); 31 | 32 | virtual void DrawLine(PCell B, int Line, int Col, ChColor color, int Width); 33 | virtual char *FormatLine(int Line); 34 | 35 | virtual void RescanList(); 36 | // virtual void UpdateList(); 37 | virtual void FreeList(); 38 | virtual int CanActivate(int Line); 39 | virtual int Activate(int No); 40 | 41 | virtual void GetName(char *AName, int MaxLen); 42 | virtual void GetPath(char *APath, int MaxLen); 43 | virtual void GetInfo(char *AInfo, int MaxLen); 44 | virtual void GetTitle(char *ATitle, int MaxLen, char *ASTitle, int SMaxLen); 45 | 46 | int isDir(int No); 47 | int FmChDir(const char *Name); 48 | int FmLoad(char *Name, EView *View); 49 | int FmRmDir(char const* Name); 50 | int ChangeDir(ExState &State); 51 | int RescanDir(); 52 | }; 53 | #endif 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /o_list.h: -------------------------------------------------------------------------------- 1 | /* o_list.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __OLIST_H__ 11 | #define __OLIST_H__ 12 | 13 | class EList; 14 | 15 | class EListPort: public EViewPort { 16 | public: 17 | EList *List; 18 | int Row, TopRow, LeftCol; 19 | int OldRow, OldTopRow, OldLeftCol, OldCount; 20 | EListPort(EList *L, EView *V); 21 | virtual ~EListPort(); 22 | 23 | void StorePos(); 24 | void GetPos(); 25 | 26 | virtual void HandleEvent(TEvent &Event); 27 | virtual void HandleMouse(TEvent &Event); 28 | 29 | void PaintView(int PaintAll); 30 | 31 | virtual void UpdateView(); 32 | virtual void RepaintView(); 33 | virtual void UpdateStatus(); 34 | virtual void RepaintStatus(); 35 | }; 36 | 37 | class EList: public EModel { 38 | public: 39 | char *Title; 40 | int Row, LeftCol, TopRow, Count; 41 | int MouseCaptured; 42 | int MouseMoved; 43 | int NeedsUpdate, NeedsRedraw; 44 | 45 | EList(int createFlags, EModel **ARoot, const char *aTitle); 46 | virtual ~EList(); 47 | 48 | virtual EViewPort *CreateViewPort(EView *V); 49 | EListPort *GetViewVPort(EView *V); 50 | EListPort *GetVPort(); 51 | 52 | void SetTitle(char *ATitle); 53 | 54 | virtual int ExecCommand(int Command, ExState &State); 55 | virtual EEventMap *GetEventMap(); 56 | virtual int GetContext(); 57 | virtual int BeginMacro(); 58 | void HandleEvent(TEvent &Event); 59 | 60 | 61 | virtual void DrawLine(PCell B, int Line, int Col, ChColor color, int Width); 62 | virtual char *FormatLine(int Line); 63 | 64 | int SetPos(int ARow, int ACol); 65 | void FixPos(); 66 | 67 | virtual void RescanList(); 68 | virtual void UpdateList(); 69 | virtual void FreeList(); 70 | virtual int CanActivate(int Line); 71 | virtual int Activate(int No); 72 | 73 | int MoveLeft(); 74 | int MoveRight(); 75 | int MoveUp(); 76 | int MoveDown(); 77 | int MoveLineStart(); 78 | int MoveLineEnd(); 79 | int MovePageUp(); 80 | int MovePageDown(); 81 | int ScrollLeft(int Cols); 82 | int ScrollRight(int Cols); 83 | int ScrollUp(int Rows); 84 | int ScrollDown(int Rows); 85 | int MovePageStart(); 86 | int MovePageEnd(); 87 | int MoveFileStart(); 88 | int MoveFileEnd(); 89 | int Activate(); 90 | 91 | int UpdateRows(int minim, int maxim); 92 | }; 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /o_messages.h: -------------------------------------------------------------------------------- 1 | /* o_messages.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __MESSAGES_H__ 11 | #define __MESSAGES_H__ 12 | 13 | #ifdef CONFIG_OBJ_MESSAGES 14 | typedef struct { 15 | char *file; 16 | int line; 17 | char *msg; 18 | char *text; 19 | EBuffer *Buf; 20 | } Error; 21 | 22 | struct aDir 23 | { 24 | aDir* next; 25 | char* name; 26 | }; 27 | 28 | class EMessages: public EList { 29 | public: 30 | char *Command; 31 | char *Directory; 32 | 33 | int ErrCount; 34 | Error **ErrList; 35 | int Running; 36 | 37 | int BufLen; 38 | int BufPos; 39 | int PipeId; 40 | int ReturnCode; 41 | int MatchCount; 42 | char MsgBuf[4096]; 43 | aDir* curr_dir; // top of dir stack. 44 | 45 | EMessages(int createFlags, EModel **ARoot, char *Dir, char *ACommand); 46 | ~EMessages(); 47 | void freeDirStack(); 48 | 49 | virtual void NotifyDelete(EModel *Deleting); 50 | void FindErrorFiles(); 51 | void FindErrorFile(int err); 52 | void AddFileError(EBuffer *B, int err); 53 | void FindFileErrors(EBuffer *B); 54 | 55 | virtual int GetContext() { return CONTEXT_MESSAGES; } 56 | virtual EEventMap *GetEventMap(); 57 | virtual int ExecCommand(int Command, ExState &State); 58 | 59 | void AddError(Error *p); 60 | void AddError(char *file, int line, char *msg, const char *text); 61 | 62 | void FreeErrors(); 63 | int GetLine(char *Line, int maxim); 64 | void GetErrors(); 65 | int Compile(char *Command); 66 | void ShowError(EView *V, int err); 67 | void DrawLine(PCell B, int Line, int Col, ChColor color, int Width); 68 | char* FormatLine(int Line); 69 | void UpdateList(); 70 | int Activate(int No); 71 | int CanActivate(int Line); 72 | void NotifyPipe(int APipeId); 73 | virtual void GetName(char *AName, int MaxLen); 74 | virtual void GetInfo(char *AInfo, int MaxLen); 75 | virtual void GetPath(char *APath, int MaxLen); 76 | virtual void GetTitle(char *ATitle, int MaxLen, char *ASTitle, int SMaxLen); 77 | 78 | int RunPipe(char *Dir, char *Command); 79 | 80 | int CompilePrevError(EView *V); 81 | int CompileNextError(EView *V); 82 | }; 83 | 84 | extern EMessages *CompilerMsgs; 85 | 86 | void FreeCRegexp(); 87 | 88 | #endif 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /o_model.cpp: -------------------------------------------------------------------------------- 1 | /* o_model.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | EModel *ActiveModel = 0; 13 | char msgbuftmp[MSGBUFTMP_SIZE] = ""; 14 | 15 | EModel *FindModelID(EModel *Model, int ID) { 16 | EModel *M = Model; 17 | int No = ID; 18 | 19 | while (M) { 20 | if (M->ModelNo == No) 21 | return M; 22 | M = M->Next; 23 | if (M == Model) 24 | break; 25 | } 26 | return 0; 27 | } 28 | 29 | int GetNewModelID(EModel *B) { 30 | static int lastid = -1; 31 | 32 | while (FindModelID(B, ++lastid) != 0) /* */; 33 | 34 | return lastid; 35 | } 36 | 37 | EModel::EModel(int createFlags, EModel **ARoot) { 38 | Root = ARoot; 39 | 40 | if (Root) { 41 | if (*Root) { 42 | if (createFlags & cfAppend) { 43 | Prev = *Root; 44 | Next = (*Root)->Next; 45 | } else { 46 | Next = *Root; 47 | Prev = (*Root)->Prev; 48 | } 49 | Prev->Next = this; 50 | Next->Prev = this; 51 | } else 52 | Prev = Next = this; 53 | 54 | if (!(createFlags & cfNoActivate)) 55 | *Root = this; 56 | } else 57 | Prev = Next = this; 58 | View = 0; 59 | ModelNo = -1; 60 | ModelNo = GetNewModelID(this); 61 | } 62 | 63 | EModel::~EModel() { 64 | EModel *D = this; 65 | 66 | while (D) { 67 | D->NotifyDelete(this); 68 | D = D->Next; 69 | if (D == this) 70 | break; 71 | } 72 | 73 | if (Next != this) { 74 | Prev->Next = Next; 75 | Next->Prev = Prev; 76 | if (*Root == this) 77 | *Root = Next; 78 | } else 79 | *Root = 0; 80 | } 81 | 82 | void EModel::AddView(EView *V) { 83 | RemoveView(V); 84 | if (V) 85 | V->NextView = View; 86 | View = V; 87 | } 88 | 89 | void EModel::RemoveView(EView *V) { 90 | EView **X = &View; 91 | 92 | if (!V) return; 93 | while (*X) { 94 | if ((*X) == V) { 95 | *X = V->NextView; 96 | return; 97 | } 98 | X = (&(*X)->NextView); 99 | } 100 | } 101 | 102 | void EModel::SelectView(EView *V) { 103 | RemoveView(V); 104 | AddView(V); 105 | } 106 | 107 | EViewPort *EModel::CreateViewPort(EView *V) { 108 | return 0; 109 | } 110 | 111 | int EModel::ExecCommand(int Command, ExState &State) { 112 | return ErFAIL; 113 | } 114 | 115 | void EModel::HandleEvent(TEvent &Event) { 116 | } 117 | 118 | void EModel::Msg(int level, const char *s, ...) { 119 | va_list ap; 120 | 121 | if (View == 0) 122 | return; 123 | 124 | va_start(ap, s); 125 | vsprintf(msgbuftmp, s, ap); 126 | va_end(ap); 127 | 128 | if (level != S_BUSY) 129 | View->SetMsg(msgbuftmp); 130 | } 131 | 132 | int EModel::CanQuit() { 133 | return 1; 134 | } 135 | 136 | int EModel::ConfQuit(GxView *V, int multiFile) { 137 | return 1; 138 | } 139 | 140 | int EModel::GetContext() { return CONTEXT_NONE; } 141 | EEventMap *EModel::GetEventMap() { return 0; } 142 | int EModel::BeginMacro() { return 1; } 143 | void EModel::GetName(char *AName, int MaxLen) { *AName = 0; } 144 | void EModel::GetPath(char *APath, int MaxLen) { *APath = 0; } 145 | void EModel::GetInfo(char *AInfo, int MaxLen) { *AInfo = 0; } 146 | void EModel::GetTitle(char *ATitle, int MaxLen, char *ASTitle, int SMaxLen) { *ATitle = 0; *ASTitle = 0; } 147 | void EModel::NotifyPipe(int PipeId) { } 148 | 149 | void EModel::NotifyDelete(EModel *Deleted) { 150 | } 151 | void EModel::DeleteRelated() { 152 | } 153 | 154 | EViewPort::EViewPort(EView *V) { View = V; ReCenter = 0; } 155 | EViewPort::~EViewPort() {} 156 | void EViewPort::HandleEvent(TEvent &Event) { } 157 | void EViewPort::UpdateView() { } 158 | void EViewPort::RepaintView() { } 159 | void EViewPort::UpdateStatus() { } 160 | void EViewPort::RepaintStatus() { } 161 | void EViewPort::GetPos() { } 162 | void EViewPort::StorePos() { } 163 | void EViewPort::Resize(int Width, int Height) {} 164 | 165 | void EModel::UpdateTitle() { 166 | char Title[256] = ""; //fte: "; 167 | char STitle[256] = ""; //"fte: "; 168 | EView *V; 169 | 170 | GetTitle((char *)(Title + 0), sizeof(Title) - 0, 171 | (char *)(STitle + 0), sizeof(STitle) - 0); 172 | 173 | V = View; 174 | while (V) { 175 | V->MView->Win->UpdateTitle(Title, STitle); 176 | V = V->NextView; 177 | } 178 | } 179 | 180 | int EModel::GetStrVar(int var, char *str, int buflen) { 181 | switch (var) { 182 | case mvCurDirectory: 183 | return GetDefaultDirectory(this, str, buflen); 184 | } 185 | return 0; 186 | } 187 | 188 | int EModel::GetIntVar(int var, int *value) { 189 | return 0; 190 | } 191 | -------------------------------------------------------------------------------- /o_model.h: -------------------------------------------------------------------------------- 1 | /* o_model.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __MODEL_H__ 11 | #define __MODEL_H__ 12 | 13 | class EView; 14 | 15 | class EViewPort { 16 | public: 17 | EView *View; 18 | int ReCenter; 19 | 20 | EViewPort(EView *V); 21 | virtual ~EViewPort(); 22 | 23 | virtual void HandleEvent(TEvent &Event); 24 | virtual void UpdateView(); 25 | virtual void RepaintView(); 26 | virtual void UpdateStatus(); 27 | virtual void RepaintStatus(); 28 | 29 | virtual void GetPos(); 30 | virtual void StorePos(); 31 | 32 | virtual void Resize(int Width, int Height); 33 | }; 34 | 35 | enum createFlags { 36 | cfAppend = 1, 37 | cfNoActivate = 2 38 | }; 39 | 40 | class EModel { 41 | public: 42 | EModel **Root; // root ptr of this list 43 | EModel *Next; // next model 44 | EModel *Prev; // prev model 45 | EView *View; // active view of model 46 | 47 | int ModelNo; 48 | 49 | EModel(int createFlags, EModel **ARoot); 50 | virtual ~EModel(); 51 | 52 | void AddView(EView *V); 53 | void RemoveView(EView *V); 54 | void SelectView(EView *V); 55 | 56 | virtual EViewPort *CreateViewPort(EView *V); 57 | 58 | virtual int GetContext(); 59 | virtual EEventMap *GetEventMap(); 60 | virtual int BeginMacro(); 61 | virtual int ExecCommand(int Command, ExState &State); 62 | virtual void HandleEvent(TEvent &Event); 63 | 64 | virtual void GetName(char *AName, int MaxLen); 65 | virtual void GetPath(char *APath, int MaxLen); 66 | virtual void GetInfo(char *AInfo, int MaxLen); 67 | virtual void GetTitle(char *ATitle, int MaxLen, 68 | char *ASTitle, int SMaxLen); 69 | 70 | void UpdateTitle(); 71 | 72 | void Msg(int level, const char *s, ...); 73 | virtual int CanQuit(); 74 | virtual int ConfQuit(GxView *V, int multiFile = 0); 75 | 76 | virtual int GetStrVar(int var, char *str, int buflen); 77 | virtual int GetIntVar(int var, int *value); 78 | 79 | virtual void NotifyPipe(int PipeId); 80 | 81 | virtual void NotifyDelete(EModel *Deleting); 82 | virtual void DeleteRelated(); 83 | }; 84 | 85 | class EView { 86 | public: 87 | EView *Next; // next view 88 | EView *Prev; // prev view 89 | ExModelView *MView; // model view controller 90 | EModel *Model; // model for this view 91 | EView *NextView; // next view for model 92 | EViewPort *Port; 93 | char *CurMsg; 94 | 95 | EView(EModel *AModel); 96 | virtual ~EView(); 97 | 98 | virtual void FocusChange(int GotFocus); 99 | virtual void Resize(int Width, int Height); 100 | 101 | void SetModel(EModel *AModel); 102 | void SelectModel(EModel *AModel); 103 | void SwitchToModel(EModel *AModel); 104 | 105 | void Activate(int GotFocus); 106 | 107 | virtual int GetContext(); 108 | virtual EEventMap *GetEventMap(); 109 | virtual int BeginMacro(); 110 | virtual int ExecCommand(int Command, ExState &State); 111 | 112 | virtual void HandleEvent(TEvent &Event); 113 | virtual void UpdateView(); 114 | virtual void RepaintView(); 115 | virtual void UpdateStatus(); 116 | virtual void RepaintStatus(); 117 | 118 | void Msg(int level, const char *s, ...); 119 | void SetMsg(char *Msg); 120 | 121 | int SwitchTo(ExState &State); 122 | int FilePrev(); 123 | int FileNext(); 124 | int FileLast(); 125 | int FileSaveAll(); 126 | int FileOpen(ExState &State); 127 | int FileOpenInMode(ExState &State); 128 | int SetPrintDevice(ExState &State); 129 | int ToggleSysClipboard(ExState &State); 130 | int ShowKey(ExState &State); 131 | int ViewBuffers(ExState &State); 132 | #ifdef CONFIG_OBJ_ROUTINE 133 | int ViewRoutines(ExState &State); 134 | #endif 135 | #ifdef CONFIG_OBJ_MESSAGES 136 | int Compile(ExState &State); 137 | int RunCompiler(ExState &State); 138 | int Compile(char *Command); 139 | int ViewMessages(ExState &State); 140 | int CompilePrevError(ExState &State); 141 | int CompileNextError(ExState &State); 142 | int ConfigRecompile(ExState &State); 143 | #endif 144 | #ifdef CONFIG_OBJ_DIRECTORY 145 | int DirOpen(ExState &State); 146 | int OpenDir(char *Directory); 147 | #endif 148 | int ShowVersion(); 149 | int ViewModeMap(ExState &State); 150 | int ClearMessages(); 151 | #ifdef CONFIG_TAGS 152 | int TagLoad(ExState &State); 153 | #endif 154 | int SysShowHelp(ExState &State, const char *word); 155 | 156 | int RemoveGlobalBookmark(ExState &State); 157 | int GotoGlobalBookmark(ExState &State); 158 | int PopGlobalBookmark(); 159 | 160 | void DeleteModel(EModel *M); 161 | int CanQuit(); 162 | 163 | int GetStrVar(int var, char *str, int buflen); 164 | int GetIntVar(int var, int *value); 165 | }; 166 | 167 | extern EModel *ActiveModel; 168 | extern EView *ActiveView; 169 | 170 | int GetNewModelID(EModel *B); 171 | EModel *FindModelID(EModel *B, int ID); 172 | 173 | #define MSGBUFTMP_SIZE 1024 174 | extern char msgbuftmp[MSGBUFTMP_SIZE]; 175 | 176 | #endif 177 | -------------------------------------------------------------------------------- /o_modemap.cpp: -------------------------------------------------------------------------------- 1 | /* o_modemap.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | EventMapView *TheEventMapView = 0; 13 | 14 | void EventMapView::AddLine(const char *Line) { 15 | if (BList) { 16 | BCount++; 17 | BList = (char **)realloc((void *)BList, sizeof(char *) * BCount); 18 | } else { 19 | BCount = 1; 20 | BList = (char **)malloc(sizeof(char *)); 21 | } 22 | assert(BList); 23 | BList[BCount - 1] = strdup(Line); 24 | } 25 | 26 | void EventMapView::DumpKey(const char *aPrefix, EKey *Key) { 27 | char KeyName[128] = ""; 28 | char Entry[2048] = ""; 29 | char *p; 30 | int id; 31 | 32 | if (aPrefix) { 33 | strcpy(KeyName, aPrefix); 34 | strcat(KeyName, "_"); 35 | } 36 | GetKeyName(KeyName + strlen(KeyName), Key->fKey); 37 | sprintf(Entry, "%13s ", KeyName); 38 | id = Key->Cmd; 39 | for (int i = 0; i < Macros[id].Count; i++) { 40 | p = Entry + strlen(Entry); 41 | if (Macros[id].cmds[i].type == CT_COMMAND) { 42 | if (Macros[id].cmds[i].repeat > 1) 43 | sprintf(p, "%d:%s ", Macros[id].cmds[i].repeat, GetCommandName(Macros[id].cmds[i].u.num)); 44 | else 45 | sprintf(p, "%s ", GetCommandName(Macros[id].cmds[i].u.num)); 46 | } else if (Macros[id].cmds[i].type == CT_NUMBER) { 47 | sprintf(p, "%ld ", Macros[id].cmds[i].u.num); 48 | } else if (Macros[id].cmds[i].type == CT_STRING) { 49 | sprintf(p, "'%s' ", Macros[id].cmds[i].u.string); 50 | } 51 | if (strlen(Entry) > 1950) { 52 | strcat(Entry, "..."); 53 | break; 54 | } 55 | } 56 | AddLine(Entry); 57 | } 58 | 59 | void EventMapView::DumpMap(const char *aPrefix, EKeyMap *aKeyMap) { 60 | EKey *Key; 61 | 62 | Key = aKeyMap->fKeys; 63 | while (Key) { 64 | if (Key->fKeyMap) { 65 | char Prefix[32] = ""; 66 | 67 | if (aPrefix) { 68 | strcpy(Prefix, aPrefix); 69 | strcat(Prefix, "_"); 70 | } 71 | GetKeyName(Prefix + strlen(Prefix), Key->fKey); 72 | DumpMap(Prefix, Key->fKeyMap); 73 | } else { 74 | DumpKey(aPrefix, Key); 75 | } 76 | Key = Key->fNext; 77 | } 78 | } 79 | 80 | void EventMapView::DumpEventMap(EEventMap *aEventMap) { 81 | char name[256]; 82 | 83 | while (aEventMap) { 84 | strcpy(name, aEventMap->Name); 85 | if (aEventMap->Parent) { 86 | strcat(name, ": "); 87 | strcat(name, aEventMap->Parent->Name); 88 | } 89 | AddLine(name); 90 | if (aEventMap->KeyMap) 91 | DumpMap(0, aEventMap->KeyMap); 92 | aEventMap = aEventMap->Parent; 93 | if (aEventMap != 0) 94 | AddLine(""); 95 | } 96 | } 97 | 98 | EventMapView::EventMapView(int createFlags, EModel **ARoot, EEventMap *Map): EList(createFlags, ARoot, "Event Map") { 99 | BCount = 0; 100 | BList = 0; 101 | DumpEventMap(EMap = Map); 102 | TheEventMapView = this; 103 | } 104 | 105 | EventMapView::~EventMapView() { 106 | FreeView(); 107 | TheEventMapView = 0; 108 | } 109 | 110 | void EventMapView::FreeView() { 111 | if (BList) { 112 | for (int i = 0; i < BCount; i++) 113 | if (BList[i]) 114 | free(BList[i]); 115 | free(BList); 116 | } 117 | BCount = 0; 118 | BList = 0; 119 | } 120 | 121 | void EventMapView::ViewMap(EEventMap *Map) { 122 | FreeView(); 123 | DumpEventMap(EMap = Map); 124 | } 125 | 126 | EEventMap *EventMapView::GetEventMap() { 127 | return FindEventMap("EVENTMAPVIEW"); 128 | } 129 | 130 | int EventMapView::ExecCommand(int Command, ExState &State) { 131 | return EList::ExecCommand(Command, State); 132 | } 133 | 134 | int EventMapView::GetContext() { 135 | return CONTEXT_MAPVIEW; 136 | } 137 | 138 | void EventMapView::DrawLine(PCell B, int Line, int Col, ChColor color, int Width) { 139 | if (Line < BCount) 140 | if (Col < int(strlen(BList[Line]))) 141 | MoveStr(B, 0, Width, BList[Line] + Col, color, Width); 142 | } 143 | 144 | char *EventMapView::FormatLine(int Line) { 145 | return strdup(BList[Line]); 146 | } 147 | 148 | void EventMapView::UpdateList() { 149 | Count = BCount; 150 | EList::UpdateList(); 151 | } 152 | 153 | int EventMapView::CanActivate(int /*Line*/) { 154 | return 0; 155 | } 156 | 157 | void EventMapView::GetName(char *AName, int MaxLen) { 158 | strncpy(AName, "EventMapView", MaxLen); 159 | } 160 | 161 | void EventMapView::GetInfo(char *AInfo, int MaxLen) { 162 | sprintf(AInfo, 163 | "%2d %04d/%03d EventMapView (%s)", 164 | ModelNo, 165 | Row + 1, Count, 166 | EMap->Name); 167 | } 168 | 169 | void EventMapView::GetTitle(char *ATitle, int MaxLen, char *ASTitle, int SMaxLen) { 170 | sprintf(ATitle, "EventMapView: %s", EMap->Name); 171 | strncpy(ASTitle, "EventMapView", SMaxLen); 172 | ASTitle[SMaxLen - 1] = 0; 173 | } 174 | 175 | -------------------------------------------------------------------------------- /o_modemap.h: -------------------------------------------------------------------------------- 1 | /* o_modemap.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __MAPVIEW_H__ 11 | #define __MAPVIEW_H__ 12 | 13 | class EventMapView: public EList { 14 | public: 15 | char **BList; 16 | int BCount; 17 | EEventMap *EMap; 18 | 19 | void AddLine(const char *Line); 20 | void DumpKey(const char *aPrefix, EKey *Key); 21 | void DumpMap(const char *aPrefix, EKeyMap *aKeyMap); 22 | void DumpEventMap(EEventMap *aEventMap); 23 | 24 | EventMapView(int createFlags, EModel **ARoot, EEventMap *Map); 25 | virtual ~EventMapView(); 26 | 27 | void FreeView(); 28 | void ViewMap(EEventMap *Map); 29 | 30 | virtual int ExecCommand(int Command, ExState &State); 31 | virtual EEventMap *GetEventMap(); 32 | virtual int GetContext(); 33 | 34 | virtual void DrawLine(PCell B, int Line, int Col, ChColor color, int Width); 35 | virtual char* FormatLine(int Line); 36 | virtual void UpdateList(); 37 | virtual int CanActivate(int Line); 38 | virtual void GetName(char *AName, int MaxLen); 39 | virtual void GetInfo(char *AInfo, int MaxLen); 40 | virtual void GetTitle(char *ATitle, int MaxLen, char *ASTitle, int SMaxLen); 41 | }; 42 | 43 | extern EventMapView *TheEventMapView; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /o_routine.cpp: -------------------------------------------------------------------------------- 1 | /* o_routine.cpp 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #include "fte.h" 11 | 12 | #ifdef CONFIG_OBJ_ROUTINE 13 | RoutineView::RoutineView(int createFlags, EModel **ARoot, EBuffer *AB): EList(createFlags, ARoot, "Routines") { 14 | Buffer = AB; 15 | if (Buffer->rlst.Count == 0) 16 | Buffer->ScanForRoutines(); 17 | Row = 0; 18 | int Row = Buffer->VToR(Buffer->CP.Row); 19 | for (int i = Buffer->rlst.Count - 1; i >= 0; --i) 20 | if (Row >= Buffer->rlst.Lines[i]) { 21 | Row = i; 22 | break; 23 | } 24 | { 25 | char CTitle[256]; 26 | 27 | sprintf(CTitle, "Routines %s: %d", 28 | Buffer->FileName, 29 | Buffer->rlst.Count); 30 | SetTitle(CTitle); 31 | } 32 | }; 33 | 34 | RoutineView::~RoutineView() { 35 | Buffer->Routines = 0; 36 | } 37 | 38 | EEventMap *RoutineView::GetEventMap() { 39 | return FindEventMap("ROUTINES"); 40 | } 41 | 42 | int RoutineView::ExecCommand(int Command, ExState &State) { 43 | switch (Command) { 44 | case ExRescan: 45 | Buffer->ScanForRoutines(); 46 | UpdateList(); 47 | return ErOK; 48 | 49 | case ExActivateInOtherWindow: 50 | if (Row < Buffer->rlst.Count) { 51 | View->Next->SwitchToModel(Buffer); 52 | Buffer->CenterPosR(0, Buffer->rlst.Lines[Row]); 53 | return ErOK; 54 | } 55 | return ErFAIL; 56 | 57 | case ExCloseActivate: 58 | return ErFAIL; 59 | } 60 | return EList::ExecCommand(Command, State); 61 | } 62 | 63 | void RoutineView::DrawLine(PCell B, int Line, int Col, ChColor color, int Width) { 64 | if (Buffer->RLine(Buffer->rlst.Lines[Line])->Count > Col) { 65 | char str[1024]; 66 | int len; 67 | 68 | len = UnTabStr(str, sizeof(str), 69 | Buffer->RLine(Buffer->rlst.Lines[Line])->Chars, 70 | Buffer->RLine(Buffer->rlst.Lines[Line])->Count); 71 | 72 | if (len > Col) 73 | MoveStr(B, 0, Width, str + Col, color, len - Col); 74 | } 75 | } 76 | 77 | char* RoutineView::FormatLine(int Line) { 78 | char *p = 0; 79 | PELine L = Buffer->RLine(Buffer->rlst.Lines[Line]); 80 | 81 | p = (char *) malloc(L->Count + 1); 82 | if (p) { 83 | memcpy(p, L->Chars, L->Count); 84 | p[L->Count] = 0; 85 | } 86 | return p; 87 | } 88 | 89 | int RoutineView::Activate(int No) { 90 | if (No < Buffer->rlst.Count) { 91 | View->SwitchToModel(Buffer); 92 | Buffer->CenterPosR(0, Buffer->rlst.Lines[No]); 93 | return 1; 94 | } 95 | return 0; 96 | } 97 | 98 | void RoutineView::RescanList() { 99 | Buffer->ScanForRoutines(); 100 | UpdateList(); 101 | NeedsRedraw = 1; 102 | } 103 | 104 | void RoutineView::UpdateList() { 105 | Count = Buffer->rlst.Count; 106 | } 107 | 108 | void RoutineView::GetName(char *AName, int MaxLen) { 109 | strncpy(AName, "Routines", MaxLen); 110 | } 111 | 112 | void RoutineView::GetInfo(char *AInfo, int MaxLen) { 113 | sprintf(AInfo, "%2d %04d/%03d Routines (%s)", ModelNo, Row + 1, Count, Buffer->FileName); 114 | } 115 | 116 | void RoutineView::GetTitle(char *ATitle, int MaxLen, char *ASTitle, int SMaxLen) { 117 | sprintf(ATitle, "Routines: %s", Buffer->FileName); 118 | strncpy(ASTitle, "Routines", SMaxLen); 119 | ASTitle[SMaxLen - 1] = 0; 120 | } 121 | #endif 122 | -------------------------------------------------------------------------------- /o_routine.h: -------------------------------------------------------------------------------- 1 | /* o_routine.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __ROUTINE_H__ 11 | #define __ROUTINE_H__ 12 | 13 | #ifdef CONFIG_OBJ_ROUTINE 14 | 15 | class RoutineView: public EList { 16 | public: 17 | EBuffer *Buffer; 18 | 19 | RoutineView(int createFlags, EModel **ARoot, EBuffer *AB); 20 | virtual ~RoutineView(); 21 | virtual EEventMap *GetEventMap(); 22 | virtual int ExecCommand(int Command, ExState &State); 23 | virtual void DrawLine(PCell B, int Line, int Col, ChColor color, int Width); 24 | virtual char* FormatLine(int Line); 25 | virtual int Activate(int No); 26 | virtual void RescanList(); 27 | void UpdateList(); 28 | virtual void GetName(char *AName, int MaxLen); 29 | virtual void GetInfo(char *AInfo, int MaxLen); 30 | virtual void GetTitle(char *ATitle, int MaxLen, char *ASTitle, int SMaxLen); 31 | }; 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /s_direct.h: -------------------------------------------------------------------------------- 1 | /* s_direct.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __SDIRECT_H 11 | #define __SDIRECT_H 12 | 13 | // error handling needs some work 14 | 15 | #define fiUNKNOWN 0 16 | #define fiFILE 1 17 | #define fiDIRECTORY 2 18 | 19 | class FileInfo { 20 | private: 21 | char *name; // minimum set of file information 22 | off_t size; 23 | time_t mtime; 24 | int type; 25 | 26 | public: 27 | FileInfo(char *Name, int type, off_t Size, time_t MTime); 28 | ~FileInfo(); 29 | 30 | char *Name() { return name; } 31 | off_t Size() { return size; } 32 | int Type() { return type; } 33 | time_t MTime() { return mtime; } 34 | }; 35 | 36 | #define ffFAST 1 // optimization for UNIX (return name only, NO TYPE CHECK), ignored on OS/2 and NT 37 | #define ffFULLPATH 2 // return full path to files 38 | #define ffDIRECTORY 4 // return directories beside files (see ffFAST) 39 | #define ffHIDDEN 8 // return hidden files (dot-files for UNIX) 40 | 41 | class FileFind { 42 | private: 43 | char *Directory; 44 | char *Pattern; 45 | int Flags; 46 | 47 | #if defined(USE_DIRENT) 48 | DIR *dir; 49 | #elif defined(OS2) && !defined(USE_DIRENT) 50 | unsigned long dir; // should be HDIR, but we don't #include huge os2.h globally 51 | #elif defined(NT) && !defined(USE_DIRENT) 52 | unsigned long dir; // should be HANDLE 53 | #endif 54 | 55 | public: 56 | FileFind(const char *aDirectory, const char *aPattern, int aFlags); 57 | ~FileFind(); 58 | 59 | int FindFirst(FileInfo **fi); 60 | int FindNext(FileInfo **fi); 61 | }; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /s_files.h: -------------------------------------------------------------------------------- 1 | /* s_files.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __FILESYS_H__ 11 | #define __FILESYS_H__ 12 | 13 | #define SDOT "." 14 | 15 | #ifdef UNIX 16 | #define SLASH '/' 17 | #define SSLASH "/" 18 | 19 | #define ISSLASH(c) ((c) == SLASH) 20 | #define ISSEP(c) ((c) == SLASH) 21 | #endif 22 | 23 | #if defined(OS2) || defined(NT) || defined(DOS) || defined(DOSP32) 24 | #if defined(DJGPP) 25 | #define SLASH '/' 26 | #define SSLASH "/" 27 | #else 28 | #define SLASH '\\' 29 | #define SSLASH "\\" 30 | #endif 31 | 32 | #define ISSLASH(c) (((c) == '/') || ((c) == '\\')) 33 | #define ISSEP(c) (((c) == ':') || ISSLASH(c)) 34 | #endif 35 | 36 | char *Slash(char *Path, int Add); 37 | char *SlashDir(char *Path); 38 | int ExpandPath(const char *Path, char *Expanded); 39 | int CompletePath(const char *Path, char *Completed, int Num); 40 | int IsSameFile(const char *Path1, const char *Path2); 41 | int JustDirectory(const char *Path, char *Dir); 42 | int JustFileName(const char *Path, char *Name); 43 | int JustLastDirectory(const char *Path, char *Dir); 44 | int JustRoot(const char *Path, char *Root); 45 | int FileExists(const char *Path); 46 | int IsFullPath(const char *Path); 47 | int IsDirectory(const char *Path); 48 | const char *ShortFName(const char *Path, int len); 49 | int ChangeDir(char *Dir); 50 | int JoinDirFile(char *Dest, const char *Dir, const char *Name); 51 | char *SepRChr(char *Dir); 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /s_util.h: -------------------------------------------------------------------------------- 1 | /* s_util.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __EDITOR_H__ 11 | #define __EDITOR_H__ 12 | 13 | #define USE_CtrlEnter 1 14 | 15 | #define S_BUSY 0 16 | #define S_INFO 1 17 | #define S_BOLD 2 18 | #define S_ERROR 3 19 | 20 | char* MakeBackup(char *FileName, char *NewName); 21 | 22 | int GetPMClip(); 23 | int PutPMClip(); 24 | 25 | int FileLoad(int createFlags, const char *FileName, const char *Mode, EView *View); 26 | int MultiFileLoad(int createFlags, const char *FileName, const char *Mode, EView *View); 27 | int ParseSearchOption(int replace, char c, unsigned long &opt); 28 | int ParseSearchOptions(int replace, const char *str, unsigned long &Options); 29 | int ParseSearchReplace(EBuffer *B, const char *str, int replace, SearchReplaceOptions &opt); 30 | int SetDefaultDirectory(EModel *M); 31 | int GetDefaultDirectory(EModel *M, char *Path, int MaxLen); 32 | int UnTabStr(char *dest, int maxlen, const char *source, int slen); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /sysdep.h: -------------------------------------------------------------------------------- 1 | /* sysdep.h 2 | * 3 | * Copyright (c) 1994-1996, Marko Macek 4 | * 5 | * You may distribute under the terms of either the GNU General Public 6 | * License or the Artistic License, as specified in the README file. 7 | * 8 | */ 9 | 10 | #ifndef __SYSDEP_H 11 | #define __SYSDEP_H 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #if defined(AIX) || defined(SCO) || defined(NCR) 19 | #include 20 | #endif 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #ifdef DBMALLOC 29 | #include 30 | #endif 31 | 32 | #if !defined(OS2) && \ 33 | !defined(NT) && \ 34 | !defined(DOSP32) && \ 35 | !defined(LINUX) && \ 36 | !defined(HPUX) && \ 37 | !defined(AIX) && \ 38 | !defined(IRIX) && \ 39 | !defined(SCO) && \ 40 | !defined(SUNOS) && \ 41 | !defined(NCR) 42 | # error Target not supported. 43 | #endif 44 | 45 | #if defined(UNIX) || defined(DJGPP) || defined(WATCOM) 46 | # define USE_DIRENT 47 | #endif 48 | 49 | #if defined(USE_DIRENT) // also needs fnmatch 50 | #ifdef WATCOM 51 | # include 52 | #else 53 | # include 54 | #endif 55 | #endif 56 | 57 | #if defined(UNIX) 58 | # include 59 | # include 60 | # if defined(__CYGWIN__) 61 | # include "fnmatch.h" 62 | # else 63 | # include 64 | # endif 65 | # define strnicmp strncasecmp 66 | # define stricmp strcasecmp 67 | # define filecmp strcmp 68 | //# define memicmp strncasecmp // FIX, fails for nulls 69 | extern "C" int memicmp(const void *s1, const void *s2, size_t n); 70 | #endif 71 | 72 | #if defined(OS2) 73 | # include 74 | # if !defined(__TOS_OS2__) 75 | # include 76 | # endif 77 | # include 78 | # include 79 | # if defined(BCPP) || defined(WATCOM) || defined(__TOS_OS2__) 80 | # include 81 | # endif 82 | # if defined(BCPP) 83 | # include 84 | # endif 85 | # define filecmp stricmp 86 | # if !defined(__EMX__) 87 | # define NO_NEW_CPP_FEATURES 88 | # endif 89 | #endif 90 | 91 | #if defined(DOS) || defined(DOSP32) 92 | # include 93 | # include 94 | # include 95 | # include 96 | # define NO_NEW_CPP_FEATURES 97 | # if defined(BCPP) 98 | # include 99 | # endif 100 | # if defined(WATCOM) 101 | # include 102 | # endif 103 | # if defined(DJGPP) 104 | # include 105 | # include 106 | # undef MAXPATH 107 | extern "C" int memicmp(const void *s1, const void *s2, size_t n); 108 | # endif 109 | # define filecmp stricmp 110 | #endif 111 | 112 | #if defined(NT) 113 | # include 114 | # include 115 | # include 116 | # include 117 | # if defined(MSVC) 118 | # include 119 | # endif 120 | # if defined(WATCOM) 121 | # include 122 | # endif 123 | # if defined(BCPP) 124 | # include 125 | # endif 126 | # if defined(MINGW) 127 | # include 128 | # endif 129 | # define filecmp stricmp 130 | # define popen _popen 131 | # define pclose _pclose 132 | #endif 133 | 134 | #ifndef MAXPATH 135 | # define MAXPATH 1024 136 | #endif 137 | 138 | #ifndef O_BINARY 139 | # define O_BINARY 0 /* defined on OS/2, no difference on unix */ 140 | #endif 141 | 142 | #if defined(OS2) || defined(NT) 143 | # if defined(__EMX__) || defined(WATCOM) || defined(__TOS_OS2__) 144 | # define FAKE_BEGINTHREAD_NULL NULL, 145 | # else 146 | # define FAKE_BEGINTHREAD_NULL 147 | # endif 148 | #endif 149 | 150 | #if !defined(__IBMC__) && !defined(__IBMCPP__) 151 | # define _LNK_CONV 152 | #endif 153 | 154 | #define PT_UNIXISH 0 155 | #define PT_DOSISH 1 156 | 157 | #ifndef S_ISDIR // NT, DOS, DOSP32 158 | # ifdef S_IFDIR 159 | # define S_ISDIR(mode) ((mode) & S_IFDIR) 160 | # else 161 | # define S_ISDIR(mode) ((mode) & _S_IFDIR) 162 | # endif 163 | #endif 164 | 165 | #ifndef S_IWGRP 166 | #define S_IWGRP 0 167 | #define S_IWOTH 0 168 | #endif 169 | 170 | #if defined(OS2) || defined(NT) || defined(DOSP32) || defined(DOS) 171 | #define PATHTYPE PT_DOSISH 172 | #else 173 | #define PATHTYPE PT_UNIXISH 174 | #endif 175 | 176 | #endif 177 | --------------------------------------------------------------------------------