home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
p2demo21.exe
/
PEL
/
MYMODE.PEL
< prev
next >
Wrap
Text File
|
1995-03-01
|
4KB
|
136 lines
#
# This file is meant to serve as a guide when creating your own emulation mode
# from scratch. For further assistance please refer to the emulation specific
# PEL files such as emacs.pel and brief.pel.
#
# Variables declared local in a file can be referenced anywhere within that
# file but not from any other file.
local my_keymap = -1; # variable that holds the key assignments for my_mode
local old_search_flags; # variable holding the old state of the search flags
function my_mode()
{
local prevPauseOnError
# check to see if we are already in "my" emulation mode, so we
# don't make all the assignments again.
if( emulation_mode == "my_mode" )
return;
# set the global variable pause_on_error to pause if an error or warning
# occurs during initialization of your mode
prevPauseOnError = pause_on_error
pause_on_error = 1
# emulation_mode is a PEL global variable indicating the current
# emulation mode
emulation_mode = "my_mode"
# add my_mode to the emulations array so it shows up in the settings notebook
emulations["my_mode"] = "My mode"
# Set the global variable search_flags to search the way you want.
# This example forces the search to be forward and have regular
# expressions on. You may set many global variables here such as
# linenumber format, scroll variables, window_flags and many more. For
# a more complete list see the online help "Variable" section. Remember
# that PEL functions and variables are case sensitive.
old_search_flags = search_flags
search_flags = SEARCH_FORWARD + SEARCH_REGEX
# execute this event so that you call the cleanup function of a previous
# emulation or any other functions attached to the changed emulation event.
execute_event_handler( EVENT_EMULATION_CHANGED )
# attach your own cleanup functions so you can restore the editor after
# you change emulation modes again
attach_event_handler( EVENT_EMULATION_CHANGED, function_id("mymode_exit") )
create_my_keymap()
# This command updates the keystrokes for the pulldown menus, if you map
# any keystrokes to the same functions that the menu item calls.
fix_menu_text()
pause_on_error = prevPauseOnError
}
global function create_my_keymap()
{
# Here you define "my_keymap". After creating a new keymap that has the
# factory default mappings to begin with, you map any other keys you want
# using the assign_key function (See documentaion for a full description of
# this function.) If the keymap already exists, you can skip the creation
# and assignment of keys.
if( my_keymap >= 0 )
{
current_keymap = my_keymap
}
else
{
current_kemap = my_keymap = create_keymap( factory_keymap )
# Here you may add any keybindings you wish
assign_key( "<Ctrl-Z>", "gui_find" ) # gui_find is provided in gui_srch.pel
assign_key( "<Backspace>", "delete_left" )
assign_key( "<Ctrl-Alt-Shift-N>", "nimble_fingers" )
}
}
function delete_left()
{
local ch, answer, p_string
prev_char()
ch = read_buffer(1)
p_string = sprintf("Are you sure you want to delete this '%s' (y/n)? ", ch)
answer = prompt(p_string, "n")
if(tolower(substr(answer, 1, 1)) == "y")
delete_chars()
else
next_char()
}
function nimble_fingers()
{
goto_buffer_top()
drop_anchor()
goto_buffer_bottom()
delete_to_scrap()
raise_anchor()
message("Buffer deleted to scrap")
}
global function mymode_exit()
{
# You may reset any variables you changed when the emulation mode was
# initialized.
search_flags = old_search_flags
message("Thank you for using my emulation mode.");
}