]> granicus.if.org Git - nethack/commitdiff
X11 scrolling message window
authorPatR <rankin@nethack.org>
Sun, 7 Feb 2016 02:25:42 +0000 (18:25 -0800)
committerPatR <rankin@nethack.org>
Sun, 7 Feb 2016 02:25:42 +0000 (18:25 -0800)
The scroll bar on the message window doesn't work for me, just like
the one on the extend commands menu.  Moving the pointer to it does
change the cursor, but neither trying to drag the slider nor clicking
above it will make it do anything.  However, at some point I managed
to accidentally scroll the message window, and new messages never
restored it to the unscrolled state.  New messages were hidden until
enough even newer ones had been delivered to push the hidden ones
into view.  So this adds key translations to scroll the message
window via the arrow keys.  Clicking on the scroll bar doesn't change
focus to the right place, so I have to click the text display area of
the message window.  That triggers a beep (I suspect it's interpreted
as an attempt to move the hero beyond the map.)  But then the messages
can be scrolled via the cursor keys.  Getting focus back to the map
seems tricky since doing it via pointer is interpreted as a travel
command.  Not quite optimal....

Anyway, being able to scroll the message window let me figure out how
to unscroll it when new messages are delivered.

win/X11/winmesg.c

index 0d537d2ff6290df8f300d90cf409b87eb304bae3..5a019ee2c865680bd2049770a3e5da8616b48de7 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 winmesg.c       $NHDT-Date: 1432512808 2015/05/25 00:13:28 $  $NHDT-Branch: master $:$NHDT-Revision: 1.9 $ */
+/* NetHack 3.6 winmesg.c       $NHDT-Date: 1454811935 2016/02/07 02:25:35 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.10 $ */
 /* Copyright (c) Dean Luick, 1992                                */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -46,8 +46,11 @@ static void FDECL(get_gc, (Widget, struct mesg_info_t *));
 static void FDECL(mesg_resized, (Widget, XtPointer, XtPointer));
 
 static char mesg_translations[] = "#override\n\
- <Key>:                input() \
-";
+ <Key>Left:     scroll(4)\n\
+ <Key>Right:    scroll(6)\n\
+ <Key>Up:       scroll(8)\n\
+ <Key>Down:     scroll(2)\n\
+ <Key>:         input()";
 
 /* Move the message window's vertical scrollbar's slider to the bottom. */
 void
@@ -79,7 +82,7 @@ Widget parent;
     wp->type = NHW_MESSAGE;
 
     wp->mesg_information = mesg_info =
-        (struct mesg_info_t *) alloc(sizeof(struct mesg_info_t));
+        (struct mesg_info_t *) alloc(sizeof (struct mesg_info_t));
 
     mesg_info->fs = 0;
     mesg_info->num_lines = 0;
@@ -228,6 +231,7 @@ void
 display_message_window(wp)
 struct xwindow *wp;
 {
+    set_message_slider(wp);
     if (wp->mesg_information->dirty)
         redraw_message_window(wp);
 }