Lugaru's Epsilon
Editor 14.04

Epsilon User's Manual and Reference
   Primitives and EEL Subroutines
      . . .
      Control Primitives
         Control Flow
         Character Types
         Examining Strings
         . . .
         Help Subroutines
      Input Primitives
         . . .
         Window Events
         Completion Subroutines
         Other Input Functions
         The Main Loop
         . . .
      Defining Language Modes
         Language-specific Subroutines

Previous   Up    Next
Listing Commands & Buffers & Files  Primitives and EEL Subroutines   Standard Dialogs

Epsilon User's Manual and Reference > Primitives and EEL Subroutines > Input Primitives >

Other Input Functions

get_strdef(char *res, char *pr, char *def)
get_strnone(char *res, char *pr, char *def)
get_string(char *res, char *pr)
get_str_auto_def(char *res, char *pr)
get_strpopup(char *res, char *title,
             char *def, char *help)

The subroutines get_string( ), get_strdef( ), and the rest each get a string from the user, and perform no completion. They each display the prompt, and accept a line of input with editing.

The get_strdef( ) routine additionally displays the default string (indicated by def) and allows the user to select the default by typing just the <Enter> key. The user can also pull in the default with Ctrl-s, and then edit the string if desired. While the other two functions use their prompt arguments as-is, get_strdef( ) constructs the actual prompt by adding a colon and space. If insert-default-response is zero, they also include the default value in the prompt, inside square brackets.

The get_strnone( ) subroutine works like get_strdef( ), except that the default string is not displayed in the prompt (even when insert-default-response is zero), and Epsilon won't replace an empty response with the default string. Use this instead of get_strdef( ) if an empty response is valid.

The get_str_auto_def( ) subroutine is like get_strdef( ), except it automatically provides the last response to the current prompt as a default.

The get_strpopup( ) subroutine is a variation of get_strnone( ) that is only available under Epsilon for Windows. It displays a simple dialog. The parameter title provides the dialog's title, and def provides the initial contents of the response area, which is returned in res. If the user presses the Help button, Epsilon will look up help for the specified command or variable name or other topic name in its help file.

int get_number(char *pr)
int numtoi(char *str)
int numtoi_with_base(char *str, int base)
int strtoi(char *str, int base)
int exptoi(char *str)
int evaluate_numeric_expression(char *expr)
char got_bad_number;

The get_number( ) subroutine is handy when a command needs a number. It prompts for the number using get_string( ), but uses the prefix argument instead if one is provided. It returns the number obtained, and also takes care of resetting iter if necessary. It also understands numbers such as 0x10 in EEL's hexadecimal (base 16) format, binary and octal numbers, and character codes like 'a'.

The numtoi( ) subroutine converts from a string to a number. It skips over any spaces at the beginning of its string parameter, determines the base (by seeing if the string starts with "0x" or similar), and then calls strtoi( ) to perform the actual conversion. The subroutine strtoi( ) takes a string and a base, and returns the value of the string assuming it is a number in that base. It handles bases from 2 to 16, and negative numbers too. It stops when it finds a character that is not a legal digit in the requested base. The numtoi_with_base( ) subroutine is similar, but where numtoi( ) assumes base 10 numbers when the user doesn't specify a base, with numtoi_with_base( ) you can specify a default base.

The evaluate_numeric_expression( ) subroutine evaluates an arithmetic expression that may contain operators like +, -, *, or /, returning its numeric value. It runs the EEL compiler to do this. The exptoi( ) subroutine does the same. However, it examines the expression first. If it contains no arithmetic operators, it calls numtoi( ) instead, which is significantly faster.

The numtoi( ) and exptoi( ) subroutines both also recognize a key name inside angle brackets, such as <Tab>, and return the key's numeric value. (The evaluate_numeric_expression( ) subroutine doesn't, only permitting proper EEL expressions.) The exptoi( ) subroutine is usually the best choice for evaluating numeric user input. The get_number( ) subroutine mentioned above calls it.

All these subroutines set the variable got_bad_number to a nonzero value if the string they receive doesn't indicate a valid number. They return the value zero in this case. If the string does represent a number, they set got_bad_number to zero.

int get_choice(int list, char *resp, char *title,
               char *msg, char *b1, char *b2,
               char *b3)
int get_key_choice(int list, char *resp, char *title, 
               char *msg, char *b1, char *b2, char *b3)
int select_menu_item(int resbuf, int menuwin,
                     int owin, int dir)

The get_choice( ) subroutine provides a way to ask the user to select one of a list of choices. The choices must appear in the buffer list, one to a line. The subroutine displays a pop-up window with the indicated title and shows the specified message.

Epsilon for Windows instead displays a dialog with the indicated title, and doesn't use the message. It uses the specified button labels (see the description of the button_dialog( ) primitive in Button Dialogs for details). The get_choice( ) subroutine puts the user's choice in resp and returns 1. If the user cancels, the subroutine returns 0.

If resp is initially nonempty, get_choice( ) will position point on the first line starting with that text. If resp is initially "", the subroutine won't change point in list.

The get_key_choice( ) subroutine is a variation on get_choice( ), designed to let the user select one of a series of options. Each of the lines in the buffer list should begin with a unique character. When the user presses that character, Epsilon moves to that entry in the list. This subroutine's behavior is otherwise identical to get_choice( ).

The get_choice( ) subroutine uses the select_menu_item( ) subroutine to handle user interaction. It takes the window handle menuwin of a window containing a list of choices and returns when the user has selected one. The parameter owin should be the handle of the window that was current before displaying menuwin. If resbuf is nonzero, Epsilon will copy the selected line to the specified buffer.

The parameter dir tells Epsilon how to behave when the user presses self-inserting keys like "a". If dir is zero, the subroutine interprets N and P to move forward and back, and Q to quit. Other normal keys are ignored. If dir is 1 or -1, and search-in-menu is nonzero, normal keys are added to the result, and Epsilon searches for the first (if 1) or last (if -1) item that matches.

Previous   Up    Next
Listing Commands & Buffers & Files  Primitives and EEL Subroutines   Standard Dialogs

Lugaru Epsilon Programmer's Editor 14.04 manual. Copyright (C) 1984, 2021 by Lugaru Software Ltd. All rights reserved.