mirror of
https://github.com/daylinmorgan/tsm.git
synced 2024-12-22 05:00:44 -06:00
feat: add configurable max height
This commit is contained in:
parent
f68672bb7f
commit
34a2cb9940
3 changed files with 19 additions and 5 deletions
|
@ -17,7 +17,9 @@ nimble install https://github.com/daylinmorgan/tsm
|
|||
|
||||
## Usage
|
||||
|
||||
To configure `tsm` export the environment variable `TSM_DIRS`, with a colon-delimited set of parent directories to find projects.
|
||||
To configure `tsm` export the below environment variables:
|
||||
> `TSM_DIRS`: a colon-delimited set of parent directories to find projects. \
|
||||
> `TSM_HEIGHT`: integer specifying number of rows in terminal (default: 15)
|
||||
|
||||
For example in your rc file:
|
||||
|
||||
|
@ -26,7 +28,7 @@ export TSM_DIRS="$HOME/projects/personal:$HOME/projects/work"
|
|||
```
|
||||
|
||||
To make full use of `tsm` you should also add a new key binding to your `tmux.conf`.
|
||||
For example you can bind the f key to show a popup with `tsm`:
|
||||
For example, you can bind the f key to show a popup with `tsm`:
|
||||
|
||||
```sh
|
||||
bind f display-popup \
|
||||
|
|
|
@ -1,12 +1,24 @@
|
|||
import std/[enumerate, os, strformat, strutils, terminal]
|
||||
|
||||
from illwill import illwillDeinit, illwillInit, getKey, Key
|
||||
import bbansi
|
||||
import term
|
||||
|
||||
import project
|
||||
|
||||
func toStr(k: Key): string = $chr(ord(k))
|
||||
|
||||
proc getMaxHeight(): int =
|
||||
result = 10
|
||||
let setting = getEnv("TSM_HEIGHT")
|
||||
if setting != "":
|
||||
try:
|
||||
result = parseInt(setting)
|
||||
except ValueError:
|
||||
termQuit fmt"failed to parse TSM_HEIGHT of `{setting}`, expected integer"
|
||||
|
||||
|
||||
let maxHeight = getMaxHeight()
|
||||
|
||||
type
|
||||
Cursor = object
|
||||
min, y: Natural = 1
|
||||
|
@ -165,7 +177,7 @@ proc draw() =
|
|||
|
||||
proc update(s: var State) =
|
||||
s.buffer.width = terminalWidth()
|
||||
s.buffer.height = min(terminalHeight(), 10 + state.buffer.inputPad)
|
||||
s.buffer.height = min(terminalHeight(), maxHeight + state.buffer.inputPad)
|
||||
s.cursor.max = s.buffer.height - state.buffer.inputPad
|
||||
|
||||
proc clear(b: var Buffer) =
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import std/strutils
|
||||
import bbansi
|
||||
|
||||
export bbansi
|
||||
const
|
||||
sep = " [magenta]|[/] "
|
||||
prefix = "[cyan]tsm[/]" & sep
|
||||
|
|
Loading…
Reference in a new issue