Page MenuHomePhorge

No OneTemporary

diff --git a/CHANGELOG b/CHANGELOG
index 7d67039..9b0d658 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,65 +1,67 @@
Copyright (C) 2022 LANNOCC (Shawn A. Wilson [lannocc@yahoo.com])
@%@~LICENSE:MIT~@%@
+saw_081022_1 - "Big F.S."
+
saw_080822_2 - Version bump. Tested on Linux and Win7.
saw_080822_1 - Big font option.
saw_080322_1 - Update README.
saw_080222_3 - Fix curses screen refresh. Add some debugging.
saw_080222_2 - New matrix method mostly working now.
saw_080222_1 - Working on new matrix-based universal screen mapping.
saw_080122_3 - Start to play with multiple windows.
saw_080122_2 - Let run() be wrapped. User setup should happen in init().
saw_080122_1 - Fix for python 3.8.
saw_073122_3 - Fix ctrl-c interrupt on Windows.
saw_073122_2 - Tested and working on Linux and Win7.
saw_073122_1 - Text scrolling and justification, window resizing.
saw_073022_10 - Linux: Improved mouse responsiveness.
saw_073022_9 - Windows: Fix unreliable mouse position while scrolling.
saw_073022_8 - Version bump: tested on Linux and Win7.
saw_073022_7 - Window movement (Windows).
saw_073022_6 - Window movement (Linux).
saw_073022_5 - Version bump: tested on Linux and Win7.
saw_073022_4 - Print containment on Windows.
saw_073022_3 - Normalized mouse input across platforms.
saw_073022_2 - Mouse input on Windows.
saw_073022_1 - Input wrangling and exception propagation.
saw_072922_3 - Version bump: tested on Linux and Win7.
saw_072922_2 - Beginning Windows backend.
saw_072922_1 - A possible approach to multiple backends.
saw_072822_6 - Some window fun.
saw_072822_5 - Bump version for pip platform dependency test.
saw_072822_4 - Test commit (turned on GPG sign in Windows).
saw_072822_3 - Add Windows support to mouse test script.
saw_072822_2 - Add a mouse test script.
saw_072822_1 - Initial commit (just termio.py from my vipy project).
diff --git a/appscii/__main__.py b/appscii/__main__.py
index 8faa381..0a19fff 100644
--- a/appscii/__main__.py
+++ b/appscii/__main__.py
@@ -1,47 +1,47 @@
from . import *
def run():
app = Application()
try:
win1 = Window(app, 30, 5, 42, 9)
win1.text.word_wrap()
win1.text.top()
win1.text.print('ESC to quit.')
win1.text.print('Click drag and scroll to test mouse.')
win1.text.print()
win1.text.print("Here's something. ", enter=False)
win1.text.print('And this continues the previous print and also wraps.')
for i in range(1, 11):
win1.text.print()
win1.text.print(i, enter=False)
win1.text.print('. This is a line of text that goes and continues' \
+ ' and keeps going some more just to see how it all works.')
win2 = Window(app, 3, 3, 22, 3)
win2.text.print('something else')
- win3 = Window(app, 9, 18, 60, 5)
- win3.text.big()
- win3.text.print('Big Font Style')
+ win3 = Window(app, 9, 18, 42, 5)
+ win3.text.big('caps')
+ win3.text.print('big fONT sTYLE')
def on_run():
while app.go:
app.sleep(1)
win1.text.center()
app.sleep(1)
win1.text.right()
app.sleep(1)
win1.text.left()
app.on_run = on_run
#raise RuntimeError('__main__ test')
app.run()
finally:
app.exit()
if __name__ == '__main__':
run()
diff --git a/appscii/__version__.py b/appscii/__version__.py
index 831fd7f..b7b6da0 100644
--- a/appscii/__version__.py
+++ b/appscii/__version__.py
@@ -1,2 +1,2 @@
-__version__ = '0.1.2'
+__version__ = '0.1.3'
diff --git a/appscii/font/big_only_caps.py b/appscii/font/big_only_caps.py
new file mode 100644
index 0000000..56f6279
--- /dev/null
+++ b/appscii/font/big_only_caps.py
@@ -0,0 +1,7 @@
+# limit to codepage 437 symbols:
+from . import big
+
+matrix = big.matrix
+
+chars = dict(filter(lambda ci: ci[0].islower(), big.chars.items()))
+
diff --git a/appscii/helper.py b/appscii/helper.py
index 62d6d31..118a067 100644
--- a/appscii/helper.py
+++ b/appscii/helper.py
@@ -1,223 +1,230 @@
-from .font import big as big_font
+from .font import big as big_font, big_only_caps as big_caps
class FlowText:
def __init__(self, w, h, notify=None, words=False, align=-1, big=False):
assert w >= 0 and h >= 0
self.w = w
self.h = h
self.notify = notify
self.words = words
self.align = align
- self.font = 1 if big else 0
+ self.font = 2 if big=='caps' else 1 if big else 0
self.prints = [ ]
self.enter = True
self.lines = [ ]
self.scroll = -1
self.flow = (0, 0)
def resize(self, w, h):
assert w >= 0 and h >= 0
if w == self.w and h == self.h: return
self.h = h
if w != self.w:
self.w = w
self.reflow(True)
else:
if self.notify: self.notify(self)
def word_wrap(self, words=None):
if words is None:
self.words = not self.words
self.reflow(True)
elif words != self.words:
self.words = words
self.reflow(True)
def left(self):
if self.align == -1: return
self.align = -1
if self.notify: self.notify(self)
def center(self):
if self.align == 0: return
self.align = 0
if self.notify: self.notify(self)
def right(self):
if self.align == 1: return
self.align = 1
if self.notify: self.notify(self)
def top(self):
if self.scroll == 0: return
self.scroll = 0
if self.notify: self.notify(self)
def bottom(self):
if self.scroll < 0: return
self.scroll = -1
if self.notify: self.notify(self)
def up(self, lines=1):
assert lines > 0
if self.scroll == 0: return
diff = len(self.lines) - self.h
if diff > 0:
self.scroll -= lines
if self.scroll > diff:
self.scroll = diff
elif self.scroll < 0:
self.scroll = 0
else:
self.scroll = 0
if self.notify: self.notify(self)
def down(self, lines=1):
assert lines > 0
if self.scroll < 0: return
diff = len(self.lines) - self.h
if diff > 0:
self.scroll += lines
if self.scroll > diff:
self.scroll = diff
else:
self.scroll = -1
if self.notify: self.notify(self)
def big(self, big=True):
- font = 1 if big else 0
+ font = 2 if big=='caps' else 1 if big else 0
if self.font == font: return
self.font = font
def print(self, txt='', enter=True):
if not isinstance(txt, str):
txt = f'{txt}'
prints = [ ]
while '\n' in txt:
idx = txt.index('\n')
prints.append(txt[:idx])
txt = txt[idx+1:]
prints.append(txt)
- if self.font == 1:
+ if self.font:
fprints = [ ]
- h = len(big_font.matrix)
+ if self.font == 1:
+ font = big_font
+ elif self.font == 2:
+ font = big_caps
+ else:
+ raise NotImplementedError(f'font type {self.font}')
+
+ h = len(font.matrix)
for line in prints:
- fprints.extend([ '' for y in big_font.matrix ])
+ fprints.extend([ '' for y in font.matrix ])
for c in line:
- if c in big_font.chars:
+ if c in font.chars:
if fprints[-1]:
for y in range(h):
fprints[-(h-y)] += ' '
- x, w = big_font.chars[c]
- for y, row in enumerate(big_font.matrix):
+ x, w = font.chars[c]
+ for y, row in enumerate(font.matrix):
fprints[-(h-y)] += row[x:x+w]
else:
for y in range(h-1):
fprints[-(h-y)] += ' '
fprints[-1] += c
prints = fprints
if self.enter:
self.prints.extend(prints)
else:
self.prints[-1] += prints[0]
self.prints.extend(prints[1:])
self.enter = enter
self.reflow()
def reflow(self, reset=False):
if reset:
self.flow = (0, 0)
if self.w < 1 or self.h < 1:
return
if self.flow[0] and self.flow[1]:
self.lines = self.lines[:self.flow[1]]
elif self.lines:
self.lines = [ ]
for entry in self.prints[self.flow[0]:]:
while len(entry) > self.w:
chunk = entry[:self.w]
if self.words and entry[self.w] != ' ' and chunk[-1] != ' ' \
and ' ' in chunk:
idx = chunk.rindex(' ')
chunk = entry[:idx]
entry = entry[idx+1:]
else:
entry = entry[self.w:]
self.lines.append(chunk)
self.lines.append(entry)
if self.enter:
self.flow = (len(self.prints), len(self.lines))
else:
self.flow = (len(self.prints) - 1, len(self.lines) - 1)
if self.notify:
self.notify(self)
def view(self):
if self.w < 1 or self.h < 1:
return None
if self.scroll < 0:
showing = self.lines[-self.h:]
else:
showing = self.lines[self.scroll:self.scroll+self.h]
while len(showing) < self.h:
showing.append('')
if self.align < 0: # left
return [ line + ' ' * (self.w - len(line)) for line in showing ]
elif self.align > 0: # right
return [ ' ' * (self.w - len(line)) + line for line in showing ]
else: # center
view = [ ]
lpad = True
for line in showing:
diff = self.w - len(line)
if diff:
left = ' ' * (diff // 2)
right = left
if diff % 2:
if lpad: left += ' '
else: right += ' '
lpad = not lpad
view.append(left + line + right)
else:
view.append(line)
return view

File Metadata

Mime Type
text/x-diff
Expires
Sat, Sep 12, 4:29 PM (2 w, 6 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3495
Default Alt Text
(10 KB)

Event Timeline