arch/cpu.resource: remove dead code
[AROS.git] / workbench / classes / zune / texteditor / mcc / TextEditor-Test.c
blob4c9ee43027766436ac8af5ce40a9f4156579a855
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 <stdio.h>
24 #include <string.h>
26 #include <clib/alib_protos.h>
28 #include <exec/tasks.h>
29 #include <libraries/mui.h>
31 #include <proto/dos.h>
32 #include <proto/exec.h>
33 #include <proto/muimaster.h>
34 #include <proto/intuition.h>
35 #include <proto/utility.h>
36 #if defined(__amigaos4__)
37 #include <dos/obsolete.h>
38 #endif
40 #include "private.h"
41 #define DEBUG_USE_MALLOC_REDEFINE
42 #include "Debug.h"
43 #include "version.h"
45 #include "SDI_hook.h"
47 // global data
48 Object *editorgad = NULL;
50 // static hooks
51 HOOKPROTONHNO(URLHookCode, LONG, struct ClickMessage *cm)
53 ULONG pos = cm->ClickPosition;
55 while(pos && *(cm->LineContents+pos-1) != ' ' && *(cm->LineContents+pos-1) != '<')
57 pos--;
60 if(strncmp(cm->LineContents+pos, "http:", 5))
62 return(FALSE);
65 return(TRUE);
67 MakeStaticHook(URLHook, URLHookCode);
69 HOOKPROTONHNONP(PosHookCode, void)
71 unsigned int x, y, sx, sy;
72 struct Rectangle *crsr;
74 if(DoMethod(editorgad, MUIM_TextEditor_BlockInfo, &x, &y, &sx, &sy))
75 printf("%d, %d, %d, %d\n", x, y, sx, sy);
77 if((crsr = (APTR)xget(editorgad, MUIA_TextEditor_CursorPosition)))
78 printf("Cursor: (%d, %d) - (%d, %d)\n", crsr->MinX, crsr->MinY, crsr->MaxX, crsr->MaxY);
80 MakeStaticHook(PosHook, PosHookCode);
82 HOOKPROTONHNONP(ExportBlockCode, void)
84 STRPTR text;
86 CallHookPkt(&PosHook, NULL, NULL);
88 if((text = (STRPTR)DoMethod(editorgad, MUIM_TextEditor_ExportBlock, MUIF_TextEditor_ExportBlock_FullLines)))
90 printf("[%s]\n", text);
92 FreeVec(text);
95 MakeStaticHook(ExportBlockHook, ExportBlockCode);
97 HOOKPROTONH(ARexxHookCode, LONG, Object *app, struct RexxMsg *rexxmsg)
99 ULONG result;
101 result = DoMethod(editorgad, MUIM_TextEditor_ARexxCmd, rexxmsg->rm_Args[0]);
103 if(result != 0)
105 if(result != TRUE)
107 printf("rexx result: '%s'\n", (char *)result);
109 set(app, MUIA_Application_RexxString, result);
111 // if the ARexxCmd returns a string we have to free
112 // the memory here.
113 FreeVec((APTR)result);
117 return(0);
119 MakeStaticHook(ARexxHook, ARexxHookCode);
121 #if defined(__amigaos4__)
122 struct Library *DiskfontBase = NULL;
123 struct Library *GfxBase = NULL;
124 struct Library *IntuitionBase = NULL;
125 struct Library *KeymapBase = NULL;
126 struct Library *LayersBase = NULL;
127 struct Library *LocaleBase = NULL;
128 struct Library *MUIMasterBase = NULL;
129 struct Library *RexxSysBase = NULL;
130 struct Library *UtilityBase = NULL;
131 struct Library *WorkbenchBase = NULL;
132 #elif defined(__MORPHOS__)
133 struct Library *DiskfontBase = NULL;
134 struct GfxBase *GfxBase = NULL;
135 struct IntuitionBase *IntuitionBase = NULL;
136 struct Library *KeymapBase = NULL;
137 struct Library *LayersBase = NULL;
138 struct Library *LocaleBase = NULL;
139 struct Library *MUIMasterBase = NULL;
140 struct Library *RexxSysBase = NULL;
141 struct Library *UtilityBase = NULL;
142 struct Library *WorkbenchBase = NULL;
143 #else
144 struct Library *DiskfontBase = NULL;
145 struct GfxBase *GfxBase = NULL;
146 struct IntuitionBase *IntuitionBase = NULL;
147 struct Library *KeymapBase = NULL;
148 struct Library *LayersBase = NULL;
149 struct Library *LocaleBase = NULL;
150 struct Library *MUIMasterBase = NULL;
151 struct Library *RexxSysBase = NULL;
152 #if defined(__AROS__)
153 struct UtilityBase *UtilityBase = NULL;
154 #else
155 struct Library *UtilityBase = NULL;
156 #endif
157 struct Library *WorkbenchBase = NULL;
158 #endif
160 #if defined(__amigaos4__)
161 struct DiskfontIFace *IDiskfont = NULL;
162 struct GraphicsIFace *IGraphics = NULL;
163 struct IntuitionIFace *IIntuition = NULL;
164 struct KeymapIFace *IKeymap = NULL;
165 struct LayersIFace *ILayers = NULL;
166 struct LocaleIFace *ILocale = NULL;
167 struct MUIMasterIFace *IMUIMaster = NULL;
168 struct RexxSysIFace *IRexxSys = NULL;
169 struct UtilityIFace *IUtility = NULL;
170 struct WorkbenchIFace *IWorkbench = NULL;
171 #endif
173 DISPATCHERPROTO(_Dispatcher);
175 static const char *page_titles[] = { "Shown", "Hidden", NULL };
177 int main(void)
179 void *slider;
180 long argarray[6] = {0,0,0,0,0,0};
181 struct MUI_CustomClass *mcc;
182 struct RDArgs *args;
184 if((DiskfontBase = OpenLibrary("diskfont.library", 38)) &&
185 GETINTERFACE(IDiskfont, DiskfontBase))
186 if((GfxBase = (APTR)OpenLibrary("graphics.library", 38)) &&
187 GETINTERFACE(IGraphics, GfxBase))
188 if((IntuitionBase = (APTR)OpenLibrary("intuition.library", 38)) &&
189 GETINTERFACE(IIntuition, IntuitionBase))
190 if((KeymapBase = OpenLibrary("keymap.library", 38)) &&
191 GETINTERFACE(IKeymap, KeymapBase))
192 if((LayersBase = OpenLibrary("layers.library", 38)) &&
193 GETINTERFACE(ILayers, LayersBase))
194 if((LocaleBase = OpenLibrary("locale.library", 38)) &&
195 GETINTERFACE(ILocale, LocaleBase))
196 if((RexxSysBase = OpenLibrary("rexxsyslib.library", 36)) &&
197 GETINTERFACE(IRexxSys, RexxSysBase))
198 if((UtilityBase = (APTR)OpenLibrary("utility.library", 38)) &&
199 GETINTERFACE(IUtility, UtilityBase))
201 /* Open workbench.library (optional) */
202 if ((WorkbenchBase = OpenLibrary("workbench.library",0)))
204 if (!(GETINTERFACE(IWorkbench, WorkbenchBase)))
206 CloseLibrary(WorkbenchBase);
207 WorkbenchBase = NULL;
211 #if defined(DEBUG)
212 SetupDebug();
213 #endif
215 if(StartClipboardServer())
217 if((args = ReadArgs("FILENAME,MIME/S,MIMEQUOTED/S,SKIPHEADER/S,FIXED/S,EMAIL/S", argarray, NULL)))
219 if((MUIMasterBase = OpenLibrary("muimaster.library", MUIMASTER_VMIN)) &&
220 GETINTERFACE(IMUIMaster, MUIMasterBase))
222 Object *app, *window, *clear, *cut, *copy, *paste, *erase,
223 *bold, *italic, *underline, *ischanged, *undo, *redo, *string,
224 *xslider, *yslider, *flow, *search, *replace, *wrapmode, *wrapborder,
225 *rgroup, *isdisabled, *isreadonly, *converttabs, *wrapwords;
226 Object *lower,*upper;
227 Object *undoslider;
229 const char *flow_text[] = { "Left", "Center", "Right", NULL };
230 const char *wrap_modes[] = { "NoWrap", "SoftWrap", "HardWrap", NULL };
231 const char *classes[] = { "TextEditor.mcc", NULL };
232 int wrap_border = 76;
234 mcc = MUI_CreateCustomClass(NULL, "Area.mui", NULL, sizeof(struct InstData), ENTRY(_Dispatcher));
236 app = MUI_NewObject("Application.mui",
237 MUIA_Application_Author, "TextEditor.mcc Open Source Team",
238 MUIA_Application_Base, "TextEditor-Test",
239 MUIA_Application_Copyright, LIB_COPYRIGHT,
240 MUIA_Application_Description, "TextEditor.mcc test program",
241 MUIA_Application_Title, "TextEditor-Test",
242 MUIA_Application_Version, "$VER: TextEditor-Test (" __DATE__ ")",
243 MUIA_Application_RexxHook, &ARexxHook,
244 MUIA_Application_UsedClasses, classes,
246 MUIA_Application_Window,
247 window = WindowObject,
248 MUIA_Window_Title, "TextEditor-Test",
249 MUIA_Window_ID, MAKE_ID('M','A','I','N'),
250 MUIA_Window_RootObject, VGroup,
251 Child, VGroup,
252 Child, HGroup,
254 Child, clear = MUI_MakeObject(MUIO_Button, "Clear"),
255 Child, cut = MUI_MakeObject(MUIO_Button, "Cut"),
256 Child, copy = MUI_MakeObject(MUIO_Button, "Copy"),
257 Child, paste = MUI_MakeObject(MUIO_Button, "_Paste"),
258 Child, erase = MUI_MakeObject(MUIO_Button, "Erase"),
259 Child, undo = MUI_MakeObject(MUIO_Button, "_Undo"),
260 Child, redo = MUI_MakeObject(MUIO_Button, "_Redo"),
261 Child, search = MUI_MakeObject(MUIO_Button, "Search"),
262 Child, replace = MUI_MakeObject(MUIO_Button, "Replace"),
263 Child, lower = MUI_MakeObject(MUIO_Button, "lower"),
264 Child, upper = MUI_MakeObject(MUIO_Button, "upper"),
266 End,
268 Child, HGroup,
270 Child, bold = TextObject,
271 MUIA_Background, MUII_ButtonBack,
272 MUIA_Frame, MUIV_Frame_Button,
273 MUIA_Text_PreParse, "\33c",
274 MUIA_Text_Contents, "Bold",
275 MUIA_FixHeight, 17,
276 MUIA_FixWidth, 24,
277 MUIA_InputMode, MUIV_InputMode_Toggle,
278 MUIA_CycleChain, TRUE,
279 End,
281 Child, italic = TextObject,
282 MUIA_Background, MUII_ButtonBack,
283 MUIA_Frame, MUIV_Frame_Button,
284 MUIA_Text_PreParse, "\33c",
285 MUIA_Text_Contents, "Italic",
286 MUIA_FixHeight, 17,
287 MUIA_FixWidth, 24,
288 MUIA_InputMode, MUIV_InputMode_Toggle,
289 MUIA_CycleChain, TRUE,
290 End,
292 Child, underline = TextObject,
293 MUIA_Background, MUII_ButtonBack,
294 MUIA_Frame, MUIV_Frame_Button,
295 MUIA_Text_PreParse, "\33c",
296 MUIA_Text_Contents, "Underline",
297 MUIA_FixHeight, 17,
298 MUIA_FixWidth, 24,
299 MUIA_InputMode, MUIV_InputMode_Toggle,
300 MUIA_CycleChain, TRUE,
301 End,
303 Child, ischanged = MUI_MakeObject(MUIO_Checkmark, "Is changed?"),
304 Child, isdisabled = MUI_MakeObject(MUIO_Checkmark, "Is disabled?"),
305 Child, isreadonly = MUI_MakeObject(MUIO_Checkmark, "Is read-only?"),
306 Child, flow = MUI_MakeObject(MUIO_Cycle, NULL, flow_text),
307 Child, wrapmode = MUI_MakeObject(MUIO_Cycle, NULL, wrap_modes),
308 Child, wrapborder = MUI_MakeObject(MUIO_Slider, NULL, 0, 10000),
309 Child, converttabs = TextObject,
310 MUIA_Background, MUII_ButtonBack,
311 MUIA_Frame, MUIV_Frame_Button,
312 MUIA_Text_PreParse, "\33c",
313 MUIA_Text_Contents, "Tabs2Spaces",
314 MUIA_FixHeight, 17,
315 MUIA_FixWidth, 24,
316 MUIA_InputMode, MUIV_InputMode_Toggle,
317 MUIA_CycleChain, TRUE,
318 End,
319 Child, wrapwords = TextObject,
320 MUIA_Background, MUII_ButtonBack,
321 MUIA_Frame, MUIV_Frame_Button,
322 MUIA_Text_PreParse, "\33c",
323 MUIA_Text_Contents, "Wrap words",
324 MUIA_FixHeight, 17,
325 MUIA_FixWidth, 24,
326 MUIA_InputMode, MUIV_InputMode_Toggle,
327 MUIA_CycleChain, TRUE,
328 End,
329 End,
331 Child, HGroup,
334 /* Child, NewObject(mcc->mcc_Class, NULL,
335 InputListFrame,
336 // MUIA_TextEditor_InVirtualGroup, TRUE,
337 MUIA_TextEditor_Contents, "Jeg er en dulle!",
338 End,
340 /* Child, ScrollgroupObject,
341 MUIA_Scrollgroup_Contents, VirtgroupObject,
344 /* Child, RegisterGroup(titles),
345 Child, HGroup,
347 /* Child, ColGroup(5),
348 Child, NewObject(mcc->mcc_Class, NULL, End,
349 Child, NewObject(mcc->mcc_Class, NULL, End,
350 Child, NewObject(mcc->mcc_Class, NULL, End,
351 Child, NewObject(mcc->mcc_Class, NULL, End,
352 Child, NewObject(mcc->mcc_Class, NULL, End,
353 Child, NewObject(mcc->mcc_Class, NULL, End,
354 Child, NewObject(mcc->mcc_Class, NULL, End,
355 Child, NewObject(mcc->mcc_Class, NULL, End,
356 Child, NewObject(mcc->mcc_Class, NULL, End,
357 Child, NewObject(mcc->mcc_Class, NULL, End,
358 End,
360 Child, rgroup = RegisterGroup(page_titles),
361 MUIA_Register_Frame, TRUE,
362 Child,HGroup,
363 MUIA_Group_Spacing, 0,
364 Child, editorgad = NewObject(mcc->mcc_Class, NULL,
365 // MUIA_Frame, "602211",
366 // InputListFrame,
367 // MUIA_Background, MUII_GroupBack,
368 // MUIA_TextEditor_FixedFont, TRUE,
369 MUIA_TextEditor_AutoClip, FALSE,
370 // MUIA_TextEditor_ReadOnly, TRUE,
371 // MUIA_TextEditor_ActiveObjectOnClick, TRUE,
372 MUIA_TextEditor_DoubleClickHook, &URLHook,
373 // MUIA_TextEditor_HorizontalScroll, TRUE,
374 MUIA_TextEditor_ImportWrap, 10023,
375 // MUIA_TextEditor_WrapBorder, wrap_border,
376 // MUIA_TextEditor_ExportWrap, 80,
377 MUIA_TextEditor_WrapMode, MUIV_TextEditor_WrapMode_NoWrap,
378 MUIA_TextEditor_ConvertTabs, FALSE,
379 MUIA_TextEditor_WrapWords, FALSE,
381 MUIA_TextEditor_ExportHook, MUIV_TextEditor_ExportHook_NoStyle,
382 // MUIA_TextEditor_ImportHook, MUIV_TextEditor_ImportHook_EMail,
383 MUIA_CycleChain, TRUE,
384 // MUIA_TextEditor_ReadOnly, TRUE,
385 // MUIA_TextEditor_InVirtualGroup, TRUE,
386 // MUIA_Disabled, TRUE,
387 // MUIA_TextEditor_Columns, 40,
388 // MUIA_TextEditor_CursorX, 30,
389 // MUIA_TextEditor_CursorY, 7,
390 MUIA_ControlChar, 'a',
391 MUIA_TextEditor_Contents,
393 "\n"
394 "a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line a very long line\n"
395 "\n"
396 "\33r\33b" __DATE__ "\33n\n"
397 "\n\33cTextEditor.mcc " LIB_REV_STRING " test program\n"
398 "Copyright (C) 1997 by Allan Odgaard\n"
399 LIB_COPYRIGHT "\n"
400 "\33l\n\33[s:9]\n"
401 "For feedback write to: Duff@DIKU.DK\n"
402 "\33b\33p[1]1\33p[2]2\33p[3]3\33p[4]4\33p[5]5\33p[6]6\33p[7]7\33p[8]8 Testtext\33n\n"
403 "For the latest version, try: \33p[7]\33uhttp://www.DIKU.dk/students/duff/texteditor/\33n\n"
404 "\n"
405 "\33hThis gadget is not \33ifreeware\33n. You may not use it in your own programs without a licence. A licence can be obtained thru the author.\n"
406 "\nColor test: \33b\33p[1]SHINE, \33p[2]HALFSHINE, \33p[3]BACKGROUND, \33p[4]HALFSHADOW, \33p[5]SHADOW, \33p[6]TEXT, \33p[7]FILL, \33p[8]MARK\33n\n"
407 "\nStyle test: \33bBOLD\33n, \33iITALIC\33n, \33uUNDERLINE\33n, \33b\33iBOLD & ITALIC\33n, \33b\33uBOLD & UNDERLINE\33n, \33i\33uITALIC & UNDERLINE\33n, \33b\33i\33uBOLD & ITALIC & UNDERLINE\33n, PLAIN\n"
408 "\n"
409 "\33[s:2]\33c\33u\33b Usage: \33n\n"
410 "\33l\n"
411 "You can doubleclick a word to select it, if you hold LMB after a doubleclick, then it will only mark \33bcomplete\33n words. Tripleclicking has the same effect, but for lines.\n"
412 "You can extend your block by holding down shift while you press LMB where you want the block to end.\n"
413 "While you drag to scroll, the farther away from the gadget your mouse pointer is, the faster the gadget will scroll.\n"
414 "\n"
415 "\33c\33[s:2]\33u\33b Keybindings \33n\n\33l"
416 "\n"
417 "Hold down shift and press a navigation key to mark. When something is marked you can use: LAmiga x, c to cut or copy. Delete or Backspace to erase. Or any other key to overwrite.\n"
418 "LAmiga + z, Z, v = Undo, Redo, Paste.\n"
419 "TAB will insert 3 spaces.\n"
420 "\n"
421 " \33u Navigation combinations: \33n\n"
422 "Ctrl + left, right, up, down = BOL, EOF, Top, Bottm.\n"
423 "Alt + left, right, up, down = BOW(PrevWord), NextWord, StartOfPage(PrevPage), EndOfPage(NextPage).\n"
424 "Ctrl-Alt + left, right, up, down = PrevSentence, NextSentence, PrevParagraph, NextParagraph.\n"
425 "\n"
426 " \33u Delete combinations: \33n\n"
427 "Ctrl + Backspace, Delete = \"Delele To BOL\", \"Delele To EOL\".\n"
428 "Alt + Backspace, Delete = \"Delele To BOW\", \"Delete To NextWord\".\n",
429 End,
430 Child, slider = MUI_NewObject("Scrollbar.mui", End,
431 End,
432 Child, VGroup,
433 Child, TextObject,
434 MUIA_Text_Contents, "TextEditor object is now hidden!!!",
435 End,
436 End,
437 End,
438 End,
439 /* End,
440 End,
442 /* Child, RectangleObject, End,
443 End,
447 End,
448 */ Child, HGroup,
449 Child, xslider = MUI_MakeObject(MUIO_Slider, NULL, 0, 10000),
450 Child, yslider = MUI_MakeObject(MUIO_Slider, NULL, 0, 1000),
451 End,
452 Child, undoslider = MUI_MakeObject(MUIO_Slider, NULL, 0, 1000),
453 Child, string = StringObject,
454 StringFrame,
455 MUIA_CycleChain, TRUE,
456 MUIA_String_MaxLen, 256,
457 End,
459 TAG_DONE ),
460 TAG_DONE ),
461 TAG_DONE ),
462 TAG_DONE );
464 if(app)
466 unsigned long sigs;
467 unsigned long running = 1;
468 BPTR fh;
470 set(clear, MUIA_CycleChain, TRUE);
471 set(cut, MUIA_CycleChain, TRUE);
472 set(copy, MUIA_CycleChain, TRUE);
473 set(paste, MUIA_CycleChain, TRUE);
474 set(erase, MUIA_CycleChain, TRUE);
475 set(undo, MUIA_CycleChain, TRUE);
476 set(redo, MUIA_CycleChain, TRUE);
477 set(search, MUIA_CycleChain, TRUE);
478 set(replace, MUIA_CycleChain, TRUE);
479 set(lower, MUIA_CycleChain, TRUE);
480 set(upper, MUIA_CycleChain, TRUE);
481 set(ischanged, MUIA_CycleChain, TRUE);
482 set(isdisabled, MUIA_CycleChain, TRUE);
483 set(isreadonly, MUIA_CycleChain, TRUE);
484 set(flow, MUIA_CycleChain, TRUE);
485 set(wrapmode, MUIA_CycleChain, TRUE);
486 set(wrapborder, MUIA_CycleChain, TRUE);
487 set(editorgad, MUIA_TextEditor_Slider, slider);
488 set(xslider, MUIA_CycleChain, TRUE);
489 set(yslider, MUIA_CycleChain, TRUE);
491 if(argarray[4])
493 set(editorgad, MUIA_TextEditor_FixedFont, TRUE);
496 if (argarray[0])
498 if((fh = Open((char *)argarray[0], MODE_OLDFILE)))
500 char *text = AllocVec(50*1024, 0L);
501 char *buffer = text;
502 int size;
504 size = Read(fh, text, (50*1024)-2);
505 text[size] = '\0';
506 Close(fh);
508 if(argarray[3])
510 while(*buffer != '\n' && buffer < &text[size])
512 while(*buffer++ != '\n');
516 if(argarray[2])
517 set(editorgad, MUIA_TextEditor_ImportHook, MUIV_TextEditor_ImportHook_MIMEQuoted);
518 else
519 if(argarray[1])
520 set(editorgad, MUIA_TextEditor_ImportHook, MUIV_TextEditor_ImportHook_MIME);
521 else
522 if(argarray[5])
523 set(editorgad, MUIA_TextEditor_ImportHook, MUIV_TextEditor_ImportHook_EMail);
525 SetAttrs(editorgad, MUIA_TextEditor_Contents, buffer,
526 TAG_DONE);
527 FreeVec(text);
531 DoMethod(window, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
533 DoMethod(flow, MUIM_Notify, MUIA_Cycle_Active, MUIV_EveryTime, editorgad, 3, MUIM_NoNotifySet, MUIA_TextEditor_Flow, MUIV_TriggerValue);
534 DoMethod(wrapmode, MUIM_Notify, MUIA_Cycle_Active, MUIV_EveryTime, editorgad, 3, MUIM_NoNotifySet, MUIA_TextEditor_WrapMode, MUIV_TriggerValue);
535 DoMethod(wrapborder, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, editorgad, 3, MUIM_NoNotifySet, MUIA_TextEditor_WrapBorder, MUIV_TriggerValue);
536 DoMethod(editorgad, MUIM_Notify, MUIA_TextEditor_Flow, MUIV_EveryTime, flow, 3, MUIM_NoNotifySet, MUIA_Cycle_Active, MUIV_TriggerValue);
538 DoMethod(editorgad, MUIM_Notify, MUIA_TextEditor_CursorX, MUIV_EveryTime, xslider, 3, MUIM_NoNotifySet, MUIA_Numeric_Value, MUIV_TriggerValue);
539 // DoMethod(xslider, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, editorgad, 3, MUIM_NoNotifySet, MUIA_TextEditor_Position, MUIV_TriggerValue);
540 DoMethod(editorgad, MUIM_Notify, MUIA_TextEditor_CursorY, MUIV_EveryTime, yslider, 3, MUIM_NoNotifySet, MUIA_Numeric_Value, MUIV_TriggerValue);
541 DoMethod(yslider, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, editorgad, 3, MUIM_NoNotifySet, MUIA_TextEditor_CursorY, MUIV_TriggerValue);
543 DoMethod(undoslider, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, editorgad, 3, MUIM_Set, MUIA_TextEditor_UndoLevels, MUIV_TriggerValue);
545 DoMethod(editorgad, MUIM_Notify, MUIA_TextEditor_AreaMarked, MUIV_EveryTime, MUIV_Notify_Self, 7, MUIM_MultiSet, MUIA_Disabled, MUIV_NotTriggerValue, cut, copy, erase, NULL);
546 DoMethod(editorgad, MUIM_Notify, MUIA_TextEditor_UndoAvailable, MUIV_EveryTime, undo, 3, MUIM_Set, MUIA_Disabled, MUIV_NotTriggerValue);
547 DoMethod(editorgad, MUIM_Notify, MUIA_TextEditor_RedoAvailable, MUIV_EveryTime, redo, 3, MUIM_Set, MUIA_Disabled, MUIV_NotTriggerValue);
548 DoMethod(editorgad, MUIM_Notify, MUIA_TextEditor_StyleBold, MUIV_EveryTime, bold, 3, MUIM_NoNotifySet, MUIA_Selected, MUIV_TriggerValue);
549 DoMethod(editorgad, MUIM_Notify, MUIA_TextEditor_StyleItalic, MUIV_EveryTime, italic, 3, MUIM_NoNotifySet, MUIA_Selected, MUIV_TriggerValue);
550 DoMethod(editorgad, MUIM_Notify, MUIA_TextEditor_StyleUnderline, MUIV_EveryTime, underline, 3, MUIM_NoNotifySet, MUIA_Selected, MUIV_TriggerValue);
552 DoMethod(editorgad, MUIM_Notify, MUIA_TextEditor_HasChanged, MUIV_EveryTime, ischanged, 3, MUIM_NoNotifySet, MUIA_Selected, MUIV_TriggerValue);
553 DoMethod(editorgad, MUIM_Notify, MUIA_TextEditor_HasChanged, MUIV_EveryTime, ischanged, 3, MUIM_NoNotifySet, MUIA_Image_State, MUIV_TriggerValue);
554 DoMethod(ischanged, MUIM_Notify, MUIA_Selected, MUIV_EveryTime, editorgad, 3, MUIM_NoNotifySet, MUIA_TextEditor_HasChanged, MUIV_TriggerValue);
556 DoMethod(isdisabled, MUIM_Notify, MUIA_Selected, MUIV_EveryTime, editorgad, 3, MUIM_Set, MUIA_Disabled, MUIV_TriggerValue);
557 DoMethod(isreadonly, MUIM_Notify, MUIA_Selected, MUIV_EveryTime, editorgad, 3, MUIM_Set, MUIA_TextEditor_ReadOnly, MUIV_TriggerValue);
559 DoMethod(clear, MUIM_Notify, MUIA_Pressed, FALSE, editorgad, 2, MUIM_TextEditor_ARexxCmd, "Clear");
560 // DoMethod(clear, MUIM_Notify, MUIA_Pressed, FALSE, editorgad, 2, MUIM_CallHook, &ExportBlockHook);
561 // DoMethod(clear, MUIM_Notify, MUIA_Pressed, FALSE, editorgad, 3, MUIM_NoNotifySet, MUIA_TextEditor_HasChanged, FALSE);
563 DoMethod(cut, MUIM_Notify, MUIA_Pressed, FALSE, editorgad, 2, MUIM_TextEditor_ARexxCmd, "Cut");
564 DoMethod(copy, MUIM_Notify, MUIA_Pressed, FALSE, editorgad, 2, MUIM_TextEditor_ARexxCmd, "Copy");
565 DoMethod(paste, MUIM_Notify, MUIA_Pressed, FALSE, editorgad, 2, MUIM_TextEditor_ARexxCmd, "Paste");
566 DoMethod(erase, MUIM_Notify, MUIA_Pressed, FALSE, editorgad, 2, MUIM_TextEditor_ARexxCmd, "Erase");
567 // DoMethod(undo, MUIM_Notify, MUIA_Pressed, FALSE, editorgad, 3, MUIM_Set, MUIA_TextEditor_Prop_First, 13*15);
568 DoMethod(undo, MUIM_Notify, MUIA_Pressed, FALSE, editorgad, 2, MUIM_TextEditor_ARexxCmd, "Undo");
569 DoMethod(redo, MUIM_Notify, MUIA_Pressed, FALSE, editorgad, 2, MUIM_TextEditor_ARexxCmd, "Redo");
570 DoMethod(search, MUIM_Notify, MUIA_Pressed, FALSE, editorgad, 3, MUIM_TextEditor_Search, "is not", 0);//MUIF_TextEditor_Search_CaseSensitive);
571 DoMethod(replace, MUIM_Notify, MUIA_Pressed, FALSE, editorgad, 3, MUIM_TextEditor_Replace, "replaced", 0);
572 DoMethod(lower, MUIM_Notify, MUIA_Pressed, FALSE, editorgad, 2, MUIM_TextEditor_ARexxCmd, "ToLower");
573 DoMethod(upper, MUIM_Notify, MUIA_Pressed, FALSE, editorgad, 2, MUIM_TextEditor_ARexxCmd, "ToUpper");
575 DoMethod(bold, MUIM_Notify, MUIA_Selected, MUIV_EveryTime, editorgad, 3, MUIM_NoNotifySet, MUIA_TextEditor_StyleBold, MUIV_TriggerValue);
576 DoMethod(italic, MUIM_Notify, MUIA_Selected, MUIV_EveryTime, editorgad, 3, MUIM_NoNotifySet, MUIA_TextEditor_StyleItalic, MUIV_TriggerValue);
577 DoMethod(underline, MUIM_Notify, MUIA_Selected, MUIV_EveryTime, editorgad, 3, MUIM_NoNotifySet, MUIA_TextEditor_StyleUnderline, MUIV_TriggerValue);
579 DoMethod(string, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime, editorgad, 2, MUIM_TextEditor_ARexxCmd, MUIV_TriggerValue);
580 // DoMethod(string, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime, window, 3, MUIM_Set, MUIA_Window_ActiveObject, string);
581 // DoMethod(string, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime, editorgad, 3, MUIM_TextEditor_Search, MUIV_TriggerValue, 0L);//MUIF_TextEditor_Search_FromTop);
582 // DoMethod(string, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime, editorgad, 3, MUIM_TextEditor_Replace, MUIV_TriggerValue, 0L);//MUIF_TextEditor_Search_FromTop);
584 DoMethod(window, MUIM_Notify, MUIA_Window_InputEvent, "f1", rgroup, 3, MUIM_Set, MUIA_Group_ActivePage, 0);
585 DoMethod(window, MUIM_Notify, MUIA_Window_InputEvent, "f2", rgroup, 3, MUIM_Set, MUIA_Group_ActivePage, 1);
587 DoMethod(editorgad, MUIM_Notify, MUIA_TextEditor_ConvertTabs, MUIV_EveryTime, converttabs, 3, MUIM_NoNotifySet, MUIA_Selected, MUIV_TriggerValue);
588 DoMethod(converttabs, MUIM_Notify, MUIA_Selected, MUIV_EveryTime, editorgad, 3, MUIM_NoNotifySet, MUIA_TextEditor_ConvertTabs, MUIV_TriggerValue);
589 DoMethod(editorgad, MUIM_Notify, MUIA_TextEditor_WrapWords, MUIV_EveryTime, converttabs, 3, MUIM_NoNotifySet, MUIA_Selected, MUIV_TriggerValue);
590 DoMethod(wrapwords, MUIM_Notify, MUIA_Selected, MUIV_EveryTime, editorgad, 3, MUIM_NoNotifySet, MUIA_TextEditor_WrapWords, MUIV_TriggerValue);
592 set(window, MUIA_Window_ActiveObject, editorgad);
593 set(window, MUIA_Window_Open, TRUE);
594 set(wrapmode, MUIA_Cycle_Active, MUIV_TextEditor_WrapMode_NoWrap);
595 // set(wrapmode, MUIA_Cycle_Active, MUIV_TextEditor_WrapMode_HardWrap);
596 // set(wrapmode, MUIA_Cycle_Active, MUIV_TextEditor_WrapMode_SoftWrap);
597 set(wrapborder, MUIA_Numeric_Value, wrap_border);
598 nnset(undoslider, MUIA_Numeric_Value, xget(editorgad, MUIA_TextEditor_UndoLevels));
601 /* {
602 ULONG delta = xget(editorgad, MUIA_TextEditor_Prop_DeltaFactor);
603 printf("Delta: %d\n", delta);
607 /* {
608 struct MUIP_TextEditor_Keybinding *key;
610 key = (struct MUIP_TextEditor_Keybinding *)DoMethod(editorgad, MUIM_TextEditor_QueryKeyAction, MUIV_TextEditor_KeyAction_Copy);
612 printf("code: %d, qualifier: %ld, action: %d\n", key->code, key->qualifier, key->action);
615 // DoMethod(editorgad, MUIM_TextEditor_MarkText, 0x000a000f, 0x0030000f);
618 ULONG changed;
620 while((LONG)DoMethod(app, MUIM_Application_NewInput, &sigs) != (LONG)MUIV_Application_ReturnID_Quit)
622 if(sigs)
624 sigs = Wait(sigs | SIGBREAKF_CTRL_C);
625 if(sigs & SIGBREAKF_CTRL_C)
626 break;
630 changed = xget(editorgad, MUIA_TextEditor_HasChanged);
631 if(argarray[0] && changed && !(sigs & SIGBREAKF_CTRL_C))
632 running = MUI_Request(app, window, 0L, "Warning", "*_Proceed|_Save|_Cancel", "\33cText '%s'\n is modified. Save it?", argarray[0]);
635 while(running == 0);
637 if(running == 2)
639 void *text = (void *)DoMethod(editorgad, MUIM_TextEditor_ExportText);
641 if(argarray[0] && (fh = Open((char *)argarray[0], MODE_NEWFILE)))
643 Write(fh, text, strlen(text));
644 Close(fh);
646 FreeVec(text);
648 MUI_DisposeObject(app);
650 if(mcc)
652 MUI_DeleteCustomClass(mcc);
655 else printf("Failed to create application\n");
657 DROPINTERFACE(IMUIMaster);
658 CloseLibrary(MUIMasterBase);
659 MUIMasterBase = NULL;
662 FreeArgs(args);
664 else
666 char prgname[32];
667 long error = IoErr();
669 GetProgramName(prgname, 32);
670 PrintFault(error, prgname);
673 ShutdownClipboardServer();
676 #if defined(DEBUG)
677 CleanupDebug();
678 #endif
681 if(WorkbenchBase)
683 DROPINTERFACE(IWorkbench);
684 WorkbenchBase = NULL;
687 if(UtilityBase)
689 DROPINTERFACE(IUtility);
690 CloseLibrary((struct Library *)UtilityBase);
693 if(RexxSysBase)
695 DROPINTERFACE(IRexxSys);
696 CloseLibrary(RexxSysBase);
699 if(LocaleBase)
701 DROPINTERFACE(ILocale);
702 CloseLibrary(LocaleBase);
705 if(LayersBase)
707 DROPINTERFACE(ILayers);
708 CloseLibrary(LayersBase);
711 if(KeymapBase)
713 DROPINTERFACE(IKeymap);
714 CloseLibrary(KeymapBase);
717 if(IntuitionBase)
719 DROPINTERFACE(IIntuition);
720 CloseLibrary((struct Library *)IntuitionBase);
723 if(GfxBase)
725 DROPINTERFACE(IGraphics);
726 CloseLibrary((struct Library *)GfxBase);
729 if(DiskfontBase)
731 DROPINTERFACE(IDiskfont);
732 CloseLibrary(DiskfontBase);
735 return 0;