Skip to content

Commit 93de53a

Browse files
authored
Merge pull request #10 from SageCreations/main
Updated README
2 parents d9ffe42 + 1b6c656 commit 93de53a

File tree

4 files changed

+79
-107
lines changed

4 files changed

+79
-107
lines changed

README.md

Lines changed: 77 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -21,139 +21,98 @@
2121

2222
</div>
2323

24-
## Usage
24+
## Contents
2525

26-
> **Note**
27-
> Odin-WebUI is under development and is currently only tested on macOS and Linux.
26+
- [Features](#features)
27+
- [Installation](#installation)
28+
- [Examples](#minimal-example)
29+
- [Debugging](#debugging)
30+
- [Documentation](#documentation)
31+
- [UI & The Web Technologies](#ui--the-web-technologies)
32+
- [Wrappers](#wrappers)
33+
- [Supported Web Browsers](#supported-web-browsers)
34+
- [License](#license)
2835

29-
### Setup as a submodule in your Odin project
36+
## Features
3037

31-
Add odin-webui as a submodule in your Odin git project:
38+
- Portable (*Needs only a web browser at runtime*)
39+
- Lightweight (*Few Kb library*) & Small memory footprint
40+
- Fast binary communication protocol
41+
- Multi-platform & Multi-Browser
42+
- Using private profile for safety
43+
- Original library is written in Pure C
44+
45+
## Installation
3246

3347
```sh
48+
# Add odin-webui as a submodule to your project
3449
git submodule add https://github.com/webui-dev/odin-webui.git webui
35-
webui/setup.sh
36-
```
3750

38-
Import the package using the relative path
51+
# Linux/MacOS
52+
webui/setup.sh
3953

40-
```odin
41-
import ui "webui"
54+
# Windows
55+
webui/setup.ps1
4256
```
4357

4458
<details>
4559
<summary><kbd>toggle</kbd> <b>Full example creating a project and adding odin-webui as a submodule.</b></summary>
4660

4761
```sh
48-
mkdir my_proj && cd my_proj
49-
git init
50-
git submodule add https://github.com/webui-dev/odin-webui.git webui
51-
# Setup the WebUI C library.
52-
weubi/setup.sh
53-
# Create a the main file for the project. And use it in the next step.
54-
touch main.odin
55-
```
56-
57-
```odin
58-
// main.odin
59-
package main
60-
61-
import ui "webui"
62-
63-
main :: proc() {
64-
w := ui.new_window()
65-
ui.show(w, "<html>Thanks for using WebUI!</html>")
66-
ui.wait()
67-
}
68-
```
69-
70-
</details>
62+
# Create your project directory
63+
mkdir my_proj
7164

72-
### Setup as regular git clone
65+
# Change Directory into the project Directory
66+
cd my_proj
7367

74-
_This approach can be useful for quick testing and for development and contribution purposes._
75-
76-
1. Clone the repository
77-
78-
```sh
79-
git clone https://github.com/webui-dev/odin-webui.git
80-
```
68+
# Initialize the directory to be a git repository
69+
git init
8170

82-
2. Setup the WebUI C library
71+
# Add odin-webui as a submodule to your project
72+
git submodule add https://github.com/webui-dev/odin-webui.git webui
8373

84-
```sh
85-
cd odin-webui
74+
# Build the linkers used for the binding from the C library.
75+
# Linux/MacOS
76+
webui/setup.sh
77+
# Windows
78+
webui/setup.ps1
8679

87-
# Setup the WebUI C library.
88-
./setup.sh
80+
# Create a file called 'main.odin' in your project directory.
81+
# Copy the minimal example code in the next step and paste into 'main.odin'.
82+
# Run the example with the command: 'odin run main.odin -file'.
8983
```
84+
</details>
9085

91-
## Example - Call Odin from JavaScript
86+
## Minimal Example
9287

9388
```odin
89+
// main.odin
9490
package main
9591
96-
import "base:runtime"
9792
import ui "webui"
98-
import "core:fmt"
99-
100-
UI :: `<!DOCTYPE html>
101-
<html lang="en">
102-
<head>
103-
<style>
104-
body {
105-
background: linear-gradient(to left, #36265a, #654da9);
106-
color: AliceBlue;
107-
font: 16px sans-serif;
108-
text-align: center;
109-
}
110-
</style>
111-
<script src="webui.js"></script>
112-
</head>
113-
<body>
114-
<h1>Thanks for using WebUI!</h1>
115-
<button onclick="webui.my_odin_func('myJSArg')">Call Odin!</button>
116-
<button id="exit">Exit</button>
117-
</body>
118-
</html>`
119-
120-
// Odin function used as bind callback.
121-
my_odin_func :: proc "c" (e: ^ui.Event) {
122-
context := runtime.default_context()
123-
124-
str_arg := ui.get_arg(string, e)
125-
fmt.printf("JS argument: %s\n", str_arg)
126-
}
12793
12894
main :: proc() {
129-
w := ui.new_window()
130-
ui.bind(w, "my_odin_func", my_odin_func)
131-
// Bind to an ID with a click event.
132-
ui.bind(w, "exit", proc "c" (_: ^ui.Event) {
133-
context := runtime.default_context()
134-
fmt.println("Bye!")
135-
ui.exit()
136-
})
137-
ui.show(w, UI)
138-
ui.wait()
95+
my_window: uint = ui.new_window()
96+
ui.show(my_window, "<html> Thanks for using WebUI! </html>")
97+
ui.wait()
13998
}
14099
```
100+
[More examples](https://github.com/webui-dev/odin-webui/tree/main/examples)
141101

142-
Running exmples from the [`examples`](https://github.com/webui-dev/odin-webui/tree/main/examples) directory:
143102

144-
```
145-
odin run examples/call_odin.odin -file
146-
```
147103

148-
### Debugging
104+
## Debugging
149105

150106
To use WebUI's debug build in your Odin-WebUI application, add the `-debug` switch. E.g.:
151107

152108
```sh
153109
odin run examples/minimal.odin -file -debug
154110
```
155111

156-
## About WebUI
112+
## Documentation
113+
- [Online Documentation](https://webui.me/docs/2.5/#/)
114+
115+
## UI & The Web Technologies
157116

158117
[Borislav Stanimirov](https://ibob.bg/) discusses using HTML5 in the web browser as GUI at the [C++ Conference 2019 (_YouTube_)](https://www.youtube.com/watch?v=bbbcZd4cuxg).
159118

@@ -193,16 +152,27 @@ Think of WebUI like a WebView controller, but instead of embedding the WebView c
193152

194153
## Wrappers
195154

196-
| Language | Status | Link |
197-
| ----------------------- | -------------- | --------------------------------------------------------- |
198-
| Go | ✔️ | [Go-WebUI](https://github.com/webui-dev/go-webui) |
199-
| Nim | ✔️ | [Nim-WebUI](https://github.com/webui-dev/nim-webui) |
200-
| Pascal | ✔️ | [Pascal-WebUI](https://github.com/webui-dev/pascal-webui) |
201-
| Python | ✔️ | [Python-WebUI](https://github.com/webui-dev/python-webui) |
202-
| Rust | _not complete_ | [Rust-WebUI](https://github.com/webui-dev/rust-webui) |
203-
| TypeScript / JavaScript | ✔️ | [Deno-WebUI](https://github.com/webui-dev/deno-webui) |
204-
| V | ✔️ | [V-WebUI](https://github.com/webui-dev/v-webui) |
205-
| Zig | _not complete_ | [Zig-WebUI](https://github.com/webui-dev/zig-webui) |
155+
| Language | v2.4.0 API | v2.5.0 API | Link |
156+
| --------------- | --- | -------------- | --------------------------------------------------------- |
157+
| Python | ✔️ | _not complete_ | [Python-WebUI](https://github.com/webui-dev/python-webui) |
158+
| Go | ✔️ | _not complete_ | [Go-WebUI](https://github.com/webui-dev/go-webui) |
159+
| Zig | ✔️ | _not complete_ | [Zig-WebUI](https://github.com/webui-dev/zig-webui) |
160+
| Nim | ✔️ | _not complete_ | [Nim-WebUI](https://github.com/webui-dev/nim-webui) |
161+
| V | ✔️ | _not complete_ | [V-WebUI](https://github.com/webui-dev/v-webui) |
162+
| Rust | _not complete_ | _not complete_ | [Rust-WebUI](https://github.com/webui-dev/rust-webui) |
163+
| TS / JS (Deno) | ✔️ | _not complete_ | [Deno-WebUI](https://github.com/webui-dev/deno-webui) |
164+
| TS / JS (Bun) | _not complete_ | _not complete_ | [Bun-WebUI](https://github.com/webui-dev/bun-webui) |
165+
| Swift | _not complete_ | _not complete_ | [Swift-WebUI](https://github.com/webui-dev/swift-webui) |
166+
| Odin | _not complete_ | _not complete_ | [Odin-WebUI](https://github.com/webui-dev/odin-webui) |
167+
| Pascal | _not complete_ | _not complete_ | [Pascal-WebUI](https://github.com/webui-dev/pascal-webui) |
168+
| Purebasic | _not complete_ | _not complete_ | [Purebasic-WebUI](https://github.com/webui-dev/purebasic-webui)|
169+
| - | | |
170+
| Common Lisp | _not complete_ | _not complete_ | [cl-webui](https://github.com/garlic0x1/cl-webui) |
171+
| Delphi | _not complete_ | _not complete_ | [WebUI4Delphi](https://github.com/salvadordf/WebUI4Delphi) |
172+
| C# | _not complete_ | _not complete_ | [WebUI4CSharp](https://github.com/salvadordf/WebUI4CSharp) |
173+
| WebUI.NET | _not complete_ | _not complete_ | [WebUI.NET](https://github.com/Juff-Ma/WebUI.NET) |
174+
| QuickJS | _not complete_ | _not complete_ | [QuickUI](https://github.com/xland/QuickUI) |
175+
| PHP | _not complete_ | _not complete_ | [PHPWebUiComposer](https://github.com/KingBes/php-webui-composer) |
206176

207177
## Supported Web Browsers
208178

@@ -219,10 +189,12 @@ Think of WebUI like a WebView controller, but instead of embedding the WebView c
219189
| Apple Safari | _not available_ | _coming soon_ | _not available_ |
220190
| Opera | _coming soon_ | _coming soon_ | _coming soon_ |
221191

192+
### License
193+
194+
> Licensed under the MIT License.
195+
222196
### Stargazers
223197

224198
[![stargazers](https://reporoster.com/stars/webui-dev/odin-webui)](https://github.com/webui-dev/odin-webui/stargazers)
225199

226-
### License
227200

228-
> Licensed under the MIT License.

examples/minimal.odin

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package main
33
import ui "../"
44

55
main :: proc() {
6-
w := ui.new_window()
7-
ui.show(w, "<html>Hellope</html>")
6+
my_window: uint = ui.new_window()
7+
ui.show(my_window, "<html><script src=\"webui.js\"></script> Hellope! </html>")
88
ui.wait()
99
}

0 commit comments

Comments
 (0)