This is a browser, created by default, that embeds the text editor.
| 32 | */ |
| 33 | public class TextEditor extends Box implements IO.Loaded { |
| 34 | |
| 35 | static public final Dict.Prop<TextEditor> textEditor = new Dict.Prop<>("textEditor").toCanon() |
| 36 | .type() |
| 37 | .doc("The TextEditor that is stuck in front of the window, in window coordinates"); |
| 38 | private final Box root; |
| 39 | @HiddenInAutocomplete |
| 40 | public Browser browser_; |
| 41 | @HiddenInAutocomplete |
| 42 | public String styles; |
| 43 | String styleSheet = "field-codemirror.css"; |
| 44 | |
| 45 | // we'll need to make sure that this is centered on larger screens |
| 46 | int maxw = 900; |
| 47 | int maxh = 1400; |
| 48 | int heightLast = -1; |
| 49 | int tick = 0; |
| 50 | Commands commandHelper = new Commands(); |
| 51 | long lastTriggerAt = -1; |
| 52 | int ignoreHide = 0; |
| 53 | private int maxhOnCreation = 0; |
| 54 | private String setHeightCode = ""; |
| 55 | private String setWidthCode = ""; |
| 56 | private String initialURL; |
| 57 | |
| 58 | public TextEditor(Box root) { |
| 59 | this.properties.put(textEditor, this); |
| 60 | this.root = root; |
| 61 | } |
| 62 | |
| 63 | @HiddenInAutocomplete |
| 64 | private static String readFile(String s, boolean append) { |
| 65 | try (BufferedReader r = new BufferedReader(new FileReader(new File(s)))) { |
| 66 | String line = ""; |
| 67 | while (r.ready()) { |
| 68 | line += r.readLine() + "\n"; |
| 69 | } |
| 70 | |
| 71 | if (append) line += "\n//# sourceURL=" + s; |
| 72 | return line; |
| 73 | |
| 74 | } catch (IOException e) { |
| 75 | e.printStackTrace(); |
| 76 | } |
| 77 | return ""; |
| 78 | } |
| 79 | |
| 80 | int frameLast = 0; |
| 81 | |
| 82 | @HiddenInAutocomplete |
| 83 | public void loaded() { |
| 84 | loaded("http://localhost:" + find(ServerSupport.server, both()).findFirst().get().port + "/init"); |
| 85 | } |
| 86 | |
| 87 | @HiddenInAutocomplete |
| 88 | public void loaded(String initialURL) { |
| 89 | |
| 90 | this.initialURL = initialURL; |
| 91 | Log.log("texteditor.debug", () -> "initializing browser"); |