ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/client/javacli/TerminalScreen.java
Revision: 1.2
Committed: Sun Jan 14 21:58:11 2001 UTC (23 years, 10 months ago) by pjm2
Branch: MAIN
CVS Tags: PROJECT_COMPLETION
Changes since 1.1: +81 -81 lines
Log Message:
Basic command line client to the server's clientinterface.
Currently displays machine name, ip and load values.

File Contents

# User Rev Content
1 pjm2 1.2 // pjm2@ukc.ac.uk
2     // class for laying out text in a terminal window. (in Java!)
3     // After hours of fiddling, anything is possible... ;-)
4    
5     public class TerminalScreen {
6    
7     private static final String ESCAPE_SEQUENCE = "[";
8    
9     public static final int BOLD = 1;
10     public static final int BLACK_BG = 7;
11     public static final int BLUE = 34;
12     public static final int PINK = 35;
13     public static final int RED = 31;
14    
15     // No-args constructor.
16     public TerminalScreen() {
17     // reserved.
18     }
19    
20     // Set the cursor position.
21     public void gotoxy(int x, int y) {
22     System.out.print(ESCAPE_SEQUENCE+y+";"+x+"H");
23     }
24    
25     // Print a string at the current position.
26     public void print(String s) {
27     System.out.print(s);
28     }
29    
30     // Print a string at the current position with the
31     // specified colour.
32     public void print(String s, int colour) {
33     System.out.print(ESCAPE_SEQUENCE+colour+"m");
34     System.out.print(s);
35     System.out.print(ESCAPE_SEQUENCE+"0m");
36     }
37    
38     // Print a string at the current position with a specified
39     // foreground and background colour.
40     public void print(String s, int colour, int other) {
41     System.out.print(ESCAPE_SEQUENCE+other+"m");
42     this.print(s, colour);
43     }
44    
45     // Clears the terminal screen and then resets the cursor position.
46     public void clear() {
47     System.out.print(ESCAPE_SEQUENCE+"2J");
48     System.out.print(ESCAPE_SEQUENCE+"1;24r");
49     }
50    
51     // Main method for testing!
52     public static void main(String[] args) throws InterruptedException {
53    
54     TerminalScreen screen = new TerminalScreen();
55    
56     screen.clear();
57    
58     screen.gotoxy(34, 10);
59     screen.print(" i - s c r e a m ", TerminalScreen.BOLD, TerminalScreen.BLACK_BG);
60     screen.gotoxy(27, 12);
61     screen.print("Central Monitoring System Client", TerminalScreen.BLUE);
62     screen.gotoxy(32,13);
63     screen.print("Unix/Linux version 1.0");
64    
65    
66     screen.gotoxy(1,1);
67     screen.print("Top left");
68     screen.gotoxy(79,24);
69     screen.print("E");
70    
71     screen.gotoxy(1,24);
72    
73     Thread.sleep(3000);
74    
75     screen.clear();
76    
77    
78    
79     }
80    
81     }