Il 28-Mag-2009, Jens Langner scrisse: > So, Gianfranco, it would be great if you could check my above changed > to your suggested functionality and adapt your SetBlock method > accordingly. Then please resubmit your diff file and if everything > looks fine you cna commit your changes. > > Of course, comments from others on this mailinglist are welcome. Done, sorry to have taken time :-) -- Bye, Gianfranco "ShInKurO" Gignina http://shinkuro.amiga.it
Index: trunk/mcc/private.h =================================================================== --- trunk/mcc/private.h (revision 512) +++ trunk/mcc/private.h (working copy) @@ -480,6 +480,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 *); @@ -597,7 +599,6 @@ FLG_NumberOf }; - #define MUIM_TextEditor_InputTrigger 0xad000101 #define MUIM_TextEditor_ToggleCursor 0xad000102 Index: trunk/mcc/Dispatcher.c =================================================================== --- trunk/mcc/Dispatcher.c (revision 512) +++ 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/Makefile =================================================================== --- trunk/mcc/Makefile (revision 512) +++ 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/SetBlock.c =================================================================== --- trunk/mcc/SetBlock.c (revision 0) +++ trunk/mcc/SetBlock.c (revision 0) @@ -0,0 +1,89 @@ +#include <string.h> + +#include <proto/utility.h> + +#include "private.h" + +ULONG OM_SetBlock(struct MUIP_TextEditor_SetBlock *msg, struct InstData *data) +{ + struct marking newblock; + + ENTER(); + +//D(DBF_STARTUP, "SetBlock\n"); + {//identify block + 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; + else if (msg->stopx == (newblock.startline)->line.Length) + newblock.stopx = msg->stopx-1; + + if (msg->starty <= (ULONG)data->totallines) + newblock.stopline = LineNode(msg->stopy+1, data); + } + +//D(DBF_STARTUP, "(newblock.startline)->line.Length=%ld\n", (newblock.startline)->line.Length); +//D(DBF_STARTUP, "MSG : startx=%ld, stopx=%ld, starty=%ld, stopy=%ld operation=%ld, value=%ld\n", msg->startx,msg->stopx,msg->starty,msg->stopy,msg->operation,msg->value); +//D(DBF_STARTUP, "NBK : startx=%ld, stopx=%ld, starty=%ld, stopy=%ld operation=%ld, value=%ld\n", newblock.startx,newblock.stopx,(LineNr(newblock.startline, data)-1), (LineNr(newblock.stopline, data)-1),msg->operation,msg->value); + + if(msg->operation & MUIF_TextEditor_SetBlock_Color) + { +//D(DBF_STARTUP, "SetBlock: color %ld\n", msg->value); + newblock.enabled=TRUE; + + AddColor(&newblock, (UWORD)msg->value, data); + + newblock.enabled=FALSE; + } + else if(msg->operation & MUIF_TextEditor_SetBlock_StyleBold) + { +//D(DBF_STARTUP, "SetBlock: StyleBold %ld\n", msg->value); + AddStyle(&newblock, BOLD, msg->value, data); + } + else if(msg->operation & MUIF_TextEditor_SetBlock_StyleItalic) + { +//D(DBF_STARTUP, "SetBlock: StyleItalic %ld\n", msg->value); + AddStyle(&newblock, ITALIC, msg->value, data); + } + else if(msg->operation & MUIF_TextEditor_SetBlock_StyleUnderline) + { +//D(DBF_STARTUP, "SetBlock: StyleUnderline %ld\n", msg->value); + AddStyle(&newblock, UNDERLINE, msg->value, data); + } + else + { + LONG start, lines = 0; + struct marking newblock2; + struct line_node *startline; +//D(DBF_STARTUP, "SetBlock: Flow %ld\n", msg->value); + data->Flow = msg->value; + + NiceBlock(&newblock, &newblock2); + startline = newblock2.startline; + start = LineToVisual(startline, data); + + do + { + lines += startline->visual; + startline->line.Flow = msg->value; + startline = startline->next; + } while(startline != newblock2.stopline->next); + + if(start < 1) + start = 1; + + if(start-1+lines > data->maxlines) + lines = data->maxlines-(start-1); + + DumpText(data->visual_y+start-1, start-1, start-1+lines, TRUE, data); + } + + + RETURN(TRUE); + return TRUE; +} Property changes on: trunk/mcc/SetBlock.c ___________________________________________________________________ Name: amiga:protection + ----rw-d ---- ---- Index: trunk/mcc/ExportBlock.c =================================================================== --- trunk/mcc/ExportBlock.c (revision 512) +++ 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 512) +++ 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 value;}; #define MUIV_TextEditor_ExportHook_Plain 0x00000000 #define MUIV_TextEditor_ExportHook_EMail 0x00000001 @@ -151,7 +153,15 @@ /* 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) +#define MUIF_TextEditor_SetBlock_Flow (1 << 4) + /* 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 512) +++ 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,69 @@ MUIM_TextEditor_InsertText MUIM_TextEditor_ExportText + TextEditor.mcc/MUIM_TextEditor_SetBlock + + NAME + MUIM_TextEditor_SetBlock (v15.29) + + SYNOPSIS + DoMethod(obj, MUIM_TextEditor_SetBlock, + ULONG startx, ULONG starty, + ULONG stopx, ULONG stopy, + ULONG operation, ULONG value); + + FUNCTION + This method performs a specific operation on a text block that + is defined by four coordinates (startx,starty,stopx,stopy) + (see MUIM_TextEditor_BlockInfo). The types of operations that + can be performed are supplied via a flag variable 'operation' + and an optional value for all operations can be supplied via + 'value'. + + Possible flags for the 'operation' variable are: + + MUIF_TextEditor_SetBlock_Color: + The text block will be assigned a text color in accordance + to the supplied color number in parameter 'value'. + (see MUIA_TextEditor_ColorMap and MUIA_TextEditor_Pen). + + MUIF_TextEditor_SetBlock_StyleBold: + Depending on the content of the 'value' (TRUE/FALSE) the + selected text block will get the bold style added or + removed. + + MUIF_TextEditor_SetBlock_StyleItalic: + Depending on the content of 'value' (TRUE/FALSE) the + selected text block will get the italic style added or + removed. + + MUIF_TextEditor_SetBlock_StyleUnderline: + Depending on the content of 'value' (TRUE/FALSE) the + selected text block will get the underline style added or + removed. + + MUIF_TextEditor_SetBlock_Flow: + Depending on the content of 'value' the selected text block + will change it's alignment. + (see MUIA_TextEditor_Flow for possible values) + + RESULT + TRUE if operation succeeded, FALSE if it failed. + + NOTE + When combining multiple operations via flags, care have to be + taken for the content of 'value'. E.g. it is not possible to + have bold style added and italic style removed because of the + global usage of the 'value' parameter. So for mutual exclusive + operations you will have to call this method multiple times. + + SEE ALSO + MUIA_TextEditor_ExportBlock + MUIM_TextEditor_BlockInfo + MUIA_TextEditor_ColorMap + MUIA_TextEditor_Pen + MUIA_TextEditor_Flow + TextEditor.mcc/MUIM_TextEditor_ExportText NAME