Hi, as topic I've implemented this attribute to avoid to get always contents of TE to know only len or if there is text... Here diff file -- Bye, Gianfranco "ShInKurO" Gignina http://shinkuro.amiga.it
Index: trunk/mcc/private.h =================================================================== --- trunk/mcc/private.h (revision 507) +++ trunk/mcc/private.h (working copy) @@ -479,6 +479,8 @@ void *ExportText(struct MUIP_TextEditor_ExportText *msg, struct InstData *data); void *ExportBlock(struct MUIP_TextEditor_ExportBlock *msg, struct InstData *data); +ULONG OM_SetBlock(struct MUIP_TextEditor_SetBlock *msg, struct InstData *data); + struct line_node *loadtext (void); unsigned short *CheckStyles (char *); Index: trunk/mcc/Dispatcher.c =================================================================== --- trunk/mcc/Dispatcher.c (revision 507) +++ trunk/mcc/Dispatcher.c (working copy) @@ -573,6 +573,7 @@ case MUIM_TextEditor_ToggleCursor: case MUIM_TextEditor_MarkText: case MUIM_TextEditor_ClearText: + case MUIM_TextEditor_SetBlock: case MUIM_HandleEvent: case MUIM_GoInactive: case MUIM_GoActive: @@ -741,7 +742,7 @@ } break; - case MUIM_TextEditor_ExportBlock: result = (ULONG)ExportBlock((struct MUIP_TextEditor_ExportBlock *)msg, data); RETURN(result); return(result); break; + case MUIM_TextEditor_ExportBlock: result = (ULONG)ExportBlock((struct MUIP_TextEditor_ExportBlock *)msg, data); RETURN(result); return(result); break; case MUIM_TextEditor_ExportText: result = (ULONG)ExportText((struct MUIP_TextEditor_ExportText *)msg, data); RETURN(result); return(result); break; case MUIM_TextEditor_ARexxCmd: result = HandleARexx(data, ((struct MUIP_TextEditor_ARexxCmd *)msg)->command); break; case MUIM_TextEditor_MarkText: result = OM_MarkText((struct MUIP_TextEditor_MarkText *)msg, data); break; @@ -749,6 +750,7 @@ case MUIM_TextEditor_Search: result = OM_Search((struct MUIP_TextEditor_Search *)msg, data); break; case MUIM_TextEditor_Replace: result = OM_Replace(obj, (struct MUIP_TextEditor_Replace *)msg, data); break; case MUIM_TextEditor_QueryKeyAction: result = OM_QueryKeyAction(cl, obj, (struct MUIP_TextEditor_QueryKeyAction *)msg); break; + case MUIM_TextEditor_SetBlock: result = OM_SetBlock((struct MUIP_TextEditor_SetBlock *)msg, data); RETURN(result); return(result); break; case MUIM_Export: { Index: trunk/mcc/ImportHook.c =================================================================== --- trunk/mcc/ImportHook.c (revision 507) +++ trunk/mcc/ImportHook.c (working copy) @@ -493,7 +493,7 @@ lastWasSeparator = TRUE; - continue; + continue; } else if(c == '/') { Index: trunk/mcc/Makefile =================================================================== --- trunk/mcc/Makefile (revision 507) +++ trunk/mcc/Makefile (working copy) @@ -298,6 +298,7 @@ $(OBJDIR)/EditorStuff.o \ $(OBJDIR)/ExportHook.o \ $(OBJDIR)/ExportBlock.o \ + $(OBJDIR)/SetBlock.o \ $(OBJDIR)/ExportText.o \ $(OBJDIR)/GetSetAttrs.o \ $(OBJDIR)/HandleARexx.o \ @@ -328,6 +329,7 @@ $(OBJDIR)/EditorStuff.o \ $(OBJDIR)/ExportHook.o \ $(OBJDIR)/ExportBlock.o \ + $(OBJDIR)/SetBlock.o \ $(OBJDIR)/ExportText.o \ $(OBJDIR)/GetSetAttrs.o \ $(OBJDIR)/HandleARexx.o \ Index: trunk/mcc/Navigation.c =================================================================== --- trunk/mcc/Navigation.c (revision 507) +++ trunk/mcc/Navigation.c (working copy) @@ -20,6 +20,7 @@ ***************************************************************************/ +#include <string.h> #include <clib/alib_protos.h> #include <proto/graphics.h> #include <proto/intuition.h> @@ -63,10 +64,9 @@ { struct TextExtent tExtend; LONG offset = data->pixel_x-FlowSpace(line->line.Flow, text, data); - if(offset < 1) offset = 1; - + res = TextFit(&data->tmprp, text, lineCharsWidth, &tExtend, NULL, 1, offset, data->font->tf_YSize); // in case of a hard-wrapped line we have to deal with @@ -96,7 +96,7 @@ ENTER(); pos = TextLength(&data->tmprp, data->actualline->line.Contents+bytes, x); - + if(*(data->actualline->line.Contents+data->CPos_X) == '\n') pos += TextLength(&data->tmprp, " ", 1)/2; else Index: trunk/mcc/GetSetAttrs.c =================================================================== --- trunk/mcc/GetSetAttrs.c (revision 507) +++ trunk/mcc/GetSetAttrs.c (working copy) @@ -188,6 +188,31 @@ ti_Data = data->undolevel; break; + case MUIA_TextEditor_ContentsLen: + { + struct line_node *node = data->firstline; + ULONG len = 0; + + while(node) + { + struct line_node *next_node = node->next; + + + len += node->line.Length; + + + // to make sure that for the last line we don't export the additional, + // artificial newline '\n' we reduce the passed length value by one. + if(next_node == NULL && node->line.Contents[node->line.Length-1] == '\n') + len--; + + node = next_node; + } + + ti_Data = len; + } + break; + default: LEAVE(); return(DoSuperMethodA(cl, obj, (Msg)msg)); Index: trunk/mcc/ExportBlock.c =================================================================== --- trunk/mcc/ExportBlock.c (revision 507) +++ trunk/mcc/ExportBlock.c (working copy) @@ -49,8 +49,25 @@ newblock.stopx = data->CPos_X; } + if(flags & MUIF_TextEditor_ExportBlock_TakeBlock) + { + + if (msg->starty <= (ULONG)data->totallines) + newblock.startline = LineNode(msg->starty+1, data); + + if (msg->startx <= (newblock.startline)->line.Length) + newblock.startx = msg->startx; + + if (msg->stopx <= (newblock.startline)->line.Length) + newblock.stopx = msg->stopx; + + if (msg->starty <= (ULONG)data->totallines) + newblock.stopline = LineNode(msg->stopy+1, data); + } + node = newblock.startline; + // clear the export message memset(&emsg, 0, sizeof(struct ExportMessage)); @@ -90,6 +107,7 @@ else emsg.SkipBack = 0; } + // call the ExportHook and exit immediately if it returns NULL if((user_data = (void*)CallHookPkt(exportHook, NULL, &emsg)) == NULL) Index: trunk/include/mui/TextEditor_mcc.h =================================================================== --- trunk/include/mui/TextEditor_mcc.h (revision 507) +++ trunk/include/mui/TextEditor_mcc.h (working copy) @@ -86,6 +86,7 @@ #define MUIA_TextEditor_UndoLevels (TextEditor_Dummy + 0x38) #define MUIA_TextEditor_WrapMode (TextEditor_Dummy + 0x39) #define MUIA_TextEditor_ActiveObjectOnClick (TextEditor_Dummy + 0x3a) +#define MUIA_TextEditor_ContentsLen (TextEditor_Dummy + 0x3b) #define MUIM_TextEditor_AddKeyBindings (TextEditor_Dummy + 0x22) #define MUIM_TextEditor_ARexxCmd (TextEditor_Dummy + 0x23) @@ -102,11 +103,12 @@ #define MUIM_TextEditor_Search (TextEditor_Dummy + 0x2b) #define MUIM_TextEditor_MarkText (TextEditor_Dummy + 0x2c) #define MUIM_TextEditor_QueryKeyAction (TextEditor_Dummy + 0x2d) +#define MUIM_TextEditor_SetBlock (TextEditor_Dummy + 0x2e) struct MUIP_TextEditor_ARexxCmd { ULONG MethodID; STRPTR command; }; struct MUIP_TextEditor_BlockInfo { ULONG MethodID; ULONG *startx; ULONG *starty; ULONG *stopx; ULONG *stopy; }; struct MUIP_TextEditor_ClearText { ULONG MethodID; }; -struct MUIP_TextEditor_ExportBlock { ULONG MethodID; ULONG flags; }; +struct MUIP_TextEditor_ExportBlock { ULONG MethodID; ULONG flags; ULONG startx; ULONG starty; ULONG stopx; ULONG stopy;}; struct MUIP_TextEditor_ExportText { ULONG MethodID; }; struct MUIP_TextEditor_HandleError { ULONG MethodID; ULONG errorcode; }; /* See below for error codes */ struct MUIP_TextEditor_InsertText { ULONG MethodID; STRPTR text; LONG pos; }; /* See below for positions */ @@ -114,6 +116,7 @@ struct MUIP_TextEditor_Search { ULONG MethodID; STRPTR SearchString; ULONG Flags; }; struct MUIP_TextEditor_MarkText { ULONG MethodID; ULONG start_crsr_x; ULONG start_crsr_y; ULONG stop_crsr_x; ULONG stop_crsr_y; }; struct MUIP_TextEditor_QueryKeyAction { ULONG MethodID; ULONG keyAction; }; +struct MUIP_TextEditor_SetBlock { ULONG MethodID; ULONG startx; ULONG starty; ULONG stopx; ULONG stopy; ULONG operation; ULONG flag;}; #define MUIV_TextEditor_ExportHook_Plain 0x00000000 #define MUIV_TextEditor_ExportHook_EMail 0x00000001 @@ -151,7 +154,14 @@ /* Flags for MUIM_TextEditor_ExportBlock */ #define MUIF_TextEditor_ExportBlock_FullLines (1 << 0) +#define MUIF_TextEditor_ExportBlock_TakeBlock (1 << 1) +/* Flags for MUIM_TextEditor_SetBlock */ +#define MUIF_TextEditor_SetBlock_Color (1 << 0) +#define MUIF_TextEditor_SetBlock_StyleBold (1 << 1) +#define MUIF_TextEditor_SetBlock_StyleItalic (1 << 2) +#define MUIF_TextEditor_SetBlock_StyleUnderline (1 << 3) + /* Error codes given as argument to MUIM_TextEditor_HandleError */ #define Error_ClipboardIsEmpty 0x01 #define Error_ClipboardIsNotFTXT 0x02