Libraryless. Click here for Pure Java version (2476L/17K/58K).
1 | !752 |
2 | |
3 | static JTextArea textArea; |
4 | static float fontSize = 24f; |
5 | static S fontSnippet = |
6 | //"#1000967" // a TrueType font (works, but no punctuation) |
7 | //"#1000969" // an OpenType font (works! but hard to read) |
8 | //"#1000970" |
9 | //"#1004887" // the great Akashi |
10 | "#1004889"; |
11 | |
12 | static Font loadFont() ctex {
|
13 | return Font.createFont(Font.TRUETYPE_FONT, loadLibrary(fontSnippet)).deriveFont(fontSize); |
14 | } |
15 | |
16 | p {
|
17 | textArea = new JTextArea(); |
18 | textArea.setFont(loadFont()); |
19 | textArea.setMargin(new Insets(10, 10, 10, 10)); |
20 | |
21 | textArea.addKeyListener(new KeyAdapter() {
|
22 | public void keyPressed(KeyEvent e) {
|
23 | if (e.getKeyCode() == KeyEvent.VK_ENTER && e.getModifiers() == 0) {
|
24 | enterPressed(); |
25 | } |
26 | } |
27 | }); |
28 | |
29 | makeFrame("Dialog", new JScrollPane(textArea));
|
30 | sleep(); // important for auto-logging as of now |
31 | } |
32 | |
33 | static void enterPressed() {
|
34 | S text = textArea.getText(); |
35 | int idx = textArea.getCaretPosition(); |
36 | |
37 | // move to end of line first |
38 | while (idx < text.length() && text.charAt(idx) != '\n') ++idx; |
39 | textArea.setCaretPosition(idx); |
40 | |
41 | //print(quote(text.substring(0, idx))); |
42 | int lineStart = text.lastIndexOf("\n", idx-1);
|
43 | //print(lineStart + " " + idx); |
44 | S line = text.substring(lineStart+1, idx); |
45 | print("?? " + line);
|
46 | processLine(line); |
47 | } |
48 | |
49 | static void processLine(S line) {
|
50 | type(line + "??"); |
51 | } |
52 | |
53 | static void type(S bla) {
|
54 | print("!! " + bla);
|
55 | textArea.insert("\n" + bla, textArea.getCaretPosition());
|
56 | } |
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1000966 |
| Snippet name: | Dialog in a fancy font |
| Eternal ID of this version: | #1000966/1 |
| Text MD5: | 2e402ee27f3a0955486af6f1d8f67c40 |
| Transpilation MD5: | 3c5812d0f68ddbcea9089dbdb8d59b41 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2016-09-13 06:20:06 |
| Source code size: | 1507 bytes / 56 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 925 / 1008 |
| Referenced in: | [show references] |