great update # aber komme mit wuffels parrable funktion nicht klar
This commit is contained in:
parent
e49d31babc
commit
d4aa1c12bb
16 changed files with 542 additions and 74 deletions
2
tengine/README.md
Normal file
2
tengine/README.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
# A little Text Engine for Cowyeet
|
||||
|
BIN
tengine/__pycache__/main.cpython-311.pyc
Normal file
BIN
tengine/__pycache__/main.cpython-311.pyc
Normal file
Binary file not shown.
BIN
tengine/__pycache__/tengine.cpython-311.pyc
Normal file
BIN
tengine/__pycache__/tengine.cpython-311.pyc
Normal file
Binary file not shown.
50
tengine/main.py
Normal file
50
tengine/main.py
Normal file
|
@ -0,0 +1,50 @@
|
|||
#!/bin/python3
|
||||
from os import get_terminal_size
|
||||
tx,ty = get_terminal_size().columns ,get_terminal_size().lines
|
||||
|
||||
def genfeld():
|
||||
return [[' ' for _ in range(tx)] for _ in range(ty)]
|
||||
|
||||
def bg_char(feld, char=' '):
|
||||
for a in range(len(feld)):
|
||||
for b in range(len(feld[0])):
|
||||
feld[a][b] = char
|
||||
return feld
|
||||
|
||||
def strfeld(feld):
|
||||
return '\n'.join([''.join(row) for row in feld])
|
||||
|
||||
def change_char(feld, character, position):
|
||||
feld[position[0]][position[1]] = character
|
||||
|
||||
def change_block(feld, block, position):
|
||||
position = [position[0]+1,position[1]]
|
||||
pposition = position
|
||||
for zeichen in block:
|
||||
if zeichen == '\n':
|
||||
pposition = [pposition[0] + 1, position[1]]
|
||||
else:
|
||||
pposition = [pposition[0], pposition[1] + 1]
|
||||
feld[pposition[0]][pposition[1]] = zeichen
|
||||
return feld
|
||||
|
||||
def clear():
|
||||
print('\033c', end='')
|
||||
|
||||
def draw_border(feld, border_char='+'):
|
||||
for i in range(len(feld)):
|
||||
feld[i][0] = feld[i][-1] = border_char
|
||||
for j in range(len(feld[0])):
|
||||
feld[0][j] = feld[-1][j] = border_char
|
||||
global tx,ty
|
||||
tx -= 2;ty -= 2
|
||||
return feld
|
||||
|
||||
#def move_cursor(x, y):
|
||||
# print(f'\033[{y};{x}H', end='')
|
||||
|
||||
def viereck(feld, start_pos, width, height, fill_char='#'):
|
||||
for i in range(height):
|
||||
for j in range(width):
|
||||
feld[start_pos[0] + i][start_pos[1] + j] = fill_char
|
||||
return feld
|
14
tengine/test.py
Normal file
14
tengine/test.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
import forgejo.cowyeet_terminal.tengine.main as main
|
||||
feld = main.genfeld()
|
||||
|
||||
block = "halli\nhallo\nfurz"
|
||||
block2 = """halli
|
||||
hallouuuuuuuuuuuuu
|
||||
furz"""
|
||||
|
||||
feld = main.bg_char(feld,"#")
|
||||
#feld = tengine.draw_border(feld)
|
||||
feld = main.change_block(feld,block2,[2,2])
|
||||
#feld = tengine.viereck(feld,[1,1],4,4,"-")
|
||||
print(main.strfeld(feld))
|
||||
#tengine.clear_screen()
|
Loading…
Add table
Add a link
Reference in a new issue