diff options
| author | ruki <[email protected]> | 2018-01-11 22:34:44 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-01-11 09:28:28 +0800 |
| commit | 749b1822cdc2dbcc3d1f12de614f397607d29b90 (patch) | |
| tree | e5c619fd2504b8afb341342f4fbd17d9b128a2b7 /xmake/core/ui/window.lua | |
| parent | 7973898f7c886f981ef3b27ad62fab129e5c5b03 (diff) | |
improve border on windows
Diffstat (limited to 'xmake/core/ui/window.lua')
| -rw-r--r-- | xmake/core/ui/window.lua | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/xmake/core/ui/window.lua b/xmake/core/ui/window.lua index 52b946300..0a5b56783 100644 --- a/xmake/core/ui/window.lua +++ b/xmake/core/ui/window.lua @@ -51,9 +51,6 @@ function window:init(name, bounds, title, shadow) -- insert border self:frame():insert(self:border()) - -- insert panel - self:frame():insert(self:panel()) - -- insert title if title then self._TITLE = label:new("window.title", rect{0, 0, #title, 1}, title) @@ -61,6 +58,9 @@ function window:init(name, bounds, title, shadow) self:frame():insert(self:title(), {centerx = true}) end + -- insert panel + self:frame():insert(self:panel()) + -- insert frame self:insert(self:frame()) end @@ -101,19 +101,38 @@ function window:border() local border = view:new("window.border", self:frame():bounds()) function border:draw() + -- the left-upper attribute + local attr_ul = curses.color_pair("white", self:background()) + if self:background() == "white" then + attr_ul = {attr_ul, "standout"} + end + + -- the right-lower attribute + local attr_rl = curses.color_pair("black", self:background()) + + -- the border characters + -- @note acs character will use 2 width on windows (pdcurses), so we use acsii characters instead of them. + local iswin = os.host() == "windows" + local hline = iswin and '-' or "hline" + local vline = iswin and '|' or "vline" + local ulcorner = iswin and ' ' or "ulcorner" + local llcorner = iswin and ' ' or "llcorner" + local urcorner = iswin and ' ' or "urcorner" + local lrcorner = iswin and ' ' or "lrcorner" + -- draw left and top border - self:canvas():attr(curses.color_pair("white", self:background())) - self:canvas():move(0, 0):putchar("hline", self:width()) - self:canvas():move(0, 0):putchar("ulcorner") - self:canvas():move(0, 1):putchar("vline", self:height() - 1, true) - self:canvas():move(0, self:height() - 1):putchar("llcorner") + self:canvas():attr(attr_ul) + self:canvas():move(0, 0):putchar(hline, self:width()) + self:canvas():move(0, 0):putchar(ulcorner) + self:canvas():move(0, 1):putchar(vline, self:height() - 1, true) + self:canvas():move(0, self:height() - 1):putchar(llcorner) -- draw bottom and right border - self:canvas():attr(curses.color_pair("black", self:background())) - self:canvas():move(1, self:height() - 1):putchar("hline", self:width() - 1) - self:canvas():move(self:width() - 1, 0):putchar("urcorner") - self:canvas():move(self:width() - 1, 1):putchar("vline", self:height() - 1, true) - self:canvas():move(self:width() - 1, self:height() - 1):putchar("lrcorner") + self:canvas():attr(attr_rl) + self:canvas():move(1, self:height() - 1):putchar(hline, self:width() - 1) + self:canvas():move(self:width() - 1, 0):putchar(urcorner) + self:canvas():move(self:width() - 1, 1):putchar(vline, self:height() - 1, true) + self:canvas():move(self:width() - 1, self:height() - 1):putchar(lrcorner) end self._BORDER = border end |
