revert between 56095 -> 55830 in arch
[AROS.git] / workbench / classes / zune / texteditor / mcc / ExportText.c
blobf7425aea6e8aa3bbf8c57608b768be74bceb8e54
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 <string.h>
25 #include <proto/utility.h>
27 #include "private.h"
28 #include "Debug.h"
30 /// mExportText()
31 IPTR mExportText(struct IClass *cl, Object *obj, UNUSED struct MUIP_TextEditor_ExportText *msg)
33 struct InstData *data = INST_DATA(cl, obj);
34 struct line_node *node;
35 struct Hook *exportHook = data->ExportHook;
36 LONG wraplen = data->ExportWrap;
37 struct ExportMessage emsg;
38 void *user_data = NULL;
40 ENTER();
42 // clear the export message
43 memset(&emsg, 0, sizeof(struct ExportMessage));
45 node = GetFirstLine(&data->linelist);
46 while(node != NULL)
48 struct line_node *next = GetNextLine(node);
50 emsg.UserData = user_data;
51 emsg.Contents = node->line.Contents;
52 emsg.Length = node->line.Length;
53 emsg.Styles = node->line.Styles;
54 emsg.Colors = node->line.Colors;
55 emsg.Highlight = node->line.Highlight;
56 emsg.Flow = node->line.Flow;
57 emsg.Separator = node->line.Separator;
58 emsg.ExportWrap = wraplen;
59 emsg.Last = next == NULL;
61 // to make sure that for the last line we don't export the additional,
62 // artificial newline '\n' we reduce the passed length value by one.
63 if(next == NULL && emsg.Contents[node->line.Length-1] == '\n')
64 emsg.Length--;
66 // call the ExportHook and exit immediately if it returns NULL
67 if((user_data = (void*)CallHookPkt(exportHook, NULL, &emsg)) == NULL)
68 break;
70 node = next;
73 RETURN((IPTR)user_data);
74 return (IPTR)user_data;
77 ///