kde

i never used an ide, except those i wrote myself

kde includes:

it is a web application that can access the local file system if you permit.
it can be installed as a progressive web application to work offline, if you so wish.

editor

the editor is codemirror with bracket matching, block editing (alt-click-move-mouse), and k syntax mode that should catch errors early: try:

clicking run restarts k and evaluates the program in the editor.
the same can be done with shift-enter or shift-rightclick in the editor. if some text is selected, these shortcuts only send the current selection to the repl, without restarting k. clicking an a line number executes that line only.

multiple files are executed, if the input field starts with k, e.g. k a.k b.k executes a.k then b.k followed by the program in the editor.

repl

the repl shows k output and remains active after running the program in the editor.
k output lines also keep a reference to the underlying k value. hovering over an output line displays it in red and shows the type information. double-clicking on it resends it to the input and right-clicking assigns it to x.

text that is written by k with `<"text" or x+ \y keeps track of the stores the source location in the output. it is shown in red and double-clicking points the editor to the source where the write call originates.

k runs in a webworker in a separate thread as the ui.
if k does not return directly (e.g. (1+)/:1), it can be interrupted with the int button, which is enabled when k is busy. int terminates and restarts the webworker. all data in k memory is reset, but the filesystem in the ui is still loaded.

file browser

by default you can edit and execute the contents of the editor.
to load files from disk, you can open a directory by clicking dir. only one directory is supported, no subdirs.
the filesystemapi is not supported by all browsers.
otherwise drop files or a directory in the window.

click on a file to open it in the editor. put writes it back to disk or downloads.
the browser highlights the open file bold and underlines modified files that have not been written. it does not track changes happening on disk.

k also has file system access within the directory that is loaded.
`file<"bytes" writes to disk and x:<`file reads.
`$<`"." returns a list of all file names as symbols.
to read a file, it must be preloaded (k.wasm cannot work with asynchronous js apis).
files are preloaded when clicking rda or when the file has been opened in the editor. k-files are always preloaded.

entering text in the the input field of the file browser searches for the input text in all loaded files and prints links for all matches in the console (like grep but no regex).

search

search in the editor by selecting text and right click to jump to the next occurance.

find files by entering a prefix in the input field above the browser. results are displayed with links in the repl. if a single file is found, it is opens in the editor.

grep in all loaded files with g str in the input field. matches are displayed in the repl. restrict the search to files with a specific extension, e.g. all k files by g.k str. the string is matched directly, not as a regular expression.

definitions of a variable in all k files are searched with :varname. all definitions show up in the repl as links.

find, grep and definitions can also be executed without argument, in which case the currently selected text from the editor is used.

feature switch

there is one switch (the checkbox) that turns everything on or off:

error indicator

when k detects an error with position, the position is an offset to the current source, a catenation of the executed files:
"\n"/:(z.k       /built-in k.wasm
       a.k;b.k   /included files
       ed)       /editor value
if the error is within the code shown in the editor, it is highlighted directly. otherwise a link is appended to the repl giving the user time to save the current file.

by default only the innermost error position is tracked by kvm. that may may be in the built-in z.k (e.g. the formatter), which may not be very informative.
for a complete stack trace, turn use the debugger by turning on the switch.

trace/debug

with the switch turned on, run uses d.wasm instead of k.wasm. it is a special build of k that traces each call in the virtual machine by calling js functions fpush and fpop. js stores all functions and their arguments on a stack that is present in case of a trap.
the repl shows an interactive stack trace with source positions: clicking on the file shows the source of the function call and double clicking on the k values prints the function or argument values in the repl.
the first line also shows the type and position of the error where it has been triggered in the source of the k interpreter.

static analysis

before running the program a static analysis check is done on the parsed input. it detects: they are shown as errors in the console that can be double clicked to jump to the source location.

todo

plot canvas

simple plot.js
 plot F          plot(1.0;x)
 plot(F;F)       plot(x;y)
 plot(F;F;..)    plot `x`y(!'x;x) multiple lines
 plot Z          polar
 plot(Z;Z;..)    polar multiple datasets
single canvas, autoscale, grid, click-to-point, zoom rectangle, no decoration