The attached patch makes
Up/Down/Space/BackSpace navigate around read-only documents
in the same way as netscape.
Personally I think this is way more convenient than navigating with the
cursor, or stretching all the way to those oh-so-distant PageUp/Down keys
;)
john
--
"Whereof one cannot speak, thereof one must be silent."
- Wittgenstein
Index: ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/ChangeLog,v
retrieving revision 1.614
diff -u -r1.614 ChangeLog
--- ChangeLog 2000/10/16 13:27:54 1.614
+++ ChangeLog 2000/10/16 15:23:46
@@ -1,3 +1,9 @@
+2000-10-16 John Levon <[EMAIL PROTECTED]>
+
+ * src/BufferView_pimpl.C:
+ * src/BufferView_pimpl.h: alter Space/BackSpace/
+ Up/Down to mimic netscape on read-only docs
+
2000-10-16 Angus Leeming <[EMAIL PROTECTED]>
* forms/layout_forms.fd:
Index: src/BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.55
diff -u -r1.55 BufferView_pimpl.C
--- src/BufferView_pimpl.C 2000/10/13 05:57:03 1.55
+++ src/BufferView_pimpl.C 2000/10/16 15:23:47
@@ -449,7 +449,7 @@
}
-int BufferView::Pimpl::scrollUp(long time)
+int BufferView::Pimpl::scrollUp(long time, int lines = 0)
{
if (buffer_ == 0) return 0;
if (!screen_) return 0;
@@ -458,7 +458,7 @@
if (value == 0) return 0;
- float add_value = (bv_->text->DefaultHeight()
+ float add_value = (bv_->text->DefaultHeight() +
+lines*bv_->text->DefaultHeight()
+ float(time) * float(time) * 0.125);
if (add_value > workarea_->height())
@@ -476,8 +476,7 @@
return 0;
}
-
-int BufferView::Pimpl::scrollDown(long time)
+int BufferView::Pimpl::scrollDown(long time, int lines = 0)
{
if (buffer_ == 0) return 0;
if (!screen_) return 0;
@@ -488,7 +487,7 @@
if (value == max) return 0;
- float add_value = (bv_->text->DefaultHeight()
+ float add_value = (bv_->text->DefaultHeight() +
+lines*bv_->text->DefaultHeight()
+ float(time) * float(time) * 0.125);
if (add_value > workarea_->height())
@@ -506,12 +505,45 @@
return 0;
}
-
void BufferView::Pimpl::workAreaKeyPress(KeySym keysym, unsigned int state)
{
- bv_->owner()->getLyXFunc()->processKeySym(keysym, state);
+ if (!buffer_ || !buffer_->isReadonly()) {
+ bv_->owner()->getLyXFunc()->processKeySym(keysym, state);
+ return;
+ }
+
+ switch (keysym) {
+ case XK_Up:
+ case XK_Down:
+ case XK_BackSpace:
+ case XK_space:
+ break;
+ default:
+ bv_->owner()->getLyXFunc()->processKeySym(keysym, state);
+ return;
+ }
+
+ if (lyxerr.debugging(Debug::KEY)) {
+ char * tmp = XKeysymToString(keysym);
+ string stm = (tmp ? tmp : "");
+ lyxerr << "BV Pimpl: KeySym is " << stm << "[" << keysym << "]" <<
+endl;
+ }
+
+ switch (keysym) {
+ case XK_Up:
+ scrollUp(0,3);
+ break;
+ case XK_Down:
+ scrollDown(0,3);
+ break;
+ case XK_BackSpace:
+ bv_->owner()->getLyXFunc()->Dispatch(LFUN_PRIOR);
+ break;
+ case XK_space:
+ bv_->owner()->getLyXFunc()->Dispatch(LFUN_NEXT);
+ break;
+ }
}
-
void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state)
{
Index: src/BufferView_pimpl.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.h,v
retrieving revision 1.21
diff -u -r1.21 BufferView_pimpl.h
--- src/BufferView_pimpl.h 2000/10/10 10:38:10 1.21
+++ src/BufferView_pimpl.h 2000/10/16 15:23:47
@@ -59,9 +59,9 @@
Inset * checkInsetHit(LyXText *, int & x, int & y,
unsigned int button);
///
- int scrollUp(long time);
+ int scrollUp(long time, int lines = 0);
///
- int scrollDown(long time);
+ int scrollDown(long time, int lines = 0);
///
void workAreaKeyPress(KeySym, unsigned int state);
///