fix shorter-than-one-line text fitting problem

right character gets cut off, but it's because the cursor is
the top left of the last character. add one character height plus
margin to the shortening, because the margin itself could be 0
in many case.
This commit is contained in:
bunnie 2021-07-29 01:02:44 +08:00
parent 1424eca689
commit 8b992bbe38
2 changed files with 6 additions and 6 deletions

View file

@ -192,8 +192,8 @@ fn xmain() -> ! {
};
// if less than one line of text, shrink the box
let finalwidth = if c.pt.y == 0 {
if c.pt.x as i16 + tv.margin.x * 3 < checkedwidth {
c.pt.x as i16 + tv.margin.x * 3
if c.pt.x as i16 + c.line_height as i16 + tv.margin.x < checkedwidth {
c.pt.x as i16 + c.line_height as i16 + tv.margin.x
} else {
checkedwidth
}
@ -243,8 +243,8 @@ fn xmain() -> ! {
// if less than one line of text, shrink the box
let finalwidth = if c.pt.y == 0 {
if c.pt.x as i16 + tv.margin.x * 3 < checkedwidth {
c.pt.x as i16 + tv.margin.x * 3
if c.pt.x as i16 + c.line_height as i16 + tv.margin.x < checkedwidth {
c.pt.x as i16 + c.line_height as i16 + tv.margin.x
} else {
checkedwidth
}
@ -299,8 +299,8 @@ fn xmain() -> ! {
// if less than one line of text, shrink the box
let finalwidth = if c.pt.y == 0 {
if c.pt.x as i16 + tv.margin.x * 3 < checkedwidth {
c.pt.x as i16 + tv.margin.x * 3
if c.pt.x as i16 + c.line_height as i16 + tv.margin.x < checkedwidth {
c.pt.x as i16 + c.line_height as i16 + tv.margin.x
} else {
checkedwidth
}