Browse Source

* edit.c: Use edit->stack_disable instead of static variable.

Pavel Roskin 22 years ago
parent
commit
0454cf6eb1
3 changed files with 20 additions and 24 deletions
  1. 4 0
      edit/ChangeLog
  2. 3 1
      edit/edit-widget.h
  3. 13 23
      edit/edit.c

+ 4 - 0
edit/ChangeLog

@@ -1,3 +1,7 @@
+2002-12-16  Pavel Roskin  <proski@gnu.org>
+
+	* edit.c: Use edit->stack_disable instead of static variable.
+
 2002-12-15  Pavel Roskin  <proski@gnu.org>
 
 	* edit.c (check_file_access): Use non-blocking open() followed

+ 3 - 1
edit/edit-widget.h

@@ -93,7 +93,9 @@ struct WEdit {
     unsigned long stack_size;
     unsigned long stack_size_mask;
     unsigned long stack_bottom;
-    struct stat stat1;
+    int stack_disable;		/* If not 0, don't save events in the undo stack */
+
+    struct stat stat1;		/* Result of mc_fstat() on the file */
 
     /* syntax higlighting */
     struct _syntax_marker *syntax_marker;

+ 13 - 23
edit/edit.c

@@ -66,9 +66,6 @@ static int current_selection = 0;
 /* Note: selection.text = selection_history[current_selection].text */
 static struct selection selection_history[NUM_SELECTION_HISTORY];
 
-static char *option_chars_move_whole_word =
-    "!=&|<>^~ !:;, !'!`!.?!\"!( !) !Aa0 !+-*/= |<> ![ !] !\\#! ";
-
 /*
  *
  * here's a quick sketch of the layout: (don't run this through indent.)
@@ -99,12 +96,6 @@ static char *option_chars_move_whole_word =
  *
  */
 
-/*
-   returns a byte from any location in the file.
-   Returns '\n' if out of bounds.
- */
-
-static int push_action_disabled = 0;
 
 static void edit_move_to_prev_col (WEdit *edit, long p);
 
@@ -439,23 +430,18 @@ edit_load_file (WEdit *edit)
     if (fast_load) {
 	edit->last_byte = edit->stat1.st_size;
 	edit_load_file_fast (edit, edit->filename);
+	/* If fast load was used, the number of lines wasn't calculated */
+	edit->total_lines = edit_count_lines (edit, 0, edit->last_byte);
     } else {
 	edit->last_byte = 0;
-    }
-
-    if (!fast_load) {
 	if (*edit->filename) {
-	    push_action_disabled = 1;
+	    edit->stack_disable = 1;
 	    if (!edit_insert_file (edit, edit->filename)) {
 		edit_clean (edit);
 		return 1;
 	    }
-	    /* FIXME: this should be an unmodification() function */
-	    push_action_disabled = 0;
+	    edit->stack_disable = 0;
 	}
-    } else {
-	/* If fast load was used, the number of lines wasn't calculated */
-	edit->total_lines = edit_count_lines (edit, 0, edit->last_byte);
     }
     return 0;
 }
@@ -720,7 +706,7 @@ void edit_push_action (WEdit * edit, long c,...)
 	}
     }
     spm1 = (edit->stack_pointer - 1) & edit->stack_size_mask;
-    if (push_action_disabled)
+    if (edit->stack_disable)
 	return;
 
 #ifdef FAST_MOVE_CURSOR
@@ -1677,10 +1663,14 @@ void edit_mark_cmd (WEdit * edit, int unmark)
     }
 }
 
-static unsigned long my_type_of (int c)
+static unsigned long
+my_type_of (int c)
 {
     int x, r = 0;
-    char *p, *q;
+    const char *p, *q;
+    const char option_chars_move_whole_word[] =
+	"!=&|<>^~ !:;, !'!`!.?!\"!( !) !Aa0 !+-*/= |<> ![ !] !\\#! ";
+
     if (!c)
 	return 0;
     if (c == '!') {
@@ -1801,7 +1791,7 @@ edit_do_undo (WEdit * edit)
     long ac;
     long count = 0;
 
-    push_action_disabled = 1;	/* don't record undo's onto undo stack! */
+    edit->stack_disable = 1;	/* don't record undo's onto undo stack! */
 
     while ((ac = pop_action (edit)) < KEY_PRESS) {
 	switch ((int) ac) {
@@ -1853,7 +1843,7 @@ edit_do_undo (WEdit * edit)
     edit_update_curs_row (edit);
 
   done_undo:;
-    push_action_disabled = 0;
+    edit->stack_disable = 0;
 }
 
 static void edit_delete_to_line_end (WEdit * edit)