Skip to content

Commit

Permalink
Merge branch 'jwilk:master' into completion
Browse files Browse the repository at this point in the history
  • Loading branch information
crpb authored Feb 10, 2024
2 parents b9357e2 + af9ce56 commit 0a5dd80
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 17 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ jobs:
printf 'Apt::Install-Recommends "false";\n' | tee -a /etc/apt/apt.conf
apt-get update
apt-get install -y python3-gi-cairo gir1.2-pango-1.0
apt-get install -y perl
- name: check Python version
run: |
python3 --version
- name: smoke test
- name: run tests
run: |
export LC_ALL=C.UTF-8
./ubanner --trim 'νιάου'
./ubanner --full-screen 'νιάου'
./ubanner --list-fonts
prove -v
static:
runs-on: ${{matrix.os}}
Expand Down
24 changes: 12 additions & 12 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ Overview

.. code:: console
$ ubanner --trim 'νιάου'
░░░
██░
█▒
$ ubanner --trim πανό
░░░
██░
█▒
░░░░░ ░░ ░░░░░ ░░░░░░ ░░ ░░░░░ ░░░░░ ░░░
▒██ ██░ ▒██ ▒██░░░▒██░ █▒ ▒██░ ░░██░ ▒██ ░██░
▒██ ░██░ ▒██ ███ ▒███▒ ███ ██▒ ▒██ ░██
▒██ ▒██ ▒██ ░██░ ███ ░██░ ▒██░ ▒██ ██▒
▒██ ░██░ ▒██ ▒██░ ▒██ ▒██ ██░ ▒██ ██▒
▒██ ▒██ ▒██ ░██▒ ███▒ ░██▒ ▒██ ▒██ ▒██
▒██ ▒█▒ ██ ░██░ ▒▒▒██ ░██░ ▒██░ ░██ ▒██░
███▒░▒██ ▒██▒▒▒░ ░███▒ ░▒█▒▒▒█▒░ ▒██▒██▒░
░░░░░░░░░░░░░░░░ ░░░░░░ ░░ ░░░░░ ░░ ░░░░░
▒██ ▒██ ▒██░░░▒██░ █▒ ▒██ ██░ ▒██░ ░░██░
▒██ ▒██ ███ ▒███▒ ▒██ ░██░ ███ ██▒
▒██ ▒██ ░██░ ███ ▒██ ▒██░ ░██░ ▒██░
▒██ ▒██ ▒██░ ▒██ ▒██ ██░ ▒██ ▒██░
▒██ ▒██ ░██▒ ███▒ ▒██ ▒██ ░██▒ ▒██
▒██ ██ ░██░ ▒▒▒██ ▒██ ▒█▒ ░██ ▒██░
▒▒███▒░▒███▒▒ ▒██▒▒▒░ ░███▒ ▒███▒░ ░▒█▒▒▒█▒░
Dependencies
============
Expand Down
17 changes: 17 additions & 0 deletions t/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

# Copyright © 2024 Jakub Wilk <[email protected]>
# SPDX-License-Identifier: MIT

set -e -u

dir="${0%/*}/.."
prog="${UBANNER_TEST_TARGET:-"$dir/ubanner"}"

is_unicode_locale()
{
local charset=$'\u2591\u2592\u2588'
test ${#charset} -eq 3
}

# vim:ts=4 sts=4 sw=4 et ft=sh
23 changes: 23 additions & 0 deletions t/full-screen.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

# Copyright © 2024 Jakub Wilk <[email protected]>
# SPDX-License-Identifier: MIT

set -e -u

. "${0%/*}/common.sh"

echo 1..1
is_unicode_locale || {
echo 'non-Unicode locale' >&2
exit 1
}
if out=$("$prog" --full-screen $'\u10E3')
then
sed -e 's/^/# /' <<< "$out"
echo ok 1
else
echo not ok 1
fi

# vim:ts=4 sts=4 sw=4 et ft=sh
19 changes: 19 additions & 0 deletions t/lists-fonts.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

# Copyright © 2024 Jakub Wilk <[email protected]>
# SPDX-License-Identifier: MIT

set -e -u

. "${0%/*}/common.sh"

echo 1..1
if out=$("$prog" --list-fonts)
then
sed -e 's/^/# /' <<< "$out"
echo ok 1
else
echo not ok 1
fi

# vim:ts=4 sts=4 sw=4 et ft=sh
23 changes: 23 additions & 0 deletions t/trim.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

# Copyright © 2024 Jakub Wilk <[email protected]>
# SPDX-License-Identifier: MIT

set -e -u

. "${0%/*}/common.sh"

echo 1..1
is_unicode_locale || {
echo 'non-Unicode locale' >&2
exit 1
}
if out=$("$prog" --trim $'\u10E3')
then
sed -e 's/^/# /' <<< "$out"
echo ok 1
else
echo not ok 1
fi

# vim:ts=4 sts=4 sw=4 et ft=sh
9 changes: 8 additions & 1 deletion ubanner
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import argparse
import bisect
import itertools
import locale
import shutil
import signal
import sys
Expand Down Expand Up @@ -62,7 +63,6 @@ def pango_render(text, size=(76, 24), font=None, font_size=None):
PangoCairo.show_layout(ctx, layout)
data = surface.get_data()
stride = surface.get_stride()
charset = ' ░▒█'
cdiv = 512 // len(charset)
for y in range(ht // 2):
s = ''
Expand Down Expand Up @@ -93,6 +93,13 @@ class act_list_fonts(argparse.Action):
seen.add(descr)
sys.exit()

encoding = locale.nl_langinfo(locale.CODESET)
charset = ' ░▒█'
try:
charset.encode(encoding, 'strict')
except UnicodeError:
charset = ' +*#'

def main():
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
ap = argparse.ArgumentParser()
Expand Down

0 comments on commit 0a5dd80

Please sign in to comment.