mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
examples: fix compilation with -prod
This commit is contained in:
@ -3,7 +3,6 @@
|
||||
// that can be found in the LICENSE file.
|
||||
module ui
|
||||
|
||||
|
||||
struct ExtraContext {
|
||||
mut:
|
||||
read_buf []byte
|
||||
@ -15,29 +14,29 @@ const (
|
||||
|
||||
pub fn init(cfg Config) &Context {
|
||||
mut ctx := &Context{
|
||||
cfg: cfg,
|
||||
cfg: cfg
|
||||
}
|
||||
ctx.read_buf = []byte{ cap: cfg.buffer_size }
|
||||
ctx.read_buf = []byte{cap: cfg.buffer_size}
|
||||
|
||||
// lmao
|
||||
unsafe {
|
||||
x := &ctx_ptr
|
||||
x := &ui.ctx_ptr
|
||||
*x = ctx
|
||||
_ = x
|
||||
}
|
||||
|
||||
return ctx
|
||||
}
|
||||
|
||||
[inline]
|
||||
fn save_title() {
|
||||
// restore the previously saved terminal title
|
||||
print('\x1b[22;0t')
|
||||
// restore the previously saved terminal title
|
||||
print('\x1b[22;0t')
|
||||
}
|
||||
|
||||
[inline]
|
||||
fn load_title() {
|
||||
// restore the previously saved terminal title
|
||||
print('\x1b[23;0t')
|
||||
// restore the previously saved terminal title
|
||||
print('\x1b[23;0t')
|
||||
}
|
||||
|
||||
pub fn (mut ctx Context) run() ? {
|
||||
@ -45,17 +44,17 @@ pub fn (mut ctx Context) run() ? {
|
||||
ctx.fail('error: x11 backend not implemented yet')
|
||||
exit(1)
|
||||
} else {
|
||||
ctx.termios_setup()?
|
||||
ctx.termios_setup() ?
|
||||
ctx.termios_loop()
|
||||
}
|
||||
}
|
||||
|
||||
[inline]
|
||||
// shifts the array left, to remove any data that was just read, and updates its len
|
||||
// TODO: remove
|
||||
[inline]
|
||||
fn (mut ctx Context) shift(len int) {
|
||||
unsafe {
|
||||
C.memmove(ctx.read_buf.data, byteptr(ctx.read_buf.data) + len, ctx.read_buf.cap - len)
|
||||
C.memmove(ctx.read_buf.data, &byte(ctx.read_buf.data) + len, ctx.read_buf.cap - len)
|
||||
ctx.resize_arr(ctx.read_buf.len - len)
|
||||
}
|
||||
}
|
||||
@ -64,5 +63,8 @@ fn (mut ctx Context) shift(len int) {
|
||||
[inline]
|
||||
fn (mut ctx Context) resize_arr(size int) {
|
||||
mut l := &ctx.read_buf.len
|
||||
unsafe { *l = size }
|
||||
unsafe {
|
||||
*l = size
|
||||
_ = l
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user