diff options
author | bptato <nincsnevem662@gmail.com> | 2024-03-21 18:27:06 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-03-21 18:27:06 +0100 |
commit | dfd6c3f2f0b5494da192ee60f2c588a92ceef089 (patch) | |
tree | 7da80dc28620fc8d9219d89c87f4af4962a6e43b /src/local | |
parent | 4a897f27bbfb114f256890eb70c4d7e053f0e19b (diff) | |
download | chawan-dfd6c3f2f0b5494da192ee60f2c588a92ceef089.tar.gz |
cell: update FormatFlag naming, remove useless templates
Diffstat (limited to 'src/local')
-rw-r--r-- | src/local/pager.nim | 2 | ||||
-rw-r--r-- | src/local/select.nim | 4 | ||||
-rw-r--r-- | src/local/term.nim | 30 |
3 files changed, 18 insertions, 18 deletions
diff --git a/src/local/pager.nim b/src/local/pager.nim index 3b75155c..98e29a39 100644 --- a/src/local/pager.nim +++ b/src/local/pager.nim @@ -371,7 +371,7 @@ proc refreshStatusMsg*(pager: Pager) = pager.writeStatusMessage(pager.alerts[0]) pager.alerts.delete(0) else: - var format = Format(flags: {FLAG_REVERSE}) + var format = Format(flags: {ffReverse}) pager.alertState = pasNormal container.clearHover() var msg = $(container.cursory + 1) & "/" & $container.numLines & " (" & diff --git a/src/local/select.nim b/src/local/select.nim index bfa3faf8..a02aa1a4 100644 --- a/src/local/select.nim +++ b/src/local/select.nim @@ -288,10 +288,10 @@ proc drawSelect*(select: Select, display: var FixedGrid) = var x = sx let dls = y * display.width if k < select.selected.len and select.selected[k] == i: - format.reverse = true + format.flags.incl(ffReverse) inc k else: - format.reverse = false + format.flags.excl(ffReverse) while j < select.options[i].len: fastRuneAt(select.options[i], j, r) let rw = r.twidth(x) diff --git a/src/local/term.nim b/src/local/term.nim index 996a8508..a5ae3567 100644 --- a/src/local/term.nim +++ b/src/local/term.nim @@ -219,17 +219,17 @@ proc startFormat(term: Terminal, flag: FormatFlags): string = when termcap_found: if term.isatty(): case flag - of FLAG_BOLD: return term.cap md - of FLAG_UNDERLINE: return term.cap us - of FLAG_REVERSE: return term.cap mr - of FLAG_BLINK: return term.cap mb - of FLAG_ITALIC: return term.cap ZH + of ffBold: return term.cap md + of ffUnderline: return term.cap us + of ffReverse: return term.cap mr + of ffBlink: return term.cap mb + of ffItalic: return term.cap ZH else: discard return SGR(FormatCodes[flag].s) proc endFormat(term: Terminal, flag: FormatFlags): string = when termcap_found: - if flag == FLAG_UNDERLINE and term.isatty(): + if flag == ffUnderline and term.isatty(): return term.cap ue return SGR(FormatCodes[flag].e) @@ -503,21 +503,21 @@ proc showCursor*(term: Terminal) = func emulateOverline(term: Terminal): bool = term.config.display.emulate_overline and - FLAG_OVERLINE notin term.formatmode and FLAG_UNDERLINE in term.formatmode + ffOverline notin term.formatmode and ffUnderline in term.formatmode proc writeGrid*(term: Terminal, grid: FixedGrid, x = 0, y = 0) = for ly in y ..< y + grid.height: for lx in x ..< x + grid.width: let i = ly * term.canvas.width + lx term.canvas[i] = grid[(ly - y) * grid.width + (lx - x)] - let isol = FLAG_OVERLINE in term.canvas[i].format.flags + let isol = ffOverline in term.canvas[i].format.flags if i >= term.canvas.width and isol and term.emulateOverline: let w = grid[(ly - y) * grid.width + (lx - x)].width() let s = i - term.canvas.width var j = s while j < term.canvas.len and j < s + w: let cell = addr term.canvas[j] - cell.format.flags.incl(FLAG_UNDERLINE) + cell.format.flags.incl(ffUnderline) if cell.str == "": cell.str = " " if cell.str == " ": @@ -821,7 +821,7 @@ proc detectTermAttributes(term: Terminal, windowOnly: bool): TermStartResult = if qaRGB in r.attrs: term.colormode = TRUE_COLOR # just assume the terminal doesn't choke on these. - term.formatmode = {FLAG_STRIKE, FLAG_OVERLINE} + term.formatmode = {ffStrike, ffOverline} if r.bgcolor.isSome: term.defaultBackground = r.bgcolor.get if r.fgcolor.isSome: @@ -841,15 +841,15 @@ proc detectTermAttributes(term: Terminal, windowOnly: bool): TermStartResult = if term.tc != nil: term.smcup = term.hascap ti if term.hascap(ZH): - term.formatmode.incl(FLAG_ITALIC) + term.formatmode.incl(ffItalic) if term.hascap(us): - term.formatmode.incl(FLAG_UNDERLINE) + term.formatmode.incl(ffUnderline) if term.hascap(md): - term.formatmode.incl(FLAG_BOLD) + term.formatmode.incl(ffBold) if term.hascap(mr): - term.formatmode.incl(FLAG_REVERSE) + term.formatmode.incl(ffReverse) if term.hascap(mb): - term.formatmode.incl(FLAG_BLINK) + term.formatmode.incl(ffBlink) else: term.smcup = true term.formatmode = {low(FormatFlags)..high(FormatFlags)} |