LibreLogiciel dot COM

Google
 
Web librelogiciel.com
Presentation
Software
Technical Support
Services
Contact
Links

Next Previous Contents

3. How to edit files with JERED ?

This editor has got a default built-in behaviour, but you can modify it by changing values in the profile files. Here you will study the default behaviour because the original profile files are exactly configured like the default built-in behaviour. Later you will see how to modify profile files.

When you run this program it first opens, loads and closes all the files you want to edit. Now lets study the user interface.

3.1 The User Interface

When you're editing a file, the screen is divided into three parts which are the status bar, the editing window and the help bar. When you want to do some actions, dialog boxes or alert boxes are eventually displayed, depending on the action to do. So let's begin with these boxes, then we will look at the three screen parts.

Alert Boxes

An alert box is made of a title, it is usually a question, and one or more buttons. You must select one of these buttons in order to answer to the question. There is always a default button, which is preselected. You can validate your choice by typing Enter or you can exit from the alert box by typing Escape. To select a button you must type either the Left or Right keys or the Tab key.

Dialog Boxes

A dialog box is made of a title and one or more fields. Each field could have a label and/or an help line. The label is usually displayed at the left of the field, the help line is displayed at the bottom of the screen. Fields are text areas that you must fill typing text in them. You can validate what you typed by typing Enter or exit from the dialog box by typing Escape. You can switch from one field to another by typing either the Up or Down keys or the Tab key.

The Status Bar

On the top line of the screen you can see informations about the current file being edited. These informations are from left ro right:

  • The cursor's current position in the file (column + line)
  • The total number of lines in the file
  • An indicator to show if you are recording or playing a macro
  • An indicator of the current insertion mode: Insert or Replace
  • The file's name

The Editing Window

In the region situated between the top and bottom lines of the screen there is the editing window. The file's content is displayed here and you can modify it by simply typing in new text. Like in any other text editor, the cursor's position is materialized by a blinking cursor.

You can directly type text, you needn't to switch between editing mode and command mode like in VI for example because you can type commands while you are typing text, this is really a great benefit for an easy to use editor.

The Help Bar

The help bar is on the bottom line of the screen. On this line important help or messages are displayed. By default it displays how to access to the most important functions of the editor, but you can change it as you want. You can highlight some parts of this line by preceding the text by a '&' (look at the default profile files to see what I mean).

3.2 The Default Key Mappings

Here you will learn all of the available functions of JERED. This section will describe the default key mappings but keep in mind that you can remap any key to any action. For each available action, I'll give you its goal and the key combination to produce it. Later you will learn the actions's internal names to allow you to remap keys to actions.

By default typing on a key produces the character written on this key on the keyboard but you can change this behaviour for example to get a Dvorak's keyboard or to write morse + plain text while you're typing (uncomment the lines in the default profile files to play morse macros and you will see how it works). The important thing to know is that you can map character strings to keys, not only one character, you can map recorded or written macros and finally you can map actions to keys. Of course you can't map a string plus a macro plus an action to the same key.

As what you can expect, you can use the arrow keys to move in the text, you can of course use PageUp, PageDown, Del, BackSpace, Tab, because they work like you want.

Home moves the cursor to the beginning of the current line while End moves it to the end of the current line.

There are small differences with other text editors: the Enter key inserts a new blank line under the current one without cutting the current line at the cursor's position.

Shift_TAB doesn't seem to work properly for me and if it is your case you can type Ctrl_T to do the same action. It is probably a problem in ncurses or in the terminfo database.

The Insert key is a switch between Insertion (default) and Replace modes.

However these differences may be modified to suit your needs by remapping the related keys to other preferred actions.

For these reasons what you just have to learn is all the default remapped keys. What I call a remapped key is a key which doesn't produce what is written on it on the keyboard. We needn't to learn that typing a 'A' will produce a 'A' because it is what people expects even if you can modify this to produce a 'B' or a 'You press a A but I type a string'

You can precede each key by Escape to multiply by two the number of accessible keys. Of course you can use the Shift or Control keys to do key combinations which are remappable too. However the Alt keys don't work for me, it is probably a problem in ncurses or in the terminfo database. Typing on the Escape key will display a new help bar showing that the editor is waiting for you to type a new key in order to make a keys sequence. There is about a one second delay for this new help bar to appear on the bottom of the screen. The system will *not* respond to another keypress *until* the new help bar is displayed. My explanation, which is also the ncurses writer's explanation: When you type Escape, the 1 second pause is done to distinguish between the user typing Escape and another key, and the user typing an extended key, which returns an extended code beginning with the escape code. This last thing will be immediate, but we must do a pause to determine if it is a user escape key or an extended key code. If the rest of the code is received immediately, then it is an extended code beginning with escape, if it is not immediate, then we are sure the user really pressed the escape key. Maybe the pause is too long but I don't know if it is possible to change it without modifying and recompiling ncurses. After you have hit the Escape key, the system is waiting for you to type another key so that it may execute the command to which that ESC+key is mapped. If you wish to cancel the pending action, hit the Escape key a second time. The "normal" help bar will appear on the bottom of the screen.

Execute an External or Internal Command - Press F1

A dialog box is displayed to allow you to enter a command to be executed. Commands may be external commands or internal ones. All the internal commands must begin with ':'. Any command which doesn't begin with the character ':' is passed directly to the shell to be executed. An acceptable external command could be any command recognized by your operating system. Later you will learn all the available internal commands.

When you launch an external command, the screen is cleared then the result of your command will appear on the screen, and you will be given a Press any key prompt. When you press any key you will be back where you were before you typed the external command. If there is more output than a single screen, you can control the output of your command by piping it to more (or, preferably, less)

E.g. to examine a big directory, which would normally scroll off the JERED screen, type:

ls /tmp/joe | less

You will be able to view the output from "less" as you would expect, and only return to JERED by first exiting from less (by use of the q key), then by typing any other key.

Do an escape to the Shell - Press F2

You temporarily quit the editor to go to the shell. If possible the prompt is modified to show you are still in an editing session. You can return to the editor by typing exit

If your aliases are defined in your .profile, they will not be active because the .profile file is only read upon login; however, if your aliases are defined in your shell configuration file (as e.g. .bashrc) they will be active, since the .bashrc file is read whenever bash is executed.

Quit the File or the Editor - Press F3

If the file was modified but not saved, this key will show an alert box asking you if you really want to quit. If you choose YES or if the file wasn't modified then the memory used by this file is freed and the editor switches to the next file being edited if any, otherwise the program exits. If you choose NO, nothing happens and you stay where you were.

Save the File - Press F4

The file being edited is saved to disk if it was modified since the last save.

Find & Replace - Press F5

A dialog box is displayed to allow you to type a text string to be searched, eventually a text string to replace with, and if you want to ignore case while searching.

If you press Enter and nothing appears to happen, i.e. the cursor stays where it was, this means that there has been no occurence of the search string found in the text.

Only the currently active file is searched, from the beginning of the cursor's line (I know, this should be modified !!!) to the end of the file.

When an occurence of the string is found you will be prompted on the bottom line of the screen with a Continue/Replace/All/Stop question.

Continue will search for the next occurence, Replace will replace the occurence with the replacing string. To delete occurences of a string, leave the replacing string empty and choose Replace when an occurence is found. All will replace all occurences of the string till the end of the file. For security reasons you can't choose All when the replacing string is empty. Stop will stop the search immediately.

Mark a Block of Lines - Press F6

If a block already exists, adds all the lines between the block and the current line to the block, otherwise creates a new block with the current line.

E.g. If you have a line marked and move the cursor somewhere off the marked line (say down 5 lines for example) and press this key again, all the lines between the original marked line (or marked block) and the current cursor line will be marked.

If it does not result in a highligted action visible on your screen it is likely because there is already another highlighted block in some other file in the edit files buffer. There may be only *one* highlighted block at a time in all the files in the edit buffer.

Unmark a Block of Lines - Press F7

If a block exists, unmarks all the lines of this block even if it is in another file than the current one.

Copy a Block of Lines - Press F8

Copy ( i.e. replicate) the current marked block just under the current cursor line. The cursor line must be OUTSIDE the highlighted marked block or the copy will not occur.

Move a Block of Lines - Press F9

Move the current marked block from where it is, to just under the current cursor line. The cursor line must be OUTSIDE the highlighted marked block or the move will not occur.

Remove a Block of Lines - Press F10

Remove the marked block. This action requires a confirmation from the user to actually carry out this command, since there is no way to undo it.

Get the ManPage on the Current Word - Press F11

Launch the man command with the current word as a parameter, e.g. if you are typing a program and you want to use the printf function but you don't remember its syntax, simply move the cursor to the word printf in your program and press this key.

Get the Gnu InfoPage on the Current Word - Press F12

Launch the info command with the current word as a parameter, e.g. if you are typing a program and you want to use the printf function but you don't remember its syntax, simply move the cursor to the word printf in your program and press this key.

Redraw the Screen Enterely - Press Ctrl_L

When something is written on the screen above the file you are editing, for example if someone issue a write command to you, you can redraw the entire screen from scratch by typing this key.

Switch to the Next File - Press Ctrl_N

All the edited files are loaded in a circular ring buffer, so when you press this key you go from one file to the next on the ring. Of course the file you leave stays in memory and you can go back to this file typing this key several times.

Begin/Stop a macro Recording - Press Ctrl_R

When you press this key for the first time, a macro file named macro.jem is created in the current directory. Whatever you will type to the keyboard until the next time you press this key will be done (of course) and recorded. When you press this key for the second time, a dialog box is displayed to allow you to give another name to this macro to save it permanently. You can either enter a new name or press Escape if you don't want to save it permanently. In all cases the new macro is immediately available to be replayed. There is no size limit for a macro.

Play a Recorded Macro - Press Ctrl_P

Plays the current macro (the file ./macro.jem). Eventually stops a macro recording but does not allow a name to be given to this macro.

Cut the Current Line - Press Ctrl_W

This will cut the current line in two parts at the cursor's position. The left part stays where it was but the right part is moved to the following line.

Delete the Current Line - Press Ctrl_Y

This key will delete the line where the cursor is.

Put JERED in the Background - Press Ctrl_Z

Like in most of the existing programs, you can press this key to put the editor in the background, so you're back to the shell but JERED is still here. You can return to the editor by typing the unix command

fg

Go to the Next Paragraph - Press ESC then Down

This key moves the cursor to the first line of the next paragraph. A blank line counts as a paragraph of one line.

Go to the Previous Paragraph - Press ESC then Up

This key moves the cursor to the line just above the current paragraph.

Go to the Next Word - Press ESC then Right

This key moves the cursor to the first character of the next word on the same line.

Go to the Previous Word - Press ESC then Left

This key moves the cursor to the first character of the current word, then to the first character of the previous word on the same line.

Put a Block of Lines in Uppercase - Press ESC then 'u'

This key will convert all the marked lines to Uppercase.

Put a Block of Lines to Lowercase - Press ESC then 'l'

This key will convert all the marked lines to Lowercase.

Align a Block of Lines to the Cursor's Column - Press ESC then 'a'

If you press this key while a block of lines exists, all the block will be aligned to the cursor's current column, keeping indentation if possible.

Reformat a Block of Lines - Press ESC then 'r'

Reformats the block of lines according to the WORDWRAPBEGIN and WORDWRAPEND variables of your JERED's profile files.

Get general help on JERED - Press ESC then 'H'

Loads the general help file of JERED, for now a sample text file is loaded but I will probably modify this behaviour to generate the general help file from this document using sgml2txt or something like that.

Get Help on Key Mappings - Press ESC then 'h'

This key will automatically and dynamically generate a help file according to the current key mappings inside JERED, this will allow you to learn how to use JERED whatever modifications are made to the default key mappings. The generated file is then loaded in JERED, just like any other file. This is probably one of the most important and useful functions of JERED.

3.3 Added Useful Key Mappings

In order for you to learn how to map text and macros to keys, some other actions are mapped to keys in the default profile file, but are not available if you don't use this profile file or don't install the macros. Here is a list of these available actions:

  • 'ESC then @' will type the text Jerome Alet - alet@librelogiciel.com
  • 'ESC then d' will create a do-while block:

    do
    {
    }
    while () ;
    

  • 'ESC then e' will create an else block:

    else
    {
    }
    

  • 'ESC then f' will create a for block:

    for (; ;)
    {
    }
    

  • 'ESC then i' will create an if block:

    if ()
    {
    }
    

  • 'ESC then s' will create a switch-case block:

    switch ()
    {
      case :
        break;
      default:
        break;
    }
    

  • 'ESC then w' will create a while block:

    while ()
    {
    }
    

  • 'ESC then /' will create a C comment:

    /* */
    

Many other actions are commented out in the default profile file, for example JERED can help you to write in morse code and plain text in the same time. To see what I mean just uncomment the morse macros lines in the default profile file.

3.4 Internal Commands

Here is a list of the internal commands of JERED, they are all accessible through the F1 key unless you've remapped this function to another key. When you type an internal command, it must begin with ':' otherwise it is considered to be an external command. Internal commands are case insensitive. With internal commands you can change internal variables values but you will see these variables later, when you will learn how to configure JERED. For now let's begin with real internal commands. In the following lines we will consider that the F1 key is mapped to allow people to enter commands because it is the default behaviour.

The :NUM command

This command allows you to go directly to the line numbered NUM in the current file. If NUM is greater than the total number of lines in the current file then the cursor is moved to the bottom line of the file. If you type an illegal value then the cursor stays at its current position. For example, if you want to go to the 125th line of the file, just type:

F1 then :125

The :EDIT command

This command allows you to load another file in the memory and to switch to it for editing purpose. You can load a non existing file to create a new one. For now you can only load one file at a time with this command and there is no wildcard expansion. For example if you're editing a file and you want to load a new file, say foo.bar, just type:

F1 then :EDIT foo.bar

The :MACRO command

This command will change the default macro to be the macro you give the name in the dialog box. This macro will then become accessible through the Play a Recorded Macro - Press Ctrl_P function. For example if you want the current macro to be my_macro.jem, just type:

F1 then :MACRO my_macro.jem
The macro my_macro.jem will be searched in the current directory, then in the directory indicated by the JEMACROS environnement variable.

The :HELP command

This command produces the same result as the Get general help on JERED - Press ESC then 'H' function.


Next Previous Contents

© 2000-2024 by Jerome Alet
Email : webmaster@librelogiciel.com