| H A N _ T E R M I F H ( )
| | | | | SOURCE: qdev_autodocs.txt 1.163 (12/09/2014) English
AMIGA - HAN_#?
----------------------------------------------------------------------------
NAME
han_termifh() - Read/write capable virtual terminal
handler for use with 'mem_openifh()'.
SYNOPSIS
osigs = han_termifh(sigs, id);
__saveds __interrupt ULONG han_termifh(
register ULONG __asm("d0"),
register struct mem_ifh_data * __asm("a1"));
FUNCTION
This handler emulates 'console.device' entriely in
memory. It is the most advanced packet handler of all
handlers in this library.
INPUTS
sigs - Current signals.
id - Handler exception data.
RETURNS
Returns the 'sigs' back to 'exec'.
BASES
SysBase
NOTES
This handler requires special preparation before it
can be used. You must 'mem_allocterm()' first of the
size you want and pass the resulting pointer in 1st
argument of 'mem_openifh()' setting 2nd arg. to 0.
With 'SetMode()' you can switch between DSR and the
terminal area. So that when you need to get CPR you
select QDEV_HAN_SMTERM_POS, but when you require to
read terminal, QDEV_HAN_SMTERM_TERM.
Call 'Seek()' with OFFSET_BEGINNING so you can req.
any byte within the terminal. All counting from top
of course. Please note that sequences may appear in
the buffer first!
Call 'Seek(<fd>, 0, 0);' to set cursor at the top of
the read area and to request optimized feed. Chunks
of text will be positioned with extra ESC[#;#H seqs.
No need to worry about cursor position in the real
terminal! This mode does not allow particular byte
to be requested.
SEE ALSO
mem_openifh(), mem_closeifh(),
han_rollifh(), han_binaryifh(), han_rwifh()
EXAMPLE
...
void *term;
LONG read;
LONG fd;
UBYTE buf[128];
if ((term = mem_allocterm(80, 25, -1)))
{
if ((fd = mem_openifh(term, 0, han_termifh)))
{
FPrintf(fd, "\x1B[10;10HHello World!");
/*
* Clear real terminal before reading virtual
* one.
*/
Write(Output(), "\x1B" "c", 2);
/*
* Request terminal area access. Normally this
* is DSR feedback.
*/
SetMode(fd, QDEV_HAN_SMTERM_TERM);
/*
* Set to the first byte. Data comming from fd
* are full terminal dump!
*/
Seek(fd, 0, OFFSET_BEGINNING);
while ((read = Read(fd, buf, sizeof(buf))) > 0)
{
Write(Output(), buf, read);
}
/*
* The very last virtual terminal byte is NULL
* mostly thus the need for LF!
*/
Write(Output(), "\n", 1);
mem_closeifh(fd);
}
mem_freeterm(term);
}
BUGS
Following sequences are not implemented because i do
not really know how they work...
;
ESCH HTS HORIZONTAL TABULATION SET
ESC[#W n CTC CURSOR TABULATION CONTROL
ESC[#g 1- TBC TABULATION CLEAR
Following sequences are implemented at abs. minimum:
;
ESC[#n 1- DSR DEVICE STATUS REPORT(6/CPR)
Most private Amiga sequences are not recognized and
will not be implemented most probably. The only priv
Amiga sequence implemented is:
;
ESC[ s 0 aSDSS SET DEFAULT SGR SETTINGS
Beware there is something wrong with color handling,
but i was not able to investigate yet. The bug shows
up when colors were requested before cursor going to
be put before current position. The background that
was of certain color is destroyed...
Interesingly or not 'console.device' V39+ has probs
handling 'ESC[#@' sequence properly. The memory will
be trashed and the machine may/will crash whenever
the cursor is at the end of line and char + 1 is to
be inserted. Use this from CLI: echo "*e[A*e[D*e[2@"
to reproduce the bug.
----------------------------------------------------------------------------
| |
| |