Skip to content

Commit

Permalink
Support octal in infocmp capabilities, fixes #408
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Jun 27, 2019
1 parent 9ef1cc2 commit 864f206
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
12 changes: 10 additions & 2 deletions terminal/src/main/java/org/jline/utils/Curses.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,16 @@ private static void doTputs(Appendable out, String str, Object... params) throws
switch (ch) {
case '\\':
ch = str.charAt(index++);
if (ch >= '0' && ch <= '9') {
throw new UnsupportedOperationException(); // todo
if (ch >= '0' && ch <= '7') {
int val = ch - '0';
for (int i = 0; i < 2; i++) {
ch = str.charAt(index++);
if (ch < '0' || ch > '7') {
throw new IllegalStateException();
}
val = val * 8 + (ch - '0');
}
out.append((char) val);
} else {
switch (ch) {
case 'e':
Expand Down
2 changes: 2 additions & 0 deletions terminal/src/main/java/org/jline/utils/InfoCmp.java
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,8 @@ public static void parseInfoCmp(
int iVal;
if (val.startsWith("0x")) {
iVal = Integer.parseInt(val.substring(2), 16);
} else if (val.startsWith("0")) {
iVal = Integer.parseInt(val.substring(1), 8);
} else {
iVal = Integer.parseInt(val);
}
Expand Down
2 changes: 1 addition & 1 deletion terminal/src/test/java/org/jline/utils/CursesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class CursesTest {
@Test
public void testTputs() throws Exception {

assertEquals("\033[3;4r", Curses.tputs("\\E[%i%p1%d;%p2%dr", 2, 3));
assertEquals("{\033[3;4r", Curses.tputs("\\173\\E[%i%p1%d;%p2%dr", 2, 3));

}

Expand Down

0 comments on commit 864f206

Please # to comment.