Professional Documents
Culture Documents
txt
Programming the HP49G editor with SystemRPL
===========================================
by Carsten Dominik <dominik@astro.uva.nl>
The HP49G ROM contains a number of supported entry points which can be
used to manipulate the editor from SysRPL programs. You can find out
where the cursor is, move around, insert and delete text, and search
for strings.
CONTENTS
========
1.
2.
3.
4.
5.
Introduction
Terminology
Examples
Executing commands from within the editor
Reference
5.1 Status
5.2 Inserting Text
5.3 Deleting Text
5.4 Moving the Cursor
5.5 Selection, Cut and Paste
5.6 Search and Replace
5.7 Evaluation
5.8 Miscellaneous
6. Acknowledgement
1. INTRODUCTION
===============
The HP49G has a builtin editor which is much faster and nicer than the
editor on the HP48. However, it is a general-purpose editor, and it
would be useful for specific applications to add some features without
having to write a whole new editor.
The HP49G ROM contains a number of supported entry points which can be
used to manipulate the editor from programs. Of course, these
programs will not be overly fast since they are written in System RPL
and not in Assembler like the builtin editor commands. But speed is
sufficient for simple tasks like inserting a template.
I don't know about any documentation on these entry points, but one
can guess some of them by looking at names containing "CMD" (probably
for "command line") or "CURS" for cursor. Other possible entry points
can be selected by proximity in ROM address to known editor commands.
This document summarizes information I have collected by trial and
Pgina 1
editor49.txt
error. Please send corrections and further discoveries to me: Carsten
Dominik <dominik@astro.uva.nl>.
2. TERMINOLOGY
==============
EditLine
Cursor position
Current line
Editor window
Selection
Word-start
Invisible chars
editor49.txt
3. EXAMPLES
===========
TakeOver
CMD_END_LINE
RCL_CMD_POS
CMD_STO_FIN
CMD_DEB_LINE
RCL_CMD_POS
CMD_STO_DEBUT
CMD_COPY
TakeOver
SELECT.LINE
CMD_COPY
b) Insert a ':: ;' template on a single line and position the cursor
between '::' and ';'.
::
TakeOver
":: ;"
CMD_PLUS
CMD_BAK
CMD_BAK
TakeOver
"::\0A\0A;"
CMD_PLUS
Pgina 3
editor49.txt
CMD_UP
SPACE$
CMD_PLUS
d) Go to next label.
::
TakeOver
"\0A*"
FindStrInCmd
IT ::
DROP
#1+
STO_CURS_POS
;
DROP
RCL_CMD
RCL_CMD_POS
DUP
GET.W<#1+SWAP
SUB$
(recall EditLine)
(current position)
(arg needed by GET.W<-)
(position of word start)
(prepare args for SUB$)
(get the substring)
Blank$
CMD_DEB_LINE
RCL_CMD
RCL_CMD_POS #1+ SUB$1
BINT42
OVER#=case
:: 2DROP
CMD_DOWN
;
BINT32 >#?SKIP
::
CMD_END_LINE
RCL_CMD_POS
CMD_DEB_LINE
DO>Skip
RCL_CMD_POS
#<ITE
DROPRDROP
DoFarBS
;
CMD_PLUS
CMD_DEB_LINE
CMD_DOWN
editor49.txt
(Line starts with whitespace:)
(Remember end of line position)
(back to beginning of line)
(jump to next word)
(Oops: already in next line: Exit)
(Kill whitespace before first word)
(Insert spaces)
(Back to beginning of line)
(Next line)
"Edit this!"
""
zero
zerozerozero
{
{
"SLINE"
::
TakeOver
SELECT.LINE
;
}
{
"CLEAR"
::
TakeOver
DEL_CMD
;
}
}
(prompt)
(initial string)
(cursor position)
(modes)
Pgina 5
editor49.txt
(initial menu line)
(abort flag)
(parse)
(and GO!)
ONE
TRUE
ZERO
InputLine
5. REFERENCE
============
The following table lists all entry points I know of which can be used
to manipulate the editor. This list may be incomplete. Let me know
if you find additional information.
The table has the following structure:
Entry name
----------
Address
-------
5.1 Status
---------RCL_CMD
2F196
EDITLINE$
2EEEB
RCL_CMD2
2F197
RCL_CMD_POS
2EF87
CURSOR@
2EF87
CAL_CURS_POS
2EF91
CAL_CURS_POS_VIS
2EF90
editor49.txt
invisible characters. The result can be
used by STO_CURS_POS_VIS to move the cursor
to that location.
( #line #col -> #pos )
RCL_CMD_MODE
2F199
STO_CMD_MODE
2F198
CMD_PLUS
2EF74
CMD_PLUS2
2F194
CMD_PLUS3
2F195
InsertEcho
2EF97
Echo$NoChr00
2F11C
TOGGLE_I/R
2577F
Pgina 7
editor49.txt
supported anyway and you can confidently
call it with its address (says JYA).
5.3 Deleting Text
----------------CMD_DEL
2EF82
CMD_DROP
2EF81
DEL_CMD
2EF95
DO<Del
2F2F0
DO>Del
2F2F1
DODEL.L
2F2F9
DoFarBS
2F2DD
DoFarDel
2F2DE
Same as RS+Del-> in
editor49.txt
STO_CURS_POS
2EF8B
STO_CURS_POS2
2EF8C
STO_CURS_POS3
2EF8D
STO_CURS_POS4
2EF8F
STO_CURS_POS_VIS
CMD_NXT
2EF7C
CMD_BAK
2EF7B
CMD_DOWN
2EF80
Next line.
(
->
)
CMD_UP
2EF7F
Same as as LEFT
Pgina 9
->
editor49.txt
)
CMD_DEB_LINE
2EF7D
Beginning of line.
(
->
)
Same as RS+LEFT.
CMD_END_LINE
2EF7E
Go to end of line.
(
->
)
Same as RS+RIGHT.
CMD_PAGED
2EF7A
CMD_PAGEL
2EF77
CMD_PAGER
2EF78
CMD_PAGEU
2EF79
DO<Skip
2F2EE
DO>Skip
2F2EF
DO>BEG
2F2E4
DO>END
2F2E5
GOTOLABEL
2F2E6
editor49.txt
CMD_STO_DEBUT
2EF83
CMD_STO_FIN
2EF84
RCL_CMD_DEB
2EF85
RCL_CMD_FIN
2EF86
ClearSelection
2F2DC
VERIF_SELECTION
2EF93
CMD_COPY
2EF8A
CMD_CUT
2EF88
CUT.EXT
2EF89
CMD_COPY.SBR
2F2FA
editor49.txt
selection first. If you don't use fonts,
:: RCL_CMD RCL_CMD_DEB RCL_CMD_END SUB$ ;
does something similar.
(
-> $sel )
PASTE.EXT
2EF94
SELECT.LINE
2F2E1
SELECT.LINEEND
2F2E2
2F2F2
GET.W->
2F2F3
GET.W<-
2F2F4
editor49.txt
the left of that position. Note the
asymmetry of this command and the previous.
( #pos -> #ws )
DOFIND
2F2E8
DONEXT
2F2EA
DOREPL
2F2E9
DOREPLACE
2F2EB
DOREPLACE/NEXT
2F2EC
REPLACEALL
2F2ED
REPLACEALLNOSCREEN 2F2FC
5.7 Evaluation
-------------EditSelect
2F2DF
EVAL.LINE
2F2E3
editor49.txt
Similar to EVAL.SELECTION, but without the
need to select the line first.
( ? -> ? )
EVAL.SELECTION
2F2FB
EXEC_CMD
2F2F8
?Space/Go>
2EF73
AddLeadingSpace
2EF76
AddTrailingSpace
2EF75
5.8 Miscellaneous
-----------------
Pgina 14
editor49.txt
ML entry point to get the size of the
EditLine. As ML entries cannot be called
directly from SysRPL, don't use it unless
you know the necessary magic.
:: RCL_CMD LEN$ ;
works for us assembler dummies ;-)
CMDSIZE
26855
CommandLineHeight
2EF9A
DOTEXTINFO
2F2DB
GET_CUR_FONT.EXT
2F2F6
NO_AFFCMD
2EF96
DispCommandLine
2F19E
?DispCommandLine
2F19F
PUT_STYLE
2F2F7
PUT_FONTE
2F2F5
editor49.txt
SELECT.FONT
2F2E7
ViewEditGrob
2F2E0
XLINE_SIZE
2EF92
6. ACKNOWLEDGEMENT
==================
Jean-Yves Avenard was kind enough to fill in the holes in the first
version of this document.
Pgina 16