[TextEditor-mcc] Re: Cursor Y position chained with vertical scroll?

  • From: "Gianfranco \"ShInKurO\" Gignina" <sh1nkur0@xxxxxxxxx>
  • To: texteditor_mcc@xxxxxxxxxxxxx
  • Date: Tue, 30 Jun 2009 08:57:53 +0200

Il 24-Giu-2009, Gianfranco "ShInKurO" Gignina scrisse:

> What do you think? 

After to have tried many solution the only praticable way is to add a new
attribute which if setted to TRUE does this work. 
My problem is that my current implementation has problems when a line is
very long and it's automatically wrapped, in this case the visual y is at
the end of the line, while I would cursor to be positioned at the first
visible line into TE obj... but I haven't understand how I can calculate
value which correspond to first visible line...

help please :)

-- 
Bye, 
Gianfranco "ShInKurO" Gignina

http://shinkuro.amiga.it
Index: mcc/private.h
===================================================================
--- mcc/private.h       (revision 521)
+++ mcc/private.h       (working copy)
@@ -291,6 +291,7 @@
   LONG    totallines;         // Total number of lines
   LONG    maxlines;         // max visual lines in gadget
   ULONG   flags;
+  BOOL    cursorFollowsSlider; //cursor follows slider movements?
 
   UWORD   cursor_shown;       // Width of stored cursor
   Object  *object;          // Pointer to the object itself
Index: mcc/GetSetAttrs.c
===================================================================
--- mcc/GetSetAttrs.c   (revision 521)
+++ mcc/GetSetAttrs.c   (working copy)
@@ -284,6 +284,10 @@
           crsr_y = ti_Data;
         break;
 
+      case MUIA_TextEditor_CursorFollowsSlider:
+        data->cursorFollowsSlider = ti_Data;
+      break;
+
       case MUIA_TextEditor_Prop_Release:
         data->smooth_wait = ti_Data;
       break;
@@ -335,6 +339,9 @@
             }
 
             DumpText(data->visual_y+line_nr, line_nr, data->maxlines+1, FALSE, 
data);
+
+            if (data->cursorFollowsSlider)
+              crsr_y = data->visual_y;
           }
           else
           {
@@ -360,6 +367,9 @@
               }
 
               DumpText(data->visual_y, 0, lines, FALSE, data);
+
+              if (data->cursorFollowsSlider)
+                crsr_y = data->visual_y;
             }
             else
             {
@@ -716,7 +726,8 @@
       data->CPos_X = (data->actualline->line.Length > (ULONG)crsr_x) ? 
(UWORD)crsr_x : (UWORD)data->actualline->line.Length-1;
     }
 
-    ScrollIntoDisplay(data);
+    if (!data->cursorFollowsSlider)
+      ScrollIntoDisplay(data);
     SetCursor(data->CPos_X, data->actualline, TRUE, data);
 
     data->pixel_x = 0;
Index: include/mui/TextEditor_mcc.h
===================================================================
--- include/mui/TextEditor_mcc.h        (revision 521)
+++ include/mui/TextEditor_mcc.h        (working copy)
@@ -100,6 +100,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_CursorFollowsSlider   (TextEditor_Dummy + 0x3b)
 
 #define MUIM_TextEditor_AddKeyBindings        (TextEditor_Dummy + 0x22)
 #define MUIM_TextEditor_ARexxCmd              (TextEditor_Dummy + 0x23)
Index: doc/MCC_TextEditor.doc
===================================================================
--- doc/MCC_TextEditor.doc      (revision 521)
+++ doc/MCC_TextEditor.doc      (working copy)
@@ -32,6 +32,7 @@
 TextEditor.mcc/MUIA_TextEditor_Rows
 TextEditor.mcc/MUIA_TextEditor_Separator
 TextEditor.mcc/MUIA_TextEditor_Slider
+TextEditor.mcc/MUIA_TextEditor_CursorFollowsSlider
 TextEditor.mcc/MUIA_TextEditor_StyleBold
 TextEditor.mcc/MUIA_TextEditor_StyleItalic
 TextEditor.mcc/MUIA_TextEditor_StyleUnderline
@@ -827,6 +828,25 @@
         MUIA_TextEditor_Prop_DeltaFactor, MUIA_TextEditor_Prop_Entries
         MUIA_TextEditor_Prop_First, MUIA_TextEditor_Prop_Visible
 
+TextEditor.mcc/MUIA_TextEditor_CursorFollowsSlider
+
+    NAME
+        MUIA_TextEditor_CursorFollowsSlider -- [IS.], BOOL (v15.29)
+
+    FUNCTION
+        When value of this tag is TRUE cursor will follow slider movements 
+        instead to stay in its current position. Useful when there are
+        many TextEditor objects into a group setted with MUIA_Group_PageMode.
+        In this case when user will return into a TextEditor object this will
+        be in the same scrolled position user had left it before to select
+        another TextEditor into that group.
+        Default is FALSE.
+
+    EXAMPLE
+
+    SEE ALSO
+        
+
 TextEditor.mcc/MUIA_TextEditor_StyleBold
 
     NAME

Other related posts: