mirror of
https://github.com/markqvist/NomadNet.git
synced 2025-05-20 06:40:24 -04:00
Added page background and foreground headers to micron
This commit is contained in:
parent
b6e4d8441a
commit
96823c8546
3 changed files with 119 additions and 22 deletions
|
@ -31,20 +31,14 @@ SYNTH_SPECS = {}
|
|||
SECTION_INDENT = 2
|
||||
INDENT_RIGHT = 1
|
||||
|
||||
def markup_to_attrmaps(markup, url_delegate = None):
|
||||
global SELECTED_STYLES
|
||||
if nomadnet.NomadNetworkApp.get_shared_instance().config["textui"]["theme"] == nomadnet.ui.TextUI.THEME_DARK:
|
||||
SELECTED_STYLES = STYLES_DARK
|
||||
else:
|
||||
SELECTED_STYLES = STYLES_LIGHT
|
||||
|
||||
attrmaps = []
|
||||
|
||||
def default_state(fg=None, bg=None):
|
||||
if fg == None: fg = SELECTED_STYLES["plain"]["fg"]
|
||||
if bg == None: bg = DEFAULT_BG
|
||||
state = {
|
||||
"literal": False,
|
||||
"depth": 0,
|
||||
"fg_color": SELECTED_STYLES["plain"]["fg"],
|
||||
"bg_color": DEFAULT_BG,
|
||||
"fg_color": fg,
|
||||
"bg_color": bg,
|
||||
"formatting": {
|
||||
"bold": False,
|
||||
"underline": False,
|
||||
|
@ -54,7 +48,25 @@ def markup_to_attrmaps(markup, url_delegate = None):
|
|||
},
|
||||
"default_align": "left",
|
||||
"align": "left",
|
||||
"default_fg": fg,
|
||||
"default_bg": bg,
|
||||
}
|
||||
return state
|
||||
|
||||
def markup_to_attrmaps(markup, url_delegate = None, fg_color=None, bg_color=None):
|
||||
global SELECTED_STYLES
|
||||
if nomadnet.NomadNetworkApp.get_shared_instance().config["textui"]["theme"] == nomadnet.ui.TextUI.THEME_DARK:
|
||||
SELECTED_STYLES = STYLES_DARK
|
||||
else:
|
||||
SELECTED_STYLES = STYLES_LIGHT
|
||||
|
||||
attrmaps = []
|
||||
|
||||
fgc = None; bgc = DEFAULT_BG
|
||||
if bg_color != None: bgc = bg_color
|
||||
if fg_color != None: fgc = fg_color
|
||||
|
||||
state = default_state(fgc, bgc)
|
||||
|
||||
# Split entire document into lines for
|
||||
# processing.
|
||||
|
@ -73,7 +85,6 @@ def markup_to_attrmaps(markup, url_delegate = None):
|
|||
|
||||
return attrmaps
|
||||
|
||||
import RNS
|
||||
def parse_line(line, state, url_delegate):
|
||||
pre_escape = False
|
||||
if len(line) > 0:
|
||||
|
@ -439,7 +450,6 @@ def make_output(state, line, url_delegate, pre_escape=False):
|
|||
escape = pre_escape
|
||||
skip = 0
|
||||
|
||||
RNS.log(f"Line [ESC {escape}] [MODE {mode}: {line}")
|
||||
for i in range(0, len(line)):
|
||||
c = line[i]
|
||||
if skip > 0:
|
||||
|
@ -458,20 +468,20 @@ def make_output(state, line, url_delegate, pre_escape=False):
|
|||
state["fg_color"] = color
|
||||
skip = 3
|
||||
elif c == "f":
|
||||
state["fg_color"] = SELECTED_STYLES["plain"]["fg"]
|
||||
state["fg_color"] = state["default_fg"]
|
||||
elif c == "B":
|
||||
if len(line) >= i+4:
|
||||
color = line[i+1:i+4]
|
||||
state["bg_color"] = color
|
||||
skip = 3
|
||||
elif c == "b":
|
||||
state["bg_color"] = DEFAULT_BG
|
||||
state["bg_color"] = state["default_bg"]
|
||||
elif c == "`":
|
||||
state["formatting"]["bold"] = False
|
||||
state["formatting"]["underline"] = False
|
||||
state["formatting"]["italic"] = False
|
||||
state["fg_color"] = SELECTED_STYLES["plain"]["fg"]
|
||||
state["bg_color"] = DEFAULT_BG
|
||||
state["fg_color"] = state["default_fg"]
|
||||
state["bg_color"] = state["default_bg"]
|
||||
state["align"] = state["default_align"]
|
||||
elif c == "c":
|
||||
if state["align"] != "center":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue