arch/cpu.resource: remove dead code
[AROS.git] / workbench / classes / zune / texteditor / mcc / GetSetAttrs.c
blobad7370b55b18174d75e94fa945837016ebff4ac6
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
19 $Id$
21 ***************************************************************************/
23 #include <intuition/classes.h>
24 #include <utility/tagitem.h>
25 #include <clib/alib_protos.h>
27 #include <proto/exec.h>
28 #include <proto/graphics.h>
29 #include <proto/utility.h>
30 #include <proto/layers.h>
31 #include <proto/intuition.h>
33 #include <libraries/mui.h>
34 #include <proto/muimaster.h>
36 #include "private.h"
37 #include "Debug.h"
39 #include "version.h"
41 /// mGet()
42 IPTR mGet(struct IClass *cl, Object *obj, struct opGet *msg)
44 struct InstData *data = INST_DATA(cl, obj);
45 IPTR ti_Data;
47 ENTER();
49 switch(msg->opg_AttrID)
51 case MUIA_TextEditor_CursorPosition:
53 LONG xplace;
54 LONG yplace;
55 LONG cursor_width;
56 LONG x = data->CPos_X;
57 struct line_node *line = data->actualline;
58 LONG line_nr = LineToVisual(data, line) - 1;
59 struct pos_info pos;
61 OffsetToLines(data, x, line, &pos);
63 // calculate the cursor width
64 // if it is set to 6 then we should find out how the width of the current char is
65 if(data->CursorWidth == 6)
66 cursor_width = TextLength(&data->tmprp, line->line.Contents[x] < ' ' ? (char *)" " : (char *)&line->line.Contents[x], 1);
67 else
68 cursor_width = data->CursorWidth;
70 xplace = _mleft(obj) + TextLength(&data->tmprp, &line->line.Contents[x-pos.x], pos.x);
71 xplace += FlowSpace(data, line->line.Flow, &line->line.Contents[pos.bytes]);
72 yplace = data->ypos + (data->fontheight * (line_nr + pos.lines - 1));
74 data->CursorPosition.MinX = xplace;
75 data->CursorPosition.MinY = yplace;
76 data->CursorPosition.MaxX = xplace + cursor_width - 1;
77 data->CursorPosition.MaxY = yplace + data->fontheight - 1;
78 ti_Data = (IPTR)&data->CursorPosition;
80 break;
82 case MUIA_TextEditor_UndoAvailable:
83 ti_Data = (data->nextUndoStep > 0) ? TRUE : FALSE;
84 break;
86 case MUIA_TextEditor_RedoAvailable:
87 ti_Data = (data->nextUndoStep < data->usedUndoSteps) ? TRUE : FALSE;
88 break;
90 case MUIA_TextEditor_ActiveObjectOnClick:
91 ti_Data = isFlagSet(data->flags, FLG_ActiveOnClick);
92 break;
94 case MUIA_TextEditor_AutoClip:
95 ti_Data = isFlagSet(data->flags, FLG_AutoClip);
96 break;
98 case MUIA_TextEditor_KeyUpFocus:
99 ti_Data = (IPTR)data->KeyUpFocus;
100 break;
102 case MUIA_Version:
103 ti_Data = LIB_VERSION;
104 break;
106 case MUIA_Revision:
107 ti_Data = LIB_REVISION;
108 break;
110 case MUIA_ControlChar:
111 ti_Data = (IPTR)data->CtrlChar;
112 break;
114 case MUIA_TextEditor_AreaMarked:
115 ti_Data = Enabled(data);
116 break;
117 case MUIA_TextEditor_CursorX:
118 ti_Data = data->CPos_X;
119 break;
120 case MUIA_TextEditor_CursorY:
121 ti_Data = LineNr(data, data->actualline)-1;
122 break;
123 case MUIA_TextEditor_ExportWrap:
124 ti_Data = data->ExportWrap;
125 break;
126 case MUIA_TextEditor_FixedFont:
127 ti_Data = data->use_fixedfont;
128 break;
129 case MUIA_TextEditor_Pen:
130 ti_Data = data->Pen;
131 break;
132 case MUIA_TextEditor_Flow:
133 ti_Data = data->Flow;
134 break;
135 case MUIA_TextEditor_Separator:
136 ti_Data = data->Separator;
137 break;
138 case MUIA_TextEditor_HasChanged:
139 ti_Data = data->HasChanged;
140 break;
141 case MUIA_TextEditor_HorizontalScroll:
142 ti_Data = isFlagSet(data->flags, FLG_HScroll);
143 break;
144 case MUIA_TextEditor_ImportWrap:
145 ti_Data = data->ImportWrap;
146 break;
147 /* case MUIA_TextEditor_InsertMode:
148 ti_Data = data->InsertMode;
149 break;
151 case MUIA_TextEditor_Prop_Entries:
152 ti_Data = data->totallines;
153 break;
154 case MUIA_TextEditor_Prop_Visible:
155 ti_Data = data->maxlines;
156 break;
157 case MUIA_TextEditor_Prop_DeltaFactor:
158 ti_Data = data->fontheight;
159 break;
160 case MUIA_TextEditor_Prop_First:
161 ti_Data = (data->visual_y-1)*data->fontheight;
162 break;
163 case MUIA_TextEditor_ReadOnly:
164 ti_Data = isFlagSet(data->flags, FLG_ReadOnly);
165 break;
166 case MUIA_TextEditor_Quiet:
167 ti_Data = isFlagSet(data->flags, FLG_Quiet);
168 break;
169 case MUIA_TextEditor_StyleBold:
170 ti_Data = ((GetStyle(data->CPos_X, data->actualline) & BOLD) ? TRUE : FALSE);
171 break;
172 case MUIA_TextEditor_StyleItalic:
173 ti_Data = ((GetStyle(data->CPos_X, data->actualline) & ITALIC) ? TRUE : FALSE);
174 break;
175 case MUIA_TextEditor_StyleUnderline:
176 ti_Data = ((GetStyle(data->CPos_X, data->actualline) & UNDERLINE) ? TRUE : FALSE);
177 break;
178 case MUIA_TextEditor_TypeAndSpell:
179 ti_Data = data->TypeAndSpell;
180 break;
182 case MUIA_TextEditor_WrapBorder:
183 ti_Data = data->WrapBorder;
184 break;
186 case MUIA_TextEditor_WrapMode:
187 ti_Data = data->WrapMode;
188 break;
190 case MUIA_TextEditor_WrapWords:
191 ti_Data = data->WrapWords;
192 break;
194 case MUIA_Font:
195 ti_Data = (IPTR)data->font;
196 break;
198 case MUIA_TextEditor_UndoLevels:
199 ti_Data = data->maxUndoSteps;
200 break;
202 case MUIA_TextEditor_PasteStyles:
203 ti_Data = isFlagSet(data->flags, FLG_PasteStyles);
204 break;
206 case MUIA_TextEditor_PasteColors:
207 ti_Data = isFlagSet(data->flags, FLG_PasteColors);
208 break;
210 case MUIA_TextEditor_ConvertTabs:
211 ti_Data = data->ConvertTabs;
212 break;
214 case MUIA_TextEditor_TabSize:
215 ti_Data = data->TabSize;
216 break;
218 case MUIA_TextEditor_MatchedKeyword:
219 // just a dummy to make notifications work
220 ti_Data = (IPTR)NULL;
221 break;
223 default:
224 LEAVE();
225 return(DoSuperMethodA(cl, obj, (Msg)msg));
228 *msg->opg_Storage = ti_Data;
230 RETURN(TRUE);
231 return(TRUE);
235 /// mSet()
236 IPTR mSet(struct IClass *cl, Object *obj, struct opSet *msg)
238 struct InstData *data = INST_DATA(cl, obj);
239 struct TagItem *tags, *tag;
240 const char *contents = NULL;
241 IPTR result = FALSE;
242 LONG crsr_x = INT_MAX;
243 LONG crsr_y = INT_MAX;
244 BOOL reimport = FALSE;
246 ENTER();
248 if(data->shown == TRUE && isFlagClear(data->flags, FLG_Draw))
250 // handle the disabled flag only if we are not under control of MUI4
251 if(isFlagClear(data->flags, FLG_MUI4) && (tag = FindTagItem(MUIA_Disabled, msg->ops_AttrList)) != NULL)
253 if(tag->ti_Data)
254 setFlag(data->flags, FLG_Ghosted);
255 else
256 clearFlag(data->flags, FLG_Ghosted);
258 data->UpdateInfo = msg;
259 MUI_Redraw(obj, MADF_DRAWUPDATE);
261 RETURN((IPTR)data->UpdateInfo);
262 return((IPTR)data->UpdateInfo);
265 tags = msg->ops_AttrList;
266 while((tag = NextTagItem((APTR)&tags)))
268 IPTR ti_Data = tag->ti_Data;
270 switch(tag->ti_Tag)
272 case MUIA_ControlChar:
273 data->CtrlChar = (UBYTE)ti_Data;
274 break;
276 case MUIA_Disabled:
278 BOOL modified = FALSE;
280 if(ti_Data && isFlagClear(data->flags, FLG_Ghosted))
282 setFlag(data->flags, FLG_Ghosted);
283 modified = TRUE;
285 else if(!ti_Data && isFlagSet(data->flags, FLG_Ghosted))
287 clearFlag(data->flags, FLG_Ghosted);
288 modified = TRUE;
291 // perform a redraw only if the disabled state has really changed
292 // and we are NOT under the control of MUI4 which does the ghost
293 // effect itself
294 if(modified == TRUE && isFlagClear(data->flags, FLG_MUI4))
296 MUI_Redraw(obj, MADF_DRAWOBJECT);
299 // make sure a possibly existing slider is disabled as well
300 if(data->slider != NULL)
301 set(data->slider, MUIA_Disabled, ti_Data);
303 break;
305 case MUIA_TextEditor_Rows:
306 data->Rows = ti_Data;
307 break;
309 case MUIA_TextEditor_Columns:
310 data->Columns = ti_Data;
311 break;
313 case MUIA_TextEditor_AutoClip:
314 if(ti_Data)
315 setFlag(data->flags, FLG_AutoClip);
316 else
317 clearFlag(data->flags, FLG_AutoClip);
318 break;
320 case MUIA_TextEditor_ColorMap:
321 data->colormap = (ULONG *)ti_Data;
322 break;
324 case MUIA_TextEditor_InVirtualGroup:
325 if(ti_Data)
326 setFlag(data->flags, FLG_InVGrp);
327 else
328 clearFlag(data->flags, FLG_InVGrp);
329 break;
331 case MUIA_TextEditor_CursorX:
332 if(data->NoNotify == FALSE)
333 crsr_x = ti_Data;
334 break;
336 case MUIA_TextEditor_CursorY:
337 if(data->NoNotify == FALSE)
338 crsr_y = ti_Data;
339 break;
341 case MUIA_TextEditor_Prop_Release:
342 data->smooth_wait = ti_Data;
343 break;
345 case MUIA_TextEditor_Prop_First:
347 if(((data->visual_y-1)*data->fontheight+(_mtop(obj) - data->ypos) != (LONG)ti_Data) && data->shown == TRUE)
349 LONG smooth;
350 LONG lastpixel = ((data->visual_y-1)*data->fontheight) + (_mtop(obj) - data->ypos);
351 struct Hook *oldhook;
352 void *cliphandle;
354 data->visual_y = (ti_Data/data->fontheight)+1;
355 smooth = ti_Data - lastpixel;
357 if(smooth > 0)
358 data->scr_direction = 1;
359 else
360 data->scr_direction = 0;
362 oldhook = InstallLayerHook(data->rport->Layer, LAYERS_NOBACKFILL);
363 cliphandle = MUI_AddClipping(muiRenderInfo(obj), _mleft(obj), _mtop(obj), _mwidth(obj), data->maxlines*data->fontheight);
364 if(smooth > 0 && smooth < data->maxlines*data->fontheight)
366 LONG line_nr;
368 ScrollRasterBF(data->rport, 0, smooth,
369 _mleft(obj), _mtop(obj),
370 _mright(obj), _mtop(obj) + (data->maxlines * data->fontheight) - 1);
372 data->ypos = _mtop(obj) - ti_Data%data->fontheight;
373 line_nr = data->maxlines-(smooth/data->fontheight)-1;
376 struct Layer *layer = data->rport->Layer;
378 if(layer->DamageList && layer->DamageList->RegionRectangle)
380 if(MUI_BeginRefresh(muiRenderInfo(obj),0))
382 MUI_Redraw(obj, MADF_DRAWOBJECT);
383 MUI_EndRefresh(muiRenderInfo(obj), 0);
388 DumpText(data, data->visual_y+line_nr, line_nr, data->maxlines+1, FALSE);
390 else
392 if(smooth < 0 && -smooth < data->maxlines*data->fontheight)
394 LONG lines;
396 ScrollRasterBF(data->rport, 0, smooth,
397 _mleft(obj), _mtop(obj),
398 _mright(obj), _mtop(obj) + (data->maxlines * data->fontheight) - 1);
399 data->ypos = _mtop(obj) - ti_Data%data->fontheight;
400 lines = (-smooth/data->fontheight)+2;
402 struct Layer *layer = data->rport->Layer;
404 if(layer->DamageList && layer->DamageList->RegionRectangle)
405 if(MUI_BeginRefresh(muiRenderInfo(obj),0))
407 MUI_Redraw(obj, MADF_DRAWOBJECT);
408 MUI_EndRefresh(muiRenderInfo(obj), 0);
412 DumpText(data, data->visual_y, 0, lines, FALSE);
414 else
416 if(smooth != 0)
417 DumpText(data, data->visual_y, 0, data->maxlines+1, FALSE);
420 MUI_RemoveClipping(muiRenderInfo(obj), cliphandle);
421 InstallLayerHook(data->rport->Layer, oldhook);
423 if(data->scrollaction == FALSE)
425 RequestInput(data);
426 data->smooth_wait = 1;
427 data->scrollaction = TRUE;
430 SetAttrs(obj, MUIA_TextEditor_Prop_Entries,
431 ((data->totallines-(data->visual_y-1) < data->maxlines) ?
432 ((data->visual_y-1)+data->maxlines) :
433 ((data->maxlines > data->totallines) ?
434 data->maxlines :
435 data->totallines))
436 * data->fontheight,
437 TAG_DONE);
439 break;
441 case MUIA_TextEditor_ReadOnly:
443 if(ti_Data)
445 SetCursor(data, data->CPos_X, data->actualline, FALSE);
446 setFlag(data->flags, FLG_ReadOnly);
448 // force the activeOnClick to be turned off
449 // in case the user explicitly sets the readonly object
450 clearFlag(data->flags, FLG_ActiveOnClick);
452 // enable that the object will automatically get a border when
453 // the ActiveObjectOnClick option is active
454 _flags(obj) &= ~(1<<7);
456 else
458 clearFlag(data->flags, FLG_ReadOnly);
459 if(data->shown == TRUE)
461 if(isFlagSet(data->flags, FLG_Active))
462 SetCursor(data, data->CPos_X, data->actualline, TRUE);
465 // disable that the object will automatically get a border when
466 // the ActiveObjectOnClick option is active
467 if(isFlagSet(data->flags, FLG_ActiveOnClick))
468 _flags(obj) |= (1<<7);
471 break;
473 case MUIA_TextEditor_ActiveObjectOnClick:
475 if(ti_Data)
477 setFlag(data->flags, FLG_ActiveOnClick);
479 // disable that the object will automatically get a border when
480 // the ActiveObjectOnClick option is active
481 _flags(obj) |= (1<<7);
483 else
485 clearFlag(data->flags, FLG_ActiveOnClick);
487 // enable that the object will automatically get a border when
488 // the ActiveObjectOnClick option is active
489 _flags(obj) &= ~(1<<7);
492 break;
494 case MUIA_TextEditor_PopWindow_Open:
496 if(ti_Data)
497 setFlag(data->flags, FLG_PopWindow);
498 else
499 clearFlag(data->flags, FLG_PopWindow);
501 break;
503 case MUIA_TextEditor_Quiet:
505 if(ti_Data)
507 setFlag(data->flags, FLG_Quiet);
509 else
511 clearFlag(data->flags, FLG_Quiet);
512 MUI_Redraw(obj, MADF_DRAWOBJECT);
513 if(data->maxlines > data->totallines)
514 set(obj, MUIA_TextEditor_Prop_Entries, data->maxlines*data->fontheight);
515 else
516 set(obj, MUIA_TextEditor_Prop_Entries, data->totallines*data->fontheight);
517 set(obj, MUIA_TextEditor_Prop_First, (data->visual_y-1)*data->fontheight);
520 break;
522 case MUIA_TextEditor_StyleBold:
523 AddStyle(data, &data->blockinfo, BOLD, ti_Data != 0);
524 break;
526 case MUIA_TextEditor_StyleItalic:
527 AddStyle(data, &data->blockinfo, ITALIC, ti_Data != 0);
528 break;
530 case MUIA_TextEditor_StyleUnderline:
531 AddStyle(data, &data->blockinfo, UNDERLINE, ti_Data != 0);
532 break;
534 case MUIA_TextEditor_Pen:
536 if(data->NoNotify == FALSE)
538 data->Pen = ti_Data;
539 AddColor(data, &data->blockinfo, (UWORD)ti_Data);
540 data->HasChanged = TRUE;
543 break;
545 case MUIA_TextEditor_KeyUpFocus:
546 data->KeyUpFocus = (Object *)ti_Data;
547 break;
549 case MUIA_TextEditor_Slider:
551 if(data->shown == FALSE)
553 data->slider = (void *)ti_Data;
555 // disable the slider right away if the texteditor
556 // gadget is disabled as well.
557 if(isFlagSet(data->flags, FLG_Ghosted))
558 set(data->slider, MUIA_Disabled, TRUE);
560 DoMethod(data->slider, MUIM_Notify,
561 MUIA_Prop_Release, MUIV_EveryTime,
562 obj, 3, MUIM_NoNotifySet, MUIA_TextEditor_Prop_Release, MUIV_TriggerValue);
563 DoMethod(data->slider, MUIM_Notify,
564 MUIA_Prop_First, MUIV_EveryTime,
565 obj, 3, MUIM_NoNotifySet, MUIA_TextEditor_Prop_First, MUIV_TriggerValue);
566 DoMethod(obj, MUIM_Notify,
567 MUIA_TextEditor_Prop_First, MUIV_EveryTime,
568 data->slider, 3, MUIM_NoNotifySet, MUIA_Prop_First, MUIV_TriggerValue);
569 DoMethod(obj, MUIM_Notify,
570 MUIA_TextEditor_Prop_Entries, MUIV_EveryTime,
571 data->slider, 3, MUIM_NoNotifySet, MUIA_Prop_Entries, MUIV_TriggerValue);
572 DoMethod(obj, MUIM_Notify,
573 MUIA_TextEditor_Prop_Visible, MUIV_EveryTime,
574 data->slider, 3, MUIM_NoNotifySet, MUIA_Prop_Visible, MUIV_TriggerValue);
575 DoMethod(obj, MUIM_Notify,
576 MUIA_TextEditor_Prop_DeltaFactor, MUIV_EveryTime,
577 data->slider, 3, MUIM_NoNotifySet, MUIA_Prop_DeltaFactor, MUIV_TriggerValue);
580 break;
582 case MUIA_TextEditor_FixedFont:
584 if(data->shown == FALSE)
586 if(ti_Data)
588 data->font = data->fixedfont;
589 data->use_fixedfont = TRUE;
591 else
593 data->font = data->normalfont;
594 data->use_fixedfont = FALSE;
597 // now we check whether we have a valid font or not
598 // and if not we take the default one of our muiAreaData
599 if(data->font == NULL)
600 data->font = _font(obj);
603 break;
605 case MUIA_TextEditor_DoubleClickHook:
606 data->DoubleClickHook = (struct Hook *)ti_Data;
607 break;
609 case MUIA_TextEditor_HasChanged:
611 data->HasChanged = ti_Data;
612 if(ti_Data == FALSE)
613 clearFlag(data->flags, FLG_UndoLost);
615 break;
617 case MUIA_TextEditor_HorizontalScroll:
619 if(ti_Data)
620 setFlag(data->flags, FLG_HScroll);
621 else
622 clearFlag(data->flags, FLG_HScroll);
624 break;
626 case MUIA_TextEditor_Contents:
627 contents = ti_Data ? (const char *)ti_Data : "";
628 break;
630 case MUIA_TextEditor_ImportHook:
632 switch(ti_Data)
634 case MUIV_TextEditor_ImportHook_Plain:
635 data->ImportHook = &ImPlainHook;
636 break;
637 case MUIV_TextEditor_ImportHook_EMail:
638 data->ImportHook = &ImEMailHook;
639 break;
640 case MUIV_TextEditor_ImportHook_MIME:
641 data->ImportHook = &ImMIMEHook;
642 break;
643 case MUIV_TextEditor_ImportHook_MIMEQuoted:
644 data->ImportHook = &ImMIMEQuoteHook;
645 break;
646 default:
647 data->ImportHook = (struct Hook *)ti_Data;
650 break;
652 case MUIA_TextEditor_ImportWrap:
653 data->ImportWrap = ti_Data;
654 break;
656 case MUIA_TextEditor_ExportHook:
658 switch(ti_Data)
660 case MUIV_TextEditor_ExportHook_Plain:
661 data->ExportHook = &ExportHookPlain;
662 break;
664 case MUIV_TextEditor_ExportHook_EMail:
665 data->ExportHook = &ExportHookEMail;
666 break;
668 case MUIV_TextEditor_ExportHook_NoStyle:
669 data->ExportHook = &ExportHookNoStyle;
670 break;
672 default:
673 data->ExportHook = (struct Hook *)ti_Data;
676 break;
678 case MUIA_TextEditor_ExportWrap:
679 data->ExportWrap = ti_Data;
680 break;
682 case MUIA_TextEditor_Flow:
684 if(data->NoNotify == FALSE)
686 LONG start, lines = 0;
688 data->Flow = ti_Data;
689 if(Enabled(data))
691 struct marking newblock;
692 struct line_node *startline;
694 NiceBlock(&data->blockinfo, &newblock);
695 startline = newblock.startline;
696 start = LineToVisual(data, startline);
700 lines += startline->visual;
701 startline->line.Flow = ti_Data;
702 startline = GetNextLine(startline);
704 while(startline != GetNextLine(newblock.stopline));
706 else
708 start = LineToVisual(data, data->actualline);
709 lines = data->actualline->visual;
710 data->actualline->line.Flow = ti_Data;
711 data->pixel_x = 0;
713 if(start < 1)
714 start = 1;
715 if(start-1+lines > data->maxlines)
716 lines = data->maxlines-(start-1);
717 DumpText(data, data->visual_y+start-1, start-1, start-1+lines, TRUE);
718 data->HasChanged = TRUE;
721 break;
723 case MUIA_TextEditor_WrapBorder:
725 if(data->WrapBorder != (LONG)ti_Data)
727 data->WrapBorder = ti_Data;
728 ResetDisplay(data);
731 break;
733 case MUIA_TextEditor_WrapMode:
735 if(data->WrapMode != ti_Data)
737 data->WrapMode = ti_Data;
738 ResetDisplay(data);
741 break;
743 case MUIA_TextEditor_TypeAndSpell:
744 data->TypeAndSpell = ti_Data;
745 break;
747 case MUIA_TextEditor_UndoLevels:
748 data->userUndoBufferSize = TRUE;
749 ResizeUndoBuffer(data, ti_Data);
750 break;
752 case MUIA_TextEditor_PasteStyles:
754 if(ti_Data)
755 setFlag(data->flags, FLG_PasteStyles);
756 else
757 clearFlag(data->flags, FLG_PasteStyles);
759 break;
761 case MUIA_TextEditor_PasteColors:
763 if(ti_Data)
764 setFlag(data->flags, FLG_PasteColors);
765 else
766 clearFlag(data->flags, FLG_PasteColors);
768 break;
770 case MUIA_TextEditor_ConvertTabs:
772 if(data->ConvertTabs != (BOOL)ti_Data)
774 data->ConvertTabs = ti_Data;
775 reimport = TRUE;
778 break;
780 case MUIA_TextEditor_TabSize:
782 if(data->TabSize != (LONG)ti_Data)
784 if(data->TabSize == MUIV_TextEditor_TabSize_Default)
786 // reset the TAB size to the configured value
787 if(data->TabSize != data->GlobalTabSize)
789 // reimport the text only if the TAB size really changes
790 data->TabSize = data->GlobalTabSize;
791 reimport = TRUE;
793 clearFlag(data->flags, FLG_ForcedTabSize);
795 else
797 data->TabSize = MINMAX(2, ti_Data, 12);
798 setFlag(data->flags, FLG_ForcedTabSize);
799 // a reimport is definitely necessary
800 reimport = TRUE;
804 break;
806 case MUIA_TextEditor_WrapWords:
808 if(data->WrapWords != (BOOL)ti_Data)
810 data->WrapWords = ti_Data;
811 ResetDisplay(data);
814 break;
816 case MUIA_TextEditor_Keywords:
818 ParseKeywords(data, (const char *)tag->ti_Data);
820 break;
824 if(reimport == TRUE)
826 // reimport the text to match the current TAB size and TAB conversion mode
827 result = ReimportText(cl, obj);
830 if(contents != NULL)
832 struct MinList newlines;
834 if(ImportText(data, contents, data->ImportHook, data->ImportWrap, &newlines) == TRUE)
836 FreeTextMem(data, &data->linelist);
837 MoveLines(&data->linelist, &newlines);
838 ResetDisplay(data);
839 ResetUndoBuffer(data);
840 result = TRUE;
844 if(crsr_x != INT_MAX || crsr_y != INT_MAX)
846 SetCursor(data, data->CPos_X, data->actualline, FALSE);
848 if(crsr_y != INT_MAX)
850 data->actualline = LineNode(data, crsr_y+1);
851 if(data->actualline->line.Length < data->CPos_X)
852 data->CPos_X = data->actualline->line.Length-1;
854 if(crsr_x != INT_MAX)
856 data->CPos_X = (data->actualline->line.Length > crsr_x) ? crsr_x : data->actualline->line.Length-1;
859 ScrollIntoDisplay(data);
860 SetCursor(data, data->CPos_X, data->actualline, TRUE);
862 data->pixel_x = 0;
863 result = TRUE;
866 RETURN(result);
867 return result;