~reesmichael1/roman

556dae4b2108daad4fd8677025c74811f5a5e6ed — Michael Rees 8 months ago f72a489
Show ellipsis on long titles instead of wrapping
1 files changed, 11 insertions(+), 1 deletions(-)

M src/romanpkg/posts.nim
M src/romanpkg/posts.nim => src/romanpkg/posts.nim +11 -1
@@ 12,12 12,22 @@ import paths
from types import Post


proc formatTitle*(p: Post): string {.raises: [].} =
proc formatTitle*(p: Post): string {.raises: [RomanError].} =
  var width: int
  try:
    width = terminalWidth()
  except ValueError:
    raise newException(RomanError, "could not get terminal width")
  if p.read:
    result = p.title
  else:
    result = "[*] " & p.title

  if result.len > width:
    # 3 for the ellipsis, 4 for the '> ' before and after the printing,
    # 2 for padding
    result = result[0..<width-9] & "..."


proc collectReadPosts(): seq[string] {.raises: [RomanError].} =
  try: