[quake2] quake2 improvements and problem
Sigurdur Hannesson
sig.axel at gmail.com
Sun Mar 27 06:51:58 EST 2005
/* how can I get end of line? */
Not sure if it'll do, but hey! Try this:
key_linepos = strlen (key_lines[edit_line];
On Sat, 26 Mar 2005 15:20:12 -0500, Thomas J Fogal
<tfogal at pascal.unh.edu> wrote:
> <op.sn8a44gohksc6a at mail.generation.no>"Anders Storsveen" writes:
> > here are some other ideas:
> >
> > http://cure.gamepoint.net/q2_enhanced_engine_wishlist.html
>
> Got bored today. Implemented one of his suggested fixes because it
> sounded easy.
>
> The following patch:
> makes HOME clear the current line, going to the 1st char
> makes CTRL-HOME and CTRL-END goto the start and end of the current
> scrollback buffer.
> additionally makes CTRL-U clear the line, a la the shell
> has framework for END to goto EOL
> fixes minor code formatting things i noticed (but not all of them)
>
> In the current setup, HOME and END cannot be made to goto the beginning
> of a line. This is because of how the scrollback buffer is
> stored/accessed; being at a certain position within a line means
> anything after that position is 'invalid'.
> Someone can, of course, modify how the data is stored/accessed, but I
> wasn't that ambitious for this patch. If they do, to make it work with
> end they should see the code around the line with the comment:
>
> /* how can I get end of line? */
>
> -tom
>
> ####
> the patch:
> ####
> --- /home/tom/src/quake2/src/client/keys.c 2002-04-02 20:08:23.000000000 -0500
> +++ keys.c 2005-03-26 15:09:00.000000000 -0500
> @@ -19,12 +19,7 @@
> */
> #include "client.h"
>
> -/*
> -
> -key up events are sent even if in console mode
> -
> -*/
> -
> +/* key up events are sent even if in console mode */
>
> #define MAXCMDLINE 256
> char key_lines[32][MAXCMDLINE];
> @@ -43,10 +38,9 @@
> int key_repeats[K_LAST]; // if > 1, it is autorepeating
> qboolean keydown[K_LAST];
>
> -typedef struct
> -{
> - char *name;
> - int keynum;
> +typedef struct {
> + char *name;
> + int keynum;
> } keyname_t;
>
> keyname_t keynames[] =
> @@ -158,9 +152,7 @@
>
> /*
> ==============================================================================
> -
> LINE TYPING INTO THE CONSOLE
> -
> ==============================================================================
> */
>
> @@ -196,7 +188,6 @@
> */
> void Key_Console (int key)
> {
> -
> switch ( key )
> {
> case K_KP_SLASH:
> @@ -272,13 +263,9 @@
> return;
> }
>
> - if ( key == 'l' )
> - {
> - if ( keydown[K_CTRL] )
> - {
> - Cbuf_AddText ("clear\n");
> - return;
> - }
> + if(key == 'l' && keydown[K_CTRL]) {
> + Cbuf_AddText ("clear\n");
> + return;
> }
>
> if ( key == K_ENTER || key == K_KP_ENTER )
> @@ -351,8 +338,7 @@
> return;
> }
>
> - if (key == K_PGUP || key == K_KP_PGUP )
> - {
> + if(key == K_PGUP || key == K_KP_PGUP) {
> con.display -= 2;
> return;
> }
> @@ -365,28 +351,42 @@
> return;
> }
>
> - if (key == K_HOME || key == K_KP_HOME )
> - {
> - con.display = con.current - con.totallines + 10;
> + /* HOME goes to beginning of the line or top of scroll buffer with CTRL */
> + if(key == K_HOME || key == K_KP_HOME) {
> + if(keydown[K_CTRL]) {
> + con.display = con.current - con.totallines + 10;
> + } else {
> + con.x = key_linepos = 1;
> + }
> return;
> }
>
> - if (key == K_END || key == K_KP_END )
> - {
> - con.display = con.current;
> + /* similarly, CTRL-U clears the current line */
> + if(key == 'u' && keydown[K_CTRL]) {
> + con.x = key_linepos = 1;
> + return;
> + }
> +
> + /* END goes to end of line or bottom of scrollbuffer w/ CTRL */
> + if(key == K_END || key == K_KP_END) {
> + if(keydown[K_CTRL]) {
> + con.current = con.display = con.totallines;
> + } else {
> + /* how can I get end of line? */
> + con.x = con.linewidth;
> + key_linepos = con.linewidth;
> + }
> return;
> }
>
> if (key < 32 || key > 127)
> return; // non printable
>
> - if (key_linepos < MAXCMDLINE-1)
> - {
> + if (key_linepos < MAXCMDLINE-1) {
> key_lines[edit_line][key_linepos] = key;
> key_linepos++;
> key_lines[edit_line][key_linepos] = 0;
> }
> -
> }
>
> //============================================================================
>
--
Regards,
Sigurdur Axel
More information about the quake2
mailing list