1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

term.ui: native Windows console implementation (#8359)

This commit is contained in:
spaceface
2021-01-27 13:52:39 +01:00
committed by GitHub
parent 2ada7b730e
commit e233911a7b
8 changed files with 468 additions and 90 deletions

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2020 Raúl Hernández. All rights reserved.
// Copyright (c) 2020-2021 Raúl Hernández. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
module ui
@@ -108,6 +108,18 @@ pub enum KeyCode {
f10 = 299
f11 = 300
f12 = 301
f13 = 302
f14 = 303
f15 = 304
f16 = 305
f17 = 306
f18 = 307
f19 = 308
f20 = 309
f21 = 310
f22 = 311
f23 = 312
f24 = 313
}
pub const (
@@ -164,10 +176,10 @@ pub:
}
pub struct Context {
ExtraContext // contains fields specific to an implementation
pub:
cfg Config
mut:
read_buf []byte
print_buf []byte
paused bool
enable_su bool
@@ -198,3 +210,38 @@ pub struct Config {
// All kill signals to set up exit listeners on
reset []int = [1, 2, 3, 4, 6, 7, 8, 9, 11, 13, 14, 15, 19]
}
[inline]
fn (ctx &Context) init() {
if ctx.cfg.init_fn != voidptr(0) {
ctx.cfg.init_fn(ctx.cfg.user_data)
}
}
[inline]
fn (ctx &Context) frame() {
if ctx.cfg.frame_fn != voidptr(0) {
ctx.cfg.frame_fn(ctx.cfg.user_data)
}
}
[inline]
fn (ctx &Context) cleanup() {
if ctx.cfg.cleanup_fn != voidptr(0) {
ctx.cfg.cleanup_fn(ctx.cfg.user_data)
}
}
[inline]
fn (ctx &Context) fail(error string) {
if ctx.cfg.fail_fn != voidptr(0) {
ctx.cfg.fail_fn(error)
}
}
[inline]
fn (ctx &Context) event(event &Event) {
if ctx.cfg.event_fn != voidptr(0) {
ctx.cfg.event_fn(event, ctx.cfg.user_data)
}
}