Commit 6770c2da authored by John Beranek's avatar John Beranek
Browse files

* Fixed the textarea_set/get_cursor_position methods to use the method...

* Fixed the textarea_set/get_cursor_position methods to use the method interface as specified in docs.textarea.  I wasn't returning values in R4 as it showed in the document, I am now.  The fetching of the cursor position (in both the get and set calls) doesn't appear to work (always returns 0) with what appears to be the correct code to achieve this.  The fixing of this is left as an exercise for the bored and very brave person...textarea internals are "interesting".

 * Added some description of the methods into docs.textarea


Version 0.21. Tagged as 'Gadgets-0_21'
parent 04521800
/* (0.20)
/* (0.21)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 0.20
#define Module_MajorVersion_CMHG 0.21
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 17 Jun 1999
#define Module_Date_CMHG 18 Jun 1999
#define Module_MajorVersion "0.20"
#define Module_Version 20
#define Module_MajorVersion "0.21"
#define Module_Version 21
#define Module_MinorVersion ""
#define Module_Date "17 Jun 1999"
#define Module_Date "18 Jun 1999"
#define Module_FullVersion "0.20"
#define Module_FullVersion "0.21"
......@@ -1131,11 +1131,12 @@ static _kernel_oserror *textarea_mclick(PrivateTextArea *tdata,
}
/* New method added by JBeranek */
static _kernel_oserror *_set_cursor_position (PrivateTextArea *tdata, unsigned int index,
unsigned int *old_index, unsigned int flags)
/* Method to set the cursor position in a TextArea */
static _kernel_oserror *_set_cursor_position (PrivateTextArea *tdata, unsigned int *index,
unsigned int flags)
{
int caret_x, caret_y, window_handle;
unsigned int old_index;
int force = 0, invisible = 0;
_kernel_oserror *er;
......@@ -1149,12 +1150,21 @@ static _kernel_oserror *_set_cursor_position (PrivateTextArea *tdata, unsigned i
if (er)
return er;
if (old_index)
*old_index = tdata->text->insert_pos;
tdata->text->insert_pos = index;
char_pos(tdata->text, tdata->text->insert_pos, &caret_x, &caret_y);
/* Save the old index */
old_index = tdata->text->insert_pos;
/* It appears the next line is unneeded, and can cause problems */
#if 0
/* Then set the new index */
tdata->text->insert_pos = *index;
#endif
char_pos(tdata->text, *index, &caret_x, &caret_y);
set_caret(window_handle, tdata->text, caret_x, caret_y, force, invisible);
/* And return the old index */
*index = old_index;
/* Seems to work OK without any display update ... */
/* update_display(tdata, first_line, last_line, line_delta);*/
......@@ -1162,12 +1172,13 @@ static _kernel_oserror *_set_cursor_position (PrivateTextArea *tdata, unsigned i
}
/* New method added by JBeranek */
/* Method to get the cursor position in a TextArea */
static _kernel_oserror *_get_cursor_position (PrivateTextArea *tdata, unsigned int *index,
unsigned int flags)
{
if (index)
*index = tdata->text->insert_pos;
IGNORE(flags);
*index = tdata->text->insert_pos;
return NULL;
}
......@@ -1576,12 +1587,11 @@ _kernel_oserror *textarea_method(PrivateTextArea *handle,
regs->r[1] = handle->background;
break;
case TextArea_SetCursorPosition:
e = _set_cursor_position (handle, (unsigned int)regs->r[4], (unsigned int *)regs->r[5],
(unsigned int)regs->r[0]);
e = _set_cursor_position (handle, (unsigned int *)&regs->r[4], (unsigned int)regs->r[0]);
break;
case TextArea_GetCursorPosition:
e = _get_cursor_position (handle, (unsigned int *)regs->r[4], (unsigned int)regs->r[0]);
e = _get_cursor_position (handle, (unsigned int *)&regs->r[4], (unsigned int)regs->r[0]);
break;
default:
......
......@@ -270,11 +270,20 @@ On entry
On exit
R4 = old index
Use
This methods sets the cursor position in a TextArea, you pass it the
index you want to change to, and it will pass back the old index value.
If Bit 0 of the flags word is set the setting of the caret position is
forced. If Bit 1 is set, the caret is set invisibly.
C veneer
extern _kernel_oserror *textarea_set_cursor_position(unsigned int flags,
ObjectId object_id, ComponentId component_id,
unsigned int index, unsigned int *new_index);
TextArea_GetCursorPosition
--------------------------
On entry
......@@ -284,13 +293,16 @@ On entry
R3 = Gadget component id
On exit
R4 = old index
R4 = index
Gets the index of the current cursor position in a TextArea.
C veneer
extern _kernel_oserror *textarea_get_cursor_position(unsigned int flags,
ObjectId object_id, ComponentId component_id,
unsigned int *index);
TextArea_SetTextBorder
----------------------
On entry
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment