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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<title>About Linux text editors / product announcement Issue 13</title>
</HEAD>
<BODY >
<H4>
"Linux Gazette...<I>making Linux just a little more fun!</I>
"</H4>
<P> <HR> <P>
<!--===================================================================-->
<center>
<H2>About Linux text editors / product announcement</H2>
<H4>By Oleg L. Machulskiy
<a href="mailto:machulsk@shade.msu.ru">machulsk@shade.msu.ru</a></H4>
</center>
<P> <HR> <P>
<ul>
<LI><A HREF="#txtunix">Generally about Linux text editors</A>
<LI><A HREF="#myreq">What I'd like to have in text editor</A>
<LI><A HREF="#Cex">Some program examples</A>
</ul>
<P>
<HR>
<P><A NAME="txtunix"></A><B>Generally about UNIX text editors</B> </P>
<P>All of my friends who use Linux always told me that text editors is
very important problem under this OS (I mean text-mode editors with 100K
executable for writing programs).
As I understand, this problem is not a problem of Linux itself,
but it's a problem of every UNIX. What's more I know which reasons cause
this trouble. There is two reasons: <TT>putc</TT> output to screen and
<TT>getc</TT> input from keyboard. In other OS-es user (programmer) can
catch <TT>Alt+<letter></TT> or <TT>Shift+<letter></TT> keystrokes
and use it as a commands of editor. In UNIX user has only 256 ASCII-codes
avialable (really, much less than 256) and because of it every UNIX editor
uses either very long sequences of keystrokes as editing commands (as emacs
or joe) or it has two editing modes (command mode and typing mode in VI
for example). On X-s everything is better, because here we can get scan
code (not real scan, but this code is anough for all my needs)
of the key pressed and status of Shift-keys (Alt, Caps, Shift, Ctrl
and mouse buttons), so we can use functional keys, arrow-keys and everything
else You can find on Your keyboard (everybody knows how to do that).
</P>
<P>But even with text mode editors under Linux everything is not so bad:
You can switch keyboard to <A HREF="#Cex">RAW mode</A>
and do with it all You want (don't
forget to get another console from which You will execute <TT>shutdown
-r now</TT> command during beta-testing Your program). But it's very important
to understand that RAW-keyboard programs will not work through telnet.
Also is very important to set <TT>SIGSEGV</TT> and <TT>SIGKILL</TT> signal
handlers so that they'll switch keyboard back to normal mode from RAW when
something happens.
Once I heard about kernel patching so that You can use <TT>ScrollLock</TT>
key to switch between raw and normal mode, but I don't know how to apply
this patch. </P>
<P>
<HR>
<P><A NAME="myreq"></A><B>What I'd like to have in text editor</B> </P>
<P><i>Caution :</i> This section is very private. Maybe someone will find something useful
for him(here) here, but probably not. This section is mostly about my own
text editor, so, if You got used to Turbo-Vision-like editors and You're
satisfied, then probably You will find the follwing not interesting. So
don't read it, don't waste Your time.</P>
<OL>
<B><LI></b>Editor must be the same on every operating system
(multi-platform).
<P><B><LI></B>Editor must handle advanced search feature: I need not only
case sensetive/insensetive search, but as a minimum a wildcard searh or
regular expressions search (this type of search includes wildcards).
<P><B><LI></B>Editor must support projects: user must be able to create
a list of files (sources of some program) and walk through these files
freely (enter into file, quit from file, switch to another file, ...).
The possible solution is to assign some keystroke as an "enter-into-file"
command, and then, when user invokes "enter-into-file", open
a file with a name similar to the word under cursor (For example, you can
enter in h-file from the text of c-program; just move cursor to the #include
"..." statement and press the "enter-into-file" key).
<P><B><LI></B>Editor must handle many files opened at the same time so
that user can freely move from one text to another (very often I need to
read declarations of functions in <TT>.h</TT> files)
<P><B><LI></B>Editor must support compiling, make etc. from within text
editor (generally: execution OS command from within editor)
<P><B><LI></B>Commands must be rather simultaneous pressings of a few keys
than sequences of keystrokes. It seems to me, it isn't comfortable to type
(F10, 'F', 'O' , <TT>filename</TT>) every time You need to open a new file.
Besides, with such a keyboard layout it's impossible to work fast. This
requirement causes a problem: text editor cannot work through telnet, because
telnet protocol transfers only ASCII-codes, but not scan-codes.
<P><B><LI></B>Text editor must consider a text not as a sequence of chars
but as a sequence of lines, where each line is a sequence of chars. There
is a lot of text editors in which text is a vector (For example ME (MSDOS
MultiEdit) , Turbo Editor (Borland Programming Environments), JOE (linux),
etc.), But I don't know how to work with tables in these editors or how
to set <TT>//</TT> (C++ comment) at the beginning of 10 lines of program
on the screen.
<P><B><LI></B>Editor must support macrocommands as a recordable sequences
of keystrokes.
<P><B><LI></B>If editor supports programming language, so that I can write
my own commands, it would be fine.
<P><B><LI></B>I think programs-structurizing is very useful feature.
I'll explain: I'd like to have text of my program in pre-hypertext
form so that I see a list of functions on the screen, I put cursor
on the name of desired function, press "open"-key and now I can
edit source of that function, but besides that I must be able
to edit this file with usual text editor and I must be able
to compile that file without errors, hence all additional info
about hypertext structure of program must be placed into comments
(comments are specific for each file type, but in most cases
it depends on file extension).
<P><B><LI></B>Keyboard layout must be as much tunable as possible (if
my <TT>End</TT> key is broken, I can use <TT>F11</TT> key instead). Besides
I often need keyboard layout for second language (cyrillic).
<P><B><LI></B>I don't like when editor wastes screen space on frames of
windows or any other unuseful things (80 * 25 isn't very roomy)
<P><B><LI></B>Font on the screen must be fixed (I hate proportional fonts).
</ol>
<P>
If You're interested in all that, You can try our example of such a text editor.
I think it isn't the best editor, but I got used to it. May It will be useful for
someone. To get it, go to
<A HREF="http://shade.msu.ru/~machulsk">http://shade.msu.ru/~machulsk</A>
and download 330K zip file,
which contains sources and 5 executables for
Linux console, Linux X11, OS/2, DOS and Win32 (95/nt).
Docs are also included in HTML / plainTeX format.
<P>
<HR>
<P><A NAME="Cex"></A><B>Example of switching to RAW keyboard mode (C++ syntax)</B> </P>
<pre>
#include < stdio.h >
#include < stdlib.h >
#include < unistd.h >
#include < errno.h >
#include < linux/kd.h >
#include < signal.h >
#include < sys/ioctl.h >
/*.................*/
void Terminate(int a) {
if( ioctl(con_fd,KDSKBMODE,om)<0 ) {puts("Press RESET?");exit(-1);}
/*trying to set old keydoard mode*/
}
/*.................*/
class TKeyboard{
int om; /* old keyboard mode descriptor */
int con_fd; /* console descriptor */
TKeyboard(){
signal(SIGKILL, Terminate ); /*setting SIGKILL signal handler*/
signal(SIGQUIT, Terminate ); /*setting SIGQUIT signal handler*/
signal(SIGSEGV, Terminate ); /*setting SIGSEGV signal handler*/
if( 0==(con_fd=open("/dev/tty",O_RDWR)) ) {puts("error");exit(-1);}
/*getting console descriptor*/
if( ioctl(con_fd,KDGKBMODE,&om)<0 ) {puts("error");exit(-1);}
/*getting old keydoard mode*/
if( ioctl(con_fd,KDSKBMODE,K_RAW)<0 ) {puts("error");exit(-1);}
/*setting RAW keydoard mode*/
}
~TKeyboard(){
Terminate(0);
}
int GetScanCode(){
int c;
ioctl(con_fd,TIOCINQ,&cd); /*query*/
if(cd==0) /*keyboard buffer is empty*/
read(con_fd,&c,1); /*get next scancode from console*/
}
} KBD;
/*.................*/
void main() {
/*.................*/
/*................. program body */
/*.................*/
}
</PRE>
<hr>
<p>Thank You!</p>
<ADDRESS> My addresses:
<I><A HREF="mailto:machulsk@shade.msu.ru">machulsk@shade.msu.ru</A></I>
</ADDRESS>
<A HREF="http://shade.msu.ru/~machulsk">homepage on(in?) Shade</A>
<hr>
<p><I>scuze me for bad english, but my native language is Russian
</I></p>
<P> <hr> <P>
<center><H5>Copyright © 1997, Oleg L. Machulskiy<BR>
Published in Issue 13 of the Linux Gazette</H5></center>
<!--===================================================================-->
<P> <hr> <P>
<A HREF="./lg_toc13.html"><IMG ALIGN=BOTTOM SRC="../gx/indexnew.gif"
ALT="[ TABLE OF CONTENTS ]"></A>
<A HREF="../lg_frontpage.html"><IMG ALIGN=BOTTOM SRC="../gx/homenew.gif"
ALT="[ FRONT PAGE ]"></A>
<A HREF="./smart.html"><IMG SRC="../gx/back2.gif"
ALT=" Back "></A>
<A HREF="./tkmail.html"><IMG SRC="../gx/fwd.gif" ALT=" Next "></A>
<P> <hr> <P>
</BODY>
</HTML>
|