diff --git a/.gitignore b/.gitignore
index 485dee6..e04276f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
.idea
+venv
diff --git a/.idea/kls.iml b/.idea/kls.iml
index d0876a7..17a1594 100644
--- a/.idea/kls.iml
+++ b/.idea/kls.iml
@@ -2,7 +2,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index a6218fe..092c1db 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,5 +3,5 @@
-
+
\ No newline at end of file
diff --git a/a.out b/a.out
new file mode 100755
index 0000000..3e2a6d9
Binary files /dev/null and b/a.out differ
diff --git a/c_kls.c b/c_kls.c
new file mode 100644
index 0000000..c7dec08
--- /dev/null
+++ b/c_kls.c
@@ -0,0 +1,20 @@
+#include
+
+int main()
+{
+ initscr(); /* Start curses mode */
+ printw("Hello World !!!\n"); /* Print Hello World */
+ refresh(); /* Print it on to the real screen */
+ def_shell_mode(); /* Save the tty modes */
+ endwin(); /* End curses mode temporarily */
+ system("vim"); /* Do whatever you like in cooked mode */
+ reset_shell_mode(); /* Return to the previous tty mode*/
+ /* stored by def_prog_mode() */
+ refresh(); /* Do refresh() to restore the */
+ /* Screen contents */
+ printw("Another String\n"); /* Back to curses use the full */
+ refresh(); /* capabilities of curses */
+ endwin(); /* End curses mode */
+
+ return 0;
+}
diff --git a/kls b/kls
index 5bbd9c1..16ea5a5 100755
--- a/kls
+++ b/kls
@@ -2,8 +2,9 @@
import curses
import subprocess
-stdscr = None
-curses.set_escdelay(1) # в curses зачем-то сделали задержку на срабатывание Escape, уменьшаем её до 1 милисекунды (до 0 нельзя)
+screen = None
+# в curses зачем-то сделали задержку на срабатывание Escape, уменьшаем её до 1 милисекунды (до 0 нельзя)
+curses.set_escdelay(1)
running = True
# состояния меню
@@ -15,12 +16,12 @@ NOT_SELECTED_WITH_SEARCH = 4
# я не знаю, что делается в этой функции.
def init_screen():
- global stdscr
- stdscr = curses.initscr()
- stdscr.refresh()
+ global screen
+ screen = curses.initscr()
+ screen.refresh()
curses.noecho()
curses.cbreak()
- stdscr.keypad(True)
+ screen.keypad(True)
curses.curs_set(0)
@@ -66,24 +67,8 @@ menu3 = Menu("Resources", pods, 0 + curses.COLS // 3 * 2, NOT_SELECTED_WITHOUT_S
menus = [menu1, menu2, menu3]
-# def run_command(command, menu, rows=None):
-# namespace = menu1.rows[menu1.row]
-# api_resource = menu2.rows[menu2.row]
-# resource = menu3.rows[menu3.row]
-# subprocess.call(eval(command), shell=True)
-# init_screen()
-# for menu in menus:
-# menu.win.clear()
-# menu.win.box()
-# menu.win.addstr(1, 2, menu.name)
-# menu.win.addstr(curses.LINES - 2, 2, menu.filter)
-# if rows and menu.name == "Resources":
-# menu.rows = rows
-# menu.row = 0
-# for index, row in enumerate(menu.rows):
-# menu.win.addstr(index + 3, 2, row)
-# menu.win.addstr(menu.row + 3, 2, menu.rows[menu.row], curses.A_REVERSE | curses.A_ITALIC)
-# menu.win.addstr(1, 2, menu.name, curses.A_REVERSE | curses.A_ITALIC)
+def run_command(command):
+ subprocess.call(eval(command), shell=True)
def update_menu3():
@@ -108,6 +93,7 @@ def draw_menu(menu):
draw_rows(menu) # рисуем строки меню
draw_search_box(menu) # рисуем строку поиска
+
def draw_header(menu):
if menu.state in [1, 2]:
menu.win.addstr(1, 2, menu.name, curses.A_REVERSE | curses.A_ITALIC)
@@ -140,7 +126,7 @@ def draw_search_box(menu):
def catch_input(menu):
global running
- key_pressed = stdscr.getkey()
+ key_pressed = screen.getkey()
match key_pressed:
case "/":
menu.state = SELECTED_WITH_SEARCH
@@ -173,6 +159,25 @@ def catch_input(menu):
navigate_vertically("down", menu)
case "KEY_UP":
navigate_vertically("up", menu)
+ case 'g':
+ if menu3.state in [1, 2]:
+ # update_menu3()
+ if menu3.rows:
+ if not menu3.rows[menu3.row].startswith("No resources"):
+ curses.def_shell_mode()
+ curses.endwin()
+ command = "f'kubectl -n {menu1.rows[menu1.row]} get {menu2.rows[menu2.row]} {menu3.rows[menu3.row]} -o yaml | batcat -l yaml --paging always --style numbers'"
+ run_command(command)
+ curses.reset_shell_mode()
+ # case 'd':
+ # if current_menu == 2 and not menus[2].rows[menus[2].row].startswith("No resources"):
+ # run_command("f'kubectl -n {namespace} describe {api_resource} {resource} | batcat -l yaml --paging always --style numbers'", current_menu)
+ # case 'l':
+ # if current_menu == 2 and not menus[2].rows[menus[2].row].startswith("No resources") and menus[1].rows[menus[1].row] == "pods":
+ # run_command("f'kubectl -n {namespace} logs {resource} | batcat -l log --paging always --style numbers'", current_menu)
+ # case 'e':
+ # if current_menu == 2 and not menus[2].rows[menus[2].row].startswith("No resources"):
+ # run_command("f'kubectl edit {api_resource} -n {namespace} {resource}'", current_menu)
case _:
if menu.state == SELECTED_WITH_SEARCH and key_pressed.isalpha() or key_pressed == "-": # объекты в кубе не могут иметь иных символов кроме a-z и -
menu.filter += key_pressed
@@ -213,9 +218,9 @@ def navigate_vertically(direction, menu):
menu.win.addstr(menu.row + 3, 2, filtered_rows[menu.row], curses.A_REVERSE | curses.A_ITALIC) # и выделяем её
-def main(stdscr):
+def main(screen):
global running
- stdscr.refresh()
+ screen.refresh()
# начальный экран
for menu in menus:
draw_menu(menu)
@@ -407,12 +412,12 @@ def main(stdscr):
# navigate_vertically("down", current_menu)
# case "KEY_UP":
# navigate_vertically("up", current_menu)
-# main(stdscr)
-curses.wrapper(main)
+main(screen)
+# curses.wrapper(main)
-# curses.nocbreak()
-# stdscr.keypad(False)
-# curses.echo()
-# curses.endwin()
-# subprocess.call(["clear"])
+curses.nocbreak()
+screen.keypad(False)
+curses.echo()
+curses.endwin()
+subprocess.call(["clear"])
#