antiright-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Antiright-devel] antiright/src/arshell textedit.c


From: Jeffrey Bedard
Subject: [Antiright-devel] antiright/src/arshell textedit.c
Date: Sun, 29 Aug 2004 19:54:12 -0400

CVSROOT:        /cvsroot/antiright
Module name:    antiright
Branch:         
Changes by:     Jeffrey Bedard <address@hidden> 04/08/29 23:49:31

Modified files:
        src/arshell    : textedit.c 

Log message:
        Fixed compilation.  Fixed the the line display when the cursor is at a 
newline character.  Added arshell_position().

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/antiright/antiright/src/arshell/textedit.c.diff?tr1=1.14&tr2=1.15&r1=text&r2=text

Patches:
Index: antiright/src/arshell/textedit.c
diff -u antiright/src/arshell/textedit.c:1.14 
antiright/src/arshell/textedit.c:1.15
--- antiright/src/arshell/textedit.c:1.14       Sun Aug 29 22:52:58 2004
+++ antiright/src/arshell/textedit.c    Sun Aug 29 23:49:31 2004
@@ -140,26 +140,26 @@
   return(lines);
 }
 void
-arshell_position(XmTextPosition current_position, unsigned int *total_lines
-                unsigned int *current_line, unsigned int *current_column)
+arshell_position(XmTextPosition current_position, unsigned int *total_lines,
+                unsigned int *current_line)
 {
   char *text=XmTextGetString(arshell.gui.widgets.work);
-  XmTextPosition position=0; 
+  XmTextPosition position=0;
+  XmTextPosition end_position=XmTextGetLastPosition(arshell.gui.widgets.work);
   (*total_lines)=1;
-  while(position < end_position)
+  while(position <= end_position)
     {
       if(text[position]=='\n')
+       (*total_lines)++;
+      if(position==current_position)
        {
-         (*total_lines)++;
-         (*current_column)=0;
+         (*current_line)=(*total_lines);
+         if(text[current_position]=='\n')
+           (*current_line)--;
        }
-      (*current_column)++;
-      if(position==current_position)
-       (*current_line)=(*total_lines);
       position++;
     }
   XtFree(text);
-  return(lines);
 }
 void
 arshell_goto_line(unsigned int line)
@@ -198,20 +198,6 @@
 }
 
 void
-arshell_status()
-{
-  char *status;
-  unsigned int lines_uint, current_uint;
-  float percent;
-  lines_uint=arshell_text_lines();
-  current_uint=arshell_current_line();
-  percent=current_uint/lines_uint;
-  asprintf(&status, "Lines:%d, Current:%d, Percent:%f", 
-          lines_uint, current_uint, percent*100);
-  antiright_status(status);
-  free(status);
-}
-void
 arshell_get_rid_of_modified_status()
 {
   if(arshell.flags.modified)
@@ -232,9 +218,11 @@
   char *status;
   XmTextPosition last=XmTextGetLastPosition(arshell.gui.widgets.work);
   XmTextPosition current=call_pointer->newInsert;
-  unsigned int lines_uint=arshell_text_lines();
-  unsigned int current_uint=arshell_line(current);
-  float percent=(float)current/(float)last;
+  unsigned int lines_uint;
+  unsigned int current_uint;
+  float percent;
+  arshell_position(current, &lines_uint, &current_uint);
+  percent=(float)current/(float)last;
   asprintf(&status, "Lines:%d, Current:%d, Percent:%f", 
           lines_uint, current_uint, percent*100);
   antiright_status(status);
@@ -328,7 +316,6 @@
     XmTextInsert(arshell.gui.widgets.work, 
                 XmTextGetInsertionPosition(arshell.gui.widgets.work), buffer);
   XmTextSetInsertionPosition(arshell.gui.widgets.work, 0);
-  arshell_status();
 }
 void
 arshell_create_default_text_entry(Widget widget_row_widget,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]