aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ChangeLog17
-rw-r--r--fm.h12
-rw-r--r--funcname.tab4
-rw-r--r--main.c73
-rw-r--r--proto.h4
5 files changed, 105 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 4c67e17..d4216fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
2002-12-11 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
+ * [w3m-dev 03553] Undo/Redo
+ * fm.h (Buffer): add undo
+ (BufferPos): added
+ * funcname.tab (REDO): added
+ (UNDO): added
+ * main.c (save_buffer_position): added
+ (main): save_buffer_position
+ (resetPos): added
+ (undoPos): added
+ (redoPos): added
+ * proto.h (undoPos): added
+ (redoPos): added
+
+2002-12-11 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
+
* [w3m-dev 03552] Re: link list
* menu.c (accesskey_menu): check hseq
(list_menu): check hseq
@@ -5687,4 +5702,4 @@ a * [w3m-dev 03276] compile error on EWS4800
* release-0-2-1
* import w3m-0.2.1
-$Id: ChangeLog,v 1.608 2002/12/10 15:41:31 ukai Exp $
+$Id: ChangeLog,v 1.609 2002/12/10 15:51:14 ukai Exp $
diff --git a/fm.h b/fm.h
index 5b706fd..0fa4cbd 100644
--- a/fm.h
+++ b/fm.h
@@ -1,4 +1,4 @@
-/* $Id: fm.h,v 1.94 2002/12/06 16:50:13 ukai Exp $ */
+/* $Id: fm.h,v 1.95 2002/12/10 15:51:14 ukai Exp $ */
/*
* w3m: WWW wo Miru utility
*
@@ -460,8 +460,18 @@ typedef struct _Buffer {
char image_flag;
char need_reshape;
Anchor *submit;
+ struct _BufferPos *undo;
} Buffer;
+typedef struct _BufferPos {
+ long top_linenumber;
+ long cur_linenumber;
+ short currentColumn;
+ short pos;
+ struct _BufferPos *next;
+ struct _BufferPos *prev;
+} BufferPos;
+
typedef struct _TabBuffer {
struct _TabBuffer *nextTab;
struct _TabBuffer *prevTab;
diff --git a/funcname.tab b/funcname.tab
index a33766f..c238ce1 100644
--- a/funcname.tab
+++ b/funcname.tab
@@ -1,4 +1,4 @@
-# $Id: funcname.tab,v 1.18 2002/12/09 15:51:08 ukai Exp $
+# $Id: funcname.tab,v 1.19 2002/12/10 15:51:14 ukai Exp $
# macro name function name
#----------------------------
@@@ nulcmd
@@ -105,6 +105,7 @@ PREV_WORD movLW
PRINT svBuf
QUIT qquitfm
READ_SHELL readsh
+REDO redoPos
REDRAW rdrwSc
REG_MARK reMark
REINIT reinit
@@ -137,6 +138,7 @@ TAB_LINK tabA
TAB_MENU tabMn
TAB_MOUSE tabMs
TAB_RIGHT tabR
+UNDO undoPos
UP lup1
VERSION dispVer
VIEW vwSrc
diff --git a/main.c b/main.c
index 21c9aa9..88fc703 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.164 2002/12/10 15:36:11 ukai Exp $ */
+/* $Id: main.c,v 1.165 2002/12/10 15:51:15 ukai Exp $ */
#define MAINPROGRAM
#include "fm.h"
#include <signal.h>
@@ -98,6 +98,7 @@ int on_target = 1;
static int add_download_list = FALSE;
void set_buffer_environ(Buffer *);
+static void save_buffer_position(Buffer *buf);
static void _followForm(int);
static void _goLine(char *);
@@ -1066,6 +1067,7 @@ main(int argc, char **argv, char **envp)
}
else {
set_buffer_environ(Currentbuf);
+ save_buffer_position(Currentbuf);
keyPressEventProc((int)c);
prec_num = 0;
if (add_download_list) {
@@ -6367,3 +6369,72 @@ ldDL(void)
}
#endif
}
+
+static void
+save_buffer_position(Buffer *buf)
+{
+ BufferPos *b = buf->undo;
+
+ if (!buf->firstLine)
+ return;
+ if (b && b->top_linenumber == TOP_LINENUMBER(buf) &&
+ b->cur_linenumber == CUR_LINENUMBER(buf) &&
+ b->currentColumn == buf->currentColumn &&
+ b->pos == buf->pos)
+ return;
+ b = New(BufferPos);
+ b->top_linenumber = TOP_LINENUMBER(buf);
+ b->cur_linenumber = CUR_LINENUMBER(buf);
+ b->currentColumn = buf->currentColumn;
+ b->pos = buf->pos;
+ b->next = NULL;
+ b->prev = buf->undo;
+ if (buf->undo)
+ buf->undo->next = b;
+ buf->undo = b;
+}
+
+static void
+resetPos(BufferPos *b)
+{
+ Buffer buf;
+ Line top, cur;
+
+ top.linenumber = b->top_linenumber;
+ cur.linenumber = b->cur_linenumber;
+ buf.topLine = &top;
+ buf.currentLine = &cur;
+ buf.pos = b->pos;
+ buf.currentColumn = b->currentColumn;
+ restorePosition(Currentbuf, &buf);
+ Currentbuf->undo = b;
+ displayBuffer(Currentbuf, B_FORCE_REDRAW);
+}
+
+void
+undoPos(void)
+{
+ BufferPos *b = Currentbuf->undo;
+ int i;
+
+ if (!Currentbuf->firstLine)
+ return;
+ if (!b || !b->prev)
+ return;
+ for (i = 0; i < PREC_NUM && b->prev; i++, b = b->prev) ;
+ resetPos(b);
+}
+
+void
+redoPos(void)
+{
+ BufferPos *b = Currentbuf->undo;
+ int i;
+
+ if (!Currentbuf->firstLine)
+ return;
+ if (!b || !b->next)
+ return;
+ for (i = 0; i < PREC_NUM && b->next; i++, b = b->next) ;
+ resetPos(b);
+}
diff --git a/proto.h b/proto.h
index 1c5d211..b3ba35c 100644
--- a/proto.h
+++ b/proto.h
@@ -1,4 +1,4 @@
-/* $Id: proto.h,v 1.67 2002/12/09 15:51:09 ukai Exp $ */
+/* $Id: proto.h,v 1.68 2002/12/10 15:51:15 ukai Exp $ */
/*
* This file was automatically generated by version 1.7 of cextract.
* Manual editing not recommended.
@@ -146,6 +146,8 @@ extern Anchor *list_menu(Buffer *buf);
#define listMn nulcmd
#define movlistMn nulcmd
#endif
+extern void undoPos(void);
+extern void redoPos(void);
extern int currentLn(Buffer *buf);
extern void tmpClearBuffer(Buffer *buf);