1 /***************************************************************************
3 TextEditor.mcc - Textediting MUI Custom Class
4 Copyright (C) 1997-2000 Allan Odgaard
5 Copyright (C) 2005-2014 TextEditor.mcc Open Source Team
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 TextEditor class Support Site: http://www.sf.net/projects/texteditor-mcc
21 ***************************************************************************/
25 #include <exec/memory.h>
26 #include <intuition/classes.h>
27 #include <clib/alib_protos.h>
28 #include <graphics/gfxmacros.h>
29 #include <proto/intuition.h>
30 #include <proto/graphics.h>
31 #include <proto/utility.h>
32 #include <proto/locale.h>
33 #include <proto/exec.h>
36 #include <proto/alib.h>
39 #include <proto/muimaster.h>
40 #include <libraries/mui.h>
45 DISPATCHERPROTO(_Dispatcher
);
48 void ResetDisplay(struct InstData
*data
)
52 data
->blockinfo
.enabled
= FALSE
;
56 data
->actualline
= GetFirstLine(&data
->linelist
);
58 data
->cursor_shown
= FALSE
;
59 if(data
->shown
== TRUE
)
61 data
->totallines
= CountLines(data
, &data
->linelist
);
62 data
->Pen
= GetColor(data
->CPos_X
, data
->actualline
);
63 data
->Flow
= data
->actualline
->line
.Flow
;
64 data
->Separator
= data
->actualline
->line
.Separator
;
65 data
->NoNotify
= TRUE
;
66 SetAttrs(data
->object
,
67 MUIA_TextEditor_Pen
, data
->Pen
,
68 MUIA_TextEditor_Flow
, data
->Flow
,
69 MUIA_TextEditor_Separator
, data
->Separator
,
70 MUIA_TextEditor_Prop_Entries
, data
->totallines
*data
->fontheight
,
71 MUIA_TextEditor_Prop_Visible
, data
->maxlines
*data
->fontheight
,
72 MUIA_TextEditor_Prop_First
, (data
->visual_y
-1)*data
->fontheight
,
73 MUIA_TextEditor_Prop_DeltaFactor
, data
->fontheight
,
75 data
->NoNotify
= FALSE
;
79 DumpText(data
, data
->visual_y
, 0, data
->maxlines
, FALSE
);
87 void RequestInput(struct InstData
*data
)
91 if(data
->scrollaction
== FALSE
&& data
->mousemove
== FALSE
)
92 DoMethod(_app(data
->object
), MUIM_Application_AddInputHandler
, &data
->ihnode
);
99 void RejectInput(struct InstData
*data
)
103 if(data
->scrollaction
== FALSE
&& data
->mousemove
== FALSE
)
104 DoMethod(_app(data
->object
), MUIM_Application_RemInputHandler
, &data
->ihnode
);
111 static IPTR
mNew(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
115 if((obj
= (Object
*)DoSuperMethodA(cl
, obj
, (Msg
)msg
)) != NULL
)
117 struct InstData
*data
= INST_DATA(cl
, obj
);
120 InitLines(&data
->linelist
);
122 #if defined(__amigaos4__)
123 data
->mypool
= AllocSysObjectTags(ASOT_MEMPOOL
, ASOPOOL_MFlags
, MEMF_SHARED
|MEMF_CLEAR
,
124 ASOPOOL_Puddle
, 3*1024,
125 ASOPOOL_Threshold
, 512,
126 ASOPOOL_Name
, "TextEditor.mcc pool",
127 ASOPOOL_LockMem
, FALSE
,
130 data
->mypool
= CreatePool(MEMF_ANY
|MEMF_CLEAR
, 3*1024, 512);
132 if(data
->mypool
!= NULL
)
134 if((data
->mylocale
= OpenLocale(NULL
)) != NULL
)
136 struct line_node
*firstLine
;
138 if((firstLine
= AllocVecPooled(data
->mypool
, sizeof(struct line_node
))) != NULL
)
140 if(Init_LineNode(data
, firstLine
, "\n") == TRUE
)
142 AddLine(&data
->linelist
, firstLine
);
144 data
->actualline
= firstLine
;
146 data
->ImportHook
= &ImPlainHook
;
147 data
->ImportWrap
= 1023;
148 data
->WrapBorder
= 0;
149 data
->WrapMode
= MUIV_TextEditor_WrapMode_HardWrap
;
150 data
->WrapWords
= TRUE
; // wrap at word boundaries
151 data
->TabSize
= 4; // default to 4 spaces per TAB
152 data
->GlobalTabSize
= 4; // default to 4 spaces per TAB
153 data
->TabSizePixels
= 4*8; // assume a fixed space width of 8 pixels per default
154 data
->ConvertTabs
= TRUE
; // convert tab to spaces per default
156 data
->ExportHook
= &ExportHookPlain
;
157 setFlag(data
->flags
, FLG_AutoClip
);
158 setFlag(data
->flags
, FLG_ActiveOnClick
);
159 setFlag(data
->flags
, FLG_PasteStyles
);
160 setFlag(data
->flags
, FLG_PasteColors
);
162 #if defined(__amigaos3__) || defined(__amigaos4__)
163 if(MUIMasterBase
->lib_Version
> 20 || (MUIMasterBase
->lib_Version
== 20 && MUIMasterBase
->lib_Revision
>= 5640))
165 // MUI 4.0 for AmigaOS4 does the disabled pattern drawing itself,
166 // no need to do this on our own
167 setFlag(data
->flags
, FLG_MUI4
);
169 #elif defined(__MORPHOS__)
170 if(MUIMasterBase
->lib_Version
> 20 || (MUIMasterBase
->lib_Version
== 20 && MUIMasterBase
->lib_Revision
>= 6906))
172 // MUI 4.0 for MorphOS does the disabled pattern drawing itself,
173 // no need to do this on our own
174 setFlag(data
->flags
, FLG_MUI4
);
178 if(FindTagItem(MUIA_Background
, msg
->ops_AttrList
))
179 setFlag(data
->flags
, FLG_OwnBackground
);
180 if(FindTagItem(MUIA_Frame
, msg
->ops_AttrList
))
181 setFlag(data
->flags
, FLG_OwnFrame
);
183 // initialize our temporary rastport
184 InitRastPort(&data
->tmprp
);
186 // walk through all attributes and check if
187 // they were set during OM_NEW
188 mSet(cl
, obj
, (struct opSet
*)msg
);
191 // start with an inactive cursor
192 data
->currentCursorState
= CS_INACTIVE
;
200 CoerceMethod(cl
, obj
, OM_DISPOSE
);
209 static IPTR
mDispose(struct IClass
*cl
, Object
*obj
, Msg msg
)
211 struct InstData
*data
= INST_DATA(cl
, obj
);
215 FreeUndoBuffer(data
);
217 data
->blockinfo
.startline
= NULL
;
218 data
->blockinfo
.stopline
= NULL
;
220 // free all lines with their contents
221 FreeTextMem(data
, &data
->linelist
);
225 if(data
->mylocale
!= NULL
)
227 CloseLocale(data
->mylocale
);
228 data
->mylocale
= NULL
;
231 if(data
->mypool
!= NULL
)
233 #if defined(__amigaos4__)
234 FreeSysObject(ASOT_MEMPOOL
, data
->mypool
);
236 DeletePool(data
->mypool
);
242 return DoSuperMethodA(cl
, obj
, msg
);
247 static IPTR
mSetup(struct IClass
*cl
, Object
*obj
, Msg msg
)
250 struct InstData
*data
= INST_DATA(cl
, obj
);
254 // initialize the configuration of our TextEditor
255 // object from the configuration set by the user
258 if(DoSuperMethodA(cl
, obj
, msg
))
260 // disable that the object will automatically get a border when
261 // the ActiveObjectOnClick option is active
262 if(isFlagSet(data
->flags
, FLG_ActiveOnClick
))
263 _flags(obj
) |= (1<<7);
265 // now we check whether we have a valid font or not
266 // and if not we take the default one of our muiAreaData
267 if(data
->font
== NULL
)
268 data
->font
= _font(obj
);
270 // initialize our temporary rastport
271 InitRastPort(&data
->tmprp
);
272 SetFont(&data
->tmprp
, data
->font
);
274 // calculate the amount of pixels a Tab<>Spaces conversion will take
275 data
->TabSizePixels
= data
->TabSize
*TextLength(&data
->tmprp
, " ", 1);
276 D(DBF_INPUT
, "TabSizePixels: %d", data
->TabSizePixels
);
278 // make sure we have a proper font setup here and
279 // that our spellchecker suggest window object is also
280 // correctly initialized.
281 if(data
->font
!= NULL
&& (data
->SuggestWindow
= SuggestWindow(data
)) != NULL
)
283 DoMethod(_app(obj
), OM_ADDMEMBER
, data
->SuggestWindow
);
285 data
->mousemove
= FALSE
;
286 data
->ehnode
.ehn_Priority
= 0;
287 data
->ehnode
.ehn_Flags
= MUI_EHF_GUIMODE
;
288 data
->ehnode
.ehn_Object
= obj
;
289 data
->ehnode
.ehn_Class
= cl
;
290 data
->ehnode
.ehn_Events
= IDCMP_INACTIVEWINDOW
| IDCMP_MOUSEBUTTONS
| IDCMP_RAWKEY
;
292 #if defined(__amigaos4__)
293 data
->ehnode
.ehn_Events
|= IDCMP_EXTENDEDMOUSE
;
296 // setup the selection pointer
297 if(data
->selectPointer
== TRUE
)
299 setFlag(data
->ehnode
.ehn_Events
, IDCMP_MOUSEMOVE
);
300 SetupSelectPointer(data
);
303 data
->ihnode
.ihn_Object
= obj
;
304 data
->ihnode
.ihn_Millis
= 20;
305 data
->ihnode
.ihn_Method
= MUIM_TextEditor_InputTrigger
;
306 data
->ihnode
.ihn_Flags
= MUIIHNF_TIMER
;
308 DoMethod(_win(obj
), MUIM_Window_AddEventHandler
, &data
->ehnode
);
310 data
->smooth_wait
= 0;
311 data
->scrollaction
= FALSE
;
326 static IPTR
mCleanup(struct IClass
*cl
, Object
*obj
, Msg msg
)
328 struct InstData
*data
= INST_DATA(cl
, obj
);
333 // cleanup the selection pointer
334 CleanupSelectPointer(data
);
336 DoMethod(_win(obj
), MUIM_Window_RemEventHandler
, &data
->ehnode
);
338 if(DoMethod(_app(obj
), OM_REMMEMBER
, data
->SuggestWindow
))
339 MUI_DisposeObject(data
->SuggestWindow
);
341 // enable that the object will automatically get a border when
342 // the ActiveObjectOnClick option is active
343 if(isFlagSet(data
->flags
, FLG_ActiveOnClick
))
344 _flags(obj
) &= ~(1<<7);
346 if(data
->mousemove
== TRUE
)
348 data
->mousemove
= FALSE
;
354 result
= DoSuperMethodA(cl
, obj
, msg
);
362 static IPTR
mAskMinMax(struct IClass
*cl
, Object
*obj
, struct MUIP_AskMinMax
*msg
)
364 struct InstData
*data
= INST_DATA(cl
, obj
);
365 struct MUI_MinMax
*mi
;
370 // call the supermethod first
371 DoSuperMethodA(cl
, obj
, (Msg
)msg
);
373 mi
= ((struct MUIP_AskMinMax
*)msg
)->MinMaxInfo
;
375 if(data
->Columns
!= 0)
377 // for the font width we take the nominal font width provided by the tf_XSize attribute
378 LONG width
= data
->Columns
* (data
->font
? data
->font
->tf_XSize
: _font(obj
)->tf_XSize
);
380 mi
->MinWidth
+= width
;
381 mi
->DefWidth
+= width
;
382 mi
->MaxWidth
+= width
;
388 mi
->MaxWidth
= MUI_MAXMAX
;
391 fontheight
= data
->font
? data
->font
->tf_YSize
: _font(obj
)->tf_YSize
;
394 LONG height
= data
->Rows
* fontheight
;
396 mi
->MinHeight
+= height
;
397 mi
->DefHeight
+= height
;
398 mi
->MaxHeight
+= height
;
402 mi
->MinHeight
+= 1 * fontheight
;
403 mi
->DefHeight
+= 15 * fontheight
;
404 mi
->MaxHeight
= MUI_MAXMAX
;
413 static IPTR
mShow(struct IClass
*cl
, Object
*obj
, Msg msg
)
415 struct InstData
*data
= INST_DATA(cl
, obj
);
419 DoSuperMethodA(cl
, obj
, msg
);
421 // now we check whether we have a valid font or not
422 // and if not we take the default one of our muiAreaData
423 if(data
->font
== NULL
)
424 data
->font
= _font(obj
);
426 data
->rport
= _rp(obj
);
427 data
->fontheight
= data
->font
->tf_YSize
;
428 data
->maxlines
= _mheight(obj
) / data
->fontheight
;
429 data
->ypos
= _mtop(obj
);
431 data
->totallines
= CountLines(data
, &data
->linelist
);
434 data
->update
= FALSE
;
435 ScrollIntoDisplay(data
);
440 MUIA_TextEditor_Prop_DeltaFactor
, data
->fontheight
,
441 MUIA_TextEditor_Prop_Entries
,
442 ((data
->totallines
-(data
->visual_y
-1) < data
->maxlines
) ?
443 ((data
->visual_y
-1)+data
->maxlines
) :
444 ((data
->maxlines
> data
->totallines
) ?
448 MUIA_TextEditor_Prop_First
, (data
->visual_y
-1)*data
->fontheight
,
449 MUIA_TextEditor_Prop_Visible
, data
->maxlines
*data
->fontheight
,
452 // initialize the doublebuffering rastport
453 InitRastPort(&data
->doublerp
);
454 data
->doublebuffer
= MUIG_AllocBitMap(_mwidth(obj
)+((data
->fontheight
-data
->font
->tf_Baseline
+1)>>1)+1, data
->fontheight
, GetBitMapAttr(data
->rport
->BitMap
, BMA_DEPTH
), (BMF_CLEAR
| BMF_INTERLEAVED
), data
->rport
->BitMap
);
455 data
->doublerp
.BitMap
= data
->doublebuffer
;
456 SetFont(&data
->doublerp
, data
->font
);
458 // initialize the copyrp rastport
459 data
->copyrp
= *_rp(obj
);
460 SetFont(&data
->copyrp
, data
->font
);
462 // initialize our temporary rastport
463 InitRastPort(&data
->tmprp
);
464 SetFont(&data
->tmprp
, data
->font
);
466 set(data
->SuggestWindow
, MUIA_Window_Open
, isFlagSet(data
->flags
, FLG_PopWindow
));
476 static IPTR
mHide(struct IClass
*cl
, Object
*obj
, Msg msg
)
478 struct InstData
*data
= INST_DATA(cl
, obj
);
483 HideSelectPointer(data
, obj
);
484 nnset(data
->SuggestWindow
, MUIA_Window_Open
, FALSE
);
485 set(_win(obj
), MUIA_Window_DisableKeys
, 0L);
486 MUIG_FreeBitMap(data
->doublebuffer
);
487 data
->doublerp
.BitMap
= NULL
;
491 return DoSuperMethodA(cl
, obj
, msg
);
496 static IPTR
mDraw(struct IClass
*cl
, Object
*obj
, struct MUIP_Draw
*msg
)
498 struct InstData
*data
= INST_DATA(cl
, obj
);
502 DoSuperMethodA(cl
, obj
, (Msg
)msg
);
504 if(isFlagSet(msg
->flags
, MADF_DRAWUPDATE
) && data
->UpdateInfo
!= NULL
)
506 setFlag(data
->flags
, FLG_Draw
);
507 data
->UpdateInfo
= (APTR
)_Dispatcher(cl
, obj
, (Msg
)data
->UpdateInfo
);
508 clearFlag(data
->flags
, FLG_Draw
);
511 if(isFlagSet(msg
->flags
, MADF_DRAWOBJECT
))
513 SetFont(data
->rport
, data
->font
);
515 /* This cases crash on simplerefresh,
516 when something covers window and
517 contents scroll (gfxcard only!)
518 */ /* data->update = FALSE;
519 ScrollIntoDisplay(data);
523 // we clear the very last part of the gadget
524 // content at the very bottom because that one will not be
525 // automatically cleared by PrintLine() later on
526 DoMethod(obj
, MUIM_DrawBackground
, _mleft(obj
), _mtop(obj
)+(data
->fontheight
* (data
->maxlines
)),
527 _mwidth(obj
), (_mheight(obj
)-(data
->fontheight
* (data
->maxlines
))),
528 _mleft(obj
), _mtop(obj
), 0);
531 DumpText(data
, data
->visual_y
, 0, data
->maxlines
, FALSE
);
533 // make sure we ghost out the whole area in case
534 // the gadget was flagged as being ghosted.
535 if(isFlagSet(data
->flags
, FLG_Ghosted
) && isFlagClear(data
->flags
, FLG_MUI4
))
537 UWORD newPattern
[] = {0x1111, 0x4444};
539 SetDrMd(data
->rport
, JAM1
);
540 SetAPen(data
->rport
, _pens(obj
)[MPEN_SHADOW
]);
541 SetAfPt(data
->rport
, newPattern
, 1);
542 RectFill(data
->rport
, _left(obj
), _top(obj
), _right(obj
), _bottom(obj
));
543 SetAfPt(data
->rport
, NULL
, (UBYTE
)-1);
553 IPTR
mGoActive(struct IClass
*cl
, Object
*obj
, Msg msg
)
555 struct InstData
*data
= INST_DATA(cl
, obj
);
560 // set the gadgets flags to active and also "activated" so that
561 // other functions know that the gadget was activated recently.
562 setFlag(data
->flags
, FLG_Active
);
563 setFlag(data
->flags
, FLG_Activated
);
565 if(data
->shown
== TRUE
)
567 SetCursor(data
, data
->CPos_X
, data
->actualline
, TRUE
);
569 // in case we ought to show a selected area in a different
570 // color than in inactive state we call MarkText()
571 if(isFlagSet(data
->flags
, FLG_ActiveOnClick
) && Enabled(data
))
572 MarkText(data
, data
->blockinfo
.startx
, data
->blockinfo
.startline
, data
->blockinfo
.stopx
, data
->blockinfo
.stopline
);
574 if(isFlagClear(data
->flags
, FLG_ReadOnly
))
575 set(_win(obj
), MUIA_Window_DisableKeys
, MUIKEYF_GADGET_NEXT
);
578 if(data
->BlinkSpeed
== 1)
580 DoMethod(_app(obj
), MUIM_Application_AddInputHandler
, &data
->blinkhandler
);
581 data
->BlinkSpeed
= 2;
584 result
= DoSuperMethodA(cl
, obj
, msg
);
592 IPTR
mGoInactive(struct IClass
*cl
, Object
*obj
, Msg msg
)
594 struct InstData
*data
= INST_DATA(cl
, obj
);
599 // clear the active and activated flag so that others know about it
600 clearFlag(data
->flags
, FLG_Active
);
601 clearFlag(data
->flags
, FLG_Activated
);
603 if(data
->shown
== TRUE
)
604 set(_win(obj
), MUIA_Window_DisableKeys
, 0L);
606 if(data
->mousemove
== TRUE
)
608 data
->mousemove
= FALSE
;
612 if(data
->scrollaction
== TRUE
)
613 data
->smooth_wait
= 1;
615 if(data
->BlinkSpeed
== 2)
617 DoMethod(_app(obj
), MUIM_Application_RemInputHandler
, &data
->blinkhandler
);
618 data
->BlinkSpeed
= 1;
621 SetCursor(data
, data
->CPos_X
, data
->actualline
, FALSE
);
623 // in case we ought to show a selected area in a different
624 // color than in inactive state we call MarkText()
625 if(isFlagSet(data
->flags
, FLG_ActiveOnClick
) && Enabled(data
))
626 MarkText(data
, data
->blockinfo
.startx
, data
->blockinfo
.startline
, data
->blockinfo
.stopx
, data
->blockinfo
.stopline
);
628 result
= DoSuperMethodA(cl
, obj
, msg
);
636 IPTR
mInsertText(struct IClass
*cl
, Object
*obj
, struct MUIP_TextEditor_InsertText
*msg
)
638 struct InstData
*data
= INST_DATA(cl
, obj
);
639 struct marking block
;
646 case MUIV_TextEditor_InsertText_Top
:
652 case MUIV_TextEditor_InsertText_Bottom
:
659 block
.startx
= data
->CPos_X
;
660 block
.startline
= data
->actualline
;
661 result
= InsertText(data
, msg
->text
, TRUE
);
662 block
.stopx
= data
->CPos_X
;
663 block
.stopline
= data
->actualline
;
664 AddToUndoBuffer(data
, ET_PASTEBLOCK
, &block
);
672 IPTR
mExport(UNUSED
struct IClass
*cl
, Object
*obj
, struct MUIP_Export
*msg
)
678 if((id
= (muiNotifyData(obj
)->mnd_ObjectID
)) != 0)
682 if((contents
= (STRPTR
)DoMethod(obj
, MUIM_TextEditor_ExportText
)) != NULL
)
684 DoMethod(msg
->dataspace
, MUIM_Dataspace_Add
, contents
, strlen(contents
)+1, id
);
695 IPTR
mImport(UNUSED
struct IClass
*cl
, Object
*obj
, struct MUIP_Import
*msg
)
701 if((id
= (muiNotifyData(obj
)->mnd_ObjectID
)) != 0)
703 STRPTR contents
= (STRPTR
)DoMethod(msg
->dataspace
, MUIM_Dataspace_Find
, id
);
705 set(obj
, MUIA_TextEditor_Contents
, contents
!= NULL
? (IPTR
)contents
: (IPTR
)"");
714 DISPATCHER(_Dispatcher
)
716 struct InstData
*data
;
726 //D(DBF_STARTUP, "Method: 0x%lx\n", msg->MethodID);
727 //D(DBF_STARTUP, "Stack usage: %ld %lx", (ULONG)FindTask(NULL)->tc_SPUpper - (ULONG)FindTask(NULL)->tc_SPReg);
729 // this one must be catched before we try to obtain the instance data, because nobody
730 // will guarantee that the pointer returned by INST_DATA() is valid if no object has
731 // been created yet!!
732 if(msg
->MethodID
== OM_NEW
)
734 result
= mNew(cl
, obj
, (struct opSet
*)msg
);
740 // now get the instance data
741 if((data
= INST_DATA(cl
, obj
)) == NULL
)
743 ASSERT(data
!= NULL
);
749 // set some variables:
750 t_totallines
= data
->totallines
;
751 t_visual_y
= data
->visual_y
;
752 t_haschanged
= data
->HasChanged
;
754 areamarked
= Enabled(data
);
756 // D(DBF_STARTUP, "cont...");
758 if(data
->shown
== TRUE
&& isFlagClear(data
->flags
, FLG_Draw
))
760 switch(msg
->MethodID
)
762 case MUIM_TextEditor_ARexxCmd
:
763 case MUIM_TextEditor_InsertText
:
764 case MUIM_TextEditor_InputTrigger
:
765 case MUIM_TextEditor_ToggleCursor
:
766 case MUIM_TextEditor_MarkText
:
767 case MUIM_TextEditor_ClearText
:
768 case MUIM_TextEditor_SetBlock
:
769 case MUIM_HandleEvent
:
770 case MUIM_GoInactive
:
773 data
->UpdateInfo
= msg
;
774 MUI_Redraw(obj
, MADF_DRAWUPDATE
);
775 result
= (IPTR
)data
->UpdateInfo
;
776 data
->UpdateInfo
= NULL
;
784 switch(msg
->MethodID
)
786 case OM_DISPOSE
: result
= mDispose(cl
, obj
, msg
); RETURN(result
); return result
; break;
787 case OM_GET
: result
= mGet(cl
, obj
, (APTR
)msg
); RETURN(result
); return result
; break;
788 case OM_SET
: result
= mSet(cl
, obj
, (APTR
)msg
); break;
789 case MUIM_Setup
: result
= mSetup(cl
, obj
, msg
); RETURN(result
); return result
; break;
790 case MUIM_Show
: result
= mShow(cl
, obj
, msg
); RETURN(result
); return result
; break;
791 case MUIM_AskMinMax
: result
= mAskMinMax(cl
, obj
, (APTR
)msg
); RETURN(result
); return result
; break;
792 case MUIM_Draw
: result
= mDraw(cl
, obj
, (APTR
)msg
); RETURN(result
); return result
; break;
793 case MUIM_Hide
: result
= mHide(cl
, obj
, msg
); RETURN(result
); return result
; break;
794 case MUIM_Cleanup
: result
= mCleanup(cl
, obj
, msg
); RETURN(result
); return result
; break;
795 case MUIM_Export
: result
= mExport(cl
, obj
, (APTR
)msg
); break;
796 case MUIM_Import
: result
= mImport(cl
, obj
, (APTR
)msg
); break;
797 case MUIM_GoActive
: result
= mGoActive(cl
, obj
, msg
); RETURN(result
); return result
; break;
798 case MUIM_GoInactive
: result
= mGoInactive(cl
, obj
, msg
); RETURN(result
); return result
; break;
799 case MUIM_HandleEvent
:
801 LONG oldx
= data
->CPos_X
;
802 struct line_node
*oldy
= data
->actualline
;
804 // process all input events
805 result
= mHandleInput(cl
, obj
, (struct MUIP_HandleEvent
*)msg
);
807 // see if the cursor was moved and if so we go and notify
809 data
->NoNotify
= TRUE
;
811 if(data
->CPos_X
!= oldx
)
812 set(obj
, MUIA_TextEditor_CursorX
, data
->CPos_X
);
814 if(data
->actualline
!= oldy
)
815 set(obj
, MUIA_TextEditor_CursorY
, LineNr(data
, data
->actualline
)-1);
817 data
->NoNotify
= FALSE
;
819 // if the HandleInput() function didn't return
820 // an MUI_EventHandlerRC_Eat we can return immediately
829 case MUIM_TextEditor_ClearText
: result
= mClearText(cl
, obj
, msg
); break;
830 case MUIM_TextEditor_ToggleCursor
: result
= mToggleCursor(cl
, obj
, msg
); RETURN(result
); return result
; break;
831 case MUIM_TextEditor_InputTrigger
: result
= mInputTrigger(cl
, obj
, msg
); break;
832 case MUIM_TextEditor_InsertText
: result
= mInsertText(cl
, obj
, (APTR
)msg
); break;
833 case MUIM_TextEditor_ExportBlock
: result
= mExportBlock(cl
, obj
, (APTR
)msg
); RETURN(result
); return result
; break;
834 case MUIM_TextEditor_ExportText
: result
= mExportText(cl
, obj
, (APTR
)msg
); RETURN(result
); return result
; break;
835 case MUIM_TextEditor_ARexxCmd
: result
= mHandleARexx(cl
, obj
, (APTR
)msg
); break;
836 case MUIM_TextEditor_MarkText
: result
= mMarkText(data
, (APTR
)msg
); break;
837 case MUIM_TextEditor_BlockInfo
: result
= mBlockInfo(data
, (APTR
)msg
); break;
838 case MUIM_TextEditor_Search
: result
= mSearch(cl
, obj
, (APTR
)msg
); break;
839 case MUIM_TextEditor_Replace
: result
= mReplace(cl
, obj
, (APTR
)msg
); break;
840 case MUIM_TextEditor_QueryKeyAction
: result
= mQueryKeyAction(cl
, obj
, (APTR
)msg
); break;
841 case MUIM_TextEditor_SetBlock
: result
= mSetBlock(data
, (APTR
)msg
); RETURN(result
); return result
; break;
842 default: result
= DoSuperMethodA(cl
, obj
, msg
); RETURN(result
); return result
; break;
845 if(t_haschanged
!= data
->HasChanged
)
846 set(obj
, MUIA_TextEditor_HasChanged
, data
->HasChanged
);
848 if(msg
->MethodID
== OM_SET
)
850 ULONG newresult
= DoSuperMethodA(cl
, obj
, msg
);
861 if(data
->visual_y
!= t_visual_y
|| data
->totallines
!= t_totallines
)
863 SetAttrs(obj
, MUIA_TextEditor_Prop_Entries
,
864 ((data
->totallines
-(data
->visual_y
-1) < data
->maxlines
) ?
865 ((data
->visual_y
-1)+data
->maxlines
) :
866 ((data
->maxlines
> data
->totallines
) ?
870 MUIA_TextEditor_Prop_First
, (data
->visual_y
-1)*data
->fontheight
,
874 data
->NoNotify
= TRUE
;
877 struct marking newblock
;
879 NiceBlock(&data
->blockinfo
, &newblock
);
880 data
->Pen
= GetColor(data
->blockinfo
.stopx
- ((data
->blockinfo
.stopx
&& newblock
.startx
== data
->blockinfo
.startx
&& newblock
.startline
== data
->blockinfo
.startline
) ? 1 : 0), data
->blockinfo
.stopline
);
883 data
->Pen
= GetColor(data
->CPos_X
, data
->actualline
);
885 if(t_pen
!= data
->Pen
)
886 set(obj
, MUIA_TextEditor_Pen
, data
->Pen
);
888 if(data
->actualline
->line
.Flow
!= data
->Flow
)
890 data
->Flow
= data
->actualline
->line
.Flow
;
891 set(obj
, MUIA_TextEditor_Flow
, data
->actualline
->line
.Flow
);
894 if(data
->actualline
->line
.Separator
!= data
->Separator
)
896 data
->Separator
= data
->actualline
->line
.Separator
;
897 set(obj
, MUIA_TextEditor_Separator
, data
->actualline
->line
.Separator
);
900 if(areamarked
!= Enabled(data
))
901 set(obj
, MUIA_TextEditor_AreaMarked
, Enabled(data
));
903 data
->NoNotify
= FALSE
;