|
7 | 7 | import textwrap |
8 | 8 | import threading |
9 | 9 | from .constants import * |
| 10 | +from .utils import * |
10 | 11 |
|
11 | 12 | _C_INIT = False |
12 | 13 |
|
@@ -66,20 +67,7 @@ def displaymsgnodelay(stdscr,message: list): |
66 | 67 | mi += 1 |
67 | 68 | stdscr.addstr(int(y//2+mi),int(x//2-len(msgl)//2),msgl) |
68 | 69 | stdscr.refresh() |
69 | | -def __retr_nbl_lst(input:list)->list: |
70 | | - return [l for l in input if str(l) != ""] |
71 | | -def __calc_nbl_list(input:list)->int: |
72 | | - x = 0 |
73 | | - for ls in input: |
74 | | - x += len(ls) |
75 | | - return x |
76 | 70 |
|
77 | | -def str_contains_word(s:str,string:str) -> bool: |
78 | | - d = s.lower().split(" ") |
79 | | - return string in d |
80 | | - |
81 | | -def list_get_maxlen(l:list) -> int: |
82 | | - return max([len(s) for s in l]) |
83 | 71 |
|
84 | 72 | def coloured_option_menu(stdscr,options:list[str],title="Please choose an option from the list below",colouring=[["back",RED]]) -> int: |
85 | 73 | """An alternate optionmenu that has colours""" |
@@ -215,7 +203,7 @@ def cursesinput(stdscr,prompt: str,lines=1,maxlen=0,passwordchar:str=None,retrem |
215 | 203 |
|
216 | 204 | curses.beep() |
217 | 205 | elif ch == curses.KEY_RIGHT: |
218 | | - if col < len(__retr_nbl_lst(text[ln])): |
| 206 | + if col < len(retr_nbl_lst(text[ln])): |
219 | 207 | col += 1 |
220 | 208 | if col-xoffset > mx-2: |
221 | 209 | xoffset += 1 |
@@ -260,7 +248,7 @@ def cursesinput(stdscr,prompt: str,lines=1,maxlen=0,passwordchar:str=None,retrem |
260 | 248 | stdscr.erase() |
261 | 249 | else: |
262 | 250 | #append |
263 | | - if __calc_nbl_list(text) == maxlen and maxlen != 0: |
| 251 | + if calc_nbl_list(text) == maxlen and maxlen != 0: |
264 | 252 | curses.beep() |
265 | 253 | ERROR = f" You have reached the character limit ({maxlen}) " |
266 | 254 | else: |
@@ -384,34 +372,6 @@ def askyesno_old(stdscr,title: str) -> bool: |
384 | 372 | return True |
385 | 373 | else: |
386 | 374 | return False |
387 | | -_AVAILABLE_COL = list(range(1,255,1)) |
388 | | -_COL_INDEX = {} |
389 | | -def set_colour(background: int, foreground: int) -> int: |
390 | | - global _C_INIT |
391 | | - global _COL_INDEX |
392 | | - global _AVAILABLE_COL |
393 | | - """Set a colour object. Use the constants provided. z |
394 | | - For attributes use | [ATTR] for example set_colour(RED,GREEN) | sdf |
395 | | - """ |
396 | | - if not _C_INIT: |
397 | | - curses.start_color() |
398 | | - curses.use_default_colors() |
399 | | - _C_INIT = True |
400 | | - |
401 | | - if str(foreground) in _COL_INDEX.keys() and str(background) in _COL_INDEX[str(foreground)].keys(): |
402 | | - return curses.color_pair(_COL_INDEX[str(foreground)][str(background)]) |
403 | | - if len(_AVAILABLE_COL) == 0: |
404 | | - raise Warning("Out of colours!") |
405 | | - _AVAILABLE_COL = list(range(1,255,1))#Replenish list |
406 | | - i = _AVAILABLE_COL.pop(0) |
407 | | - curses.init_pair(i,foreground,background) |
408 | | - if not str(foreground) in _COL_INDEX.keys(): |
409 | | - _COL_INDEX[str(foreground)] = {} |
410 | | - _COL_INDEX[str(foreground)][str(background)] = i |
411 | | - return curses.color_pair(i) |
412 | | - |
413 | | -def set_color(background: int,foreground: int) -> int: |
414 | | - return set_colour(background,foreground) |
415 | 375 |
|
416 | 376 | def displayerror(stdscr,e,msg: str): |
417 | 377 | """ |
|
0 commit comments