|
From: Rene S. <sa...@us...> - 2011-07-07 21:10:20
|
Update of /cvsroot/jake2/jake2/src/jake2/client
In directory vz-cvs-3.sog:/tmp/cvs-serv19748/src/jake2/client
Modified Files:
Key.java Menu.java Console.java console_t.java
Log Message:
clipboard support for console
Index: Menu.java
===================================================================
RCS file: /cvsroot/jake2/jake2/src/jake2/client/Menu.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** Menu.java 13 Dec 2009 11:20:46 -0000 1.24
--- Menu.java 7 Jul 2011 21:10:18 -0000 1.25
***************
*** 4464,4469 ****
* * support pasting from the clipboard
*/
! if ((Character.toUpperCase(key) == 'V' && keydown[K_CTRL])
! || (((key == K_INS) || (key == K_KP_INS)) && keydown[K_SHIFT])) {
String cbd;
--- 4464,4470 ----
* * support pasting from the clipboard
*/
!
! if ( key == K_CTRLV && keydown[K_CTRL] || (((key == K_INS) || (key == K_KP_INS)) && keydown[K_SHIFT])) { // sfranzyshen
!
String cbd;
Index: Key.java
===================================================================
RCS file: /cvsroot/jake2/jake2/src/jake2/client/Key.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** Key.java 18 Dec 2005 22:10:12 -0000 1.12
--- Key.java 7 Jul 2011 21:10:18 -0000 1.13
***************
*** 30,33 ****
--- 30,34 ----
import jake2.game.Cmd;
import jake2.qcommon.*;
+ import jake2.sys.Sys;
import jake2.util.Lib;
***************
*** 47,50 ****
--- 48,53 ----
public static final int K_ESCAPE = 27;
public static final int K_SPACE = 32;
+ public static final int K_CTRLV = 22;
+
// normal keys should be passed as lowercased ascii
***************
*** 210,213 ****
--- 213,218 ----
consolekeys[i] = true;
consolekeys[K_ENTER] = true;
+ consolekeys[K_CTRLV] = true;
+
consolekeys[K_KP_ENTER] = true;
consolekeys[K_TAB] = true;
***************
*** 231,234 ****
--- 236,240 ----
consolekeys[K_SHIFT] = true;
consolekeys[K_INS] = true;
+ consolekeys[K_DEL] = true; // sfranzyshen
consolekeys[K_KP_INS] = true;
consolekeys[K_KP_DEL] = true;
***************
*** 237,240 ****
--- 243,249 ----
consolekeys[K_KP_MINUS] = true;
consolekeys[K_KP_5] = true;
+ consolekeys[K_MWHEELUP] = true; // sfranzyshen
+ consolekeys[K_MWHEELDOWN] = true; // sfranzyshen
+ consolekeys[K_CTRL] = true; // sfranzyshen
consolekeys['`'] = false;
***************
*** 283,286 ****
--- 292,296 ----
Globals.key_lines[Globals.edit_line][1] = 0; // clear any typing
Globals.key_linepos = 1;
+ Globals.con.backedit = 0; // sfranzyshen
}
***************
*** 474,477 ****
--- 484,492 ----
public static void Message(int key) {
+ // sfranzyshen -- start
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(Globals.chat_buffer);
+ int offset = buffer.length() - Globals.chat_backedit;
+
if (key == K_ENTER || key == K_KP_ENTER) {
if (Globals.chat_team)
***************
*** 479,520 ****
else
Cbuf.AddText("say \"");
!
Cbuf.AddText(Globals.chat_buffer);
Cbuf.AddText("\"\n");
!
Globals.cls.key_dest = Defines.key_game;
Globals.chat_buffer = "";
return;
}
!
if (key == K_ESCAPE) {
Globals.cls.key_dest = Defines.key_game;
Globals.chat_buffer = "";
return;
}
-
- if (key < 32 || key > 127)
- return; // non printable
-
if (key == K_BACKSPACE) {
! if (Globals.chat_buffer.length() > 2) {
! Globals.chat_buffer = Globals.chat_buffer.substring(0, Globals.chat_buffer.length() - 2);
}
! else
! Globals.chat_buffer = "";
return;
}
!
! if (Globals.chat_buffer.length() > Defines.MAXCMDLINE)
! return; // all full
!
! Globals.chat_buffer += (char) key;
! }
!
/**
* Interactive line editing and console scrollback.
*/
public static void Console(int key) {
!
switch (key) {
case K_KP_SLASH :
--- 494,592 ----
else
Cbuf.AddText("say \"");
!
Cbuf.AddText(Globals.chat_buffer);
Cbuf.AddText("\"\n");
!
Globals.cls.key_dest = Defines.key_game;
Globals.chat_buffer = "";
+ Globals.chat_backedit = 0;
return;
}
!
!
if (key == K_ESCAPE) {
Globals.cls.key_dest = Defines.key_game;
Globals.chat_buffer = "";
+ Globals.chat_backedit = 0;
+ return;
+ }
+ if (key == K_END || key == K_KP_END) {
+ Globals.chat_backedit = 0;
+ return;
+ }
+ if (key == K_HOME || key == K_KP_HOME) {
+ Globals.chat_backedit = Globals.chat_buffer.length();
return;
}
if (key == K_BACKSPACE) {
! if (buffer.length() > 0) { // we have a buffer to edit
! if (Globals.chat_backedit > 0) { // we are somewhere mid line
! if (offset == 0) { // we are at the start of the line
! return;
! }
! buffer.deleteCharAt(offset-1);
! }
! else { // we are at the end of line
! buffer.deleteCharAt(buffer.length()-1);
! }
}
! Globals.chat_buffer = buffer.toString();
return;
}
!
! if (key == K_DEL || key == K_KP_DEL) {
! if (buffer.length() > 0 && Globals.chat_backedit > 0) { // we have a buffer & we are somewhere mid line
! buffer.deleteCharAt(offset);
! Globals.chat_backedit--;
! if (Globals.chat_backedit < 0) {
! Globals.chat_backedit = 0;
! }
! }
! Globals.chat_buffer = buffer.toString();
! return;
! }
!
! if (key == K_LEFTARROW) {
! if (buffer.length() > 0 && offset > 0) { //we have a buffer & we are not at the start of line
! Globals.chat_backedit++;
! if (Globals.chat_backedit > buffer.length()) {
! Globals.chat_backedit = buffer.length();
! }
! }
! Globals.chat_buffer = buffer.toString();
! return;
! }
!
! if (key == K_RIGHTARROW) {
! if (buffer.length() > 0 && Globals.chat_backedit > 0) { // we have a buffer & we are not at the end of line
! Globals.chat_backedit--;
! if (Globals.chat_backedit < 0) {
! Globals.chat_backedit = 0;
! }
! }
! Globals.chat_buffer = buffer.toString();
! return;
! }
!
! if (key < 32 || key > 127)
! return; // non printable
!
! if (Globals.chat_backedit > 0) {
! buffer.insert(offset, (char) key);
! //Globals.chat_backedit++;
! }
! else {
! buffer.append((char) key);
! }
! Globals.chat_buffer = buffer.toString();
! // sfranzyshen -- stop
! }
!
/**
* Interactive line editing and console scrollback.
*/
public static void Console(int key) {
! int i;
!
switch (key) {
case K_KP_SLASH :
***************
*** 561,568 ****
--- 633,673 ----
break;
}
+ // sfranzyshen -start
+ if ((key == K_CTRLV && keydown[K_CTRL] ) || ((( key == K_INS ) || ( key == K_KP_INS )) && keydown[K_SHIFT] )) {
+ String cbd;
+
+ if (( cbd = Sys.GetClipboardData()) != null) {
+ int x;
+
+ x = cbd.length();
+
+ if ( x + Globals.key_linepos >= MAXCMDLINE )
+ x = MAXCMDLINE - Globals.key_linepos;
+
+ if ( x > 0 )
+ {
+ if (Globals.con.backedit > 0) {
+ for (i = Globals.key_linepos - Globals.con.backedit; i < Globals.key_linepos; i++)
+ Globals.key_lines[Globals.edit_line][i + x] = Globals.key_lines[Globals.edit_line][i];
+
+ for (i = Globals.key_linepos - Globals.con.backedit; i < Globals.key_linepos - Globals.con.backedit + x; i++)
+ Globals.key_lines[Globals.edit_line][i] = (byte) cbd.charAt(i - (Globals.key_linepos - Globals.con.backedit));
+ con.backedit += x;
+ } else {
+ for (i = Globals.key_linepos; i < Globals.key_linepos + x; i++)
+ Globals.key_lines[Globals.edit_line][i] = (byte) cbd.charAt(i - Globals.key_linepos);
+ }
+ Globals.key_linepos += x;
+ }
+ }
+ return;
+ }
+ // sfranzyshen -stop
+
if (key == 'l') {
if (Globals.keydown[K_CTRL]) {
Cbuf.AddText("clear\n");
+ Globals.con.backedit = 0; // sfranzyshen
return;
}
***************
*** 587,590 ****
--- 692,697 ----
Globals.key_lines[Globals.edit_line][0] = ']';
Globals.key_linepos = 1;
+ Globals.con.backedit = 0; // sfranzyshen
+
if (Globals.cls.state == Defines.ca_disconnected)
SCR.UpdateScreen(); // force an update, because the command may take some time
***************
*** 595,606 ****
// command completion
CompleteCommand();
return;
}
! if ((key == K_BACKSPACE) || (key == K_LEFTARROW) || (key == K_KP_LEFTARROW) || ((key == 'h') && (Globals.keydown[K_CTRL]))) {
if (Globals.key_linepos > 1)
Globals.key_linepos--;
return;
}
if ((key == K_UPARROW) || (key == K_KP_UPARROW) || ((key == 'p') && Globals.keydown[K_CTRL])) {
--- 702,768 ----
// command completion
CompleteCommand();
+ Globals.con.backedit = 0; // sfranzyshen
return;
}
! // sfranzyshen - start
! if (key == K_BACKSPACE)
! {
if (Globals.key_linepos > 1)
+ {
+ if (Globals.con.backedit > 0 && Globals.con.backedit < Globals.key_linepos)
+ {
+ if (Globals.key_linepos - Globals.con.backedit <= 1)
+ return;
+
+ for (i = Globals.key_linepos - Globals.con.backedit - 1; i < Globals.key_linepos; i++)
+ Globals.key_lines[Globals.edit_line][i] = Globals.key_lines[Globals.edit_line][i+1];
+
+ if (Globals.key_linepos > 1)
+ Globals.key_linepos--;
+ }
+ else
+ {
+ Globals.key_linepos--;
+ }
+ }
+ return;
+ }
+
+ if (key == K_DEL || key == K_KP_DEL)
+ {
+ if (Globals.key_linepos > 1 && Globals.con.backedit > 0)
+ {
+ for (i = Globals.key_linepos - Globals.con.backedit; i < Globals.key_linepos; i++)
+ Globals.key_lines[Globals.edit_line][i] = Globals.key_lines[Globals.edit_line][i+1];
+
+ Globals.con.backedit--;
Globals.key_linepos--;
+ }
return;
}
+
+ if (key == K_LEFTARROW || key == K_KP_LEFTARROW)
+ {
+ if (Globals.key_linepos>1)
+ {
+ Globals.con.backedit++;
+ if (Globals.con.backedit > Globals.key_linepos -1) Globals.con.backedit = Globals.key_linepos-1;
+ }
+ return;
+ }
+
+ if (key == K_RIGHTARROW || key == K_KP_RIGHTARROW)
+ {
+ if (Globals.key_linepos > 1)
+ {
+ Globals.con.backedit--;
+ if (Globals.con.backedit<0) Globals.con.backedit = 0;
+ }
+ return;
+ }
+ // sfranzyshen - stop
+
+
if ((key == K_UPARROW) || (key == K_KP_UPARROW) || ((key == 'p') && Globals.keydown[K_CTRL])) {
***************
*** 614,617 ****
--- 776,780 ----
System.arraycopy(Globals.key_lines[history_line], 0, Globals.key_lines[Globals.edit_line], 0, Globals.key_lines[Globals.edit_line].length);
Globals.key_linepos = Lib.strlen(Globals.key_lines[Globals.edit_line]);
+ Globals.con.backedit = 0; // sfranzyshen
return;
}
***************
*** 632,645 ****
System.arraycopy(Globals.key_lines[history_line], 0, Globals.key_lines[Globals.edit_line], 0, Globals.key_lines[Globals.edit_line].length);
Globals.key_linepos = Lib.strlen(Globals.key_lines[Globals.edit_line]);
}
return;
}
! if (key == K_PGUP || key == K_KP_PGUP) {
Globals.con.display -= 2;
return;
}
! if (key == K_PGDN || key == K_KP_PGDN) {
Globals.con.display += 2;
if (Globals.con.display > Globals.con.current)
--- 795,809 ----
System.arraycopy(Globals.key_lines[history_line], 0, Globals.key_lines[Globals.edit_line], 0, Globals.key_lines[Globals.edit_line].length);
Globals.key_linepos = Lib.strlen(Globals.key_lines[Globals.edit_line]);
+ Globals.con.backedit = 0; // sfranzyshen
}
return;
}
! if (key == K_MWHEELUP || key == K_PGUP || key == K_KP_PGUP) {
Globals.con.display -= 2;
return;
}
! if (key == K_MWHEELDOWN || key == K_PGDN || key == K_KP_PGDN) {
Globals.con.display += 2;
if (Globals.con.display > Globals.con.current)
***************
*** 648,669 ****
}
if (key == K_HOME || key == K_KP_HOME) {
! Globals.con.display = Globals.con.current - Globals.con.totallines + 10;
return;
}
if (key == K_END || key == K_KP_END) {
! Globals.con.display = Globals.con.current;
return;
}
if (key < 32 || key > 127)
return; // non printable
if (Globals.key_linepos < Defines.MAXCMDLINE - 1) {
! Globals.key_lines[Globals.edit_line][Globals.key_linepos] = (byte) key;
! Globals.key_linepos++;
! Globals.key_lines[Globals.edit_line][Globals.key_linepos] = 0;
}
}
--- 812,849 ----
}
+ // sfranzyshen - start
if (key == K_HOME || key == K_KP_HOME) {
! //Globals.con.display = Globals.con.current - Globals.con.totallines + 10;
! Globals.con.backedit = Globals.key_linepos -1;
return;
}
if (key == K_END || key == K_KP_END) {
! //Globals.con.display = Globals.con.current;
! Globals.con.backedit = 0;
return;
}
+ // sfranzyshen - stop
+
+
if (key < 32 || key > 127)
return; // non printable
+ // sfranzyshen -start
if (Globals.key_linepos < Defines.MAXCMDLINE - 1) {
! if (Globals.con.backedit > 0) { //insert character...
! for (i = Globals.key_linepos; i > Globals.key_linepos - Globals.con.backedit; i--)
! Globals.key_lines[Globals.edit_line][i] = Globals.key_lines[Globals.edit_line][i -1];
! Globals.key_lines[Globals.edit_line][i] = (byte) key;
! Globals.key_linepos++;
! Globals.key_lines[Globals.edit_line][Globals.key_linepos] = 0;
! } else {
! Globals.key_lines[Globals.edit_line][Globals.key_linepos++] = (byte) key;
! Globals.key_lines[Globals.edit_line][Globals.key_linepos] = 0;
! }
}
+ // sfranzyshen -stop
+
}
Index: console_t.java
===================================================================
RCS file: /cvsroot/jake2/jake2/src/jake2/client/console_t.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** console_t.java 7 Jul 2004 19:58:52 -0000 1.1.1.1
--- console_t.java 7 Jul 2011 21:10:18 -0000 1.2
***************
*** 42,45 ****
--- 42,47 ----
int linewidth; // characters across screen
int totallines; // total lines in console scrollback
+
+ int backedit; // sfranzyshen
float cursorspeed;
Index: Console.java
===================================================================
RCS file: /cvsroot/jake2/jake2/src/jake2/client/Console.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** Console.java 2 Mar 2008 16:43:18 -0000 1.9
--- Console.java 7 Jul 2011 21:10:18 -0000 1.10
***************
*** 149,152 ****
--- 149,153 ----
public static void Init() {
Globals.con.linewidth = -1;
+ Globals.con.backedit = 0;
CheckResize();
***************
*** 183,186 ****
--- 184,188 ----
width = 38;
Globals.con.linewidth = width;
+ Globals.con.backedit = 0; // sfranzyshen
Globals.con.totallines = Defines.CON_TEXTSIZE
/ Globals.con.linewidth;
***************
*** 189,192 ****
--- 191,195 ----
int oldwidth = Globals.con.linewidth;
Globals.con.linewidth = width;
+ Globals.con.backedit = 0; // sfranzyshen
int oldtotallines = Globals.con.totallines;
Globals.con.totallines = Defines.CON_TEXTSIZE
***************
*** 409,412 ****
--- 412,416 ----
if (cls.key_dest == key_menu)
return;
+
if (cls.key_dest != key_console && cls.state == ca_active)
return; // don't draw anything (always draw if not active)
***************
*** 415,422 ****
// add the cursor frame
! text[key_linepos] = (byte) (10 + ((int) (cls.realtime >> 8) & 1));
// fill out remainder with spaces
! for (i = key_linepos + 1; i < con.linewidth; i++)
text[i] = ' ';
--- 419,426 ----
// add the cursor frame
! //text[key_linepos] = (byte) (10 + ((int) (cls.realtime >> 8) & 1)); //sfranzyshen
// fill out remainder with spaces
! for (i = key_linepos ; i < con.linewidth; i++) // sfranzyshen
text[i] = ' ';
***************
*** 428,434 ****
// y = con.vislines-16;
! for (i = 0; i < con.linewidth; i++)
! re.DrawChar((i + 1) << 3, con.vislines - 22, text[i]);
!
// remove cursor
key_lines[edit_line][key_linepos] = 0;
--- 432,446 ----
// y = con.vislines-16;
! // sfranzyshen --start
! for (i = 0; i < con.linewidth; i++) {
! //old:re.DrawChar((i + 1) << 3, con.vislines - 22, text[i]);
! if (con.backedit == key_linepos-i && (((int)(Globals.cls.realtime >> 8)&1) !=0))
! re.DrawChar ((i + 1) << 3, con.vislines - 22, (char)11);
! else
! re.DrawChar ((i + 1) << 3, con.vislines - 22, text[i]);
! }
! // sfranzyshen - stop
!
!
// remove cursor
key_lines[edit_line][key_linepos] = 0;
***************
*** 481,492 ****
s = chat_buffer;
if (chat_bufferlen > (viddef.getWidth() >> 3) - (skip + 1))
! s = s.substring(chat_bufferlen
! - ((viddef.getWidth() >> 3) - (skip + 1)));
for (x = 0; x < s.length(); x++) {
! re.DrawChar((x + skip) << 3, v, s.charAt(x));
}
! re.DrawChar((x + skip) << 3, v,
! (int) (10 + ((cls.realtime >> 8) & 1)));
v += 8;
}
--- 493,514 ----
s = chat_buffer;
if (chat_bufferlen > (viddef.getWidth() >> 3) - (skip + 1))
! //s = s.substring(chat_bufferlen
! // - ((viddef.getWidth() >> 3) - (skip + 1)));
!
! // sfranzyshen -start
! s = s.substring(chat_bufferlen - ((viddef.getWidth() >> 3) - (skip + 1)));
for (x = 0; x < s.length(); x++) {
! if (chat_backedit > 0 && chat_backedit == chat_buffer.length() -x && ((int)(cls.realtime>>8)&1) !=0) {
! re.DrawChar((x + skip) << 3, v, (char)11);
! } else {
! re.DrawChar((x + skip) << 3, v, s.charAt(x));
! }
}
!
! if (chat_backedit == 0)
! re.DrawChar((x + skip) << 3, v, (int) (10 + ((cls.realtime >> 8) & 1)));
! // sfranzyshen -stop
!
v += 8;
}
|