Rename project to "bowl"
This commit is contained in:
parent
11bd7778cf
commit
c8b495c0e5
33 changed files with 14 additions and 292 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
## Next version
|
## Next version
|
||||||
|
|
||||||
|
- Rename project from "cheuph" to "bowl"
|
||||||
- Clean up code
|
- Clean up code
|
||||||
|
|
||||||
## 0.1.0 (2019-04-12)
|
## 0.1.0 (2019-04-12)
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,12 @@ from .euph_config import EuphConfig, EuphLoader
|
||||||
__all__ = ["DEFAULT_CONFIG_PATHS", "launch"]
|
__all__ = ["DEFAULT_CONFIG_PATHS", "launch"]
|
||||||
|
|
||||||
DEFAULT_CONFIG_PATHS = [
|
DEFAULT_CONFIG_PATHS = [
|
||||||
"~/.config/cheuph/cheuph.yaml",
|
"~/.config/bowl/bowl.yaml",
|
||||||
"~/.cheuph/cheuph.yaml",
|
"~/.bowl/bowl.yaml",
|
||||||
"~/.cheuph.yaml",
|
"~/.bowl.yaml",
|
||||||
]
|
]
|
||||||
|
|
||||||
GITHUB_URL = "https://github.com/Garmelon/cheuph"
|
GITHUB_URL = "https://github.com/Garmelon/bowl"
|
||||||
|
|
||||||
def parse_arguments() -> argparse.Namespace:
|
def parse_arguments() -> argparse.Namespace:
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
8
setup.py
8
setup.py
|
|
@ -1,15 +1,15 @@
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="cheuph",
|
name="bowl",
|
||||||
version="0.0.1",
|
version="0.0.1",
|
||||||
packages=[
|
packages=[
|
||||||
"cheuph",
|
"bowl",
|
||||||
"cheuph.euphoria",
|
"bowl.euphoria",
|
||||||
],
|
],
|
||||||
entry_points={
|
entry_points={
|
||||||
"console_scripts": [
|
"console_scripts": [
|
||||||
"cheuph = cheuph.euphoria:launch_single_room_application",
|
"bowl = bowl.euphoria:launch_single_room_application",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
install_requires=[
|
install_requires=[
|
||||||
|
|
|
||||||
80
test.py
80
test.py
|
|
@ -1,80 +0,0 @@
|
||||||
import curses
|
|
||||||
import subprocess
|
|
||||||
import tempfile
|
|
||||||
from typing import Any, List, Optional
|
|
||||||
|
|
||||||
from cheuph.element import Element, Id, RenderedElement
|
|
||||||
from cheuph.element_supply import MemoryElementSupply
|
|
||||||
from cheuph.markup import AttributedText
|
|
||||||
from cheuph.tree_display import TreeDisplay
|
|
||||||
|
|
||||||
|
|
||||||
class TestElement(Element):
|
|
||||||
DEPTHSTR = "| "
|
|
||||||
|
|
||||||
def __init__(self,
|
|
||||||
id: Id,
|
|
||||||
parent_id: Optional[Id],
|
|
||||||
text: List[str],
|
|
||||||
) -> None:
|
|
||||||
|
|
||||||
super().__init__(id, parent_id)
|
|
||||||
self.text = text
|
|
||||||
|
|
||||||
def render(self,
|
|
||||||
width: int,
|
|
||||||
depth: int,
|
|
||||||
highlighted: bool = False,
|
|
||||||
folded: bool = False,
|
|
||||||
) -> RenderedElement:
|
|
||||||
|
|
||||||
depth_text = self.DEPTHSTR * depth
|
|
||||||
lines = [f"{depth_text}{line}" for line in self.text]
|
|
||||||
attributed_lines = [AttributedText(line) for line in lines]
|
|
||||||
return RenderedElement(self, attributed_lines)
|
|
||||||
|
|
||||||
def main(stdscr: Any) -> None:
|
|
||||||
messages = MemoryElementSupply()
|
|
||||||
messages.add(TestElement("a", None, ["test element a"]))
|
|
||||||
messages.add(TestElement("b", "a", ["test element b","child of a"]))
|
|
||||||
messages.add(TestElement("c", None, ["test element c"]))
|
|
||||||
|
|
||||||
display = TreeDisplay(messages, 80, 15)
|
|
||||||
display.anchor_id = "a"
|
|
||||||
display.anchor_offset = 5
|
|
||||||
|
|
||||||
display.rerender()
|
|
||||||
display.render_display_lines()
|
|
||||||
|
|
||||||
print("-"*80)
|
|
||||||
for line in display.display_lines:
|
|
||||||
print(str(line))
|
|
||||||
print("-"*80)
|
|
||||||
|
|
||||||
# while True:
|
|
||||||
# key = stdscr.getkey()
|
|
||||||
#
|
|
||||||
# if key in {"\x1b", "q"}:
|
|
||||||
# return
|
|
||||||
#
|
|
||||||
# elif key == "e":
|
|
||||||
# with tempfile.TemporaryDirectory() as tmpdirname:
|
|
||||||
# tmpfilename = tmpdirname + "/" + "tempfile"
|
|
||||||
# #stdscr.addstr(f"{curses.COLOR_PAIRS!r}\n")
|
|
||||||
# stdscr.addstr(f"{tmpdirname!r} | {tmpfilename!r}\n")
|
|
||||||
#
|
|
||||||
# stdscr.getkey()
|
|
||||||
#
|
|
||||||
# curses.endwin()
|
|
||||||
# subprocess.run(["nvim", tmpfilename])
|
|
||||||
# stdscr.refresh()
|
|
||||||
#
|
|
||||||
# stdscr.getkey()
|
|
||||||
#
|
|
||||||
# with open(tmpfilename) as f:
|
|
||||||
# for line in f:
|
|
||||||
# stdscr.addstr(line)
|
|
||||||
|
|
||||||
|
|
||||||
#curses.wrapper(main)
|
|
||||||
main(None)
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import cheuph
|
from bowl import CursorTreeRenderer
|
||||||
|
|
||||||
__all__ = ["TestCursorTreeRenderer"]
|
__all__ = ["TestCursorTreeRenderer"]
|
||||||
|
|
||||||
class TestCursorTreeRenderer(unittest.TestCase):
|
class TestCursorTreeRenderer(unittest.TestCase):
|
||||||
|
|
||||||
def test_static_offset(self):
|
def test_static_offset(self):
|
||||||
gao = cheuph.CursorTreeRenderer.get_absolute_offset
|
gao = CursorTreeRenderer.get_absolute_offset
|
||||||
gro = cheuph.CursorTreeRenderer.get_relative_offset
|
gro = CursorTreeRenderer.get_relative_offset
|
||||||
|
|
||||||
self.assertEqual(0, gao(0.0, 6))
|
self.assertEqual(0, gao(0.0, 6))
|
||||||
self.assertEqual(1, gao(0.2, 6))
|
self.assertEqual(1, gao(0.2, 6))
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from cheuph import AT
|
from bowl import AT
|
||||||
|
|
||||||
__all__ = ["TestAttributedText"]
|
__all__ = ["TestAttributedText"]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from cheuph import Element, RenderedElementCache
|
from bowl import Element, RenderedElementCache
|
||||||
|
|
||||||
__all__ = ["TestRenderedElementCache"]
|
__all__ = ["TestRenderedElementCache"]
|
||||||
|
|
||||||
|
|
|
||||||
2
test_scripts/.gitignore
vendored
2
test_scripts/.gitignore
vendored
|
|
@ -1,2 +0,0 @@
|
||||||
cheuph
|
|
||||||
yaboli
|
|
||||||
|
|
@ -1,60 +0,0 @@
|
||||||
import urwid
|
|
||||||
import urwid.curses_display
|
|
||||||
|
|
||||||
import cheuph
|
|
||||||
from cheuph import AT, AttributedLines, AttributedLinesWidget
|
|
||||||
|
|
||||||
|
|
||||||
class TestWidget(urwid.WidgetWrap):
|
|
||||||
def __init__(self):
|
|
||||||
long_line = AT("super", style="red")
|
|
||||||
long_line += AT(" long", style="cyan")
|
|
||||||
long_line += AT(" line", style="magenta")
|
|
||||||
lines = [
|
|
||||||
({}, AT("abc", style="green")),
|
|
||||||
({"style": "blue"}, AT("Hello world")),
|
|
||||||
({}, AT(" ").join([long_line] * 10)),
|
|
||||||
]
|
|
||||||
self.lines = AttributedLinesWidget(AttributedLines(lines))
|
|
||||||
super().__init__(self.lines)
|
|
||||||
|
|
||||||
def selectable(self):
|
|
||||||
return True
|
|
||||||
|
|
||||||
def keypress(self, size, key):
|
|
||||||
if key == "left":
|
|
||||||
self.lines.horizontal_offset -= 1
|
|
||||||
elif key == "right":
|
|
||||||
self.lines.horizontal_offset += 1
|
|
||||||
elif key == "home":
|
|
||||||
self.lines.horizontal_offset = 0
|
|
||||||
elif key == "up":
|
|
||||||
self.lines.upper_offset += 1
|
|
||||||
elif key == "down":
|
|
||||||
self.lines.upper_offset -= 1
|
|
||||||
|
|
||||||
def mouse_event(self, size, event, button, col, row, focus):
|
|
||||||
if event == "mouse press":
|
|
||||||
if button == 4:
|
|
||||||
self.lines.upper_offset += 1
|
|
||||||
if button == 5:
|
|
||||||
self.lines.upper_offset -= 1
|
|
||||||
|
|
||||||
def main():
|
|
||||||
screen = urwid.curses_display.Screen()
|
|
||||||
palette = [
|
|
||||||
("red", "light red", ""),
|
|
||||||
("yellow", "yellow", ""),
|
|
||||||
("green", "light green", ""),
|
|
||||||
("blue", "light blue", ""),
|
|
||||||
("magenta", "light magenta", ""),
|
|
||||||
("cyan", "light cyan", ""),
|
|
||||||
]
|
|
||||||
loop = urwid.MainLoop(
|
|
||||||
TestWidget(),
|
|
||||||
screen=screen,
|
|
||||||
palette=palette,
|
|
||||||
)
|
|
||||||
loop.run()
|
|
||||||
|
|
||||||
main()
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
import urwid
|
|
||||||
import urwid.curses_display
|
|
||||||
|
|
||||||
import cheuph
|
|
||||||
from cheuph import AT, AttributedTextWidget
|
|
||||||
|
|
||||||
|
|
||||||
class TestWidget(urwid.WidgetWrap):
|
|
||||||
def __init__(self):
|
|
||||||
text = AT("Hello world!\nThis is some text.\nThird line.")
|
|
||||||
self.text = AttributedTextWidget(text)
|
|
||||||
self.filler = urwid.Filler(self.text)
|
|
||||||
super().__init__(self.filler)
|
|
||||||
|
|
||||||
def main():
|
|
||||||
screen = urwid.curses_display.Screen()
|
|
||||||
loop = urwid.MainLoop(TestWidget(), screen=screen)
|
|
||||||
loop.run()
|
|
||||||
|
|
||||||
main()
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
import urwid
|
|
||||||
import urwid.curses_display
|
|
||||||
|
|
||||||
class TestWidget(urwid.WidgetWrap):
|
|
||||||
KEY_LIMIT = 10
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.last_keys = []
|
|
||||||
self.text = urwid.Text("No key pressed yet", align=urwid.CENTER)
|
|
||||||
self.filler = urwid.Filler(self.text)
|
|
||||||
super().__init__(self.filler)
|
|
||||||
|
|
||||||
def selectable(self):
|
|
||||||
return True
|
|
||||||
|
|
||||||
def keypress(self, size, key):
|
|
||||||
self.last_keys.append(repr(key))
|
|
||||||
self.last_keys = self.last_keys[-self.KEY_LIMIT:]
|
|
||||||
self.text.set_text("\n".join(self.last_keys))
|
|
||||||
|
|
||||||
def mouse_event(self, size, event, button, col, row, focus):
|
|
||||||
self.last_keys.append(f"{event!r} {button!r} ({row}, {col})")
|
|
||||||
self.last_keys = self.last_keys[-self.KEY_LIMIT:]
|
|
||||||
self.text.set_text("\n".join(self.last_keys))
|
|
||||||
|
|
||||||
def main():
|
|
||||||
screen = urwid.curses_display.Screen()
|
|
||||||
loop = urwid.MainLoop(TestWidget(), screen=screen)
|
|
||||||
loop.run()
|
|
||||||
|
|
||||||
main()
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
import urwid
|
|
||||||
import urwid.curses_display
|
|
||||||
|
|
||||||
import cheuph
|
|
||||||
from cheuph import AT, AttributedTextWidget
|
|
||||||
from cheuph.euphoria.room_widget import RoomLayout
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
widget = RoomLayout(
|
|
||||||
AttributedTextWidget(AT("&test"), align=urwid.CENTER),
|
|
||||||
urwid.SolidFill("n"),
|
|
||||||
urwid.SolidFill("t"),
|
|
||||||
AttributedTextWidget(AT("edit\ning")),
|
|
||||||
nick_list_width = 15,
|
|
||||||
border_attrs = {"style": "dim"},
|
|
||||||
)
|
|
||||||
widget.set_edit_visible(True)
|
|
||||||
palette = [
|
|
||||||
("dim", "dark gray,bold", ""),
|
|
||||||
]
|
|
||||||
screen = urwid.curses_display.Screen()
|
|
||||||
loop = urwid.MainLoop(
|
|
||||||
widget,
|
|
||||||
palette=palette,
|
|
||||||
#screen=screen,
|
|
||||||
)
|
|
||||||
loop.run()
|
|
||||||
|
|
||||||
main()
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
import datetime
|
|
||||||
|
|
||||||
import urwid
|
|
||||||
import urwid.curses_display
|
|
||||||
|
|
||||||
import cheuph
|
|
||||||
from cheuph import (AT, BasicCursorRenderer, CursorTreeRenderer,
|
|
||||||
CursorTreeWidget, InMemorySupply, Message)
|
|
||||||
|
|
||||||
|
|
||||||
def add(supply, level, text, amount=4):
|
|
||||||
t = datetime.datetime(2019, 5, 7, 13, 25, 6)
|
|
||||||
if level < 0: return
|
|
||||||
for i in range(amount):
|
|
||||||
new_text = f"{text}->{i}"
|
|
||||||
supply.add(Message(new_text, text or None, t, str(i), new_text))
|
|
||||||
add(supply, level - 1, new_text, amount=amount)
|
|
||||||
|
|
||||||
def main():
|
|
||||||
s = InMemorySupply()
|
|
||||||
r = BasicCursorRenderer()
|
|
||||||
t = CursorTreeRenderer(s, r)
|
|
||||||
|
|
||||||
add(s, 4, "")
|
|
||||||
|
|
||||||
#screen = urwid.curses_display.Screen()
|
|
||||||
event_loop = urwid.AsyncioEventLoop()
|
|
||||||
loop = urwid.MainLoop(
|
|
||||||
cheuph.CursorTreeWidget(t),
|
|
||||||
#screen=screen,
|
|
||||||
event_loop=event_loop,
|
|
||||||
)
|
|
||||||
loop.run()
|
|
||||||
|
|
||||||
main()
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
import asyncio
|
|
||||||
import logging
|
|
||||||
from typing import List, Optional
|
|
||||||
|
|
||||||
import urwid
|
|
||||||
|
|
||||||
from cheuph.euphoria.single_room_application import SingleRoomApplication
|
|
||||||
|
|
||||||
logging.disable()
|
|
||||||
|
|
||||||
def main():
|
|
||||||
loop = asyncio.get_event_loop()
|
|
||||||
main_loop = urwid.MainLoop(
|
|
||||||
SingleRoomApplication(),
|
|
||||||
event_loop=urwid.AsyncioEventLoop(loop=loop),
|
|
||||||
)
|
|
||||||
|
|
||||||
main_loop.run()
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue