[TextEditor-mcc] Re: MUIA_TextEditor_ContentsLen

  • From: "Gianfranco \"ShInKurO\" Gignina" <sh1nkur0@xxxxxxxxx>
  • To: texteditor_mcc@xxxxxxxxxxxxx
  • Date: Tue, 26 May 2009 10:18:30 +0200

Il 20-Mag-2009, Jens Langner scrisse:



>
> (1) remove your MUIA_TextEditor_ContentsLen change again as I express
> my doubts about its usability. So please consider to write an
> MUIM_TextEditor_ExportTextLen method instead if you really need such a
> functionality. So please do a "svn revert GetSetAttrs.c"

done

>
> (2) There is still a proposed change in ImportHook.c and Navigation.c
> where only white spaces are changed. Please revert these changes by
> executing "svn revert ImportHook.c Navigation.c"
>

done

> (3) For the new MUIM_TextEditor_SetBlock you have an "ULONG operation"
> attribute. What is the purpose of this as I can't see it being used
> somewhere. 

It's explained into autodoc and it's used into SetBlock.c :)

In addition, I can't see the SetBlock.c content. So please
> do a "svn add SetBlock.c" before submitting the next diff.

Done:)

However, I've yet conflict:

svn: Aborting commit:
'/ShinKy-Data/Dev/C-AmigaOS/texteditor-mcc/trunk/mcc/private.h' remains in
conflict

Here diff file...


btw: I've sent my TheBar diff file into ml :-)

-- 
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,7 +598,6 @@
   FLG_NumberOf
 };
 
-
 #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/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/SetBlock.c
===================================================================
--- trunk/mcc/SetBlock.c        (revision 0)
+++ trunk/mcc/SetBlock.c        (revision 0)
@@ -0,0 +1,67 @@
+#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, flag=%ld\n", 
msg->startx,msg->stopx,msg->starty,msg->stopy,msg->operation,msg->flag);
+//D(DBF_STARTUP, "NBK : startx=%ld, stopx=%ld, starty=%ld, stopy=%ld 
operation=%ld, flag=%ld\n", 
newblock.startx,newblock.stopx,(LineNr(newblock.startline, data)-1), 
(LineNr(newblock.stopline, data)-1),msg->operation,msg->flag);
+
+  if(msg->operation & MUIF_TextEditor_SetBlock_Color)
+  {
+//D(DBF_STARTUP, "SetBlock: color %ld\n", msg->flag);
+     newblock.enabled=TRUE;
+
+     AddColor(&newblock, (UWORD)msg->flag, data);
+
+     newblock.enabled=FALSE;
+  }
+  else
+  {  
+    if(msg->operation & MUIF_TextEditor_SetBlock_StyleBold)
+    {
+//D(DBF_STARTUP, "SetBlock: StyleBold %ld\n", msg->flag);
+      AddStyle(&newblock, BOLD, msg->flag, data);
+    }
+
+    if(msg->operation & MUIF_TextEditor_SetBlock_StyleItalic)
+    {
+//D(DBF_STARTUP, "SetBlock: StyleItalic %ld\n", msg->flag);
+      AddStyle(&newblock, ITALIC, msg->flag, data);
+  }
+
+    if(msg->operation & MUIF_TextEditor_SetBlock_StyleUnderline)
+    {
+//D(DBF_STARTUP, "SetBlock: StyleUnderline %ld\n", msg->flag);
+      AddStyle(&newblock, UNDERLINE, msg->flag, 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 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

Other related posts: