Skip to content

Commit af3e7d8

Browse files
committed
Add "beep" example in demo
1 parent d65fd8c commit af3e7d8

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/test/java/com/flowingcode/vaadin/addons/xterm/DemoView.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@
2626
import java.time.format.DateTimeFormatter;
2727
import java.time.temporal.ChronoUnit;
2828

29-
import com.flowingcode.vaadin.addons.xterm.XTerm;
30-
import com.flowingcode.vaadin.addons.xterm.XTermClipboard;
31-
import com.flowingcode.vaadin.addons.xterm.XTermConsole;
32-
import com.flowingcode.vaadin.addons.xterm.XTermFit;
29+
import com.flowingcode.vaadin.addons.xterm.ITerminalOptions.BellStyle;
3330
import com.flowingcode.vaadin.addons.xterm.ITerminalOptions.CursorStyle;
3431
import com.flowingcode.vaadin.addons.xterm.XTermClipboard.UseSystemClipboard;
3532
import com.vaadin.flow.component.notification.Notification;
@@ -50,10 +47,10 @@ public DemoView() {
5047

5148
xterm = new XTerm();
5249
xterm.writeln("xterm add-on by Flowing Code S.A.\n\n");
53-
xterm.writeln("If you write \"time\" I'll tell you what time it is, "+
54-
"if you write \"date\" I'll tell you what date it is.\n");
50+
xterm.writeln("Commands: time, date, beep\n");
5551
xterm.setCursorBlink(true);
5652
xterm.setCursorStyle(CursorStyle.UNDERLINE);
53+
xterm.setBellStyle(BellStyle.SOUND);
5754

5855
xterm.setSizeFull();
5956
xterm.loadFeature(new XTermClipboard(), clipboard->{
@@ -64,13 +61,18 @@ public DemoView() {
6461
});
6562
xterm.loadFeature(new XTermConsole(), console->{
6663
console.addLineListener(ev->{
67-
String line = ev.getLine();
68-
if (line.equalsIgnoreCase("time")) {
64+
switch (ev.getLine().toLowerCase()) {
65+
case "time":
6966
xterm.writeln(LocalTime.now().truncatedTo(ChronoUnit.SECONDS).format(DateTimeFormatter.ISO_TIME));
70-
} else if (line.equalsIgnoreCase("date")) {
67+
break;
68+
case "date":
7169
xterm.writeln(LocalDate.now().toString());
70+
break;
71+
case "beep":
72+
xterm.write("\u0007");
73+
break;
7274
}
73-
Notification.show(line);
75+
Notification.show(ev.getLine());
7476
});
7577
});
7678

0 commit comments

Comments
 (0)