From e39ae3c05c9859731159742ad8233fcc22c571d2 Mon Sep 17 00:00:00 2001 From: chrys Date: Sat, 5 Nov 2016 17:52:14 +0100 Subject: [PATCH 1/6] fix style --- src/fenrir/commands/commands/toggle_highlight_tracking.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fenrir/commands/commands/toggle_highlight_tracking.py b/src/fenrir/commands/commands/toggle_highlight_tracking.py index 6a987d9b..628e2448 100644 --- a/src/fenrir/commands/commands/toggle_highlight_tracking.py +++ b/src/fenrir/commands/commands/toggle_highlight_tracking.py @@ -16,7 +16,7 @@ class command(): return 'enables or disables tracking of highlighted' def run(self): - currMode=self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'highlight') + currMode = self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'highlight') self.env['runtime']['settingsManager'].setSetting('focus', 'highlight', str(not currMode)) self.env['runtime']['settingsManager'].setSetting('focus', 'cursor', str(currMode)) From 55466466a9b6993d1c1c49b0cac353f1811e81f7 Mon Sep 17 00:00:00 2001 From: chrys Date: Sat, 5 Nov 2016 17:54:16 +0100 Subject: [PATCH 2/6] correct default path if scriptpath is not available in settings.conf --- src/fenrir/core/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fenrir/core/settings.py b/src/fenrir/core/settings.py index 6d092ad5..6355147e 100644 --- a/src/fenrir/core/settings.py +++ b/src/fenrir/core/settings.py @@ -53,7 +53,7 @@ settings = { 'dateFormat': '%A, %B %d, %Y', 'autoSpellCheck': False, 'spellCheckLanguage': 'en_US', - 'scriptPath':'/etc/fenrir/scripts', + 'scriptPath':'/usr/share/fenrir/scripts', }, 'focus':{ 'cursor': True, From d70c8e20329587aaa6585a153b9bde09b0fb87c0 Mon Sep 17 00:00:00 2001 From: chrys87 Date: Mon, 7 Nov 2016 10:49:32 +0100 Subject: [PATCH 3/6] Update README.md --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 39f10454..dcd19ded 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,11 @@ ReadWrite permission - python-daemonize [use fenrir as background service on Unix like systems] # installation -Currently there is no setupscript (sorry). But you can just run as root or setup needed permission +- Archlinux: PKGBUILD in AUR +- install.sh (there is currently no uninstall) +- run from git: +You can just run the following as root: cd src/fenrir-package/ -sudo ./fenrir.py -Settings are located in the config directory. +sudo ./fenrir +Settings are located in the "config" directory. + From f6034484965844fb50733d87befe98653dfe0f55 Mon Sep 17 00:00:00 2001 From: chrys87 Date: Mon, 7 Nov 2016 16:38:33 +0100 Subject: [PATCH 4/6] Update screen_utils.py --- src/fenrir/utils/screen_utils.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/fenrir/utils/screen_utils.py b/src/fenrir/utils/screen_utils.py index 54190ffe..86946dd2 100644 --- a/src/fenrir/utils/screen_utils.py +++ b/src/fenrir/utils/screen_utils.py @@ -32,19 +32,23 @@ def trackHighlights(oldAttr, newAttr, text, lenght): old = splitEvery(oldAttr,lenght) new = splitEvery(newAttr,lenght) textLines = text.split('\n') + background = [] if len(textLines) != len(new): return result, currCursor - try: - background = Counter(newAttr).most_common(1) - background = background[0][0] + bgStat = Counter(newAttr).most_common(3) + background.append(bgStat[0][0]) + # if there is a third color add a secondary background (for dialogs for example) + if len(bgStat) > 2: + if bgStat[1][1] > 20: + background.append(bgStat[1][0]) except Exception as e: - background = chr(7) + background.append(chr(7)) for line in range(len(new)): if old[line] != new[line]: for column in range(len(new[line])): if old[line][column] != new[line][column]: - if new[line][column] != background: + if not new[line][column] in background: if not currCursor: currCursor = {} currCursor['x'] = column From ecb261558f15ca93f155b240761ee61bd9f0e097 Mon Sep 17 00:00:00 2001 From: chrys87 Date: Mon, 7 Nov 2016 16:42:20 +0100 Subject: [PATCH 5/6] Update screen_utils.py --- src/fenrir/utils/screen_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fenrir/utils/screen_utils.py b/src/fenrir/utils/screen_utils.py index 86946dd2..4eb81945 100644 --- a/src/fenrir/utils/screen_utils.py +++ b/src/fenrir/utils/screen_utils.py @@ -40,7 +40,7 @@ def trackHighlights(oldAttr, newAttr, text, lenght): background.append(bgStat[0][0]) # if there is a third color add a secondary background (for dialogs for example) if len(bgStat) > 2: - if bgStat[1][1] > 20: + if bgStat[1][1] > 40: background.append(bgStat[1][0]) except Exception as e: background.append(chr(7)) From fc963b14a5b13d63a6274a951885621bfe108743 Mon Sep 17 00:00:00 2001 From: chrys Date: Tue, 8 Nov 2016 00:07:08 +0100 Subject: [PATCH 6/6] demo code vor vcsa attributes --- play zone/vcsa.py | 92 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100755 play zone/vcsa.py diff --git a/play zone/vcsa.py b/play zone/vcsa.py new file mode 100755 index 00000000..6742fd6f --- /dev/null +++ b/play zone/vcsa.py @@ -0,0 +1,92 @@ +#!/usr/bin/python + +from cairo import * +from fcntl import ioctl +from array import array +import struct +import errno +import sys + +GIO_UNIMAP = 0x4B66 +VT_GETHIFONTMASK = 0x560D + +if len(sys.argv) != 3: + print "Usage: %s " % sys.argv[0] + exit() + +ttyno = int(sys.argv[1]) +png = sys.argv[2] + +tty = open('/dev/tty%d' % ttyno, 'rb') +himask = array("H", (0,)) +ioctl(tty, VT_GETHIFONTMASK, himask) +hichar, = struct.unpack_from("@H", himask) + +sz = 512 +while True: + try: + unipairs = array("H", [0]*(2*sz)) + unimapdesc = array("B", struct.pack("@HP", sz, unipairs.buffer_info()[0])) + ioctl(tty.fileno(), GIO_UNIMAP, unimapdesc) + break + except IOError as e: + if e.errno != errno.ENOMEM: + raise + sz *= 2 +tty.close() + +ncodes, = struct.unpack_from("@H", unimapdesc) +utable = struct.unpack_from("@%dH" % (2*ncodes), unipairs) + +charmap = {} +for u, b in zip(utable[::2], utable[1::2]): + if charmap.get(b) is None: + charmap[b] = unichr(u) + +vcs = open('/dev/vcsa%d' % ttyno, 'rb') + +head = vcs.read(4) +rows = ord(head[0]) +cols = ord(head[1]) +caretX = ord(head[2]) +caretY = ord(head[3]) + +surf = ImageSurface(FORMAT_RGB24, cols * 8, rows * 16) + +cr = Context(surf) +cr.set_source_rgb(1,1,1) +cr.set_font_face(ToyFontFace("Mono", FONT_SLANT_NORMAL, FONT_WEIGHT_NORMAL)); +m = Matrix() +m.scale(10.0, 12.0) +cr.set_font_matrix(m) + +def CairoColor(b, a): + return (b if a & 4 else 0, b if a & 2 else 0, b if a & 1 else 0) + +for y in range(rows): + for x in range(cols): + data = vcs.read(2) + (sh,) = struct.unpack("=H", data) + attr = (sh >> 8) & 0xFF + ch = sh & 0xFF + if hichar == 0x100: + attr >>= 1 + + ink = attr & 0x0F + paper = (attr>>4) & 0x0F + b = 1.0 if attr & 0x80 else 0.75 + if sh & hichar: + ch |= 0x100 + + cr.set_source_rgb(*CairoColor(b, paper)) + cr.rectangle(x*8, y*16, 8, 16) + cr.fill() + + cr.set_source_rgb(*CairoColor(b, ink)) + cr.move_to(x*8, 12 + y*16) + cr.show_text(charmap.get(ch, u'?')) + cr.stroke() +vcs.close() + +surf.write_to_png(png) +