git://git.nikiroo.be
/
fanfix.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Refactoring - boolean getters and miscellaneous
[fanfix.git]
/
src
/
jexer
/
tterminal
/
ECMA48.java
diff --git
a/src/jexer/tterminal/ECMA48.java
b/src/jexer/tterminal/ECMA48.java
index df157cf4af9bbdee13e7dcd245e45a1a12c1f767..7b41594be4eff9ab073437f9fb64f2302b18f259 100644
(file)
--- a/
src/jexer/tterminal/ECMA48.java
+++ b/
src/jexer/tterminal/ECMA48.java
@@
-179,7
+179,7
@@
public class ECMA48 implements Runnable {
* @param deviceType DeviceType.VT100, DeviceType, XTERM, etc.
* @param baseLang a base language without UTF-8 flag such as "C" or
* "en_US"
* @param deviceType DeviceType.VT100, DeviceType, XTERM, etc.
* @param baseLang a base language without UTF-8 flag such as "C" or
* "en_US"
- * @return "
LANG=en_US", "LANG=
en_US.UTF-8", etc.
+ * @return "
en_US", "
en_US.UTF-8", etc.
*/
public static String deviceTypeLang(final DeviceType deviceType,
final String baseLang) {
*/
public static String deviceTypeLang(final DeviceType deviceType,
final String baseLang) {
@@
-614,7
+614,7
@@
public class ECMA48 implements Runnable {
*
* @return if true, the cursor is visible
*/
*
* @return if true, the cursor is visible
*/
- public final boolean
visibleCursor
() {
+ public final boolean
isCursorVisible
() {
return cursorVisible;
}
return cursorVisible;
}
@@
-690,6
+690,15
@@
public class ECMA48 implements Runnable {
private boolean columns132 = false;
/**
private boolean columns132 = false;
/**
+ * Get 132 columns value.
+ *
+ * @return if true, the terminal is in 132 column mode
+ */
+ public final boolean isColumns132() {
+ return columns132;
+ }
+
+ /**
* true = reverse video. Set by DECSCNM.
*/
private boolean reverseVideo = false;
* true = reverse video. Set by DECSCNM.
*/
private boolean reverseVideo = false;
@@
-891,7
+900,7
@@
public class ECMA48 implements Runnable {
* @param type one of the DeviceType constants to select VT100, VT102,
* VT220, or XTERM
* @param inputStream an InputStream connected to the remote side. For
* @param type one of the DeviceType constants to select VT100, VT102,
* VT220, or XTERM
* @param inputStream an InputStream connected to the remote side. For
- * type == XTERM, inputStrem is converted to a Reader with UTF-8
+ * type == XTERM, inputStre
a
m is converted to a Reader with UTF-8
* encoding.
* @param outputStream an OutputStream connected to the remote user. For
* type == XTERM, outputStream is converted to a Writer with UTF-8
* encoding.
* @param outputStream an OutputStream connected to the remote user. For
* type == XTERM, outputStream is converted to a Writer with UTF-8
@@
-978,7
+987,6
@@
public class ECMA48 implements Runnable {
* Handle a linefeed.
*/
private void linefeed() {
* Handle a linefeed.
*/
private void linefeed() {
- int i;
if (currentState.cursorY < scrollRegionBottom) {
// Increment screen y
if (currentState.cursorY < scrollRegionBottom) {
// Increment screen y
@@
-1096,25
+1104,18
@@
public class ECMA48 implements Runnable {
* @param mouse mouse event received from the local user
*/
public void mouse(final TMouseEvent mouse) {
* @param mouse mouse event received from the local user
*/
public void mouse(final TMouseEvent mouse) {
+
/*
/*
- * TODO:
- *
- * - Parse the mouse requests from the remote side regarding protocol
- * + encoding
- *
- * - Send mouse events to the other side.
- *
- * - Handle the cursor (double invert).
+ System.err.printf("mouse(): protocol %s encoding %s mouse %s\n",
+ mouseProtocol, mouseEncoding, mouse);
*/
*/
- // System.err.printf("Mouse: %s\n", mouse);
-
- /*
if (mouseEncoding != MouseEncoding.UTF8) {
if (mouseEncoding != MouseEncoding.UTF8) {
- // We only support UTF8 encoding, bail out now.
- return;
+ // We will support X10 but only for (160,94) and smaller.
+ if ((mouse.getX() >= 160) || (mouse.getY() >= 94)) {
+ return;
+ }
}
}
- */
switch (mouseProtocol) {
switch (mouseProtocol) {
@@
-1144,11
+1145,11
@@
public class ECMA48 implements Runnable {
* have a button down (i.e. drag-and-drop).
*/
if (mouse.getType() == TMouseEvent.Type.MOUSE_MOTION) {
* have a button down (i.e. drag-and-drop).
*/
if (mouse.getType() == TMouseEvent.Type.MOUSE_MOTION) {
- if (!mouse.
get
Mouse1()
- && !mouse.
get
Mouse2()
- && !mouse.
get
Mouse3()
- && !mouse.
get
MouseWheelUp()
- && !mouse.
get
MouseWheelDown()
+ if (!mouse.
is
Mouse1()
+ && !mouse.
is
Mouse2()
+ && !mouse.
is
Mouse3()
+ && !mouse.
is
MouseWheelUp()
+ && !mouse.
is
MouseWheelDown()
) {
return;
}
) {
return;
}
@@
-1165,15
+1166,17
@@
public class ECMA48 implements Runnable {
sb.append((char) 0x1B);
sb.append('[');
sb.append('M');
sb.append((char) 0x1B);
sb.append('[');
sb.append('M');
- if (mouse.getMouse1()) {
+ if (mouse.getType() == TMouseEvent.Type.MOUSE_UP) {
+ sb.append((char) (0x03 + 32));
+ } else if (mouse.isMouse1()) {
sb.append((char) (0x00 + 32));
sb.append((char) (0x00 + 32));
- } else if (mouse.
get
Mouse2()) {
+ } else if (mouse.
is
Mouse2()) {
sb.append((char) (0x01 + 32));
sb.append((char) (0x01 + 32));
- } else if (mouse.
get
Mouse3()) {
+ } else if (mouse.
is
Mouse3()) {
sb.append((char) (0x02 + 32));
sb.append((char) (0x02 + 32));
- } else if (mouse.
get
MouseWheelUp()) {
+ } else if (mouse.
is
MouseWheelUp()) {
sb.append((char) (0x04 + 64));
sb.append((char) (0x04 + 64));
- } else if (mouse.
get
MouseWheelDown()) {
+ } else if (mouse.
is
MouseWheelDown()) {
sb.append((char) (0x05 + 64));
} else {
sb.append((char) (0x03 + 32));
sb.append((char) (0x05 + 64));
} else {
sb.append((char) (0x03 + 32));
@@
-1204,16
+1207,16
@@
public class ECMA48 implements Runnable {
*/
private String keypressToString(final TKeypress keypress) {
*/
private String keypressToString(final TKeypress keypress) {
- if ((fullDuplex == false) && (!keypress.
getIs
Key())) {
+ if ((fullDuplex == false) && (!keypress.
isFn
Key())) {
/*
* If this is a control character, process it like it came from
* the remote side.
*/
/*
* If this is a control character, process it like it came from
* the remote side.
*/
- if (keypress.getCh() < 0x20) {
- handleControlChar(keypress.getCh());
+ if (keypress.getCh
ar
() < 0x20) {
+ handleControlChar(keypress.getCh
ar
());
} else {
// Local echo for everything else
} else {
// Local echo for everything else
- printCharacter(keypress.getCh());
+ printCharacter(keypress.getCh
ar
());
}
}
}
}
@@
-1223,18
+1226,18
@@
public class ECMA48 implements Runnable {
}
// Handle control characters
}
// Handle control characters
- if ((keypress.
getCtrl()) && (!keypress.getIs
Key())) {
+ if ((keypress.
isCtrl()) && (!keypress.isFn
Key())) {
StringBuilder sb = new StringBuilder();
StringBuilder sb = new StringBuilder();
- char ch = keypress.getCh();
+ char ch = keypress.getCh
ar
();
ch -= 0x40;
sb.append(ch);
return sb.toString();
}
// Handle alt characters
ch -= 0x40;
sb.append(ch);
return sb.toString();
}
// Handle alt characters
- if ((keypress.
getAlt()) && (!keypress.getIs
Key())) {
+ if ((keypress.
isAlt()) && (!keypress.isFn
Key())) {
StringBuilder sb = new StringBuilder("\033");
StringBuilder sb = new StringBuilder("\033");
- char ch = keypress.getCh();
+ char ch = keypress.getCh
ar
();
sb.append(ch);
return sb.toString();
}
sb.append(ch);
return sb.toString();
}
@@
-1632,9
+1635,9
@@
public class ECMA48 implements Runnable {
}
// Non-alt, non-ctrl characters
}
// Non-alt, non-ctrl characters
- if (!keypress.
getIs
Key()) {
+ if (!keypress.
isFn
Key()) {
StringBuilder sb = new StringBuilder();
StringBuilder sb = new StringBuilder();
- sb.append(keypress.getCh());
+ sb.append(keypress.getCh
ar
());
return sb.toString();
}
return "";
return sb.toString();
}
return "";
@@
-3312,17
+3315,31
@@
public class ECMA48 implements Runnable {
* DECSTBM - Set top and bottom margins.
*/
private void decstbm() {
* DECSTBM - Set top and bottom margins.
*/
private void decstbm() {
- int top = getCsiParam(0, 1, 1, height) - 1;
- int bottom = getCsiParam(1, height, 1, height) - 1;
+ boolean decPrivateModeFlag = false;
- if (top > bottom) {
- top = bottom;
+ for (int i = 0; i < collectBuffer.length(); i++) {
+ if (collectBuffer.charAt(i) == '?') {
+ decPrivateModeFlag = true;
+ break;
+ }
}
}
- scrollRegionTop = top;
- scrollRegionBottom = bottom;
+ if (decPrivateModeFlag) {
+ // This could be restore DEC private mode values.
+ // Ignore it.
+ } else {
+ // DECSTBM
+ int top = getCsiParam(0, 1, 1, height) - 1;
+ int bottom = getCsiParam(1, height, 1, height) - 1;
- // Home cursor
- cursorPosition(0, 0);
+ if (top > bottom) {
+ top = bottom;
+ }
+ scrollRegionTop = top;
+ scrollRegionBottom = bottom;
+
+ // Home cursor
+ cursorPosition(0, 0);
+ }
}
/**
}
/**
@@
-3529,7
+3546,7
@@
public class ECMA48 implements Runnable {
for (int i = start; i <= end; i++) {
DisplayLine line = display.get(currentState.cursorY);
if ((!honorProtected)
for (int i = start; i <= end; i++) {
DisplayLine line = display.get(currentState.cursorY);
if ((!honorProtected)
- || ((honorProtected) && (!line.charAt(i).
get
Protect()))) {
+ || ((honorProtected) && (!line.charAt(i).
is
Protect()))) {
switch (type) {
case VT100:
switch (type) {
case VT100:
@@
-3688,7
+3705,7
@@
public class ECMA48 implements Runnable {
*
* @param ch character from the remote side
*/
*
* @param ch character from the remote side
*/
- p
ublic
void consume(char ch) {
+ p
rivate
void consume(char ch) {
// DEBUG
// System.err.printf("%c", ch);
// DEBUG
// System.err.printf("%c", ch);