oi (odin index) is a documentation viewer for the Odin programming language.
oi-preview.mov
It is an alternative to the pkg.odin-lang.org website, that I started, because:
- The site was too slow on my laptop :(.
- I dislike the fuzzy, scattered matching
- I eventually found myself just typing out the entire:
pkg.odin-lang.org/core/stringsto go tostrings... - also there still is no os/os2 there and I can never find where laytan's HTTP library docs are...
And now:
- Well, I went outside and my kernel borked, but I do use SDL with heavy culling of UI elements (and lazy text rendering)
- There are a bunch of search methods, (default: "dotstar" --
strings.contains+ only.*from regex) Ctrl + Tto open packages (almost all packages have unique names after 3-4 letters, so why bother typing "core/")- base:intrinsics and base:builtin were (for now) traded in for os2 and user libraries (just enter their path)
- Source can be viewed directly in the user's editor (instead of Github) by pressing
Ctrl + G(or in right click menu)
The environment variable ODIN_ROOT is necessary (also needed by odin compiler)
The Odin compiler has to be in your PATH to generate the oi.exe directory/cache
git clone https://github.com/Up05/oi
cd oi && odin run .
Could use for "release": odin build . -o:speed
The program is configured through source code.
Entire configuration may be found in the main.odin.
Simply edit it and rebuild -> reinstall/add to PATH
This is only somewhat inspired by suckless software, since
there is no patching, and I haven't figured out how to properly do source code config
without the user having to merge their sh*t or copy-paste onto updated sources main.odin.
Sorry...
The UI is made up of "boxes" (only). Content and navbar box contents + some other stuff is cached is tabs, but there can only be 1 tab at once.
All boxes are children of window.root, but (generally) you will want to append to one of window.boxes.(sidebar|content|toolbar).
Boxes are layed out automatically, although, after editing them, be sure to set window.should_relayout to true!
The function to append new boxes is:
append_box( parent, ..templates )
// example:
more_generic_text_input: Box = {
type = .TEXT_INPUT,
font = .MONO,
background = .BG1, // 1 is darkest, 4 is brightest
border = true, // BASIC elements can't have a border (currently)
border_in = true, // border_in[set]
...
}
append_box(toolbar, more_generic_text_input, {
// 0 in min_size means "fill parent"
// (negative numbers are also allowed, just 'parent.x|y - abs(min_size.x|y)')
min_size = { 0, CONFIG_FONT_SIZE },
text = "search in package"
})The templates are "merged" i.e.: properties of the previous structs get overwritten by (non-zero) properties of following structs
I just add all of the random-ass global state to window.
# base building blocks
main - configuration and the main function
header - type and many global variable declarations
sdl - layer of indirection on top of SDL2 and TTF + stuff related
os - the gateway to core:os/os2
ui - most of ui implementation + setup_base_ui
util - utility functions and type aliasses
# specific features
toolbar - toolbar + tab
modules - sidebar + content modules
formatter - odin source code formatter + syntax highlighter
# function pointer implementations
keybinds - keyboard shortcut procedures
event - event handling procedures
- use the os[2] package outside of os.odin
- unalign my code intentionally or remove leading whitespace via tool
- add unnecessary things to main.odin
- (to younger me) split up the
Boxmega struct to save <200kb