- Added support for setting the terminal foreground color.
- Some improvements to error handling.
This commit is contained in:
@@ -1,17 +1,26 @@
|
||||
package net.rubygrapefruit.platform.internal;
|
||||
|
||||
public class FunctionResult {
|
||||
String message;
|
||||
int errno;
|
||||
|
||||
void failed(int errno) {
|
||||
void failed(String message, int errno) {
|
||||
this.message = message;
|
||||
this.errno = errno;
|
||||
}
|
||||
|
||||
public boolean isFailed() {
|
||||
return errno != 0;
|
||||
void failed(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public int getErrno() {
|
||||
return errno;
|
||||
public boolean isFailed() {
|
||||
return message != null;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
if (errno != 0) {
|
||||
return String.format("%s (errno %d)", message, errno);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.rubygrapefruit.platform.internal;
|
||||
|
||||
public class NativeLibraryFunctions {
|
||||
public static final int VERSION = 1;
|
||||
public static final int VERSION = 2;
|
||||
|
||||
public static native int getVersion();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,12 @@ public class TerminfoFunctions {
|
||||
*/
|
||||
public static native void initTerminal(int filedes, FunctionResult result);
|
||||
|
||||
public static native void bold(int filedes, FunctionResult result);
|
||||
public static native void bold(FunctionResult result);
|
||||
|
||||
public static native void normal(int filedes, FunctionResult result);
|
||||
public static native void reset(FunctionResult result);
|
||||
|
||||
/**
|
||||
* Set the foreground color to the given ansi color.
|
||||
*/
|
||||
public static native void foreground(int ansiColor, FunctionResult result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user