-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f844738
commit f556270
Showing
9 changed files
with
97 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package de.curses.window.components; | ||
|
||
import de.curses.NativeCurses; | ||
import de.curses.window.Component; | ||
|
||
public class Selector extends Component { | ||
|
||
private String[] values; | ||
private int index; | ||
|
||
public Selector(Window parent, int x, int y, int width, int color, String... values) { | ||
super(parent, x, y, width, 2, color); | ||
this.values = values; | ||
} | ||
|
||
@Override | ||
public void draw() { | ||
drawBox(-1); | ||
NativeCurses.instance().drawArrow(x+1, y+1, 0, color); | ||
NativeCurses.instance().drawArrow(x+width-1, y+1, 1, color); | ||
drawCenteredString((width/2), 1, current().substring(0, Math.min(current().length(), width-5)), color); | ||
} | ||
|
||
public String current() { | ||
return values[index%values.length]; | ||
} | ||
|
||
@Override | ||
public boolean handleKey(char ch) { | ||
if(ch == 260) { | ||
if(index-1 <= 0) index=values.length; | ||
index--; | ||
return true; | ||
}else if(ch==261) { | ||
index++; | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.