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

vrepl: add support for Home and End keys (#16116)

This commit is contained in:
locriacyber
2022-10-20 17:07:57 +00:00
committed by GitHub
parent f8a28b5a5d
commit a3b050aced
5 changed files with 72 additions and 60 deletions

View File

@@ -57,30 +57,3 @@ pub fn string_from_wide2(_wstr &u16, len int) string {
return ''
}
}
// Reads an utf8 character from standard input
pub fn utf8_getchar() int {
c := C.getchar()
len := utf8_len(u8(~c))
if c < 0 {
return 0
} else if len == 0 {
return c
} else if len == 1 {
return -1
} else {
mut uc := c & ((1 << (7 - len)) - 1)
for i := 0; i + 1 < len; i++ {
c2 := C.getchar()
if c2 != -1 && (c2 >> 6) == 2 {
uc <<= 6
uc |= (c2 & 63)
} else if c2 == -1 {
return 0
} else {
return -1
}
}
return uc
}
}