diff options
| author | ruki <[email protected]> | 2020-05-09 22:44:01 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-05-09 22:44:01 +0800 |
| commit | a7720294713d5c86afcf8b2f9260fdcf6706ce96 (patch) | |
| tree | 404fa74d1eef5821b63e0575146a89da7ae928ac | |
| parent | c9eacb29c8b3d067e6a64f8eb23c0ef5043d7b5c (diff) | |
improve textarea
| -rw-r--r-- | xmake/core/ui/textarea.lua | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/xmake/core/ui/textarea.lua b/xmake/core/ui/textarea.lua index 56c3b1f53..7624aeda1 100644 --- a/xmake/core/ui/textarea.lua +++ b/xmake/core/ui/textarea.lua @@ -62,9 +62,12 @@ function textarea:on_draw(transparent) -- draw progress if self:option("progress") then - local progress = math.floor((self._STARTLINE + math.min(self:height(), self._LINECOUNT)) * 100 / self._LINECOUNT) - if (self._STARTLINE > 0 or progress < 100) and self:width() > 20 then - self:canvas():move(self:width() - 10, self:height() - 1):putstr(string.format("(%d%%)", progress)) + local tb = self._STARTLINE + local fator = self:height() / self._LINECOUNT + local sb = math.min(math.floor(tb * fator), self:height() - 1) + local se = math.min(sb + math.ceil(self:height() * fator), self:height()) + if se > sb and se - sb < self:height() then + self:canvas():attr("black"):move(self:width() - 1, sb):putchar(' ', se - sb, true) end end end |
