-
Notifications
You must be signed in to change notification settings - Fork 0
Tutorial Project Structure Example
Now that we know the structure of an EzTerm project, we'll create the smallest working example possible to get the structure into our fingers. After that we will move on to explain how to create an actual UI in detail (for which we can use the project we are now creating).
Step 1: Create a new cargo project:
We'll create a new Rust project first using cargo. Feel free to choose another name.
cargo-new ez_term_test
In cargo.toml include the framework as a dependency (if you are copy pasting this, fill in the latest version of the dependency):
[dependencies]
ez_term = "0.1.0"
Step 2: Define the UI:
Create a folder named 'ui' in the root of the project. Create a file named 'ui.ez' in the new folder. These names are not mandatory, you can call the folder and file whatever you like. If you choose the default names your project folder now looks like this:
/ez_term_test
/cargo.toml
/src
/main.rs
/ui
/ui.ez
In the 'ui.ez' file write or copy the below config to create a small 'hello world' UI (don't worry if the syntax of the .ez file is still unfamiliar, we'll dive into it in the next chapter):
- Layout:
mode: box
orientation: horizontal
- Label:
text: Hello,
border: true
- Label:
text: World!
border: true
Step 3: Create the UI rust module
We now have a UI definiton in the .ez file. We will need to initialize it in a rust module. We will use the existing 'main.rs' to initialize and run the UI. Modify 'main.rs' to look like this:
use ez_term::*;
fn main() {
let (root_widget, state_tree, mut scheduler) = load_ui();
run(root_widget, state_tree, scheduler);
}
Step 4: Compile and run the project
First we let cargo know where our .ez files can be found through an environment variable:
- On Linux:
export EZ_FOLDER="/path/to/ez_term_test/ui"
- On Windows:
$env:EZ_FOLDER="C:\path\to\ez_term_test\ui"
Make sure you use a full path. Cargo needs to know the location of our .ez files so it can merge them into the binary. Now run the following cargo command in any OS terminal:
cargo run
You should you be able to see the 'hello world' UI! Press Escape to quit.
Now that you know how to create a basic UI, we'll dive into the specifics of the framework.
The general tutorial continues with: EzLang.
Tutorial
Tutorial-Project-StructureMinimal example
EzLang
EzLang basics
EzLang Templates
Ezlang Layout modes
EzLang Box mode layouts
EzLang Stack mode layouts
EzLang Table mode layouts
EzLang Float mode layouts
EzLang Tab mode layouts
EzLang Screen mode layouts
EzLang Layout Scrolling
EzLang Layout Views
EzLang Widget overview
EzLang Label
EzLang Text Input
EzLang Button
EzLang Checkbox
EzLang Radio button
EzLang Dropdown
EzLang Slider
EzLang Canvas
EzLang Property Binding
EzLang Sizing
EzLang Size hints
EzLang Auto scaling
EzLang Maths Sizing
EzLang Manual Sizing
EzLang Positioning
EzLang Layout Mode Positioning
EzLang Position Hints
EzLang Position Maths
EzLang Manual Position
EzLang Adjusting Position
EzLang Keyboard Selection
Scheduler
Widget States and the State Tree
The Scheduler Object
Managing callbacks
Callback Structure
Callback Configs
Callback: On keyboard enter
Callback: On Left Mouse Click
Callback: On Press
Callback: On Select
Callback: On Deselect
Callback: On Right Mouse Click
Callback: On Hover
Callback: On Drag
Callback: On Scroll Up
Callback: On Scroll Down
Callback: On Value Change
Callback: Custom Key Binds
Callback: Global Key Binds
Callback: Property Binds
Tasks
Scheduled Single Exectution Tasks
Scheduled Recurring Tasks
Threaded Tasks
Custom Properties
Modals
Programmatic Widgets
Updating widgets
Managing selection
Default global (key)binds
Performance
Examples
Layout: Box Mode NestedLayout: Box Mode Size Hints
Layout: Stack Mode
Layout: Table Mode Dynamic
Layout: Table Mode Static
Layout: Float Mode Manual
Layout: Float Mode Position hints
Layout: Screen Mode
Layout: Tab Mode
Layout: Scrolling
Layout: Views
Widget: Label
Widget: Text input
Widget: Button
Widget: Checkbox
Widget: Radio Button
Widget: Dropdown
Widget: Slider
Widget: Progress Bar
Widget: Canvas
Scheduler: Schedule Once
Scheduler: Schedule Once Callback
Scheduler: Schedule Recurring
Scheduler: Schedule Recurring Callback
Scheduler: Threaded Task State Tree
Scheduler: Threaded Task Custom Property
Scheduler: Create Widgets
Scheduler: Modal Popup
Reference
WidgetsCommon Properties
Label
Text Input
Button
Checkbox
Radio button
Dropdown
Slider
Canvas
Scheduler
Schedule once
Schedule Recurring
Schedule Threaded
Cancel Task
Cancel Recurring Task
Create Widget
Remove Widget
Select Widget
Deselect Widget
Update Widget
Force Redraw
Open Modal
Dismiss Modal
Bind Global Key
Remove Global Key
Clear Global Keys
Bind Property
Create Custom Properties
Get Property
Get Property Mut
Overwrite Callback Config
Update Callback Config
Exit