Skip to content

Commit

Permalink
#44 #43 Update to terminal
Browse files Browse the repository at this point in the history
- Added placeholders with command suggestions
- Updated the terminal to monospace font scheme
  • Loading branch information
rohankishore authored Nov 9, 2023
1 parent 9fcb929 commit b73399d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 36 deletions.
48 changes: 19 additions & 29 deletions auratext/Core/terminal.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,36 @@
from __future__ import annotations

import random
import time
from typing import TYPE_CHECKING
import os
import subprocess
from art import text2art

from PyQt6.QtCore import Qt
from PyQt6.QtGui import QShortcut, QKeySequence
from PyQt6.QtGui import QShortcut, QKeySequence, QFont
from PyQt6.QtWidgets import QWidget, QLineEdit, QTextEdit, QVBoxLayout
import sys
from pyjokes import pyjokes

from datetime import datetime
from pyqtconsole.console import PythonConsole

now = datetime.now()

if TYPE_CHECKING:
from .window import Window

example_cmds = ["'ascii Hello'", "'joke' for some byte sized humour", "'pip'",
"'cpath' to view the current project path", "'ctheme' to view the current theme", "'ipconfig'"]

class AuraTextTerminalWidget(QWidget):
def __init__(self, window: Window):
super().__init__(window)
self._window = window

self.script_edit = QLineEdit()
self.setStyleSheet("QWidget {background-color: #000000;}")
self.script_edit.setPlaceholderText(("Try " + random.choice(example_cmds)))
self.script_edit.setFont(QFont("Consolas"))
self.setStyleSheet("QWidget {background-color: #FFFFFF;}")
self.script_edit.setStyleSheet(
"QLineEdit {"
" border-radius: 5px;"
Expand All @@ -35,7 +40,9 @@ def __init__(self, window: Window):
"}"
)
self.script_edit.setAlignment(Qt.AlignmentFlag.AlignBottom)
self.script_edit.textChanged.connect(self.update_placeholders)
self.text = QTextEdit()
self.text.setFont(QFont("Consolas"))
self.text.setReadOnly(True)
self.text.setStyleSheet("QTextEdit {background-color: #000000;color: white; border:none;}")

Expand All @@ -48,10 +55,18 @@ def __init__(self, window: Window):
self.quitSc = QShortcut(QKeySequence("Return"), self)
self.quitSc.activated.connect(self.run_script)

def update_placeholders(self):
self.script_edit.setPlaceholderText(("Try " + random.choice(example_cmds)))

def run_script(self):
print("hi")
script = self.script_edit.text()
self.script_edit.clear()

self._window._terminal_history.append(script)
print("hi")
print(self._window._terminal_history)

if script == "ctheme":
self.text.setPlainText(self._window._themes["theme"])

Expand All @@ -71,21 +86,6 @@ def run_script(self):
ascii_art = text2art(a)
self.text.setPlainText(ascii_art)

elif "iplugins" in script or "IPLUGINS" in script:

def list_files_without_extension(directory_path):
files_without_extension = []
for file_name in os.listdir(directory_path):
file_path = os.path.join(directory_path, file_name)
if os.path.isfile(file_path): # Check if it's a file and not a directory
name_without_extension, _ = os.path.splitext(file_name)
files_without_extension.append(name_without_extension)
return files_without_extension

files_list = list_files_without_extension("Plugins")
for file_name in files_list:
self.text.append(file_name)

elif "birthday" in script or "BIRTHDAY" in script:
self.text.setPlainText("Aura Text's GitHub Repo was created on 2022-10-05.")

Expand All @@ -109,13 +109,3 @@ def list_files_without_extension(directory_path):
except Exception as e:
print(e)


class PythonShell(QWidget):
def __init__(self):
super().__init__()

console = PythonConsole()
console.eval_in_thread()
layout1 = QVBoxLayout()
layout1.addWidget(console)
self.setLayout(layout1)
8 changes: 1 addition & 7 deletions auratext/Core/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Window(QMainWindow):
def __init__(self):
super().__init__()
self.local_app_data = local_app_data
self._terminal_history = ""
#self._terminal_history = ""

with open(f"{local_app_data}/data/theme.json", "r") as json_file:
self._themes = json.load(json_file)
Expand All @@ -69,7 +69,6 @@ def __init__(self):
with open(f"{local_app_data}/data/terminal_history.txt", "r+") as thfile:
self._terminal_history = thfile.readlines()
#self._terminal_history.split('\n')
print(self._terminal_history)

# Splash Screen
splash_pix = ""
Expand Down Expand Up @@ -193,8 +192,6 @@ def __init__(self):

def create_editor(self):
self.text_editor = CodeEditor(self)
# self.tabifyDockWidget(self.sidebar_main, self.plugin_dock)
# self.tabifyDockWidget(self.sidebar_main, self.terminal_dock)
return self.text_editor

def load_plugins(self):
Expand Down Expand Up @@ -400,7 +397,6 @@ def markdown_open(self, path_data):
def markdown_new(self):
ModuleFile.markdown_new(self)

# TREEVIEW
def open_file(self, index):
path = self.model.filePath(index)
image_extensions = ["png", "jpg", "jpeg", "ico", "gif", "bmp"]
Expand Down Expand Up @@ -442,8 +438,6 @@ def add_image_tab():
except FileNotFoundError:
return

def check_for_issues(self):
ModuleFile.check_for_issues()

def configure_menuBar(self):
MenuConfig.configure_menuBar(self)
Expand Down

0 comments on commit b73399d

Please sign in to comment.