diff --git a/dataobjs.py b/dataobjs.py index 721ee5e..f2dc448 100644 --- a/dataobjs.py +++ b/dataobjs.py @@ -1,4 +1,8 @@ +import re +import random +import itertools import logging +from datetime import datetime PchumLog = logging.getLogger("pchumLogger") try: @@ -6,9 +10,6 @@ try: except ImportError: print("PyQt5 fallback (dataobjs.py)") from PyQt5 import QtGui -from datetime import datetime -import re -import random from mood import Mood from parsetools import ( @@ -31,6 +32,7 @@ _ctagre = re.compile("()", re.I) _smilere = re.compile("|".join(list(smiledict.keys()))) _memore = re.compile(r"(\s|^)(#[A-Za-z0-9_]+)") _handlere = re.compile(r"(\s|^)(@[A-Za-z0-9_]+)") +_alternian = re.compile(r".*?") class pesterQuirk: @@ -167,20 +169,18 @@ class pesterQuirks: if checkstate == 2: # Check for substring that should be excluded. excludes = [] - # Check for links, store in list. - for match in re.finditer(_urlre, string): - excludes.append(match) - # Check for smilies, store in list. - for match in re.finditer(_smilere, string): - excludes.append(match) - # Check for @handles, store in list. - for match in re.finditer(_handlere, string): - excludes.append(match) - # Check for #memos, store in list. - for match in re.finditer(_memore, string): - excludes.append(match) + # Return matches for links, smilies, handles, memos. + # Chain the iterators and add to excludes list. + matches = itertools.chain( + re.finditer(_urlre, string), + re.finditer(_smilere, string), + re.finditer(_handlere, string), + re.finditer(_memore, string), + re.finditer(_alternian, string), + ) + excludes.extend(matches) - if len(excludes) >= 1: + if excludes: # SORT !!! excludes.sort(key=lambda exclude: exclude.start()) # Recursion check. diff --git a/fonts/alternian/AllisDaedric-VYWz.otf b/fonts/alternian/AllisDaedric-VYWz.otf new file mode 100644 index 0000000..1183577 Binary files /dev/null and b/fonts/alternian/AllisDaedric-VYWz.otf differ diff --git a/fonts/alternian/info.txt b/fonts/alternian/info.txt new file mode 100644 index 0000000..7cf5d40 --- /dev/null +++ b/fonts/alternian/info.txt @@ -0,0 +1,2 @@ +license: Public Domain +link: https://www.fontspace.com/allis-daedric-font-f20263 \ No newline at end of file diff --git a/parsetools.py b/parsetools.py index c0fa2c5..0eefe4f 100644 --- a/parsetools.py +++ b/parsetools.py @@ -40,6 +40,8 @@ _oocre = re.compile(r"([\[(\{])\1.*([\])\}])\2") # _format_end = re.compile(r"(?i)") _honk = re.compile(r"(?i)\bhonk\b") _groupre = re.compile(r"\\([0-9]+)") +_alternian_begin = re.compile(r"") # Matches get set to alternian font +_alternian_end = re.compile(r"") quirkloader = ScriptQuirks() _functionre = None @@ -169,9 +171,9 @@ class hyperlink(lexercon.Chunk): def convert(self, format): if format == "html": - return "{}".format(self.string, self.string) + return f"{self.string}" elif format == "bbcode": - return "[url]%s[/url]" % (self.string) + return f"[url]{self.string}[/url]" else: return self.string @@ -184,6 +186,30 @@ class hyperlink_lazy(hyperlink): self.string = "http://" + string +class alternianTagBegin(lexercon.Chunk): + def __init__(self, string): + self.string = string + + def convert(self, format): + if format == "html": + return "" + elif format == "text": + return "" + return self.string + + +class alternianTagEnd(lexercon.Chunk): + def __init__(self, string): + self.string = string + + def convert(self, format): + if format == "html": + return "" + elif format == "text": + return "" + return self.string + + class imagelink(lexercon.Chunk): def __init__(self, string, img): self.string = string @@ -285,6 +311,8 @@ def kxlexMsg(msg: str): def lexMessage(string: str): lexlist = [ (mecmd, _mecmdre), + (alternianTagBegin, _alternian_begin), + (alternianTagEnd, _alternian_end), (colorBegin, _ctag_begin), # (colorBegin, _gtag_begin), (colorEnd, _ctag_end), diff --git a/pesterchum.py b/pesterchum.py index b590dc5..b750365 100755 --- a/pesterchum.py +++ b/pesterchum.py @@ -1653,9 +1653,10 @@ class PesterWindow(MovingWindow): if not self.config.defaultprofile(): self.changeProfile() - # Fuck you some more OSX leopard! >:( - # if not ostools.isOSXLeopard(): - # QtCore.QTimer.singleShot(1000, self.mspacheck) + # Load font + QtGui.QFontDatabase.addApplicationFont( + os.path.join("fonts", "alternian", "AllisDaedric-VYWz.otf") + ) self.pcUpdate[str, str].connect(self.updateMsg) diff --git a/pyinst.py b/pyinst.py index eb47b2f..00d6c3e 100644 --- a/pyinst.py +++ b/pyinst.py @@ -17,6 +17,7 @@ add_data = [ "smilies;smilies", "themes;themes", "docs;docs", + "fonts;fonts", "README.md;.", "LICENSE;.", "CHANGELOG.md;.", @@ -28,6 +29,7 @@ data_folders = { "smilies": "smilies", "themes": "themes", "docs": "docs", + "fonts": "fonts", } data_files = { "README.md": "README.md.txt", diff --git a/quirks/gradient.py b/quirks/gradient.py index a814af4..c02b7fe 100644 --- a/quirks/gradient.py +++ b/quirks/gradient.py @@ -56,6 +56,8 @@ def rainbow(text): re.finditer(_smilere, text), re.finditer(_memore, text), re.finditer(_handlere, text), + re.finditer(_alternian_begin, text), + re.finditer(_alternian_end, text), ) for match in match_chain: for color_and_position in colors_and_positions: @@ -161,3 +163,5 @@ _smilere = re.compile("|".join(list(smiledict.keys()))) _urlre = re.compile(r"(?i)(?:^|(?<=\s))(?:(?:https?|ftp)://|magnet:)[^\s]+") _memore = re.compile(r"(\s|^)(#[A-Za-z0-9_]+)") _handlere = re.compile(r"(\s|^)(@[A-Za-z0-9_]+)") +_alternian_begin = re.compile(r"") # Matches get set to alternian font +_alternian_end = re.compile(r"")