Beispiel #1
0
def Shellmain():
    normalMode = ShellModes(0, "Normal", [])
    insertMode = ShellModes(1, "Insert", [])
    ReplaceMode = ShellModes(2, "Replace", [])
    CommandMode = ShellModes(3, "Command", [])
    clear()
    ShellDraw.reload_all()
    while True:
        key = getKey(debug=True)
        sys.stdout.write("\033[0;0H")
        # print(get_key_bytes(True))
        if ShellModes.currentMode == 0:  # Normal Mode
            ShellModes.all_mode(key)
            ShellModes.normal_mode(key)
            ShellModes.normal_insert_mode(key)
        elif ShellModes.currentMode == 1:
            ShellModes.all_mode(key)
            ShellModes.insert_mode(key)
            ShellModes.normal_insert_mode(key)
        elif ShellModes.currentMode == 2:
            ShellModes.all_mode(key)
        elif ShellModes.currentMode == 3:
            ShellModes.all_mode(key)
        ShellDraw.cursor_key()
        sys.stdout.flush()
Beispiel #2
0
def launch():
    print("---")
    print("1: demineur terminal")
    print("2: conter le nombre de lignes")
    print("3: graphical demineur")
    print("4: terminal snake")
    print("---")
    menu = input("Menu: ")
    # TODO match
    if menu == "1":
        clear()
        demineur()
    if menu == "2":
        print("---")
        print("1: file")
        print("2: folder")
        print("---")
        menu = input("Menu : ")
        if menu == "1":
            print(count_number_of_lines_in_file(input("Nom de fichier: ")))
        if menu == "2":
            print("---")
            print("1: match")
            print("2: all match at racine")
            print("---")
            menu = input("Menu : ")
            if menu == "1":
                count_number_of_lines_in_folder(input("folder"),
                                                input("match"))
            elif menu == "2":
                print("DOSSIER " + str(os.getcwd()) + "/../")
                print(
                    "All Ext\t",
                    count_number_of_lines_in_folder(
                        "../", "(.py$|.md$|.png$|.txt$|LICENCE|.json$)"),
                    "\t Pour être plus précis: (.py$|.md$|.png$|.txt$|LICENCE|.json$)"
                )
                print("py$ md$\t",
                      count_number_of_lines_in_folder("../", "(.py$|.md$)"))
                print("py$\t", count_number_of_lines_in_folder("../", ".py$"))
    if menu == "3":
        import main_minesweeper
        import os
        os.chdir("./resources")
        main_minesweeper.Main.start()
    if menu == "4":
        import main_terminalsnake
        debug = False
        main_terminalsnake.main()
Beispiel #3
0
def launch():
    print("---")
    print("1: demineur terminal")
    print("2: conter le nombre de lignes")
    print("---")
    menu = input("Menu: ")
    # TODO match
    if menu == "1":
        clear()
        demineur()
    if menu == "2":
        print("---")
        print("1: file")
        print("2: folder")
        print("---")
        menu = input("Menu : ")
        if menu == "1":
            print(count_number_of_lines_in_file(input("Nom de fichier: ")))
        if menu == "2":
            print("---")
            print("1: match")
            print("2: all match at racine")
            print("---")
            menu = input("Menu : ")
            if menu == "1":
                count_number_of_lines_in_folder(input("folder"),
                                                input("match"))
            elif menu == "2":
                print("DOSSIER " + str(os.getcwd()) + "/../")
                print(
                    "All Ext\t",
                    count_number_of_lines_in_folder(
                        "../", "(.py$|.md$|.png$|.txt$|LICENCE|.json$)"),
                    "\t Pour être plus précis: (.py$|.md$|.png$|.txt$|LICENCE|.json$)"
                )
                print("py$ md$\t",
                      count_number_of_lines_in_folder("../", "(.py$|.md$)"))
                print("py$\t", count_number_of_lines_in_folder("../", ".py$"))
Beispiel #4
0
def clilaunch():
    """
    # TODO, Apps a faire: 
    autoreadme, compressint, countligne, ?duplicateFile, keyboardGenerator, minesweeper, readmereader, getbyteskey, tetris
    """
    from main_terminalGetKey import getKey
    global current_menu  # 0 = Normal, 1=CountLine,
    current_menu = 0  # 0 = Normal, 1=CountLine,
    Apps_to_launch = [{
        '0': ('demineur', lambda: demineur()),
        '1': ('menu count ligne', lambda: change_current_menu(1))
    }, {
        '0': ('print ok', lambda: print("ok")),
        '1': ('print okj2', lambda: print('ojk2'))
    }]
    while True:
        # TODO Afficher les aides
        key = getKey(debug=True)
        if key in Apps_to_launch[current_menu]:
            clear()
            Apps_to_launch[current_menu][key][1]()
        else:
            print("Commande Inconnue")
        print(current_menu)
Beispiel #5
0
def demineur(size: int = 10):
    game_open = True
    drapeau_map = [[False for j in range(size)] for i in range(size)]
    plateau = []
    for i in range(size):
        ligne = []
        for j in range(size):
            if randint(1, 10) >= 3:
                ligne += [10]
            else:
                ligne += [9]
        plateau += [ligne]
    nouveau_plateau = []
    for i in range(len(plateau)):
        ligne = []
        for j in range(len(plateau[i])):
            if plateau[i][j] == 9:
                ligne += [9]
            else:
                somme = 0
                for k in range(-1, 2):
                    for l in range(-1, 2):
                        if not (k == 0 and l == 0):
                            if 0 <= i + k < 10 and 0 <= j + l < 10:
                                if plateau[i + k][j + l] == 9:
                                    somme += 1
                if somme == 0:
                    ligne += [10]
                else:
                    ligne += [-somme]
        nouveau_plateau += [ligne]
    del ligne
    plateau = nouveau_plateau
    # Plateau = [[0 if randint(1,10) >= 2 else -1 for j in range(size)] for i in range(size)]
    # Cache = [[1 for j in range(size)] for i in range(size)]
    x, y = size // 2, size // 2
    player_a_gagner = False
    ligne = False
    while game_open:
        if player_a_gagner:
            clear()
            print_char(
                1, 1, "Vous avez gagné\n" + "restart: Enter\n" + "exit: CtrlC")
            key = getKey(debug=True)
            if key == "\r":
                demineur()
        elif ligne:
            clear()
            print_char(
                1, 1, "Vous avez perdu\n" + "restart: Enter\n" + "exit: CtrlC")
            for i in range(len(plateau)):
                print("\n ", end="")
                for j in range(len(plateau[i])):
                    if plateau[i][j] == 0:
                        char_item = " "
                    elif 1 <= plateau[i][j] <= 8:
                        char_item = plateau[i][j]
                    elif -1 >= plateau[i][j] >= -8:
                        char_item = "\u2588"
                    elif plateau[i][j] == 10:
                        char_item = "\u2588"
                    elif plateau[i][j] == 9:
                        char_item = "\033[31m☭\033[0m"
                    elif plateau[i][j] == 12:
                        char_item = "\033[31m☭\033[0m"
                    else:
                        char_item = "?"
                    print_char(((terminal_size("X") - size) // 2) + i,
                               ((terminal_size("Y") - size) // 2) + j,
                               char_item)
            key = getKey(debug=True)
            if key == "\r":
                demineur()
        else:
            print_char(
                1, 1,
                "left: q ou ← \n" + "up: z ou ↑ \n" + "right: d ou → \n" +
                "down: s ou ↓ \n" + "click: a ou Enter \n" + "flag: e")
            size_trop_petit = message_page_trop_petite(size + 2, size + 2)
            if not size_trop_petit:
                # print(Plateau)
                player_a_gagner = True
                for i in range(len(plateau)):
                    print("\n ", end="")
                    for j in range(len(plateau[i])):
                        if plateau[i][j] == 0:
                            char_item = " "
                        elif 1 <= plateau[i][j] <= 8:
                            char_item = plateau[i][j]
                        elif -1 >= plateau[i][j] >= -8:
                            char_item = "\u2588"
                            player_a_gagner = False
                        elif plateau[i][j] == 10:
                            char_item = "\u2588"
                            player_a_gagner = False
                        elif plateau[i][j] == 9:
                            char_item = "\u2588"
                        elif plateau[i][j] == 12:
                            char_item = "\033[31m☭\033[0m"
                        else:
                            char_item = "?"
                        print_char(
                            ((terminal_size("X") - size) // 2) + i,
                            ((terminal_size("Y") - size) // 2) + j,
                            (
                                lambda elem, char_item_lambda: "⚑"
                                if elem  # ⚐⚑
                                else char_item_lambda)(drapeau_map[i][j],
                                                       char_item))
                print_char(((terminal_size("X") - size) // 2) + x,
                           ((terminal_size("Y") - size) // 2) + y, "X")
                key = getKey(debug=True)
                clear()
                if key == "q" or key == "\x1b[D":
                    x = max(0, x - 1)
                if key == "d" or key == "\x1b[C":
                    x = min(size - 1, x + 1)
                if key == "z" or key == "\x1b[A":
                    y = max(0, y - 1)
                if key == "s" or key == "\x1b[B":
                    y = min(size - 1, y + 1)
                if key == "a" or key == "\r":
                    if plateau[x][y] == 9:
                        ligne = True
                    if plateau[x][y] < 0:
                        plateau[x][y] = -plateau[x][y]
                    if plateau[x][y] == 10:
                        plateau[x][y] = 0
                if key == "e":
                    drapeau_map[x][y] = not drapeau_map[x][y]
Beispiel #6
0
 def reload_all(cls):
     clear()
     cls.draw_footer()
     cls.actulise_input()
     cls.cursor_key()