diff options
| author | ruki <[email protected]> | 2020-12-06 21:56:23 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-12-06 21:56:23 +0800 |
| commit | e000c9404afce3a7a793fbf6bd8579a0f132f84e (patch) | |
| tree | 67845c40f2b18929562bec99079d9f56af3a52c4 | |
| parent | 5a0f7be900e316e968886b91df31d053c4e7c2e8 (diff) | |
fix bits op
| -rw-r--r-- | xmake/core/ui/label.lua | 3 | ||||
| -rw-r--r-- | xmake/core/ui/textedit.lua | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/xmake/core/ui/label.lua b/xmake/core/ui/label.lua index f6a65b0e9..64cdf646e 100644 --- a/xmake/core/ui/label.lua +++ b/xmake/core/ui/label.lua @@ -24,6 +24,7 @@ local view = require("ui/view") local event = require("ui/event") local action = require("ui/action") local curses = require("ui/curses") +local bit = require("bit") -- define module local label = label or view() @@ -129,7 +130,7 @@ function label:splitext(text, width) while #line > width do local size = 0 for i = 1, #line do - if (line:byte(i) & 0xc0) ~= 0x80 then + if bit.band(line:byte(i), 0xc0) ~= 0x80 then size = size + 1 if size > width then table.insert(result, line:sub(1, i - 1)) diff --git a/xmake/core/ui/textedit.lua b/xmake/core/ui/textedit.lua index 54b295571..be9bd08fd 100644 --- a/xmake/core/ui/textedit.lua +++ b/xmake/core/ui/textedit.lua @@ -27,6 +27,7 @@ local border = require("ui/border") local curses = require("ui/curses") local textarea = require("ui/textarea") local action = require("ui/action") +local bit = require("bit") -- define module local textedit = textedit or textarea() @@ -85,7 +86,7 @@ function textedit:on_event(e) if #text > 0 then local size = 1 -- while continuation byte - while (text:byte(#text - size + 1) & 0xc0) == 0x80 do + while bit.band(text:byte(#text - size + 1), 0xc0) == 0x80 do size = size + 1 end self:text_set(text:sub(1, #text - size)) |
