about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/display/term.nim6
-rw-r--r--src/local/pager.nim11
-rw-r--r--src/local/select.nim4
-rw-r--r--src/render/renderdocument.nim8
-rw-r--r--src/types/cell.nim7
5 files changed, 16 insertions, 20 deletions
diff --git a/src/display/term.nim b/src/display/term.nim
index b3f98230..cd2df219 100644
--- a/src/display/term.nim
+++ b/src/display/term.nim
@@ -322,7 +322,7 @@ proc processFormat*(term: Terminal, format: var Format, cellf: Format): string =
   if cellf.fgcolor != format.fgcolor and cellf.fgcolor == defaultColor or
       cellf.bgcolor != format.bgcolor and cellf.bgcolor == defaultColor:
     result &= term.resetFormat()
-    format = newFormat()
+    format = Format()
 
   if cellf.fgcolor != format.fgcolor:
     var color = cellf.fgcolor
@@ -397,7 +397,7 @@ proc processOutputString*(term: Terminal, str: string, w: var int): string =
     return es.readAll()
 
 proc generateFullOutput(term: Terminal, grid: FixedGrid): string =
-  var format = newFormat()
+  var format = Format()
   result &= term.cursorGoto(0, 0)
   result &= term.resetFormat()
   result &= term.clearDisplay()
@@ -441,7 +441,7 @@ proc generateSwapOutput(term: Terminal, grid, prev: FixedGrid): string =
         result &= term.cursorGoto(cx, y)
         vy = y
       result &= term.resetFormat()
-      var format = newFormat()
+      var format = Format()
       for x in cx ..< grid.width:
         while w < x: # if previous cell had no width, catch up with x
           result &= ' '
diff --git a/src/local/pager.nim b/src/local/pager.nim
index 254c074e..9275a5d3 100644
--- a/src/local/pager.nim
+++ b/src/local/pager.nim
@@ -277,7 +277,7 @@ proc refreshDisplay(pager: Pager, container = pager.container) =
     container.highlightMarks(pager.display, hlcolor)
 
 # Note: this function does not work correctly if start < i of last written char
-proc writeStatusMessage(pager: Pager, str: string, format = newFormat(),
+proc writeStatusMessage(pager: Pager, str: string, format = Format(),
     start = 0, maxwidth = -1, clip = '$'): int {.discardable.} =
   var maxwidth = maxwidth
   if maxwidth == -1:
@@ -302,7 +302,7 @@ proc writeStatusMessage(pager: Pager, str: string, format = newFormat(),
     pager.statusgrid[i].format = format
     i += w
   result = i
-  var def = newFormat()
+  var def = Format()
   while i < e:
     pager.statusgrid[i].str = ""
     pager.statusgrid[i].format = def
@@ -327,8 +327,7 @@ proc refreshStatusMsg*(pager: Pager) =
     pager.writeStatusMessage(pager.alerts[0])
     pager.alerts.delete(0)
   else:
-    var format = newFormat()
-    format.reverse = true
+    var format = Format(flags: {FLAG_REVERSE})
     pager.alerton = false
     container.clearHover()
     var msg = $(container.cursory + 1) & "/" & $container.numLines & " (" &
@@ -350,7 +349,7 @@ proc showAlerts*(pager: Pager) =
     pager.refreshStatusMsg()
 
 proc drawBuffer*(pager: Pager, container: Container, ostream: Stream) =
-  var format = newFormat()
+  var format = Format()
   container.readLines(proc(line: SimpleFlexibleLine) =
     if line.formats.len == 0:
       ostream.write(line.str & "\n")
@@ -370,7 +369,7 @@ proc drawBuffer*(pager: Pager, container: Container, ostream: Stream) =
         s &= pager.term.processFormat(format, f.format)
       if i < line.str.len:
         s &= pager.term.processOutputString(line.str.substr(i), w)
-      s &= pager.term.processFormat(format, newFormat()) & "\n"
+      s &= pager.term.processFormat(format, Format()) & "\n"
       ostream.write(s))
   ostream.flush()
 
diff --git a/src/local/select.nim b/src/local/select.nim
index 0be38104..bfa3faf8 100644
--- a/src/local/select.nim
+++ b/src/local/select.nim
@@ -223,7 +223,7 @@ proc drawBorders(display: var FixedGrid, sx, ex, sy, ey: int,
   let tr = if upmore: VerticalBar else: CornerTopRight
   let bl = if downmore: VerticalBar else: CornerBottomLeft
   let br = if downmore: VerticalBar else: CornerBottomRight
-  const fmt = newFormat()
+  const fmt = Format()
   display[sy * display.width + sx].str = tl
   display[sy * display.width + ex].str = tr
   display[ey * display.width + sx].str = bl
@@ -279,7 +279,7 @@ proc drawSelect*(select: Select, display: var FixedGrid) =
   inc sx
   var r: Rune
   var k = 0
-  var format = newFormat()
+  var format = Format()
   while k < select.selected.len and select.selected[k] < si:
     inc k
   for y in sy ..< ey:
diff --git a/src/render/renderdocument.nim b/src/render/renderdocument.nim
index 264489e4..f86f276a 100644
--- a/src/render/renderdocument.nim
+++ b/src/render/renderdocument.nim
@@ -85,7 +85,7 @@ proc setText(grid: var FlexibleGrid, linestr: string, x, y: int,
 
   if padwidth > 0:
     # Replace formats for padding
-    var padformat = newFormat()
+    var padformat = Format()
     if fi == -1:
       # No formats
       inc fi # insert after first format (meaning fi = 0)
@@ -124,7 +124,7 @@ proc setText(grid: var FlexibleGrid, linestr: string, x, y: int,
     # No formats => just insert a new format at 0
     inc fi
     grid[y].insertFormat(x, fi, format, node)
-    lformat = newFormat()
+    lformat = Format()
   else:
     # First format's pos may be == x here.
     lformat = grid[y].formats[fi].format # save for later use
@@ -240,12 +240,12 @@ proc paintBackground(grid: var FlexibleGrid, color: CellColor, startx,
     # Process formatting around startx
     if grid[y].formats.len == 0:
       # No formats
-      grid[y].addFormat(startx, newFormat())
+      grid[y].addFormat(startx, Format())
     else:
       let fi = grid[y].findFormatN(startx) - 1
       if fi == -1:
         # No format <= startx
-        grid[y].insertFormat(startx, 0, newFormat())
+        grid[y].insertFormat(startx, 0, Format())
       elif grid[y].formats[fi].pos == startx:
         # Last format equals startx => next comes after, nothing to be done
         discard
diff --git a/src/types/cell.nim b/src/types/cell.nim
index c7a92c96..f3ffd919 100644
--- a/src/types/cell.nim
+++ b/src/types/cell.nim
@@ -105,9 +105,6 @@ func width*(line: FlexibleLine): int =
 func width*(cell: FixedCell): int =
   return cell.str.width()
 
-func newFormat*(): Format =
-  return Format(fgcolor: defaultColor, bgcolor: defaultColor)
-
 # Get the first format cell after pos, if any.
 func findFormatN*(line: FlexibleLine|SimpleFlexibleLine, pos: int): int =
   var i = 0
@@ -252,14 +249,14 @@ proc parseSGRAspect(parser: AnsiCodeParser, format: var Format,
       format.flags.incl(entry.flag)
     return true
   elif u == 0:
-    format = newFormat()
+    format = Format()
     return true
   else:
     return parser.parseSGRColor(format, i, u)
 
 proc parseSGR(parser: AnsiCodeParser, format: var Format) =
   if parser.params.len == 0:
-    format = newFormat()
+    format = Format()
   else:
     var i = 0
     while i < parser.params.len: