File: README

package info (click to toggle)
sunclock 3.57-15
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,620 kB
  • sloc: ansic: 14,419; makefile: 815; perl: 111; sh: 33
file content (331 lines) | stat: -rw-r--r-- 12,316 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
Edt - small footprint Wordstar clone for VT100 terminals
Emt - small footprint Emacs clone for VT100 terminals
Edx - small footprint Wordstar clone for the X Window system
Emx - small footprint Emacs clone for the X Window system

Version 1.01, June 19, 2002
(C) 2002 Jean-Pierre Demailly <demailly@ujf-grenoble.fr>

This package is derived from the Editor Kit edx-0.56 by Terry Loveall. 
Aside minor improvements of the editing routines (unlimited buffer size,
left and right justification), it adds a variant of edx (aka emx) which uses
Emacs bindings rather than Wordstar bindings. A compile switch also allows
to produce edt/emt for VT100 consoles rather than for the X Window system.
The editor engine is almost identical in all cases, provided by the 
routines contained in 'edit.c'. The programs just require the raw X11 
libraries (edx/emx), or the termcap library (edt/emt).

Various compile options can be used to increase or reduce the feature set
(see the Makefile for details).

In particular, the standard compile options yield the possibility to use
arbitrary key bindings, bound to Alt-? or Esc-!-?. They should
be copied to /usr/share/edmtx/edxrc (resp. to /usr/share/edmtx/emxrc, etc) 
for a system wide installation, or in $HOME/.edxrc (resp. $HOME/.emxrc, etc). 
Check 'rc.example' to get an idea.

==============================================================================

Copy of original README of edx-0.56 by Terry Loveall
----------------------------------------------------

Edx - an X wrapper around an ASCII terminal editor engine.
Copyright (C) 2002, Terry Loveall, email: <loveall@qwest.net>
This program is released into the public domain.

THIS PROGRAM COMES WITH ABSOLUTELY NO WARRANTY OR BINARIES. COMPILE AND USE 
AT YOUR OWN RISK.

To build: run 'make', copy the resulting binary named edx to some place in
your path or run it in the build directory with './edx'.

Please send any questions, bug fixes or improvements to the above email.
------------------------------------------------------------------------

                   ASCII Text Editor to X Conversion
                        and theory of operation

The purpose of the edx.c/eeng.c package is a proof of concept for converting a
'standard' ASCII terminal based text editor to the GUI X windows.

Using a text editor as a native window application enables the user to have 
multiple applications open simultaneously on screen. Yet the available X text
editors have always left something to be desired. Usually an incomplete or 
hostile UI coupled with one or more of the following: written in C++
preventing easy modification, over-sized binaries which are slow to load and
respond or just plain buggy code.

In the interest of attempting to alleviate some, if not all, of the above
complaints, the edx text editor is presented. It is composed of two files:
edx.c which provides the direct interface to X windows, and eeng.c which
provides a relatively simple basic text editor engine. 

Edx.c description:

The functions provided by edx.c are a generic set designed to provide all 
necessary functions that are not inherent to the text editor engine.

Edx.c provides the basic X windows initialization code, character/mouse input,
character/string output, cursor positioning, X clipboard selection and the
main event driven executive loop.

These are:

Cursor:

void gotoxy(int horz,int vert);
void cursor_draw(unsigned long color);
void draw_cursor();
void undraw_cursor();

Character:

void drawstring(char *str, int len);
void cputs(char *prntstr);
int putch(char chr);
void clreol();
void highvideo();
void lowvideo();
void clrscr();

Window support:

void bell();
void update();
void sig_handler(int);
void font_height(void);

X clipboard selection

int paste_primary(int win, int property, int Delete);
int request_selection(int time);
char *mrealloc(char *s, int len);
void set_selection();
void send_selection(XSelectionRequestEvent * rq);
void moveto();
void do_paste();
void do_select(int delete);

App Initialization and execution:

void init(int argc,char *argv[]);
void handle_key(char *astr, int skey, int state);
int main(int argc,char *argv[]);

--------------------------
Terminal X app conversion:

Converting an ASCII text editor, that runs in a terminal environment, to an
event driven windowed GUI app is fairly straight forward in concept.

The analysis results in a separation of functions into window dependent and
window independent.

For window dependent functions, analysis produces the following 6 categories:

1. Window creation and application initialization.
2. Executive loop and function dispatch.
3. Window support.
4. Character display
5. Cursor management
6. X clipboard/selection

A potential 7th category, dialogs, is not included in X for the sake of
program simplicity. Dialogs are presented and controlled in the context of the
ASCII status bar by the editor engine.

1. Window creation and application initialization:

The function 'main(argc, argv)' is where window creation and initialization is
controlled. The sequence is as follows:

    disconnect from the console

    call init:
      open the display
      setup to gracefully respond to exit requests from X
      establish window manager hints data structure
      setup font(s)
      setup window dimensions
      initialize clreol string to all blanks
      create the only window
      setup window hints
      setup window class resource names
      notify X on how to force the app to exit
      specify accepted XEvent loop events
      make the window real by mapping it
      create the Graphic Context for drawing purposes
      allocate required colors
      apply colors to window
      set the font

    App init in main()
      get command line options
      open a (possibly) named file for editing
      request/create WM_PROTOCOLS atom
      set up the signal handler response
      display the initial cursor

2. Executive loop and function dispatch:

At the successful completion of window creation and app initialization, 
execution enters the main() event loop, where requested events are decoded and
dispatched to the appropriate functions.

The event categories decoded are as follows:

    Expose
    MotionNotify
    ButtonPress
      Button1
      Button2
      Button3
    ButtonRelease
      Button1
      Button2
      Button3
    KeyPress
    ConfigureNotify
    ClientMessage
    DestroyNotify

The four event categories of concern are ButtonPress, ButtonRelease,
MotionNotify and KeyPress. 

The button and motion events call the editor functions which:

    set the cursor position, 
    select text with highlights and 
    insert text from a buffer.

KeyPress calls one of several key decoding functions that are mode specific in
the text editor engine. These modes correspond to:

    normal editor cursor and text input, 
    file and search string dialogs and 
    option settings.

3. Window support:

Window support amounts to only 5 functions that are broken out to improve
readability. They are:

    bell: make noise for incorrect input.
    update: redraw the screen.
    sig_handler: handle signal events from the OS.
    font_height: calculate font height.

4. Character display:

    drawstring is the basic text output.
    cputs outputs an ASCIIZ string.
    putch just outputs one char.
    lowvideo sets output to normal mode.
    highvideo sets output to highligted mode.
    clreol erases from the current output position to the right edge.
    clrscr erases the entire window.

5. Cursor management:

    gotoxy positions the cursor relative to the upper left window corner.
    cursor_draw draws a cursor at current location in the specified color.
    draw_cursor draws a cursor in the foreground color.
    undraw_cursor draws a cursor in the background color.

6. X clipboard/selection:

    mrealloc manages the buffer size for X selection
    paste_primary sequentially feeds chars to handle_char for pasting
    request_selection requests the current selection from XA_CUT_BUFFER0 if any
    set_selection processes and sends the marked block to XA_CUT_BUFFER0
    send_selection posts an event saying selection is available
	moveto mouse support convenience function for multiple calls
	do_paste paste function for both keyboard and mouse
	do_select also for both keyboard and mouse

-------------------
Eeng.c description:

Eeng.c provides window independent functions and is derived from a functional
ASCII text editor in a non-windowed environment. Changes made to eeng.c amount
to converting the following functions from loop form to single pass character
decoding: 

main executive:
    main_exec: dispatch ASCII characters and function keys for processing.

all ASCII text dialogs:
    file_save: file open/save/new.
    goto_line: request specified line number to goto.
    goto_col: request goto column in current line
    goto_search: request string to search for.
    goto_replace: request search string for search&replace operation.
    replace_with: request replace string for search&replace operation.
    ask_replace: confirm replacement (Y/N/Esc/!) for search&replace operation.
    tab_size: request new tab size.
    window_size: request new right margin for block reformat.
    block_read: request file name to insert at current position.
    block_write: request file name to write marked block to.

select and set options:
    show_mode: 

An additional change to the text dialogs was to use a generic string input
with prompt format and a callback. The callback provides specific processing
of the input string.

The change to a windowed environment also required replacing all terminal I/O
with equivalent X functions. This code did not change, but rather was replaced
by the same named X functions. These functions are comprised of the X cursor
and character groups. The major source difference was specifying function and
control keys from <X11/keysymdef.h>.

-----------------------------
Basic eeng.c code structures:

The center of the editor engine is the char* pointer 'line_start'. All 
operations center around it. cur_pos is calculated by 'line_start+x_offset'.
Conversion from screen x co-ordinate is accomplished with 'get_tru'. Moving
around within the text file always requires moving line_start and counting
EOLs.

Text display counts back 'y' number of lines to generate a complete screen in
the function 'show_scr'. There, the left margin display offset 'lxo' is used 
to determine the start of each display line. lxo is primarily maintained by
cursor_left and cursor_right functions.

Text insertion and deletion is provided by the function 'file_resize', which,
when destination address is greater than source, opens a gap for insert
operations, or deletes when destination address is less than source. Undo
recording basically monitors 'file_resize' plus a few special cases such as
block_fill and others.

Main program execution is controlled by the function 'main_exec' which is 
basically just a conditional state test to select the proper 'switch(key)'
function from one of key_normal, key_control, ctrlk_key, ctrlq_key, func_key
and key_alt. Each one of these decodes for a specific set of keys and the
key state from the global key event data structure 'keve'. From there, the
individual key functions are invoked.

X windows just passes basic key values and keyboard state. The difference
between an ASCII 'A' and a control 'A' is only in the bit indicating the
control key is pressed. The bad part is the program has to decode this in
order to respond reasonably. The good part is the program gets to decode this
in order to respond reasonably and controls _all_ decoding. If you do not like
the way edx operates you _can_ change it.

Marked block operation is comprised of flag[BLK], the char pointer 'mk' and
cur_pos. If flag[BLK] is set, only then can you have a marked block.

File operations are basically treated as block operations, and do very
conventional file I/O.

External program execution:

SYSTEM forks a new process to run '/bin/sh $@'
gorun invokes a dialog to get a command line from the user to execute
newedx invokes a new instance of edx
mterm opens an rxvt terminal in the current directory

For more detailed operation of the edx editor see the files 'MANUAL' and
'eeng.c'.