1
0
Fork 0
forked from AbleOS/ableos

text editor work and misc changes

This commit is contained in:
koniifer 2024-11-08 01:48:17 +00:00
parent 7f01b0e0f8
commit adbf32d970
9 changed files with 108 additions and 307 deletions

147
Cargo.lock generated
View file

@ -17,21 +17,6 @@ version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
[[package]]
name = "android-tzdata"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
[[package]]
name = "android_system_properties"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.92" version = "1.0.92"
@ -110,26 +95,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
version = "0.4.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401"
dependencies = [
"android-tzdata",
"iana-time-zone",
"js-sys",
"num-traits",
"wasm-bindgen",
"windows-targets",
]
[[package]]
name = "core-foundation-sys"
version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
[[package]] [[package]]
name = "crossbeam-queue" name = "crossbeam-queue"
version = "0.3.11" version = "0.3.11"
@ -208,7 +173,6 @@ checksum = "05669f8e7e2d7badc545c513710f0eba09c2fbef683eb859fd79c46c355048e0"
dependencies = [ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"byteorder", "byteorder",
"chrono",
"log", "log",
] ]
@ -264,12 +228,12 @@ dependencies = [
[[package]] [[package]]
name = "hbbytecode" name = "hbbytecode"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#513d2c71276441d1951281eef0f27d5f94d1f738" source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#0374848b283f29547625c76e7629d5d61bac3109"
[[package]] [[package]]
name = "hblang" name = "hblang"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#513d2c71276441d1951281eef0f27d5f94d1f738" source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#0374848b283f29547625c76e7629d5d61bac3109"
dependencies = [ dependencies = [
"hashbrown 0.15.1", "hashbrown 0.15.1",
"hbbytecode", "hbbytecode",
@ -281,34 +245,11 @@ dependencies = [
[[package]] [[package]]
name = "hbvm" name = "hbvm"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#513d2c71276441d1951281eef0f27d5f94d1f738" source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#0374848b283f29547625c76e7629d5d61bac3109"
dependencies = [ dependencies = [
"hbbytecode", "hbbytecode",
] ]
[[package]]
name = "iana-time-zone"
version = "0.1.61"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220"
dependencies = [
"android_system_properties",
"core-foundation-sys",
"iana-time-zone-haiku",
"js-sys",
"wasm-bindgen",
"windows-core",
]
[[package]]
name = "iana-time-zone-haiku"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
dependencies = [
"cc",
]
[[package]] [[package]]
name = "icu_collections" name = "icu_collections"
version = "1.5.0" version = "1.5.0"
@ -458,15 +399,6 @@ dependencies = [
"hashbrown 0.15.1", "hashbrown 0.15.1",
] ]
[[package]]
name = "js-sys"
version = "0.3.72"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9"
dependencies = [
"wasm-bindgen",
]
[[package]] [[package]]
name = "kernel" name = "kernel"
version = "0.2.0" version = "0.2.0"
@ -567,15 +499,6 @@ version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
[[package]]
name = "num-traits"
version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
dependencies = [
"autocfg",
]
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.20.2" version = "1.20.2"
@ -986,61 +909,6 @@ version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasm-bindgen"
version = "0.2.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e"
dependencies = [
"cfg-if",
"once_cell",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358"
dependencies = [
"bumpalo",
"log",
"once_cell",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68"
dependencies = [
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d"
[[package]] [[package]]
name = "webpki-roots" name = "webpki-roots"
version = "0.26.6" version = "0.26.6"
@ -1050,15 +918,6 @@ dependencies = [
"rustls-pki-types", "rustls-pki-types",
] ]
[[package]]
name = "windows-core"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9"
dependencies = [
"windows-targets",
]
[[package]] [[package]]
name = "windows-sys" name = "windows-sys"
version = "0.52.0" version = "0.52.0"

View file

@ -24,10 +24,6 @@ version = "0.3"
default-features = false default-features = false
features = ["alloc", "nightly"] features = ["alloc", "nightly"]
# [dependencies.clparse]
# git = "https://git.ablecorp.us/ableos/ableos_userland"
# default-features = false
[dependencies.derive_more] [dependencies.derive_more]
version = "1" version = "1"
default-features = false default-features = false

View file

@ -6,29 +6,15 @@ edition = "2021"
[dependencies] [dependencies]
str-reader = "0.1" str-reader = "0.1"
derive_more = { version = "1", default-features = false, features = [ derive_more = { version = "1", default-features = false, features = [
"add",
"add_assign",
"constructor",
"display", "display",
"from",
"into",
"mul",
"mul_assign",
"not",
"sum",
] } ] }
error-stack = "0.5" error-stack = "0.5"
fatfs = "0.3" fatfs = { version = "0.3", default-features = false, features = [
toml = "0.8"
hblang = { git = "https://git.ablecorp.us/AbleOS/holey-bytes.git", features = [
"std", "std",
# "opts", "alloc",
], default-features = false } ] }
toml = "0.8"
hblang.git = "https://git.ablecorp.us/AbleOS/holey-bytes.git"
log = "0.4" log = "0.4"
raw-cpuid = "11" raw-cpuid = "11"
ureq = { version = "2", default-features = false, features = ["tls"] } ureq = { version = "2", default-features = false, features = ["tls"] }
# [dependencies.reqwest]
# version = "0.12"
# default-features = false
# features = ["rustls-tls", "blocking"]

File diff suppressed because one or more lines are too long

View file

@ -1,19 +1,42 @@
.{memory, log, string} := @use("../../../../libraries/stn/src/lib.hb") .{memory, log, string} := @use("../../../../libraries/stn/src/lib.hb")
render := @use("../../../../libraries/render/src/lib.hb") render := @use("../../../../libraries/render/src/lib.hb")
/* expected result: /* expected result: almost-not-trash notepad app
trash notepad app, colours should change with r,g,b,w keys */ very jank
-----------------
features:
- basic keys
- holding support with DAS
- visible cursor
- shift key support
*/
psf := @embed("../../../../consolefonts/tamsyn/10x20r.psf") psf := @embed("../../../../consolefonts/tamsyn/10x20r.psf")
send_byte := fn(byte: u8): u8 { handle_char := fn(char: u8, cursor: ^u8, buf: ^u8): ^u8 {
memory.outb(96, byte) if char == 0 {
return memory.inb(96) return cursor
}
if char != 0x8 {
*cursor = char
return cursor + 1
} else if char == 0xA {
*cursor = 32
cursor += 1;
*cursor = 92
return cursor + 1
} else if cursor > buf {
cursor -= 1;
*cursor = 32
return cursor
}
return cursor
} }
example := fn(): void { example := fn(): void {
screen := render.init(true) screen := render.init(true)
font := render.text.font_from_psf2(@bitcast(&psf), false) window := render.new_surface(480, 340)
font := render.text.font_from_psf2(@bitcast(&psf), true)
msg := "ableboard (tm) (patent pending):\n\0" msg := "ableboard (tm) (patent pending):\n\0"
msg_len := string.length(msg) msg_len := string.length(msg)
@ -25,147 +48,86 @@ example := fn(): void {
if font == null { if font == null {
return return
} };
_ = send_byte(238) *cursor = 95
log.info("PS/2 Driver Loaded\0") draw(screen, window, font, buf);
if send_byte(238) == 238 { *cursor = 0
log.info("PS/2 Keyboard Echoed\0")
}
if send_byte(244) == 250 {
log.info("Enabled scanning\0")
}
color := render.white memory.outb(96, 238)
memory.outb(96, 238)
memory.outb(96, 244)
prev_input := @as(u8, 0xFF)
current_key := @as(u8, 0)
holding_timer := @as(u32, 0)
is_shift_pressed := @as(bool, false)
initial_delay := @as(u32, 50)
repeat_delay := @as(u32, 7)
prev_input := 250
loop { loop {
input := memory.inb(96) input := memory.inb(96)
if input != prev_input { is_release := (input & 0x80) != 0
prev_input = input key_code := input & 0x7F
char := map_keys(input)
if char != 0 {
if char == 0xA {
*cursor = 32
cursor += 1;
*cursor = 92
cursor += 1
} else if char == 0x72 {
color = render.red
} else if char == 0x67 {
color = render.green
} else if char == 0x62 {
color = render.blue
} else if char == 0x77 {
color = render.white
} else if char == 0xE {
cursor -= 1;
*cursor = 32
continue if input != prev_input {
}; if is_release {
*cursor = char if key_code == current_key {
cursor += 1 current_key = 0
holding_timer = 0
} else if input == 0xAA | input == 0xB6 {
is_shift_pressed = false
}
} else {
if input == 0x2A | input == 0x36 {
is_shift_pressed = true
} else {
current_key = input
holding_timer = 1
cursor = handle_char(map_keys(current_key, is_shift_pressed), cursor, buf)
}
}
prev_input = input
}
if current_key != 0 & holding_timer > 0 {
holding_timer += 1
if holding_timer >= initial_delay {
cursor = handle_char(map_keys(current_key, is_shift_pressed), cursor, buf)
holding_timer = initial_delay - repeat_delay
}
};
*cursor = 95
draw(screen, window, font, buf);
*cursor = 0
if holding_timer > 0 & current_key != 0 {
if (memory.inb(96) & 0x80) != 0 {
current_key = 0
holding_timer = 0
} }
} }
render.clear(screen, render.black)
render.put_rect(screen, .(0, 0), .(screen.width - 1, screen.height - 1), render.white)
render.put_text(screen, font, .(0, 0), color, buf)
render.sync(screen)
} }
return return
} }
map_keys := fn(inp: u8): u8 { draw := fn(screen: render.Surface, window: render.Surface, font: render.text.Font, buf: ^u8): void {
if inp == 0x29 { render.clear(screen, render.black)
return 0x7E render.clear(window, render.black)
} else if inp == 0x2 { render.put_rect(window, .(0, 0), .(window.width - 1, window.height - 1), render.white)
return 0x31 render.put_text(window, font, .(7, 7), render.gray, buf)
} else if inp == 0x3 { render.put_surface(screen, window, .(100, 100), false)
return 0x32 render.sync(screen)
} else if inp == 0x4 { }
return 0x33
} else if inp == 0x5 { ps2_table := [u8].(0x0, 0x1B, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x2D, 0x3D, 0x8, 0x9, 0x71, 0x77, 0x65, 0x72, 0x74, 0x79, 0x75, 0x69, 0x6F, 0x70, 0x5B, 0x5D, 0xA, 0x0, 0x61, 0x73, 0x64, 0x66, 0x67, 0x68, 0x6A, 0x6B, 0x6C, 0x3B, 0x27, 0x60, 0x0, 0x5C, 0x7A, 0x78, 0x63, 0x76, 0x62, 0x6E, 0x6D, 0x2C, 0x2E, 0x2F, 0x0, 0x2A, 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1B, 0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0x28, 0x29, 0x5F, 0x2B, 0x8, 0x9, 0x51, 0x57, 0x45, 0x52, 0x54, 0x59, 0x55, 0x49, 0x4F, 0x50, 0x7B, 0x7D, 0xA, 0x0, 0x41, 0x53, 0x44, 0x46, 0x47, 0x48, 0x4A, 0x4B, 0x4C, 0x3A, 0x22, 0x7E, 0x0, 0x7C, 0x5A, 0x58, 0x43, 0x56, 0x42, 0x4E, 0x4D, 0x3C, 0x3E, 0x3F, 0x0, 0x0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
return 0x34
} else if inp == 0x6 { map_keys := fn(scancode: u8, shift: bool): u8 {
return 0x35 if shift {
} else if inp == 0x7 { return ps2_table[scancode + 0x40]
return 0x36 }
} else if inp == 0x8 { return ps2_table[scancode]
return 0x37
} else if inp == 0x9 {
return 0x38
} else if inp == 0xA {
return 0x39
} else if inp == 0xB {
return 0x30
} else if inp == 0xC {
return 0x2D
} else if inp == 0xD {
return 0x3D
} else if inp == 0xE {
return 0xE
} else if inp == 0x1C {
return 0xA
} else if inp == 0x10 {
return 0x71
} else if inp == 0x11 {
return 0x77
} else if inp == 0x12 {
return 0x65
} else if inp == 0x13 {
return 0x72
} else if inp == 0x14 {
return 0x74
} else if inp == 0x15 {
return 0x79
} else if inp == 0x16 {
return 0x75
} else if inp == 0x17 {
return 0x69
} else if inp == 0x18 {
return 0x6F
} else if inp == 0x19 {
return 0x70
} else if inp == 0x1E {
return 0x61
} else if inp == 0x1F {
return 0x73
} else if inp == 0x20 {
return 0x64
} else if inp == 0x21 {
return 0x66
} else if inp == 0x22 {
return 0x67
} else if inp == 0x23 {
return 0x68
} else if inp == 0x24 {
return 0x6A
} else if inp == 0x25 {
return 0x6B
} else if inp == 0x26 {
return 0x6C
} else if inp == 0x2C {
return 0x7A
} else if inp == 0x2D {
return 0x78
} else if inp == 0x2E {
return 0x63
} else if inp == 0x2F {
return 0x76
} else if inp == 0x30 {
return 0x62
} else if inp == 0x31 {
return 0x6E
} else if inp == 0x32 {
return 0x6D
} else if inp == 0x2B {
return 0x5C
} else if inp == 0x39 {
return 32
} else {
return 0
}
} }

View file

@ -1 +1 @@
.{example: main} := @use("./examples/image.hb") .{example: main} := @use("./examples/text.hb")

View file

@ -28,8 +28,8 @@ resolution = "1024x768x24"
# [boot.limine.ableos.modules.diskio_driver] # [boot.limine.ableos.modules.diskio_driver]
# path = "boot:///diskio_driver.hbf" # path = "boot:///diskio_driver.hbf"
# [boot.limine.ableos.modules.render_example] [boot.limine.ableos.modules.render_example]
# path = "boot:///render_example.hbf" path = "boot:///render_example.hbf"
# [boot.limine.ableos.modules.serial_driver] # [boot.limine.ableos.modules.serial_driver]
# path = "boot:///serial_driver.hbf" # path = "boot:///serial_driver.hbf"