init
This commit is contained in:
commit
c67a0e78eb
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
hr
|
||||||
|
hr.1.gz
|
9
Makefile
Normal file
9
Makefile
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
PREFIX := "$$HOME/.local"
|
||||||
|
|
||||||
|
all:
|
||||||
|
nimble build
|
||||||
|
rst2man src/hr.1.rst | gzip -9 -c > hr.1.gz
|
||||||
|
|
||||||
|
install:
|
||||||
|
install -D hr $(PREFIX)/bin/hr
|
||||||
|
install -D hr.1.gz $(PREFIX)/share/man/man1/hr.1.gz
|
12
README.md
Normal file
12
README.md
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# hr
|
||||||
|
|
||||||
|
A horizontal ruler for your terminal.
|
||||||
|
|
||||||
|
Just another implementation of [hr](https://github.com/LuRsT/hr/wiki#alternative-hrs=) on Nim language.
|
||||||
|
|
||||||
|
# Installation
|
||||||
|
|
||||||
|
```
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
```
|
14
hr.nimble
Normal file
14
hr.nimble
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# Package
|
||||||
|
|
||||||
|
version = "0.1.0"
|
||||||
|
author = "ge"
|
||||||
|
description = "A horizontal ruler for your terminal"
|
||||||
|
license = "Unlicense"
|
||||||
|
srcDir = "src"
|
||||||
|
bin = @["hr"]
|
||||||
|
|
||||||
|
|
||||||
|
# Dependencies
|
||||||
|
|
||||||
|
requires "nim >= 1.6.6"
|
||||||
|
requires "ncurses >= 1.0.2"
|
44
src/hr.1.rst
Normal file
44
src/hr.1.rst
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
==
|
||||||
|
hr
|
||||||
|
==
|
||||||
|
|
||||||
|
------------------------------------
|
||||||
|
A horizontal ruler for your terminal
|
||||||
|
------------------------------------
|
||||||
|
|
||||||
|
:Author: ge
|
||||||
|
:Copyright: Unlicense
|
||||||
|
:Date: 2022 Jul 20
|
||||||
|
:Manual section: 1
|
||||||
|
:Version: baf 0.1.0
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
========
|
||||||
|
|
||||||
|
hr <string>...
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
===========
|
||||||
|
|
||||||
|
Print line with passed characters till the end of terminal window.
|
||||||
|
|
||||||
|
EXAMPLES
|
||||||
|
========
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
$ hr '*'
|
||||||
|
***************************************
|
||||||
|
|
||||||
|
$ hr '#--'
|
||||||
|
#--#--#--#--#--#--#--#--#--#--#--#--#--
|
||||||
|
|
||||||
|
$ hr + - +
|
||||||
|
++++++++++++++++++++++++++++++++++++++++
|
||||||
|
----------------------------------------
|
||||||
|
++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
========
|
||||||
|
|
||||||
|
``ncurses``\(3X)
|
53
src/hr.nim
Normal file
53
src/hr.nim
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#[
|
||||||
|
hr - A horizontal ruler for your terminal.
|
||||||
|
|
||||||
|
This is free and unencumbered software released into the public domain.
|
||||||
|
|
||||||
|
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||||
|
distribute this software, either in source code form or as a compiled
|
||||||
|
binary, for any purpose, commercial or non-commercial, and by any
|
||||||
|
means.
|
||||||
|
|
||||||
|
In jurisdictions that recognize copyright laws, the author or authors
|
||||||
|
of this software dedicate any and all copyright interest in the
|
||||||
|
software to the public domain. We make this dedication for the benefit
|
||||||
|
of the public at large and to the detriment of our heirs and
|
||||||
|
successors. We intend this dedication to be an overt act of
|
||||||
|
relinquishment in perpetuity of all present and future rights to this
|
||||||
|
software under copyright law.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
For more information, please refer to <http://unlicense.org/>
|
||||||
|
]#
|
||||||
|
|
||||||
|
import std/os
|
||||||
|
import std/strutils
|
||||||
|
import ncurses
|
||||||
|
|
||||||
|
var
|
||||||
|
cols: cint
|
||||||
|
params: seq[string]
|
||||||
|
|
||||||
|
let win = initscr() # Initialise screen
|
||||||
|
|
||||||
|
# Get terminal lines and columns
|
||||||
|
cols = getmaxx(win); endwin()
|
||||||
|
|
||||||
|
when declared(commandLineParams):
|
||||||
|
params = commandLineParams()
|
||||||
|
else:
|
||||||
|
discard
|
||||||
|
|
||||||
|
if paramCount() == 0:
|
||||||
|
params = @["="]
|
||||||
|
|
||||||
|
# Draw horisontal rule
|
||||||
|
for str in params:
|
||||||
|
echo str.repeat(cols)[0 .. (cols - 1)]
|
Loading…
Reference in New Issue
Block a user