2626import java .time .format .DateTimeFormatter ;
2727import 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 ;
3330import com .flowingcode .vaadin .addons .xterm .ITerminalOptions .CursorStyle ;
3431import com .flowingcode .vaadin .addons .xterm .XTermClipboard .UseSystemClipboard ;
3532import 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