Il 20-Mag-2009, Jens Langner scrisse: > > Which BTW is also available in italian language ;) > > http://svnbook.red-bean.com/nightly/it/svn-book.html Oh, finally you have understand my real problem :) btw, I've just removed that >>><<< problems some days ago:) here diff :-) -- 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 *); @@ -596,6 +598,7 @@ FLG_NumberOf }; +#define MUIA_TextEditor_ContentsLen (TextEditor_Dummy + 0x3b) #define MUIM_TextEditor_InputTrigger 0xad000101 #define MUIM_TextEditor_ToggleCursor 0xad000102 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) @@ -102,11 +102,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 +115,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 +153,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 Index: trunk/doc/MCC_TextEditor.doc =================================================================== --- trunk/doc/MCC_TextEditor.doc (revision 507) +++ trunk/doc/MCC_TextEditor.doc (working copy) @@ -1106,6 +1106,11 @@ SYNOPSIS DoMethod(obj, MUIM_TextEditor_ExportBlock, ULONG flags); + DoMethod(obj, MUIM_TextEditor_ExportBlock, + MUIF_TextEditor_ExportBlock_TakeBlock, + ULONG startx, ULONG starty, + ULONG stopx, ULONG stopy); + FUNCTION This method exports portions of the current text via the active export hook and returns it in an AllocVec() allocated string. @@ -1122,6 +1127,13 @@ non-marked characters as well. If no text is marked, then the line where the current cursor is on will be exported. + MUIF_TextEditor_ExportBlock_TakeBlock: + Passing this flag the method will accept 4 ULONG coordinates, + startx, starty, stopx, stopy. Passing after this flag these + coordinates permitts to retrieve a block of text without it is + currently marked. useful to analize a block without user sees a + similar behaviour marking a block. + RESULT Depends on the export hook. The built-in hooks will return a pointer to a NUL-terminated buffer containing all the text. @@ -1133,6 +1145,50 @@ MUIM_TextEditor_InsertText MUIM_TextEditor_ExportText +TextEditor.mcc/MUIM_TextEditor_SetBlock + + NAME + MUIM_TextEditor_SetBlock + + SYNOPSIS + DoMethod(obj, MUIM_TextEditor_SetBlock, + ULONG startx, ULONG starty, + ULONG stopx, ULONG stopy, + ULONG operation, ULONG flag); + + FUNCTION + This method sets style or color of a block of text identified + using 4 ULONG coordinates startx, starty, stopx, stopy (so, + without to mark it, see MUIM_TextEditor_ExportBlock). You can + decide what modification you will make to your block passing + one of this special value which identifies an operation: + + MUIF_TextEditor_SetBlock_Color: + Text block will assume color of value pen passed as last + flag parameter (it depends from current render pen, see + MUIA_TextEditor_ColorMap and MUIA_TextEditor_Pen). + + MUIF_TextEditor_SetBlock_StyleBold: + Text block will assume bold style if flag value passed as + last flag parameter will be TRUE and will removed bold style + from text block if flag value passed will be FALSE; + + MUIF_TextEditor_SetBlock_StyleItalic: + Text block will assume italic style if flag value passed as + last flag parameter will be TRUE and will removed italic style + from text block if flag value passed will be FALSE; + + MUIF_TextEditor_SetBlock_StyleUnderline: + Text block will assume underline style if flag value passed as + last flag parameter will be TRUE and will removed underline style + from text block if flag value passed will be FALSE; + + RESULT + This methos will return always TRUE. + + SEE ALSO + MUIA_TextEditor_ExportBlock + TextEditor.mcc/MUIM_TextEditor_ExportText NAME