From 21a424f3e66238c192712316530047fde028230c Mon Sep 17 00:00:00 2001 From: Paul Wilde Date: Fri, 17 Feb 2023 11:44:13 +0000 Subject: [PATCH] dynamic line number for rofi --- globurrl.nim | 9 ++++++--- pingclurrk/src/pingclurrk.nim | 1 - 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/globurrl.nim b/globurrl.nim index c6430d8..dc6986e 100644 --- a/globurrl.nim +++ b/globurrl.nim @@ -60,7 +60,7 @@ const alert* = "#bd2c40" const font = "Hermit-12" const WL_DMENU = "dmenu" const WL_ROFI = "wofi --dmenu" -var MAX_LINES* = 0 +const MAX_LINES = 20 var loop* = false var stoploop* = true var tool* = "dmenu" @@ -198,14 +198,17 @@ proc genMenuCmd*(data: Info, opts: varargs[string], rofi: bool = false): string cmd = cmd & text & "\n" cmd.removeSuffix("\n") + var x_lines = len(opts) + if x_lines > MAX_LINES: + x_lines = MAX_LINES + cmd = "echo -e" & quote(cmd) & " | " var menu = newMenu() cmd = cmd & menu.command & " " cmd = cmd & menu.extra_cmd & " " cmd = cmd & menu.i_case & " " - if MAX_LINES > 0: - cmd = cmd & menu.lines_shown & " " & $MAX_LINES & " " + cmd = cmd & menu.lines_shown & " " & $MAX_LINES & " " cmd = cmd & menu.prompt & quote(data.title) cmd = cmd & menu.norm_bg & quote(data.unselected_bg) cmd = cmd & menu.norm_fg & quote(data.unselected_fg) diff --git a/pingclurrk/src/pingclurrk.nim b/pingclurrk/src/pingclurrk.nim index d3d99e9..d01bcef 100644 --- a/pingclurrk/src/pingclurrk.nim +++ b/pingclurrk/src/pingclurrk.nim @@ -82,5 +82,4 @@ proc main() = main() if isMainModule: - MAX_LINES = 0 main()