Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • redox-os/orbutils
  • stratact/orbutils
  • jD91mZM2/orbutils
  • lupine/orbutils
  • xTibor/orbutils
  • Capucho/orbutils
  • hughlang/orbutils
  • JCake/orbutils
  • RoboticDinosaur/orbutils
  • Dominic12/orbutils
  • 4lDO2/orbutils
  • andrewdavidmackenzie/orbutils
  • freewilll/orbutils
  • carrot93/orbutils
  • bjorn3/orbutils
  • kivimango/orbutils
  • rw_van/orbutils
  • CastilloDel/orbutils
  • andrey.turkin/orbutils
19 results
Show changes
Commits on Source (110)
Showing with 6218 additions and 787 deletions
/target/
.idea
_imports/
.DS_Store
build:linux:
image: "redoxos/redoxer"
before_script:
- apt-get update
- apt-get install cmake libsdl2-dev libfreetype6-dev libexpat1-dev -y
script:
- cargo +nightly build --bin calendar
- cargo +nightly build --bin character_map
- cargo +nightly build --bin editor
- cargo +nightly build --bin file_manager
- cargo +nightly build --bin viewer
test:linux:
image: "redoxos/redoxer"
before_script:
- apt-get update
- apt-get install cmake libsdl2-dev libfreetype6-dev libexpat1-dev -y
script:
- cargo +nightly test --bin calendar
- cargo +nightly test --bin character_map
- cargo +nightly test --bin editor
- cargo +nightly test --bin file_manager
- cargo +nightly test --bin viewer
language: rust
rust:
- nightly
sudo: required
install:
- sudo add-apt-repository -y ppa:zoogie/sdl2-snapshots
- sudo apt-get update -qq
- sudo apt-get install -qq libsdl2-dev
notifications:
email: false
This diff is collapsed.
[package]
name = "orbutils"
description = "The Orbital Utilities"
repository = "https://github.com/redox-os/orbutils"
version = "0.1.16"
license-file = "LICENSE"
readme = "README.md"
authors = ["Jeremy Soller <jackpot51@gmail.com>"]
[[bin]]
name = "background"
path = "src/background/main.rs"
[[bin]]
name = "browser"
path = "src/browser/main.rs"
[[bin]]
name = "calculator"
path = "src/calculator/main.rs"
[[bin]]
name = "character_map"
path = "src/character_map/main.rs"
[[bin]]
name = "editor"
path = "src/editor/main.rs"
[[bin]]
name = "file_manager"
path = "src/file_manager/main.rs"
[[bin]]
name = "launcher"
path = "src/launcher/main.rs"
[[bin]]
name = "orblogin"
path = "src/orblogin/main.rs"
[[bin]]
name = "viewer"
path = "src/viewer/main.rs"
[[bin]]
name = "calendar"
path = "src/calendar/main.rs"
[dependencies]
calculate = "0.1.*"
chrono = "0.4"
html5ever = "0.15"
hyper-rustls = "0.6"
mime_guess = "1.8"
mime = "0.2"
orbclient = "0.3"
orbfont = "0.1"
orbimage = "0.1"
orbtk = { git = "https://github.com/redox-os/orbtk.git" }
tendril = "0.4"
url = "1.5"
redox_users = { git = "https://github.com/redox-os/users.git" }
[dependencies.hyper]
version = "0.10"
default-features = false
[target.'cfg(not(target_os = "redox"))'.dependencies]
libc = "0.2"
[target.'cfg(target_os = "redox")'.dependencies]
redox_event = { git = "https://github.com/redox-os/event.git" }
redox_syscall = "0.1"
[workspace]
members = [
"orbutils",
"calculator",
"launcher",
]
resolver = "2"
[patch.crates-io]
softbuffer = { git = "https://gitlab.redox-os.org/redox-os/softbuffer", branch = "redox-0.2" }
winit = { git = "https://gitlab.redox-os.org/redox-os/winit", branch = "redox-0.28.6" }
The MIT License (MIT)
Copyright (c) 2015 Jeremy Soller
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
This diff is collapsed.
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
# orbutils
The Orbital Utilities. Compatible with Redox and SDL2 platforms.
# OrbUtils
[![Travis Build Status](https://travis-ci.org/redox-os/orbutils.svg?branch=master)](https://travis-ci.org/redox-os/orbutils)
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
The Orbital Utilities a setup of desktop applications. Compatible with Redox and SDL2 platforms.
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE-MIT)
[![crates.io](http://meritbadge.herokuapp.com/orbutils)](https://crates.io/crates/orbutils)
## Cross Platform Support
Some of the applications in this crate can be developed and ran across multiple operating systems
(namely redox-os, linux and macos) thanks to the display being rendered via the `orbclient` crate which in turn uses
`sdl2`
There are three applications that are more fundamental to redox-os, that interact with orbital more directly and are
(currently) deemed to not make sense on other platforms that are running other windowing systems or display managers.
These are namely:
- launcher
- orblogin
- background
## Quick setup
To run on Linux/OSX you will need SDL2
......@@ -30,3 +42,30 @@ Clone and run
git clone https://github.com/redox-os/orbutils.git
cargo run --bin calculator
```
## How to run Slint ports
For the `Slint` ports `SDL2` is not necessary. On `Redox` the port will run with
[slint_orbclient](https://gitlab.redox-os.org/redox-os/slint_orbclient) backend and on other platforms Slint will
choose a suitable e.g. `winit` or `qt`.
To can use the `slint_orbclient` also on other platform you can run for example
`cargo run --bin calculator --no-default-features --features=orbclient`
## Current project status
After the sunset of [OrbTk](https://gitlab.redox-os.org/redox-os/orbtk) the `OrbUtils` will be
ported [Slint](https://slint-ui.com).
With this also a new CI pipeline for GitLab will be used.
### Slint ports done
* calculator
## License
The source code of the OrbUtils is available under the terms the MIT license (See [LICENSE-MIT](LICENSE-MIT) for details.)
However, because of the use of GPL dependencies, the OrbUtils, as a whole, is licensed
under the terms of the GPLv3 (See [LICENSE-GPL](LICENSE-GPL))
name=Calculator
binary=/usr/bin/calculator
icon=/ui/icons/apps/accessories-calculator.png
author=Jeremy Soller
description=Calculator for Redox
name=Calendar
binary=/usr/bin/calendar
icon=/ui/icons/apps/calendar.png
author=Bojan Kogoj
description=Calendar for Redox
name=Viewer
binary=/usr/bin/viewer
icon=/ui/icons/apps/multimedia-photo-viewer.png
accept=*.bmp
accept=*.jpg
accept=*.jpeg
accept=*.png
author=Jeremy Soller
description=Image Viewer for Redox
name=File Manager
binary=/usr/bin/file_manager
icon=/ui/icons/apps/system-file-manager.png
accept=*/
author=Jeremy Soller
description=File Manager for Redox
name=Editor
binary=/usr/bin/editor
icon=/ui/icons/apps/accessories-text-editor.png
accept=*.asm
accept=*.conf
accept=*.html
accept=*.ion
accept=*.list
accept=*.lua
accept=*.md
accept=*.rc
accept=*.rs
accept=*.sh
accept=*.toml
accept=*.txt
author=Jeremy Soller
description=Editor for Redox
name=Character Map
binary=/usr/bin/character_map
icon=/ui/icons/apps/accessories-character-map.png
accept=*.ttf
author=Jeremy Soller
description=Character Map for Redox
[env]
RUST_FONTCONFIG_DLOPEN = "on"
[package]
name = "calculator"
version = "0.2.0"
license-file = "../LICENSE-MIT"
authors = ["Redox OS Developers <info@redox-os.org>"]
edition = "2021"
build = "build.rs"
[[bin]]
name = "calculator"
path = "src/main.rs"
[dependencies]
calculate = { git = "https://gitlab.redox-os.org/redox-os/calc.git" }
slint = { git = "https://github.com/slint-ui/slint", default-features = false, features = ["compat-1-0", "renderer-winit-software"], rev = "a01726537688fac2522156ced5f4cb836e96ac03" }
[build-dependencies]
slint-build = { git = "https://github.com/slint-ui/slint", rev = "a01726537688fac2522156ced5f4cb836e96ac03" }
coop_widgets = { git = "https://codeberg.org/flovansl/co_sl", rev = "e5f2f10644f9c7a06df6d82246d7ceebbdfaecf1" }
[features]
default = []
slint-default = ["slint/default"]
#[cfg(not(feature = "slint-default"))]
fn main() {
coop_widgets::generate_import().unwrap();
let config = slint_build::CompilerConfiguration::new()
.embed_resources(slint_build::EmbedResourcesKind::EmbedForSoftwareRenderer);
slint_build::compile_with_config("ui/app.slint", config).unwrap();
slint_build::print_rustc_flags().unwrap();
}
#[cfg(feature = "slint-default")]
fn main() {
coop_widgets::generate_import().unwrap();
slint_build::compile("ui/app.slint").unwrap();
}
\ No newline at end of file
#[allow(clippy::all)]
mod generated_code {
slint::include_modules!();
}
pub use generated_code::*;
use slint::SharedString;
fn eval(input: &str) -> String {
match calc::eval(input) {
Ok(s) => s.to_string(),
Err(e) => e.into(),
}
}
pub fn main() {
let app = App::new().unwrap();
app.global::<Theme>().set_embedded_helper(true);
app.on_backspace(backspace);
app.on_calculate(calculate);
app.on_validate(validate);
app.run().unwrap();
}
fn backspace(input: SharedString) -> SharedString {
let mut input = input.to_string();
input.pop();
input.into()
}
fn calculate(input: SharedString) -> SharedString {
eval(input.as_str()).into()
}
fn validate(input: SharedString) -> SharedString {
let valid = match input.as_str() {
"(" | ")" | "^" | "/" | "*" | "-" | "+" | "." | " " => true,
"0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" => true,
_ => false,
};
if valid {
return input;
}
SharedString::default()
}
#[cfg(test)]
mod tests {
use slint::platform::Key;
use super::*;
#[test]
fn test_backspace() {
assert_eq!(
backspace(SharedString::from("5+3")),
SharedString::from("5+")
);
assert_eq!(backspace(SharedString::from("5+")), SharedString::from("5"));
assert_eq!(backspace(SharedString::from("5")), SharedString::from(""));
assert_eq!(backspace(SharedString::from("")), SharedString::from(""));
}
#[test]
fn test_calculate() {
assert_eq!(
calculate(SharedString::from("6/2")),
SharedString::from("3")
);
assert_eq!(
calculate(SharedString::from("5+3")),
SharedString::from("8")
);
assert_eq!(
calculate(SharedString::from("5 + 3")),
SharedString::from("8")
);
assert_eq!(
calculate(SharedString::from("(5 + 3)")),
SharedString::from("8")
);
assert_eq!(
calculate(SharedString::from("5*3")),
SharedString::from("15")
);
assert_eq!(
calculate(SharedString::from("5 * 3")),
SharedString::from("15")
);
assert_eq!(
calculate(SharedString::from("(5 * 3)")),
SharedString::from("15")
);
assert_eq!(
calculate(SharedString::from("5/2")),
SharedString::from("2.5")
);
assert_eq!(
calculate(SharedString::from("5 / 2")),
SharedString::from("2.5")
);
assert_eq!(
calculate(SharedString::from("(5 / 2)")),
SharedString::from("2.5")
);
assert_eq!(
calculate(SharedString::from("2*5+3")),
SharedString::from("13")
);
assert_eq!(
calculate(SharedString::from("2 * 5 + 3")),
SharedString::from("13")
);
assert_eq!(
calculate(SharedString::from("(2 * 5) + 3")),
SharedString::from("13")
);
}
#[test]
fn test_validate() {
assert_eq!(validate(SharedString::from("(")), SharedString::from("("));
assert_eq!(validate(SharedString::from(")")), SharedString::from(")"));
assert_eq!(validate(SharedString::from("^")), SharedString::from("^"));
assert_eq!(validate(SharedString::from("/")), SharedString::from("/"));
assert_eq!(validate(SharedString::from("*")), SharedString::from("*"));
assert_eq!(validate(SharedString::from("-")), SharedString::from("-"));
assert_eq!(validate(SharedString::from("+")), SharedString::from("+"));
assert_eq!(validate(SharedString::from(".")), SharedString::from("."));
assert_eq!(validate(SharedString::from(" ")), SharedString::from(" "));
assert_eq!(validate(SharedString::from("0")), SharedString::from("0"));
assert_eq!(validate(SharedString::from("1")), SharedString::from("1"));
assert_eq!(validate(SharedString::from("2")), SharedString::from("2"));
assert_eq!(validate(SharedString::from("3")), SharedString::from("3"));
assert_eq!(validate(SharedString::from("4")), SharedString::from("4"));
assert_eq!(validate(SharedString::from("5")), SharedString::from("5"));
assert_eq!(validate(SharedString::from("6")), SharedString::from("6"));
assert_eq!(validate(SharedString::from("7")), SharedString::from("7"));
assert_eq!(validate(SharedString::from("8")), SharedString::from("8"));
assert_eq!(validate(SharedString::from("9")), SharedString::from("9"));
assert_eq!(validate(SharedString::from("=")), SharedString::from(""));
assert_eq!(
validate(SharedString::from(Key::Shift)),
SharedString::from("")
);
assert_eq!(
validate(SharedString::from(Key::Menu)),
SharedString::from("")
);
assert_eq!(
validate(SharedString::from(Key::Control)),
SharedString::from("")
);
}
}
import { CoopWindow, RoundButton, MediumTitle, Button, Theme } from "_imports/coop_widgets.slint";
export { Theme }
export component App inherits CoopWindow {
private property <bool> display_result;
private property <string> text <=> i_text.text;
callback calculate(string) -> string;
callback backspace(string) -> string;
callback validate(string) -> string;
title: "Calculator";
width: 200px;
height: 222px;
accent_color: #5294E2;
on_accent_color: white;
forward-focus: i_focus_scope;
VerticalLayout {
padding_top: Theme.spaces.medium;
padding_left: Theme.spaces.small;
padding_right: Theme.spaces.small;
padding_bottom: Theme.spaces.small;
spacing: Theme.spaces.medium;
Rectangle {
vertical-stretch: 0;
clip: true;
i_text := MediumTitle {
width: 100%;
height: 100%;
vertical_alignment: center;
horizontal-alignment: right;
}
}
GridLayout {
spacing: Theme.spaces.extra-small;
Row {
Button {
text: "(";
clicked => { root.input(self.text); }
}
Button {
text: ")";
clicked => { root.input(self.text); }
}
Button {
text: "^";
clicked => { root.input(self.text); }
}
Button {
primary: true;
text: "/";
clicked => { root.input(self.text); }
}
}
Row {
Button {
text: "7";
clicked => { root.input(self.text); }
}
Button {
text: "8";
clicked => { root.input(self.text); }
}
Button {
text: "9";
clicked => { root.input(self.text); }
}
Button {
primary: true;
text: "*";
clicked => { root.input(self.text); }
}
}
Row {
Button {
text: "4";
clicked => { root.input(self.text); }
}
Button {
text: "5";
clicked => { root.input(self.text); }
}
Button {
text: "6";
clicked => { root.input(self.text); }
}
Button {
primary: true;
text: "-";
clicked => { root.input(self.text); }
}
}
Row {
Button {
text: "1";
clicked => { root.input(self.text); }
}
Button {
text: "2";
clicked => { root.input(self.text); }
}
Button {
text: "3";
clicked => { root.input(self.text); }
}
Button {
primary: true;
text: "+";
clicked => { root.input(self.text); }
}
}
Row {
Button {
text: "0";
clicked => { root.input(self.text); }
}
Button {
text: ".";
clicked => { root.input(self.text); }
}
Button {
text: "C";
clicked => { root.clear(); }
}
i_result_button := Button {
primary: true;
text: "=";
clicked => {
root.text = root.calculate(root.text);
display_result = true;
}
}
}
}
}
i_focus_scope := FocusScope {
width: 0px;
key_pressed(e) => {
if(e.text == Key.Backspace) {
root.text = root.backspace(root.text);
return accept;
}
if(e.text == Key.Return || e.text == "=") {
i_result_button.clicked();
return accept;
}
if(e.text == "C") {
root.clear();
return accept;
}
root.input(e.text);
accept
}
}
function input(text: string) {
if(display_result) {
root.text = "";
root.display_result = false;
}
root.text += validate(text);
}
function clear() {
root.display_result = false;
root.text = "";
}
}
\ No newline at end of file