ide
HolyIDE: an editor and a workbench for HolyPHP, written in HolyPHP on top of HolyHTML. The library is the whole IDE except the window, which is why all of it is tested without one.
Two halves, one import
| File | What it is |
|---|---|
ide/editor.hphp | the document model: lines, caret and selection, editing keys, undo/redo, the syntax tokenizer, the completion vocabulary |
ide/workbench.hphp | the chrome: explorer tree, tabs, code pane, terminal and problems panel, status bar, command palette, key table, runner — rendered to HTML and handed to an HtmlView |
holyide/holyide.hphp | the window: one canvas, forwarded events, a frame timer. Not part of the library — it is the ~140-line app around it. |
The editor on its own
The buffer, the caret and the editing operations have no idea a screen exists. Load a file, type into it, undo, save — no window anywhere.
import "ide";
$ed = new IdeEditor();
$ed->load("holyide/holyide.hphp");
$ed->move("docstart", false);
$ed->type_char("/");
$ed->type_char("/");
echo substr($ed->line(0), 0, 20); // //// ==== ...
$ed->undo_step();
echo $ed->status(); // undo/redo state, position, tokens
echo $ed->word_at_cursor();
foreach ($ed->completions("str", 8) as $w) { echo $w; }
The workbench, driven headlessly
The workbench owns state and renders it to HTML. A test — or your own
tool — builds one with no canvas (0), opens a folder, lays the
document out with ensure() and then reads boxes, clicks and key
results. tests/positive/ide_workbench.hphp does exactly that.
import "ide";
$wb = new IdeWorkbench(0, 1180, 760, html_theme_dark());
$wb->open_root(".");
$wb->open("lib/ide/workbench.hphp");
$wb->ensure(); // parse, style, lay out (no ink)
echo $wb->ed()->line_count() . " lines";
echo "code pane: " . $wb->ed_rows() . " rows x " . $wb->ed_cols() . " cols";
$wb->key(80, "", 1); // Ctrl+P: the file palette
$wb->key(0, "work", 0); // type a query
$wb->key(13, "", 0); // Enter: open the first match
Opening it in a window
hphp run holyide/holyide.hphp # the current folder
hphp run holyide/holyide.hphp ../my-project # another one
hphp build holyide/holyide.hphp -o holyide.exe
The app forwards canvas events to key() / mouse(),
pumps the running program from a frame timer, follows window resizes and acts
on the one string that needs a window: "quit".
Keys
| Keys | Action |
|---|---|
Ctrl+P / Ctrl+Shift+P / Ctrl+G | go to file · all commands · go to line |
Ctrl+S / Ctrl+K Ctrl+S | save · save all |
F5 / Shift+F5 / Ctrl+R | run the active file · stop · run |
Ctrl+Space / Tab / Enter | complete the word at the caret · accept · accept |
Ctrl+` | the terminal's command line |
Ctrl+B / Ctrl+J | toggle explorer · toggle panel |
Ctrl+/ / Ctrl+D / Alt+↑↓ | toggle comment · duplicate line · move line |
Ctrl+= / Ctrl+- / Ctrl+0 | zoom in · out · reset |
Ctrl+Shift+W | quit |
What the mouse does
- A click in the code puts the caret where the pointer is; the gutter picks the whole line. Hold the button and drag to select.
- A double click selects the word under the pointer.
- The explorer folds: clicking a folder shows or hides what is in it, clicking a file opens it in a tab.
- The 5px strip between the explorer and the editor, and between the editor and the panel, is a grip: drag it and that pane changes size. Hovering lights it up, so it can be found.
- The wheel moves the code one line a notch - it is a scroll, not a jump - and two rows a notch in the explorer.
What runs a file
Ctrl+R starts hphp run <file> through the
runtime's proc_* pipe API, in the file's own folder. Output
appears in the terminal panel; a failing compile is parsed into the problems
list, and clicking a problem opens the file at its line.
The panel is also a terminal, in the small sense: a command line at the
bottom, Ctrl+` or a click to focus it, Enter to run through
cmd /c in the project folder, Up/Down for history, Tab to hand
the keyboard back to the editor. It is a command line over pipes, not a TTY
- no interactive prompt, no colours, no full-screen programs.
Status
The workbench is complete and tested headlessly: 100+ assertions cover the
editor, the layout numbers, the palette ranking, tabs, the runner and the draw
list. The window app exists and passes a pixel self-check
(holyide --selftest). What is not there yet — search across
files, git, a settings system, split editors, a debugger — is listed in
STATUS.md at the repo root, next to the rest of the roadmap.