mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
vlib: fix typos and formatting (#19649)
This commit is contained in:
parent
fc2e75503f
commit
f98bb863ab
23 changed files with 152 additions and 154 deletions
|
@ -1095,7 +1095,7 @@ fn test_hex() {
|
||||||
assert st1.hex() == '41'.repeat(100)
|
assert st1.hex() == '41'.repeat(100)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_left_shift_precendence() {
|
fn test_left_shift_precedence() {
|
||||||
mut arr := []int{}
|
mut arr := []int{}
|
||||||
arr << 1 + 1
|
arr << 1 + 1
|
||||||
arr << 1 - 1
|
arr << 1 - 1
|
||||||
|
|
|
@ -11,7 +11,7 @@ pub mut:
|
||||||
f_reserved [2]u64
|
f_reserved [2]u64
|
||||||
f_index u32
|
f_index u32
|
||||||
f_size u32
|
f_size u32
|
||||||
f_mod_base u64 // Base Address of module comtaining this symbol
|
f_mod_base u64 // Base Address of module containing this symbol
|
||||||
f_flags u32
|
f_flags u32
|
||||||
f_value u64 // Value of symbol, ValuePresent should be 1
|
f_value u64 // Value of symbol, ValuePresent should be 1
|
||||||
f_address u64 // Address of symbol including base address of module
|
f_address u64 // Address of symbol including base address of module
|
||||||
|
|
|
@ -14,7 +14,7 @@ struct array_buffer {
|
||||||
|
|
||||||
fn (mut a array_buffer) make_copy() {
|
fn (mut a array_buffer) make_copy() {
|
||||||
if a.index_start != 0 || a.has_slice {
|
if a.index_start != 0 || a.has_slice {
|
||||||
mut new_arr := JS.makeEmtpyJSArray()
|
mut new_arr := JS.makeEmptyJSArray()
|
||||||
for i in 0 .. a.len {
|
for i in 0 .. a.len {
|
||||||
#new_arr.push(a.val.get(i))
|
#new_arr.push(a.val.get(i))
|
||||||
|
|
||||||
|
@ -148,10 +148,10 @@ pub fn (a array) repeat(count int) array {
|
||||||
}
|
}
|
||||||
|
|
||||||
#function makeEmptyArray() { return new array(new array_buffer({ arr: [], len: new int(0), index_start: new int(0), cap: new int(0) })); }
|
#function makeEmptyArray() { return new array(new array_buffer({ arr: [], len: new int(0), index_start: new int(0), cap: new int(0) })); }
|
||||||
#function makeEmtpyJSArray() { return new Array(); }
|
#function makeEmptyJSArray() { return new Array(); }
|
||||||
|
|
||||||
fn JS.makeEmptyArray() array
|
fn JS.makeEmptyArray() array
|
||||||
fn JS.makeEmtpyJSArray() JS.Array
|
fn JS.makeEmptyJSArray() JS.Array
|
||||||
fn empty_array() array {
|
fn empty_array() array {
|
||||||
return JS.makeEmptyArray()
|
return JS.makeEmptyArray()
|
||||||
}
|
}
|
||||||
|
@ -222,13 +222,13 @@ fn v_filter(arr array, callback fn (voidptr) bool) array {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn v_map(arr array, callback fn (voidptr) voidptr) array {
|
fn v_map(arr array, callback fn (voidptr) voidptr) array {
|
||||||
mut maped := empty_array()
|
mut mapped := empty_array()
|
||||||
|
|
||||||
for i := 0; i < arr.arr.len; i++ {
|
for i := 0; i < arr.arr.len; i++ {
|
||||||
maped.push(callback(arr.arr.get(i)))
|
mapped.push(callback(arr.arr.get(i)))
|
||||||
}
|
}
|
||||||
|
|
||||||
return maped
|
return mapped
|
||||||
}
|
}
|
||||||
|
|
||||||
struct array_iterator {
|
struct array_iterator {
|
||||||
|
|
|
@ -1052,7 +1052,7 @@ fn test_hex() {
|
||||||
assert st1.hex() == '41'.repeat(100)
|
assert st1.hex() == '41'.repeat(100)
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
fn test_left_shift_precendence() {
|
fn test_left_shift_precedence() {
|
||||||
mut arr := []int{}
|
mut arr := []int{}
|
||||||
arr << 1 + 1
|
arr << 1 + 1
|
||||||
arr << 1 - 1
|
arr << 1 - 1
|
||||||
|
|
|
@ -32,7 +32,7 @@ fn test_str_methods() {
|
||||||
// assert u64(-1).str() == '18446744073709551615'
|
// assert u64(-1).str() == '18446744073709551615'
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_and_precendence() {
|
fn test_and_precedence() {
|
||||||
assert (2 & 0 == 0) == ((2 & 0) == 0)
|
assert (2 & 0 == 0) == ((2 & 0) == 0)
|
||||||
assert (2 & 0 != 0) == ((2 & 0) != 0)
|
assert (2 & 0 != 0) == ((2 & 0) != 0)
|
||||||
assert (0 & 0 >= 0) == ((0 & 0) >= 0)
|
assert (0 & 0 >= 0) == ((0 & 0) >= 0)
|
||||||
|
@ -41,7 +41,7 @@ fn test_and_precendence() {
|
||||||
assert (1 & 2 > 0) == ((1 & 2) > 0)
|
assert (1 & 2 > 0) == ((1 & 2) > 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_or_precendence() {
|
fn test_or_precedence() {
|
||||||
assert (1 | 0 == 0) == ((1 | 0) == 0)
|
assert (1 | 0 == 0) == ((1 | 0) == 0)
|
||||||
assert (1 | 0 != 1) == ((1 | 0) != 1)
|
assert (1 | 0 != 1) == ((1 | 0) != 1)
|
||||||
assert (1 | 0 >= 2) == ((1 | 0) >= 2)
|
assert (1 | 0 >= 2) == ((1 | 0) >= 2)
|
||||||
|
@ -50,7 +50,7 @@ fn test_or_precendence() {
|
||||||
assert (1 | 0 > 1) == ((1 | 0) > 1)
|
assert (1 | 0 > 1) == ((1 | 0) > 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_xor_precendence() {
|
fn test_xor_precedence() {
|
||||||
assert (1 ^ 0 == 2) == ((1 ^ 0) == 2)
|
assert (1 ^ 0 == 2) == ((1 ^ 0) == 2)
|
||||||
assert (1 ^ 0 != 2) == ((1 ^ 0) != 2)
|
assert (1 ^ 0 != 2) == ((1 ^ 0) != 2)
|
||||||
assert (1 ^ 0 >= 0) == ((1 ^ 0) >= 0)
|
assert (1 ^ 0 >= 0) == ((1 ^ 0) >= 0)
|
||||||
|
@ -59,12 +59,12 @@ fn test_xor_precendence() {
|
||||||
assert (1 ^ 0 > 1) == ((1 ^ 0) > 1)
|
assert (1 ^ 0 > 1) == ((1 ^ 0) > 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_left_shift_precendence() {
|
fn test_left_shift_precedence() {
|
||||||
assert (2 << 4 | 3) == ((2 << 4) | 3)
|
assert (2 << 4 | 3) == ((2 << 4) | 3)
|
||||||
assert (2 << 4 | 3) != (2 << (4 | 3))
|
assert (2 << 4 | 3) != (2 << (4 | 3))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_right_shift_precendence() {
|
fn test_right_shift_precedence() {
|
||||||
assert (256 >> 4 | 3) == ((256 >> 4) | 3)
|
assert (256 >> 4 | 3) == ((256 >> 4) | 3)
|
||||||
assert (256 >> 4 | 3) != (256 >> (4 | 3))
|
assert (256 >> 4 | 3) != (256 >> (4 | 3))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module builtin
|
module builtin
|
||||||
|
|
||||||
pub interface JS.Promise {
|
pub interface JS.Promise {
|
||||||
then(onFullfilled JS.Any, onRejected JS.Any)
|
then(onFullfiled JS.Any, onRejected JS.Any)
|
||||||
catch(onCatch JS.Any) JS.Promise
|
catch(onCatch JS.Any) JS.Promise
|
||||||
finally(callback JS.Any) JS.Promise
|
finally(callback JS.Any) JS.Promise
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,8 @@ pub fn promise_new[T](executor fn (resolve fn (T), reject fn (JS.Any))) Promise[
|
||||||
return Promise[T]{promise}
|
return Promise[T]{promise}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (p Promise[T]) then(on_fullfilled fn (T), on_rejected fn (JS.Any)) {
|
pub fn (p Promise[T]) then(on_fulfilled fn (T), on_rejected fn (JS.Any)) {
|
||||||
p.promise.then(on_fullfilled, on_rejected)
|
p.promise.then(on_fulfilled, on_rejected)
|
||||||
}
|
}
|
||||||
|
|
||||||
// catch method returns a Promise and deals with rejected cases only.
|
// catch method returns a Promise and deals with rejected cases only.
|
||||||
|
|
|
@ -669,7 +669,7 @@ https://blog.rchapman.org/posts/Linux_System_Call_Table_for_x86_64/
|
||||||
239 sys_get_mempolicy int *policy unsigned long *nmask unsigned long maxnode unsigned long addr unsigned long flags
|
239 sys_get_mempolicy int *policy unsigned long *nmask unsigned long maxnode unsigned long addr unsigned long flags
|
||||||
240 sys_mq_open const char *u_name int oflag mode_t mode struct mq_attr *u_attr
|
240 sys_mq_open const char *u_name int oflag mode_t mode struct mq_attr *u_attr
|
||||||
241 sys_mq_unlink const char *u_name
|
241 sys_mq_unlink const char *u_name
|
||||||
242 sys_mq_timedsend mqd_t mqdes const char *u_msg_ptr size_t msg_len unsigned int msg_prio const stuct timespec *u_abs_timeout
|
242 sys_mq_timedsend mqd_t mqdes const char *u_msg_ptr size_t msg_len unsigned int msg_prio const struct timespec *u_abs_timeout
|
||||||
243 sys_mq_timedreceive mqd_t mqdes char *u_msg_ptr size_t msg_len unsigned int *u_msg_prio const struct timespec *u_abs_timeout
|
243 sys_mq_timedreceive mqd_t mqdes char *u_msg_ptr size_t msg_len unsigned int *u_msg_prio const struct timespec *u_abs_timeout
|
||||||
244 sys_mq_notify mqd_t mqdes const struct sigevent *u_notification
|
244 sys_mq_notify mqd_t mqdes const struct sigevent *u_notification
|
||||||
245 sys_mq_getsetattr mqd_t mqdes const struct mq_attr *u_mqstat struct mq_attr *u_omqstat
|
245 sys_mq_getsetattr mqd_t mqdes const struct mq_attr *u_mqstat struct mq_attr *u_omqstat
|
||||||
|
|
|
@ -101,7 +101,7 @@ fn abs64(x i64) u64 {
|
||||||
//_9876543210987654321098765432109876543210
|
//_9876543210987654321098765432109876543210
|
||||||
//_nPPPPPPPPBBBBWWWWWWWWWWTDDDDDDDSUAA=====
|
//_nPPPPPPPPBBBBWWWWWWWWWWTDDDDDDDSUAA=====
|
||||||
// = data type 5 bit max 32 data type
|
// = data type 5 bit max 32 data type
|
||||||
// A allign 2 bit Note: for now only 1 used!
|
// A align 2 bit Note: for now only 1 used!
|
||||||
// U uppercase 1 bit 0 do nothing, 1 do to_upper()
|
// U uppercase 1 bit 0 do nothing, 1 do to_upper()
|
||||||
// S sign 1 bit show the sign if positive
|
// S sign 1 bit show the sign if positive
|
||||||
// D decimals 7 bit number of decimals digit to show
|
// D decimals 7 bit number of decimals digit to show
|
||||||
|
@ -116,7 +116,7 @@ fn abs64(x i64) u64 {
|
||||||
// convert from data format to compact u64
|
// convert from data format to compact u64
|
||||||
pub fn get_str_intp_u64_format(fmt_type StrIntpType, in_width int, in_precision int, in_tail_zeros bool, in_sign bool, in_pad_ch u8, in_base int, in_upper_case bool) u64 {
|
pub fn get_str_intp_u64_format(fmt_type StrIntpType, in_width int, in_precision int, in_tail_zeros bool, in_sign bool, in_pad_ch u8, in_base int, in_upper_case bool) u64 {
|
||||||
width := if in_width != 0 { abs64(in_width) } else { u64(0) }
|
width := if in_width != 0 { abs64(in_width) } else { u64(0) }
|
||||||
allign := if in_width > 0 { u64(1 << 5) } else { u64(0) } // two bit 0 .left 1 .rigth, for now we use only one
|
align := if in_width > 0 { u64(1 << 5) } else { u64(0) } // two bit 0 .left 1 .right, for now we use only one
|
||||||
upper_case := if in_upper_case { u64(1 << 7) } else { u64(0) }
|
upper_case := if in_upper_case { u64(1 << 7) } else { u64(0) }
|
||||||
sign := if in_sign { u64(1 << 8) } else { u64(0) }
|
sign := if in_sign { u64(1 << 8) } else { u64(0) }
|
||||||
precision := if in_precision != 987698 {
|
precision := if in_precision != 987698 {
|
||||||
|
@ -126,14 +126,14 @@ pub fn get_str_intp_u64_format(fmt_type StrIntpType, in_width int, in_precision
|
||||||
}
|
}
|
||||||
tail_zeros := if in_tail_zeros { u32(1) << 16 } else { u32(0) }
|
tail_zeros := if in_tail_zeros { u32(1) << 16 } else { u32(0) }
|
||||||
base := u64(u32(in_base & 0xf) << 27)
|
base := u64(u32(in_base & 0xf) << 27)
|
||||||
res := u64((u64(fmt_type) & 0x1F) | allign | upper_case | sign | precision | tail_zeros | (u64(width & 0x3FF) << 17) | base | (u64(in_pad_ch) << 31))
|
res := u64((u64(fmt_type) & 0x1F) | align | upper_case | sign | precision | tail_zeros | (u64(width & 0x3FF) << 17) | base | (u64(in_pad_ch) << 31))
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert from data format to compact u32
|
// convert from data format to compact u32
|
||||||
pub fn get_str_intp_u32_format(fmt_type StrIntpType, in_width int, in_precision int, in_tail_zeros bool, in_sign bool, in_pad_ch u8, in_base int, in_upper_case bool) u32 {
|
pub fn get_str_intp_u32_format(fmt_type StrIntpType, in_width int, in_precision int, in_tail_zeros bool, in_sign bool, in_pad_ch u8, in_base int, in_upper_case bool) u32 {
|
||||||
width := if in_width != 0 { abs64(in_width) } else { u32(0) }
|
width := if in_width != 0 { abs64(in_width) } else { u32(0) }
|
||||||
allign := if in_width > 0 { u32(1 << 5) } else { u32(0) } // two bit 0 .left 1 .rigth, for now we use only one
|
align := if in_width > 0 { u32(1 << 5) } else { u32(0) } // two bit 0 .left 1 .right, for now we use only one
|
||||||
upper_case := if in_upper_case { u32(1 << 7) } else { u32(0) }
|
upper_case := if in_upper_case { u32(1 << 7) } else { u32(0) }
|
||||||
sign := if in_sign { u32(1 << 8) } else { u32(0) }
|
sign := if in_sign { u32(1 << 8) } else { u32(0) }
|
||||||
precision := if in_precision != 987698 {
|
precision := if in_precision != 987698 {
|
||||||
|
@ -143,7 +143,7 @@ pub fn get_str_intp_u32_format(fmt_type StrIntpType, in_width int, in_precision
|
||||||
}
|
}
|
||||||
tail_zeros := if in_tail_zeros { u32(1) << 16 } else { u32(0) }
|
tail_zeros := if in_tail_zeros { u32(1) << 16 } else { u32(0) }
|
||||||
base := u32(u32(in_base & 0xf) << 27)
|
base := u32(u32(in_base & 0xf) << 27)
|
||||||
res := u32((u32(fmt_type) & 0x1F) | allign | upper_case | sign | precision | tail_zeros | (u32(width & 0x3FF) << 17) | base | (u32(in_pad_ch & 1) << 31))
|
res := u32((u32(fmt_type) & 0x1F) | align | upper_case | sign | precision | tail_zeros | (u32(width & 0x3FF) << 17) | base | (u32(in_pad_ch & 1) << 31))
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ pub fn get_str_intp_u32_format(fmt_type StrIntpType, in_width int, in_precision
|
||||||
fn (data &StrIntpData) process_str_intp_data(mut sb strings.Builder) {
|
fn (data &StrIntpData) process_str_intp_data(mut sb strings.Builder) {
|
||||||
x := data.fmt
|
x := data.fmt
|
||||||
typ := unsafe { StrIntpType(x & 0x1F) }
|
typ := unsafe { StrIntpType(x & 0x1F) }
|
||||||
allign := int((x >> 5) & 0x01)
|
align := int((x >> 5) & 0x01)
|
||||||
upper_case := ((x >> 7) & 0x01) > 0
|
upper_case := ((x >> 7) & 0x01) > 0
|
||||||
sign := int((x >> 8) & 0x01)
|
sign := int((x >> 8) & 0x01)
|
||||||
precision := int((x >> 9) & 0x7F)
|
precision := int((x >> 9) & 0x7F)
|
||||||
|
@ -166,7 +166,7 @@ fn (data &StrIntpData) process_str_intp_data(mut sb strings.Builder) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// if width > 0 { println("${x.hex()} Type: ${x & 0x7F} Width: ${width} Precision: ${precision} allign:${allign}") }
|
// if width > 0 { println("${x.hex()} Type: ${x & 0x7F} Width: ${width} Precision: ${precision} align:${align}") }
|
||||||
|
|
||||||
// manage base if any
|
// manage base if any
|
||||||
if base > 0 {
|
if base > 0 {
|
||||||
|
@ -190,20 +190,20 @@ fn (data &StrIntpData) process_str_intp_data(mut sb strings.Builder) {
|
||||||
len1: len1_set // number of decimal digits, if needed
|
len1: len1_set // number of decimal digits, if needed
|
||||||
positive: true // mandatory: the sign of the number passed
|
positive: true // mandatory: the sign of the number passed
|
||||||
sign_flag: sign_set // flag for print sign as prefix in padding
|
sign_flag: sign_set // flag for print sign as prefix in padding
|
||||||
allign: .left // alignment of the string
|
align: .left // alignment of the string
|
||||||
rm_tail_zero: tail_zeros // false // remove the tail zeros from floats
|
rm_tail_zero: tail_zeros // false // remove the tail zeros from floats
|
||||||
}
|
}
|
||||||
|
|
||||||
// allign
|
// align
|
||||||
if fmt_pad_ch == 0 {
|
if fmt_pad_ch == 0 {
|
||||||
match allign {
|
match align {
|
||||||
0 { bf.allign = .left }
|
0 { bf.align = .left }
|
||||||
1 { bf.allign = .right }
|
1 { bf.align = .right }
|
||||||
// 2 { bf.allign = .center }
|
// 2 { bf.align = .center }
|
||||||
else { bf.allign = .left }
|
else { bf.align = .left }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bf.allign = .right
|
bf.align = .right
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -708,7 +708,7 @@ pub fn str_intp_g64(in_str string) string {
|
||||||
[manualfree]
|
[manualfree]
|
||||||
pub fn str_intp_sub(base_str string, in_str string) string {
|
pub fn str_intp_sub(base_str string, in_str string) string {
|
||||||
index := base_str.index('%%') or {
|
index := base_str.index('%%') or {
|
||||||
eprintln('No strin interpolation %% parameteres')
|
eprintln('No string interpolation %% parameters')
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
// return base_str[..index] + in_str + base_str[index+2..]
|
// return base_str[..index] + in_str + base_str[index+2..]
|
||||||
|
|
|
@ -52,7 +52,7 @@ fn (mut f Flag) free() {
|
||||||
// str returns a string representation of the given Flag
|
// str returns a string representation of the given Flag
|
||||||
pub fn (f Flag) str() string {
|
pub fn (f Flag) str() string {
|
||||||
return '' + ' flag:\n' + ' name: ${f.name}\n' +
|
return '' + ' flag:\n' + ' name: ${f.name}\n' +
|
||||||
' abbr: `${f.abbr.ascii_str()}`\n' + ' usag: ${f.usage}\n' +
|
' abbr: `${f.abbr.ascii_str()}`\n' + ' usage: ${f.usage}\n' +
|
||||||
' desc: ${f.val_desc}'
|
' desc: ${f.val_desc}'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ fn (mut fs FlagParser) parse_value(longhand string, shorthand u8) []string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for i, del in to_delete {
|
for i, del in to_delete {
|
||||||
// i entrys are deleted so it's shifted left i times.
|
// i entries are deleted so it's shifted left i times.
|
||||||
fs.args.delete(del - i)
|
fs.args.delete(del - i)
|
||||||
}
|
}
|
||||||
return found_entries
|
return found_entries
|
||||||
|
|
|
@ -236,7 +236,7 @@ fn test_could_expect_no_free_args() {
|
||||||
assert args.len < 0 // expect an error and need to use args
|
assert args.len < 0 // expect an error and need to use args
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_allow_abreviations() {
|
fn test_allow_abbreviations() {
|
||||||
mut fp := flag.new_flag_parser(['-v', '-o', 'some_file', '-i', '42', '-f', '2.0'])
|
mut fp := flag.new_flag_parser(['-v', '-o', 'some_file', '-i', '42', '-f', '2.0'])
|
||||||
v := fp.bool('version', `v`, false, '')
|
v := fp.bool('version', `v`, false, '')
|
||||||
o := fp.string('output', `o`, 'empty', '')
|
o := fp.string('output', `o`, 'empty', '')
|
||||||
|
|
|
@ -923,7 +923,7 @@ pub fn (ctx &Context) draw_ellipse_empty(x f32, y f32, rw f32, rh f32, c gx.Colo
|
||||||
sgl.end()
|
sgl.end()
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw_ellipse_filled draws an opaque elipse.
|
// draw_ellipse_filled draws an opaque ellipse.
|
||||||
// `x`,`y` defines the center of the ellipse.
|
// `x`,`y` defines the center of the ellipse.
|
||||||
// `rw` defines the *width* radius of the ellipse.
|
// `rw` defines the *width* radius of the ellipse.
|
||||||
// `rh` defines the *height* radius of the ellipse.
|
// `rh` defines the *height* radius of the ellipse.
|
||||||
|
|
|
@ -8,17 +8,18 @@ NSColor* nscolor(gx__Color c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString* nsstring(string s) {
|
NSString* nsstring(string s) {
|
||||||
return [ [ NSString alloc ] initWithBytesNoCopy:s.str length:s.len
|
return [[NSString alloc] initWithBytesNoCopy:s.str
|
||||||
encoding:NSUTF8StringEncoding freeWhenDone: false];
|
length:s.len
|
||||||
|
encoding:NSUTF8StringEncoding
|
||||||
|
freeWhenDone:false];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gg__Size gg_get_screen_size() {
|
gg__Size gg_get_screen_size() {
|
||||||
NSScreen* screen = [NSScreen mainScreen];
|
NSScreen* screen = [NSScreen mainScreen];
|
||||||
NSDictionary* description = [screen deviceDescription];
|
NSDictionary* description = [screen deviceDescription];
|
||||||
NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue];
|
NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue];
|
||||||
CGSize displayPhysicalSize = CGDisplayScreenSize(
|
CGSize displayPhysicalSize =
|
||||||
[[description objectForKey:@"NSScreenNumber"] unsignedIntValue]);
|
CGDisplayScreenSize([[description objectForKey:@"NSScreenNumber"] unsignedIntValue]);
|
||||||
gg__Size res;
|
gg__Size res;
|
||||||
res.width = displayPixelSize.width;
|
res.width = displayPixelSize.width;
|
||||||
res.height = displayPixelSize.height;
|
res.height = displayPixelSize.height;
|
||||||
|
@ -36,7 +37,6 @@ if (cfg.bold) {
|
||||||
font = [[NSFontManager sharedFontManager] convertFont:font toHaveTrait:NSBoldFontMask];
|
font = [[NSFontManager sharedFontManager] convertFont:font toHaveTrait:NSBoldFontMask];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NSDictionary* attr = @{
|
NSDictionary* attr = @{
|
||||||
NSForegroundColorAttributeName : nscolor(cfg.color),
|
NSForegroundColorAttributeName : nscolor(cfg.color),
|
||||||
// NSParagraphStyleAttributeName: paragraphStyle,
|
// NSParagraphStyleAttributeName: paragraphStyle,
|
||||||
|
@ -51,8 +51,7 @@ int darwin_text_width(string s) {
|
||||||
if (s.len == 1) {
|
if (s.len == 1) {
|
||||||
// println('len=1')
|
// println('len=1')
|
||||||
n = [NSString stringWithFormat:@"%c", s.str[0]];
|
n = [NSString stringWithFormat:@"%c", s.str[0]];
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
n = nsstring(s);
|
n = nsstring(s);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -75,7 +74,6 @@ void darwin_draw_rect(float x, float y, float width, float height, gx__Color c)
|
||||||
NSRectFill(rect);
|
NSRectFill(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void darwin_window_refresh() {
|
void darwin_window_refresh() {
|
||||||
//[g_view setNeedsDisplay:YES];
|
//[g_view setNeedsDisplay:YES];
|
||||||
// update UI on the main thread TODO separate fn
|
// update UI on the main thread TODO separate fn
|
||||||
|
@ -122,4 +120,3 @@ void darwin_draw_circle(float x, float y, float d, gx__Color color) {
|
||||||
[circlePath fill];
|
[circlePath fill];
|
||||||
// NSRectFill(rect);
|
// NSRectFill(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import stbi
|
||||||
import sokol.gfx
|
import sokol.gfx
|
||||||
import sokol.sgl
|
import sokol.sgl
|
||||||
|
|
||||||
// Image holds the fileds and data needed to
|
// Image holds the fields and data needed to
|
||||||
// represent a bitmap/pixel based image in memory.
|
// represent a bitmap/pixel based image in memory.
|
||||||
[heap]
|
[heap]
|
||||||
pub struct Image {
|
pub struct Image {
|
||||||
|
|
|
@ -27,7 +27,7 @@ pub fn (x Vec4) str() string {
|
||||||
return '|${x.e[0]:-6.3},${x.e[1]:-6.3},${x.e[2]:-6.3},${x.e[3]:-6.3}|'
|
return '|${x.e[0]:-6.3},${x.e[1]:-6.3},${x.e[2]:-6.3},${x.e[3]:-6.3}|'
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a Vec4 function passing x,y,z as parameteres. w is set to 1
|
// create a Vec4 function passing x,y,z as parameters. w is set to 1
|
||||||
pub fn vec3(x f32, y f32, z f32) Vec4 {
|
pub fn vec3(x f32, y f32, z f32) Vec4 {
|
||||||
return Vec4{
|
return Vec4{
|
||||||
e: [x, y, z, 1]!
|
e: [x, y, z, 1]!
|
||||||
|
|
2
vlib/gg/testdata/draw_elipses.vv
vendored
2
vlib/gg/testdata/draw_elipses.vv
vendored
|
@ -7,7 +7,7 @@ fn main() {
|
||||||
mut context := gg.new_context(
|
mut context := gg.new_context(
|
||||||
width: 200
|
width: 200
|
||||||
height: 200
|
height: 200
|
||||||
window_title: 'Elipses'
|
window_title: 'Ellipses'
|
||||||
frame_fn: frame
|
frame_fn: frame
|
||||||
)
|
)
|
||||||
context.run()
|
context.run()
|
||||||
|
|
|
@ -107,7 +107,7 @@ pub fn ntoh16(net u16) u16 {
|
||||||
// The returned array length .len, will be in [1,2,4,8] .
|
// The returned array length .len, will be in [1,2,4,8] .
|
||||||
pub fn u64tovarint(n u64) ![]u8 {
|
pub fn u64tovarint(n u64) ![]u8 {
|
||||||
if n > u64(1) << 62 {
|
if n > u64(1) << 62 {
|
||||||
return error('cannnot encode more than 2^62-1')
|
return error('cannot encode more than 2^62-1')
|
||||||
}
|
}
|
||||||
msb := match true {
|
msb := match true {
|
||||||
n < 64 {
|
n < 64 {
|
||||||
|
|
|
@ -44,14 +44,14 @@ The syntax for a format specifier is:
|
||||||
The Flags field may be zero or more (in any order) of:
|
The Flags field may be zero or more (in any order) of:
|
||||||
|
|
||||||
| Character | Description |
|
| Character | Description |
|
||||||
| ----------- | ------------------------------------------------------------ |
|
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||||
| `-` (minus) | Left-align the output of this specifier. (The default is to right-align the output.) |
|
| `-` (minus) | Left-align the output of this specifier. (The default is to right-align the output.) |
|
||||||
| `+` (plus) | Prepends a plus for positive signed-numeric types. positive = `+`, negative = `-`. (The default doesn't prepend anything to positive numbers.) |
|
| `+` (plus) | Prepends a plus for positive signed-numeric types. positive = `+`, negative = `-`. (The default doesn't prepend anything to positive numbers.) |
|
||||||
| `0` (zero) | When the 'width' option is specified, prepends zeros for numeric types. (The default prepends spaces.) For example, `printf("%4X",3)` produces ` 3`, while `printf("%04X",3)` produces `0003`. |
|
| `0` (zero) | When the 'width' option is specified, prepends zeros for numeric types. (The default prepends spaces.) For example, `printf("%4X",3)` produces ` 3`, while `printf("%04X",3)` produces `0003`. |
|
||||||
|
|
||||||
#### Width field
|
#### Width field
|
||||||
|
|
||||||
The Width field specifies a *maximum* number of characters to output,
|
The Width field specifies a _maximum_ number of characters to output,
|
||||||
and is typically used to pad fixed-width fields in tabulated output,
|
and is typically used to pad fixed-width fields in tabulated output,
|
||||||
it causes truncation of oversized fields.
|
it causes truncation of oversized fields.
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ with a total width of 5 characters.
|
||||||
The Length field can be omitted or be any of:
|
The Length field can be omitted or be any of:
|
||||||
|
|
||||||
| Character | Description |
|
| Character | Description |
|
||||||
| --------- | ------------------------------------------------------------ |
|
| --------- | -------------------------------------------------------------------------- |
|
||||||
| `hh` | For integer types, causes `printf` to expect an `byte` or `i8` argument. |
|
| `hh` | For integer types, causes `printf` to expect an `byte` or `i8` argument. |
|
||||||
| `h` | For integer types, causes `printf` to expect an `int16` or `u16` argument. |
|
| `h` | For integer types, causes `printf` to expect an `int16` or `u16` argument. |
|
||||||
| `l` | For integer types, causes `printf` to expect an `i64` or `u64` argument. |
|
| `l` | For integer types, causes `printf` to expect an `i64` or `u64` argument. |
|
||||||
|
@ -78,7 +78,7 @@ The Length field can be omitted or be any of:
|
||||||
The Type field can be any of:
|
The Type field can be any of:
|
||||||
|
|
||||||
| Character | Description |
|
| Character | Description |
|
||||||
| --------- | ------------------------------------------------------------ |
|
| --------- | --------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `%` | Prints a literal `%` character (this type doesn't accept any flags, width, precision, length fields). |
|
| `%` | Prints a literal `%` character (this type doesn't accept any flags, width, precision, length fields). |
|
||||||
| `d`, `i` | `int` as a signed `int` `%d` and `%i` are synonymous for output. The size of the argument is specified by the length field. |
|
| `d`, `i` | `int` as a signed `int` `%d` and `%i` are synonymous for output. The size of the argument is specified by the length field. |
|
||||||
| `u` | `unsigned int`. The size of the argument is specified by the length field. |
|
| `u` | `unsigned int`. The size of the argument is specified by the length field. |
|
||||||
|
@ -244,7 +244,7 @@ struct BF_param {
|
||||||
len1 int = 6 // number of decimal digits, if needed
|
len1 int = 6 // number of decimal digits, if needed
|
||||||
positive bool = true // mandatory: the sign of the number passed
|
positive bool = true // mandatory: the sign of the number passed
|
||||||
sign_flag bool = false // flag for print sign as prefix in padding
|
sign_flag bool = false // flag for print sign as prefix in padding
|
||||||
allign Align_text = .right // alignment of the string
|
align Align_text = .right // alignment of the string
|
||||||
rm_tail_zero bool = false // remove the tail zeros from floats
|
rm_tail_zero bool = false // remove the tail zeros from floats
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,8 @@ pub mut:
|
||||||
len1 int = 6 // number of decimal digits, if needed
|
len1 int = 6 // number of decimal digits, if needed
|
||||||
positive bool = true // mandatory: the sign of the number passed
|
positive bool = true // mandatory: the sign of the number passed
|
||||||
sign_flag bool // flag for print sign as prefix in padding
|
sign_flag bool // flag for print sign as prefix in padding
|
||||||
allign Align_text = .right // alignment of the string
|
align Align_text = .right // alignment of the string
|
||||||
|
allign Align_text [deprecated: 'use align instead'; deprecated_after: '2023-11-30'] = .right
|
||||||
rm_tail_zero bool // remove the tail zeros from floats
|
rm_tail_zero bool // remove the tail zeros from floats
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,13 +104,13 @@ pub fn format_str(s string, p BF_param) string {
|
||||||
defer {
|
defer {
|
||||||
unsafe { res.free() }
|
unsafe { res.free() }
|
||||||
}
|
}
|
||||||
if p.allign == .right {
|
if p.align == .right {
|
||||||
for i1 := 0; i1 < dif; i1++ {
|
for i1 := 0; i1 < dif; i1++ {
|
||||||
res.write_u8(p.pad_ch)
|
res.write_u8(p.pad_ch)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res.write_string(s)
|
res.write_string(s)
|
||||||
if p.allign == .left {
|
if p.align == .left {
|
||||||
for i1 := 0; i1 < dif; i1++ {
|
for i1 := 0; i1 < dif; i1++ {
|
||||||
res.write_u8(p.pad_ch)
|
res.write_u8(p.pad_ch)
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,13 +21,13 @@ pub fn format_str_sb(s string, p BF_param, mut sb strings.Builder) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.allign == .right {
|
if p.align == .right {
|
||||||
for i1 := 0; i1 < dif; i1++ {
|
for i1 := 0; i1 < dif; i1++ {
|
||||||
sb.write_u8(p.pad_ch)
|
sb.write_u8(p.pad_ch)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sb.write_string(s)
|
sb.write_string(s)
|
||||||
if p.allign == .left {
|
if p.align == .left {
|
||||||
for i1 := 0; i1 < dif; i1++ {
|
for i1 := 0; i1 < dif; i1++ {
|
||||||
sb.write_u8(p.pad_ch)
|
sb.write_u8(p.pad_ch)
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ pub fn format_dec_sb(d u64, p BF_param, mut res strings.Builder) {
|
||||||
dif := p.len0 - number_len
|
dif := p.len0 - number_len
|
||||||
mut sign_written := false
|
mut sign_written := false
|
||||||
|
|
||||||
if p.allign == .right {
|
if p.align == .right {
|
||||||
if p.pad_ch == `0` {
|
if p.pad_ch == `0` {
|
||||||
if p.positive {
|
if p.positive {
|
||||||
if p.sign_flag {
|
if p.sign_flag {
|
||||||
|
@ -127,7 +127,7 @@ pub fn format_dec_sb(d u64, p BF_param, mut res strings.Builder) {
|
||||||
}
|
}
|
||||||
//===========================================
|
//===========================================
|
||||||
|
|
||||||
if p.allign == .left {
|
if p.align == .left {
|
||||||
for i1 := 0; i1 < dif; i1++ {
|
for i1 := 0; i1 < dif; i1++ {
|
||||||
res.write_u8(p.pad_ch)
|
res.write_u8(p.pad_ch)
|
||||||
}
|
}
|
||||||
|
@ -365,7 +365,7 @@ pub fn format_fl(f f64, p BF_param) string {
|
||||||
|
|
||||||
// make the padding if needed
|
// make the padding if needed
|
||||||
dif := p.len0 - buf_i + sign_len_diff
|
dif := p.len0 - buf_i + sign_len_diff
|
||||||
if p.allign == .right {
|
if p.align == .right {
|
||||||
for i1 := 0; i1 < dif; i1++ {
|
for i1 := 0; i1 < dif; i1++ {
|
||||||
out[out_i] = p.pad_ch
|
out[out_i] = p.pad_ch
|
||||||
out_i++
|
out_i++
|
||||||
|
@ -373,7 +373,7 @@ pub fn format_fl(f f64, p BF_param) string {
|
||||||
}
|
}
|
||||||
vmemcpy(&out[out_i], &buf[0], buf_i)
|
vmemcpy(&out[out_i], &buf[0], buf_i)
|
||||||
out_i += buf_i
|
out_i += buf_i
|
||||||
if p.allign == .left {
|
if p.align == .left {
|
||||||
for i1 := 0; i1 < dif; i1++ {
|
for i1 := 0; i1 < dif; i1++ {
|
||||||
out[out_i] = p.pad_ch
|
out[out_i] = p.pad_ch
|
||||||
out_i++
|
out_i++
|
||||||
|
@ -436,7 +436,7 @@ pub fn format_es(f f64, p BF_param) string {
|
||||||
|
|
||||||
// make the padding if needed
|
// make the padding if needed
|
||||||
dif := p.len0 - buf_i + sign_len_diff
|
dif := p.len0 - buf_i + sign_len_diff
|
||||||
if p.allign == .right {
|
if p.align == .right {
|
||||||
for i1 := 0; i1 < dif; i1++ {
|
for i1 := 0; i1 < dif; i1++ {
|
||||||
out[out_i] = p.pad_ch
|
out[out_i] = p.pad_ch
|
||||||
out_i++
|
out_i++
|
||||||
|
@ -444,7 +444,7 @@ pub fn format_es(f f64, p BF_param) string {
|
||||||
}
|
}
|
||||||
vmemcpy(&out[out_i], &buf[0], buf_i)
|
vmemcpy(&out[out_i], &buf[0], buf_i)
|
||||||
out_i += buf_i
|
out_i += buf_i
|
||||||
if p.allign == .left {
|
if p.align == .left {
|
||||||
for i1 := 0; i1 < dif; i1++ {
|
for i1 := 0; i1 < dif; i1++ {
|
||||||
out[out_i] = p.pad_ch
|
out[out_i] = p.pad_ch
|
||||||
out_i++
|
out_i++
|
||||||
|
|
|
@ -15,7 +15,7 @@ pub fn format_str_sb(s string, p BF_param, mut sb strings.Builder) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.allign == .right {
|
if p.align == .right {
|
||||||
for i1 := 0; i1 < dif; i1++ {
|
for i1 := 0; i1 < dif; i1++ {
|
||||||
sb.write_u8(p.pad_ch)
|
sb.write_u8(p.pad_ch)
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ pub fn format_str_sb(s string, p BF_param, mut sb strings.Builder) {
|
||||||
|
|
||||||
sb.write_string(s)
|
sb.write_string(s)
|
||||||
|
|
||||||
if p.allign == .left {
|
if p.align == .left {
|
||||||
for i1 := 0; i1 < dif; i1++ {
|
for i1 := 0; i1 < dif; i1++ {
|
||||||
sb.write_u8(p.pad_ch)
|
sb.write_u8(p.pad_ch)
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ pub fn format_dec_sb(d u64, p BF_param, mut res strings.Builder) {
|
||||||
dif := p.len0 - number_len
|
dif := p.len0 - number_len
|
||||||
mut sign_written := false
|
mut sign_written := false
|
||||||
|
|
||||||
if p.allign == .right {
|
if p.align == .right {
|
||||||
if p.pad_ch == `0` {
|
if p.pad_ch == `0` {
|
||||||
if p.positive {
|
if p.positive {
|
||||||
if p.sign_flag {
|
if p.sign_flag {
|
||||||
|
@ -94,7 +94,7 @@ pub fn format_dec_sb(d u64, p BF_param, mut res strings.Builder) {
|
||||||
|
|
||||||
//===========================================
|
//===========================================
|
||||||
|
|
||||||
if p.allign == .left {
|
if p.align == .left {
|
||||||
for i1 := 0; i1 < dif; i1++ {
|
for i1 := 0; i1 < dif; i1++ {
|
||||||
res.write_u8(p.pad_ch)
|
res.write_u8(p.pad_ch)
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ pub fn v_sprintf(str string, pt ...voidptr) string {
|
||||||
mut i := 0 // main string index
|
mut i := 0 // main string index
|
||||||
mut p_index := 0 // parameter index
|
mut p_index := 0 // parameter index
|
||||||
mut sign := false // sign flag
|
mut sign := false // sign flag
|
||||||
mut allign := Align_text.right
|
mut align := Align_text.right
|
||||||
mut len0 := -1 // forced length, if -1 free length
|
mut len0 := -1 // forced length, if -1 free length
|
||||||
mut len1 := -1 // decimal part for floats
|
mut len1 := -1 // decimal part for floats
|
||||||
def_len1 := 6 // default value for len1
|
def_len1 := 6 // default value for len1
|
||||||
|
@ -66,7 +66,7 @@ pub fn v_sprintf(str string, pt ...voidptr) string {
|
||||||
for i < str.len {
|
for i < str.len {
|
||||||
if status == .reset_params {
|
if status == .reset_params {
|
||||||
sign = false
|
sign = false
|
||||||
allign = .right
|
align = .right
|
||||||
len0 = -1
|
len0 = -1
|
||||||
len1 = -1
|
len1 = -1
|
||||||
pad_ch = ` `
|
pad_ch = ` `
|
||||||
|
@ -130,11 +130,11 @@ pub fn v_sprintf(str string, pt ...voidptr) string {
|
||||||
i++
|
i++
|
||||||
continue
|
continue
|
||||||
} else if ch == `-` {
|
} else if ch == `-` {
|
||||||
allign = .left
|
align = .left
|
||||||
i++
|
i++
|
||||||
continue
|
continue
|
||||||
} else if ch in [`0`, ` `] {
|
} else if ch in [`0`, ` `] {
|
||||||
if allign == .right {
|
if align == .right {
|
||||||
pad_ch = ch
|
pad_ch = ch
|
||||||
}
|
}
|
||||||
i++
|
i++
|
||||||
|
@ -298,7 +298,7 @@ pub fn v_sprintf(str string, pt ...voidptr) string {
|
||||||
len1: 0
|
len1: 0
|
||||||
positive: positive
|
positive: positive
|
||||||
sign_flag: sign
|
sign_flag: sign
|
||||||
allign: allign
|
align: align
|
||||||
)
|
)
|
||||||
res.write_string(tmp)
|
res.write_string(tmp)
|
||||||
unsafe { tmp.free() }
|
unsafe { tmp.free() }
|
||||||
|
@ -349,7 +349,7 @@ pub fn v_sprintf(str string, pt ...voidptr) string {
|
||||||
len1: 0
|
len1: 0
|
||||||
positive: positive
|
positive: positive
|
||||||
sign_flag: sign
|
sign_flag: sign
|
||||||
allign: allign
|
align: align
|
||||||
)
|
)
|
||||||
res.write_string(tmp)
|
res.write_string(tmp)
|
||||||
unsafe { tmp.free() }
|
unsafe { tmp.free() }
|
||||||
|
@ -408,7 +408,7 @@ pub fn v_sprintf(str string, pt ...voidptr) string {
|
||||||
len1: 0
|
len1: 0
|
||||||
positive: true
|
positive: true
|
||||||
sign_flag: false
|
sign_flag: false
|
||||||
allign: allign
|
align: align
|
||||||
)
|
)
|
||||||
res.write_string(tmp)
|
res.write_string(tmp)
|
||||||
unsafe { tmp.free() }
|
unsafe { tmp.free() }
|
||||||
|
@ -432,7 +432,7 @@ pub fn v_sprintf(str string, pt ...voidptr) string {
|
||||||
len1: len1
|
len1: len1
|
||||||
positive: positive
|
positive: positive
|
||||||
sign_flag: sign
|
sign_flag: sign
|
||||||
allign: allign
|
align: align
|
||||||
)
|
)
|
||||||
if ch == `F` {
|
if ch == `F` {
|
||||||
tmp := s.to_upper()
|
tmp := s.to_upper()
|
||||||
|
@ -459,7 +459,7 @@ pub fn v_sprintf(str string, pt ...voidptr) string {
|
||||||
len1: len1
|
len1: len1
|
||||||
positive: positive
|
positive: positive
|
||||||
sign_flag: sign
|
sign_flag: sign
|
||||||
allign: allign
|
align: align
|
||||||
)
|
)
|
||||||
if ch == `E` {
|
if ch == `E` {
|
||||||
tmp := s.to_upper()
|
tmp := s.to_upper()
|
||||||
|
@ -491,7 +491,7 @@ pub fn v_sprintf(str string, pt ...voidptr) string {
|
||||||
len1: len1
|
len1: len1
|
||||||
positive: positive
|
positive: positive
|
||||||
sign_flag: sign
|
sign_flag: sign
|
||||||
allign: allign
|
align: align
|
||||||
rm_tail_zero: true
|
rm_tail_zero: true
|
||||||
)
|
)
|
||||||
unsafe { tmp.free() }
|
unsafe { tmp.free() }
|
||||||
|
@ -504,7 +504,7 @@ pub fn v_sprintf(str string, pt ...voidptr) string {
|
||||||
len1: len1
|
len1: len1
|
||||||
positive: positive
|
positive: positive
|
||||||
sign_flag: sign
|
sign_flag: sign
|
||||||
allign: allign
|
align: align
|
||||||
rm_tail_zero: true
|
rm_tail_zero: true
|
||||||
)
|
)
|
||||||
unsafe { tmp.free() }
|
unsafe { tmp.free() }
|
||||||
|
@ -534,7 +534,7 @@ pub fn v_sprintf(str string, pt ...voidptr) string {
|
||||||
len1: 0
|
len1: 0
|
||||||
positive: true
|
positive: true
|
||||||
sign_flag: false
|
sign_flag: false
|
||||||
allign: allign
|
align: align
|
||||||
)
|
)
|
||||||
res.write_string(tmp)
|
res.write_string(tmp)
|
||||||
unsafe { tmp.free() }
|
unsafe { tmp.free() }
|
||||||
|
@ -631,13 +631,13 @@ pub fn format_fl_old(f f64, p BF_param) string {
|
||||||
|
|
||||||
dif := p.len0 - s.len + sign_len_diff
|
dif := p.len0 - s.len + sign_len_diff
|
||||||
|
|
||||||
if p.allign == .right {
|
if p.align == .right {
|
||||||
for i1 := 0; i1 < dif; i1++ {
|
for i1 := 0; i1 < dif; i1++ {
|
||||||
res.write_u8(p.pad_ch)
|
res.write_u8(p.pad_ch)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res.write_string(s)
|
res.write_string(s)
|
||||||
if p.allign == .left {
|
if p.align == .left {
|
||||||
for i1 := 0; i1 < dif; i1++ {
|
for i1 := 0; i1 < dif; i1++ {
|
||||||
res.write_u8(p.pad_ch)
|
res.write_u8(p.pad_ch)
|
||||||
}
|
}
|
||||||
|
@ -699,13 +699,13 @@ fn format_es_old(f f64, p BF_param) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
dif := p.len0 - s.len + sign_len_diff
|
dif := p.len0 - s.len + sign_len_diff
|
||||||
if p.allign == .right {
|
if p.align == .right {
|
||||||
for i1 := 0; i1 < dif; i1++ {
|
for i1 := 0; i1 < dif; i1++ {
|
||||||
res.write_u8(p.pad_ch)
|
res.write_u8(p.pad_ch)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res.write_string(s)
|
res.write_string(s)
|
||||||
if p.allign == .left {
|
if p.align == .left {
|
||||||
for i1 := 0; i1 < dif; i1++ {
|
for i1 := 0; i1 < dif; i1++ {
|
||||||
res.write_u8(p.pad_ch)
|
res.write_u8(p.pad_ch)
|
||||||
}
|
}
|
||||||
|
@ -796,13 +796,13 @@ pub fn format_dec_old(d u64, p BF_param) string {
|
||||||
}
|
}
|
||||||
dif := p.len0 - s.len + sign_len_diff
|
dif := p.len0 - s.len + sign_len_diff
|
||||||
|
|
||||||
if p.allign == .right {
|
if p.align == .right {
|
||||||
for i1 := 0; i1 < dif; i1++ {
|
for i1 := 0; i1 < dif; i1++ {
|
||||||
res.write_u8(p.pad_ch)
|
res.write_u8(p.pad_ch)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res.write_string(s)
|
res.write_string(s)
|
||||||
if p.allign == .left {
|
if p.align == .left {
|
||||||
for i1 := 0; i1 < dif; i1++ {
|
for i1 := 0; i1 < dif; i1++ {
|
||||||
res.write_u8(p.pad_ch)
|
res.write_u8(p.pad_ch)
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,8 +165,8 @@ pub fn header(text string, divider string) string {
|
||||||
} else {
|
} else {
|
||||||
cols - 3 - 2 * divider.len
|
cols - 3 - 2 * divider.len
|
||||||
})
|
})
|
||||||
tlimit_alligned := if (tlimit % 2) != (cols % 2) { tlimit + 1 } else { tlimit }
|
tlimit_aligned := if (tlimit % 2) != (cols % 2) { tlimit + 1 } else { tlimit }
|
||||||
tstart := imax(0, (cols - tlimit_alligned) / 2)
|
tstart := imax(0, (cols - tlimit_aligned) / 2)
|
||||||
mut ln := ''
|
mut ln := ''
|
||||||
if divider.len > 0 {
|
if divider.len > 0 {
|
||||||
ln = divider.repeat(1 + cols / divider.len)[0..cols]
|
ln = divider.repeat(1 + cols / divider.len)[0..cols]
|
||||||
|
|
|
@ -171,7 +171,7 @@ pub fn (mut g Gen) gen_pe_header() {
|
||||||
|
|
||||||
g.pe_coff_hdr_pos = g.pos()
|
g.pe_coff_hdr_pos = g.pos()
|
||||||
for i, b in pe_header {
|
for i, b in pe_header {
|
||||||
end_addr := i * 2 + 2 // allign correctly with description table
|
end_addr := i * 2 + 2 // align correctly with description table
|
||||||
g.write16(b)
|
g.write16(b)
|
||||||
if g.pref.is_verbose && pe_header_description[end_addr] != '' {
|
if g.pref.is_verbose && pe_header_description[end_addr] != '' {
|
||||||
g.println(pe_header_description[end_addr])
|
g.println(pe_header_description[end_addr])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue