Home  /  Autodocs

texteditor.gadget

FUNCTIONS

GM_TEXTEDITOR_ARexxCmd GM_TEXTEDITOR_ClearText GM_TEXTEDITOR_ExportBlock GM_TEXTEDITOR_ExportText GM_TEXTEDITOR_HandleError
GM_TEXTEDITOR_InsertText GM_TEXTEDITOR_MacroBegin GM_TEXTEDITOR_MacroEnd GM_TEXTEDITOR_MacroExecute GM_TEXTEDITOR_MarkText
GM_TEXTEDITOR_Search OM_TEXTEDITOR_Replace

FUNCTION

texteditor.gadget is a fast multiline stringgadget. It can hold quite large texts without noticeable slowdowns. It supports the clipboard, it can show text with different styles, alignments and colors. It can hold separators, it has multilevel undo/redo and it can easily be configured to use an external spell checker for type 'n' spell and word guessing.

ATTRIBUTES

GA_TEXTEDITOR_AreaMarked (BOOL)
This tag will be set to TRUE when text is marked. And back to FALSE when nothing is marked. You can create a notifyevent with this tag and let your cut/copy buttons become ghosted when nothing is marked.

GA_TEXTEDITOR_ColorMap (LONG *)
This is a map of allocated colors, which corresponds to the pen number you set with GA_TEXTEDITOR_Pen. By default the map looks like this:

0 = Normal (user configured text/highlight color)
1 = Shine
2 = Halfshine
3 = Background
4 = Halfshadow
5 = Shadow
6 = Text
7 = Fill
8 = Mark
9 = Screen pen 0
10 = Screen pen 1
11 = Screen pen 3
.. = ...
255 = Screen pen 246

If you supply your own colormap, then pen value 0 will still be "Normal", i.e. the first entry in your colormap has pen value 1. This may seem a bit illogical, suggest an alternative if you want!

You are allowed to dynamically change the colormap. However if you change an entry which is on-screen, then it won't have any immediate effect. The idea is that you should e.g. supply a colormap with 16 unused LONGs, allow the user to select a custom color, allocate that color and store the screen pen value into the colormap. Now you can use that entry as argument to GA_TEXTEDITOR_Pen.

Have in mind that your application may change screen, so the best place to allocate/free colors is when you show and hide the texteditor.

GA_TEXTEDITOR_Contents (APTR)
Set the contents of this gadget. This should normally be a pointer to a text buffer, but if you have supplied your own importhook, then you can set this to anything you like, e.g. a filehandle.

Related tags: GA_TEXTEDITOR_ImportHook, GM_TEXTEDITOR_InsertText

GA_TEXTEDITOR_CursorX (ULONG)
You can get or set the cursor's x position with this tag. The first character on a paragraph has position 0. The position is not affected by the gadgets `autowrap' feature. If you set a value higher than the length of the current paragraph, then it will automatically be truncated.

GA_TEXTEDITOR_CursorY (ULONG)
You can get or set the cursor's y position with this tag. The first paragraph has position 0. The position is not affected by the gadgets `autowrap' feature. If you set a value higher than the number of paragraphs, then it will automatically be truncated.

GA_TEXTEDITOR_DoubleClickHook (struct Hook *)
If you use the gadget in ReadOnly mode then you may want a special action to take place when the user doubleclick certain words. For example a mail or news client, using this gadget to show mails, may want the user to be able to click on URL's to lookup the link.

The hook will be called with A1 pointing to a ClickMessage, and A0 will point to the hook itself. Your hook should return TRUE if it wants to stop the editor from blocking.

// This hook will test if the user doubleclicked an http address

BOOL URLHookCode (register __a1 struct ClickMessage *clickmsg)
{
UWORD pos = clickmsg->ClickPosition;

while(pos && *(clickmsg->LineContents+pos-1) != ' ' &&
*(clickmsg->LineContents+pos-1) != '<')
{
pos--;
}

if(strncmp(clickmsg->LineContents+pos, "http:", 5))
{
return(FALSE);
}
LookupURL(clickmsg->LineContents+pos);
return(TRUE);
}

GA_TEXTEDITOR_ExportHook (struct Hook *)

GV_TEXTEDITOR_ExportHook_EMail
see next

GV_TEXTEDITOR_ExportHook_Plain
The EMail export hook will convert a bold word to *bold*, italic words to /italic/ and underlined words to _underline_. It also export separators such as <sb> or <tsb>.

See GA_TEXTEDITOR_ImportHook for more documentation.

GA_TEXTEDITOR_ExportWrap (ULONG)
This attribute allows the builtin export hooks to perform wordwrap. Zero means no wrap (default).

GA_TEXTEDITOR_FixedFont (BOOL)
Use this to set a fixed font.

GA_TEXTEDITOR_Flow (UWORD)
The current alignment. If an area is marked while you set this attribute, then the new alignment will be set for the complete area.

The following values are allowed:

  • GV_TEXTEDITOR_Flow_Left

  • GV_TEXTEDITOR_Flow_Right

  • GV_TEXTEDITOR_Flow_Center

  • GV_TEXTEDITOR_Flow_Justified (not yet implemented)

GA_TEXTEDITOR_HasChanged (BOOL)
This tag will show if the contents of the gadget has changed. You can take notify on this tag, so that you can connect it with a checkmark or textobject. You should set this tag to FALSE whenever you export the contents of the gadget (in the sense of saving).

The tag is not affected by GM_TEXTEDITOR_Export (as you may only be copying and not saving)

GA_TEXTEDITOR_HighlighterHook (struct Hook *)
The supplied hook will be called for every line in the document both after load and when the user edits the document

When calling the hook the object is a value that needs to be passed back in when calling HightLightSetFormat(), HighlightSetState()

GA_TEXTEDITOR_ImportHook (struct Hook *)
Since this gadget allows different text styles, you can supply an importhook to parse the text correctly.

It can also have the following special values:

GV_TEXTEDITOR_ImportHook_EMail

GV_TEXTEDITOR_ImportHook_MIME

GV_TEXTEDITOR_ImportHook_MIMEQuoted

GV_TEXTEDITOR_ImportHook_Plain (default)

The default importhook understands the following escape sequences:

<ESC> + u Set the soft style to underline.
<ESC> + b Set the soft style to bold.
<ESC> + i Set the soft style to italic.
<ESC> + n Set the soft style back to normal.
<ESC> + h Highlight the current line.
<ESC> + p[x] Change to color x, where x is taken from the
colormap. 0 means normal. The color is reset for each
new line.

The following sequences are only valid at the beginning of a line.

<ESC> + l Left justify current and following lines.
<ESC> + r Right justify current and following lines.
<ESC> + c Center current and following lines.
<ESC> + [s:x] Create a separator. x is a bit combination of flags:
Placement (mutually exclusive):
1 = Top
2 = Middle
4 = Bottom
Cosmetical:
8 = StrikeThru - Draw separator ontop of text.
16 = Thick - Make separator extra thick.

GV_TEXTEDITOR_ImportHook_MIME:

This builtin hook will convert quoted-printables (e.g. "=E5") to the ASCII representation, and merge lines ending with a "=", it will wordwrap the text (using the value set with GA_TEXTEDITOR_ImportWrap), it will highlight all lines which start with ">" it will make real *bold*, /italic/, _underline_ and #colored#, and it will replace <sb> or <tsb> with a real separator bar. It stops parsing when it reaches a NULL byte.

The color used for #colored# text is colormap entry 6, which defaults to MPEN_FILL. To override it, just supply a colormap with entry 6 set to whatever color you would like.

GV_TEXTEDITOR_ImportHook_MIMEQuoted:

Like the MIME importhook, but each line gets quoted and highlighted.

GV_TEXTEDITOR_ImportHook_EMail:

Like the MIME importhook, but it doesn't convert quoted printables.

You can of course create your own importhook, there is an external file which describes the procedure.

Don't use custom hooks yet. Although the above hooks import style correctly, the style information will be garbaged it the user edits the text.

GA_TEXTEDITOR_ImportWrap (ULONG)
This is here to allow the builtin import hooks to perform wordwrap. The builtin hooks accepts a value between 4 and 1024. Defaults to 1023.

GA_TEXTEDITOR_IndentWidth (ULONG)
When changing indentation this is the number of spaces each level is. A value of 0 wil use tab characters to indent

GA_TEXTEDITOR_InsertMode (BOOL)
Not yet implemented...

GA_TEXTEDITOR_LeftBarHook (struct Hook *)
When set you will get a left sidebar where the hook will be asked to render. The supplied hook will be called for every line in the document when rendering the document

It should not draw line numbers. Use GA_TEXTEDITOR_ShowLineNumbers to get line numbers. You can have both linenumbers and a hook. Different messages must be handled correctly. Unless otherwise specified you should return NULL for all.

It will be called with struct LeftBarRenderMessage for each line The object in the call is for now NULL The implementation can paint using the RastPort which for now isn't clipped but will be in the future so keep your painting within. Font is set and position points to topleft of area. You have 20 pixels x TxHeight to render within.

It will be called with struct LeftBarInputMessage if the user clicks in the area. It is called on the input.device context so be careful. Returning TRUE to this message will cause a repaint.

GA_TEXTEDITOR_LineEndingExport (WORD)
Instruct the texteditor to export in this format

LINEENDING_LF Amiga/unix/OSX

LINEENDING_CR MacOS pre OSX

LINEENDING_CRLF Dos and Windows

LINEENDING_ASIMPORT Same as was imported (see GA_TEXTEDITOR_LineEndingImported)

GA_TEXTEDITOR_LineEndingImported (WORD)
Tells what lineendings the latest import had

LINEENDING_LF Amiga/unix/OSX

LINEENDING_CR MacOS pre OSX

LINEENDING_CRLF Dos and Windows

GA_TEXTEDITOR_Pen (UBYTE)
The value of this tag reflects the current render pen.

Not yet implemented...

GA_TEXTEDITOR_Prop_DeltaFactor (ULONG)
OBSOLETE This tag can tell you how high a line is. This is useful when you set

the increment value of a slider, as GA_TEXTEDITOR_Prop_Entries holds the lines in pixels.

GA_TEXTEDITOR_Prop_Entries (ULONG)
This value is the total number of lines in the editor. If you want a slider attached to the gadget you should create a notify on this attribute.

GA_TEXTEDITOR_Prop_First (ULONG)
Get or set the first displayed line. The purpose of this attribute is to allow connection between the editorgadget and a scrollbar.

GA_TEXTEDITOR_Prop_Visible (ULONG)
This value is the number of lines that currently fits in the window. If you want a slider attached to the gadget you should create a notify on this attribute.

GA_TEXTEDITOR_Quiet (BOOL)
If you need to insert a lot of text "line by line" you should set this tag to TRUE before starting, and then back to FALSE when you are done adding text.

GA_TEXTEDITOR_ReadOnly (BOOL)
This tag is not supported in the ReAction version. Use GA_ReadOnly instead.

In ReadOnly-mode there will be:

No cursor (but a normal frame). TAB will activate the next gadget (instead of alt TAB). The frame will be set to a ReadListFrame. (may change). There is no ARexx support, except "Copy".

The GA_TEXTEDITOR_StyleXXX tags are still useable.

GA_TEXTEDITOR_RectangularSelections (BOOL)
When set the editor has rectangular selections

GA_TEXTEDITOR_RedoAvailable (BOOL)
This tag is set to TRUE when the user is able to redo his action(s) (normally after an undo).

You can create a notify on this tag and let your redo button be ghosted when there is nothing to redo.

GA_TEXTEDITOR_Separator (UWORD *)
Each line can act as a separator.

A separator can be either thick or thin. It can be rendered over the lines contents, or only on both sides of the contents. The placement can be either top, middle or bottom.

This tag reflects the current line. See gadgets/texteditor.h for definitions.

GA_TEXTEDITOR_ShowLineNumbers (BOOL)
If TRUE you will get a a left sidebar where linenumbers is shown

GA_TEXTEDITOR_SpacesPerTAB (ULONG)
A tab corresponds to this many spaces.

GA_TEXTEDITOR_StyleBold (BOOL)
This tag shows whether the cursor or selection is over bolded text or not. You can set this tag to TRUE or FALSE if you want the style changed.

Not yet implemented...

GA_TEXTEDITOR_StyleItalic (BOOL)
This tag shows whether the cursor or selection is over text in italics or not.

You can set this tag to TRUE or FALSE if you want the style changed.

Not yet implemented...

GA_TEXTEDITOR_StyleUnderline (BOOL)
This tag shows whether the cursor or selection is over underlined text or not. You can set this tag to TRUE or FALSE if you want the style changed.

Not yet implemented...

GA_TEXTEDITOR_TabKeyPolicy (ULONG)
When pressing the tab key and the cursor is past the leading whitespace of the block then one of these things can happen:

GV_TEXTEDITOR_TabKey_IndentsLine
The line is indented

GV_TEXTEDITOR_TabKey_IndentsAfter
Indents text after the cursor

GA_TEXTEDITOR_TypeAndSpell (BOOL)
(NOT in V47) This is a shortcut to the Type'n'spell switch that the user can set in the .mcp module. Never integrate this into the settings of your preferences.

GA_TEXTEDITOR_UndoAvailable (BOOL)
This tag is set to TRUE when the user is able to undo his action(s) You can create a notify on this tag and let your undo button be ghosted when there is nothing to undo.

GA_TEXTEDITOR_WrapBorder (ULONG)
The gadget will insert a linebreak infront of the current word, if the cursor comes beyond the column given here.

Please remember that the gadget can do nondesctructive dynamic wordwrap which is much better! This tag is for special cases!!!