annoyance: undo does not reset "modified" status
Adam Byrtek / alpha
alpha at student.uci.agh.edu.pl
Fri Apr 4 13:54:19 UTC 2003
On Wed, Apr 02, 2003 at 08:01:25PM +0200, Oswald Buddenhagen wrote:
> i often accidentally do minor modifications (mostly partial escape
> sequences) which i undo of course. anyway, afterwards i still don't know
> if this was the only modification.
Patch attached.
BTW I'm not sure if it is wide to undo every cursor movement. IMO
pop_action should apply EVERY movement action till the last action
which actually modified something (including this action).
Regards
--
_.|._ |_ _. : Adam Byrtek /alpha alpha at debian.org
(_|||_)| |(_| : http://krakow.linux.org.pl/ pgp 0xB25952C0
|
-------------- next part --------------
Index: edit-widget.h
===================================================================
RCS file: /cvs/gnome/mc/edit/edit-widget.h,v
retrieving revision 1.16
diff -u -r1.16 edit-widget.h
--- edit-widget.h 2 Apr 2003 19:36:10 -0000 1.16
+++ edit-widget.h 4 Apr 2003 13:46:06 -0000
@@ -88,6 +88,7 @@
unsigned long stack_size;
unsigned long stack_size_mask;
unsigned long stack_bottom;
+ unsigned char stack_wrapped;
int stack_disable; /* If not 0, don't save events in the undo stack */
struct stat stat1; /* Result of mc_fstat() on the file */
Index: edit.c
===================================================================
RCS file: /cvs/gnome/mc/edit/edit.c,v
retrieving revision 1.75
diff -u -r1.75 edit.c
--- edit.c 2 Apr 2003 22:25:00 -0000 1.75
+++ edit.c 4 Apr 2003 13:46:15 -0000
@@ -457,6 +457,7 @@
if (!edit->filename || !*edit->filename)
return;
+ edit->stack_disable = 1;
filename = vfs_canon (edit->filename);
load_file_position (filename, &line, &column);
g_free (filename);
@@ -465,6 +466,7 @@
edit->prev_col = column;
edit_move_to_prev_col (edit, edit_bol (edit, edit->curs1));
edit_move_display (edit, line - (edit->num_widget_lines / 2));
+ edit->stack_disable = 0;
}
/* Save cursor position in the file */
@@ -546,6 +548,7 @@
edit_set_filename (edit, filename);
edit->stack_size = START_STACK_SIZE;
edit->stack_size_mask = START_STACK_SIZE - 1;
+ edit->stack_wrapped = 0;
edit->undo_stack = g_malloc ((edit->stack_size + 10) * sizeof (long));
if (edit_load_file (edit)) {
/* edit_load_file already gives an error message */
@@ -770,17 +773,16 @@
if (c == edit->stack_bottom || ((c + 1) & edit->stack_size_mask) == edit->stack_bottom)
do {
edit->stack_bottom = (edit->stack_bottom + 1) & edit->stack_size_mask;
+ edit->stack_wrapped = 1;
} while (edit->undo_stack[edit->stack_bottom] < KEY_PRESS && edit->stack_bottom != edit->stack_pointer);
/*If a single key produced enough pushes to wrap all the way round then we would notice that the [stack_bottom] does not contain KEY_PRESS. The stack is then initialised: */
- if (edit->stack_pointer != edit->stack_bottom && edit->undo_stack[edit->stack_bottom] < KEY_PRESS)
+ if (edit->stack_pointer != edit->stack_bottom && edit->undo_stack[edit->stack_bottom] < KEY_PRESS) {
edit->stack_bottom = edit->stack_pointer = 0;
+ edit->stack_wrapped = 1;
+ }
}
-/*
- TODO: if the user undos until the stack bottom, and the stack has not wrapped,
- then the file should be as it was when he loaded up. Then set edit->modified to 0.
- */
static long
pop_action (WEdit * edit)
{
@@ -1800,6 +1802,11 @@
while ((ac = pop_action (edit)) < KEY_PRESS) {
switch ((int) ac) {
case STACK_BOTTOM:
+ if (!edit->stack_wrapped) {
+ if (edit->locked)
+ edit->locked = edit_unlock_file (edit->filename);
+ edit->modified = 0;
+ }
goto done_undo;
case CURS_RIGHT:
edit_cursor_move (edit, 1);
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/mc/edit/ChangeLog,v
retrieving revision 1.159
diff -u -u -0 -r1.159 ChangeLog
--- ChangeLog 2 Apr 2003 22:25:00 -0000 1.159
+++ ChangeLog 4 Apr 2003 13:51:11 -0000
@@ -0,0 +1,9 @@
+2003-04-03 Adam Byrtek <alpha at debian.org>
+
+ * edit-widget.h: New property stack_wrapped.
+ * edit.c (edit_push_action, pop_action): When undo stack hits
+ bottom (without wrapping) buffer is treated as unmodified and
+ is unlocked.
+
+ * edit.c (load_position): Disable undo stack.
+
More information about the mc-devel
mailing list