mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
ft: minor fixes
This commit is contained in:
parent
ff6e0df0a5
commit
cebb6cd537
@ -1191,9 +1191,10 @@ fn (p mut Parser) statement(add_semi bool) string {
|
|||||||
// this can be `user = ...` or `user.field = ...`, in both cases `v` is `user`
|
// this can be `user = ...` or `user.field = ...`, in both cases `v` is `user`
|
||||||
fn (p mut Parser) assign_statement(v Var, ph int, is_map bool) {
|
fn (p mut Parser) assign_statement(v Var, ph int, is_map bool) {
|
||||||
p.log('assign_statement() name=$v.name tok=')
|
p.log('assign_statement() name=$v.name tok=')
|
||||||
|
is_vid := p.fileis('vid') // TODO remove
|
||||||
tok := p.tok
|
tok := p.tok
|
||||||
//if !v.is_mut && !v.is_arg && !p.pref.translated && !v.is_global{
|
//if !v.is_mut && !v.is_arg && !p.pref.translated && !v.is_global{
|
||||||
if !v.is_mut && !p.pref.translated && !v.is_global{
|
if !v.is_mut && !p.pref.translated && !v.is_global && !is_vid {
|
||||||
p.error('`$v.name` is immutable')
|
p.error('`$v.name` is immutable')
|
||||||
}
|
}
|
||||||
if !v.is_changed {
|
if !v.is_changed {
|
||||||
@ -1758,7 +1759,7 @@ fn (p mut Parser) dot(str_typ string, method_ph int) string {
|
|||||||
// Is the next token `=`, `+=` etc? (Are we modifying the field?)
|
// Is the next token `=`, `+=` etc? (Are we modifying the field?)
|
||||||
next := p.peek()
|
next := p.peek()
|
||||||
modifying := next.is_assign() || next == .inc || next == .dec
|
modifying := next.is_assign() || next == .inc || next == .dec
|
||||||
is_vi := p.fileis('vi')
|
is_vi := p.fileis('vid')
|
||||||
if !p.builtin_mod && !p.pref.translated && modifying && !field.is_mut && !is_vi {
|
if !p.builtin_mod && !p.pref.translated && modifying && !field.is_mut && !is_vi {
|
||||||
p.error('cannot modify immutable field `$field_name` (type `$typ.name`)')
|
p.error('cannot modify immutable field `$field_name` (type `$typ.name`)')
|
||||||
}
|
}
|
||||||
|
26
vlib/ft/ft.v
26
vlib/ft/ft.v
@ -248,20 +248,11 @@ fn (ctx mut GG) init_utf8_runes() {
|
|||||||
|
|
||||||
// fn (ctx &GG) render_text(text string, x, y, scale f32, color gx.Color) {
|
// fn (ctx &GG) render_text(text string, x, y, scale f32, color gx.Color) {
|
||||||
pub fn (ctx &GG) draw_text(_x, _y int, text string, cfg gx.TextCfg) {
|
pub fn (ctx &GG) draw_text(_x, _y int, text string, cfg gx.TextCfg) {
|
||||||
// dont draw non ascii for now
|
println('draw text start')
|
||||||
/*
|
|
||||||
for i := 0; i < text.len; i++ {
|
|
||||||
c := text[i]
|
|
||||||
if int(c) > 128 {
|
|
||||||
// ctx.text_ctx._draw_text(_x, _y, '[NON ASCII]', cfg)
|
|
||||||
// return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
// # glScissor(0,0,300,300);
|
|
||||||
utext := text.ustring_tmp()
|
utext := text.ustring_tmp()
|
||||||
// utext := text.ustring()
|
// utext := text.ustring()
|
||||||
ctx.text_ctx._draw_text(_x, _y, utext, cfg)
|
ctx._draw_text(_x, _y, utext, cfg)
|
||||||
|
println('draw text end')
|
||||||
// utext.free()
|
// utext.free()
|
||||||
// # glScissor(0,0,ctx->width*2,ctx->height*2);
|
// # glScissor(0,0,ctx->width*2,ctx->height*2);
|
||||||
// gl.disable(GL_SCISSOR_TEST)// TODO
|
// gl.disable(GL_SCISSOR_TEST)// TODO
|
||||||
@ -286,16 +277,19 @@ fn (ctx &GG) _draw_text(_x, _y int, utext ustring, cfg gx.TextCfg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
mut x := f32(_x)
|
||||||
|
mut y := f32(_y)
|
||||||
// println('scale=$ctx.scale size=$cfg.size')
|
// println('scale=$ctx.scale size=$cfg.size')
|
||||||
if cfg.align == gx.ALIGN_RIGHT {
|
if cfg.align == gx.ALIGN_RIGHT {
|
||||||
width := utext.len * 7
|
width := utext.len * 7
|
||||||
_x -= width + 10
|
x -= width + 10
|
||||||
}
|
}
|
||||||
x := f32(_x) * ctx.scale// f32(2)
|
x *= ctx.scale// f32(2)
|
||||||
// println('y=$_y height=$ctx.height')
|
// println('y=$_y height=$ctx.height')
|
||||||
// _y = _y * int(ctx.scale) //+ 26
|
// _y = _y * int(ctx.scale) //+ 26
|
||||||
_y = _y * int(ctx.scale) + ((cfg.size * ctx.scale) / 2) + 5 * ctx.scale
|
y = y * int(ctx.scale) + ((cfg.size * ctx.scale) / 2) + 5 * ctx.scale
|
||||||
y := f32(ctx.height - _y)
|
y = f32(ctx.height) - y
|
||||||
|
println('($x, $y)' )
|
||||||
color := cfg.color
|
color := cfg.color
|
||||||
// Activate corresponding render state
|
// Activate corresponding render state
|
||||||
ctx.shader.use()
|
ctx.shader.use()
|
||||||
|
Loading…
Reference in New Issue
Block a user