Added support for Terminal.cursorStartOfLine() and clearToEndOfLine().

This commit is contained in:
Adam Murdoch
2012-08-04 17:18:16 +10:00
parent ec9d8d7bf8
commit e0c31aa176
7 changed files with 69 additions and 6 deletions

View File

@@ -131,4 +131,26 @@ public class TerminfoTerminal extends AbstractTerminal {
}
return this;
}
@Override
public Terminal cursorStartOfLine() throws NativeException {
stream.flush();
FunctionResult result = new FunctionResult();
TerminfoFunctions.startLine(result);
if (result.isFailed()) {
throw new NativeException(String.format("Could not move cursor to start of line for %s: %s", this, result.getMessage()));
}
return this;
}
@Override
public Terminal clearToEndOfLine() throws NativeException {
stream.flush();
FunctionResult result = new FunctionResult();
TerminfoFunctions.clearToEndOfLine(result);
if (result.isFailed()) {
throw new NativeException(String.format("Could not clear to end of line for %s: %s", this, result.getMessage()));
}
return this;
}
}

View File

@@ -97,4 +97,14 @@ public class WindowsTerminal extends AbstractTerminal {
public Terminal cursorRight(int count) throws NativeException {
throw new UnsupportedOperationException();
}
@Override
public Terminal cursorStartOfLine() throws NativeException {
throw new UnsupportedOperationException();
}
@Override
public Terminal clearToEndOfLine() throws NativeException {
throw new UnsupportedOperationException();
}
}

View File

@@ -21,4 +21,8 @@ public class TerminfoFunctions {
public static native void up(int count, FunctionResult result);
public static native void down(int count, FunctionResult result);
public static native void startLine(FunctionResult result);
public static native void clearToEndOfLine(FunctionResult result);
}