Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
AkshuDev authored Nov 15, 2024
1 parent e74d37c commit de3b8af
Show file tree
Hide file tree
Showing 68 changed files with 19,620 additions and 0 deletions.
124 changes: 124 additions & 0 deletions Tests/CLITest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# Command Line Interface ToolKit Test

import sys
import os
import time
import keyboard
import string

# sys.path.append(os.path.join(os.path.dirname(__file__), '..'))

from phardwareitk.CLI import cliToolKit as cli
from phardwareitk.Extensions import *

global dataBuffer
dataBuffer:str = ""

def StatusLabel():
cli.Cursor.MoveCursorToBottom()
cli.Text.WriteText(" ^X - Exit\t^O - Write Out")
cli.Cursor.RestoreCursorPosition()

def Start_SuperCLI():
cli.Screen.ClearScreen()
cli.Cursor.SetCursorPositionToHome()
cli.Cursor.SaveCursorPosition()

def WriteOut(data:str):
cli.Cursor.MoveCursorToBottom()
cli.Cursor.MoveCursorUp(3)
cli.Cursor.SetCursorToBeginningOfLine()
filePath:str = cli.Text.InputText(" File Path: ")
cli.Screen.ClearCurrentLine()
cli.Cursor.SetCursorToBeginningOfLine()
mode:str = cli.Text.InputText(" Mode: ")
cli.Screen.ClearCurrentLine()
cli.Cursor.RestoreCursorPosition()

if os.path.exists(filePath):
cli.Cursor.MoveCursorToBottom()
cli.Cursor.MoveCursorUp(3)
cli.Cursor.SetCursorToBeginningOfLine()
cli.Text.WriteText(" Path Exist!")
time.sleep(2)
cli.Screen.ClearCurrentLine()
cli.Cursor.RestoreCursorPosition()
else:
if not mode.lower() in ["binary", "bin", "normal", "utf-8"]:
cli.Cursor.MoveCursorToBottom()
cli.Cursor.MoveCursorUp(3)
cli.Cursor.SetCursorToBeginningOfLine()
cli.Text.WriteText(" Mode doesn't Exist! Available Modes -> [binary/bin], [normal/utf-8]")
time.sleep(2)
cli.Screen.ClearCurrentLine()
cli.Cursor.RestoreCursorPosition()
else:
if mode.lower() == "binary" or mode.lower() == "bin":
with open(filePath, "wb") as f:
f.write(data.encode())
f.close()
elif mode.lower() == "normal" or mode.lower() == "utf-8":
with open(filePath, "w") as f:
f.write(data)
f.close()

Start_SuperCLI()
StatusLabel()

def AddData(key:keyboard.KeyboardEvent):
global dataBuffer

if key.name == "Enter":
dataBuffer += "\n"
cli.Text.WriteText("\n")
cli.Cursor.SaveCursorPosition()

if key.name == "space":
dataBuffer += " "
cli.Text.WriteText(" ")
cli.Cursor.SaveCursorPosition()

if (key.name in string.printable or key.name == "space") and (len(key.name) == 1 or len(key.name == 5)):
dataBuffer += key.name
cli.Text.WriteText(key.name)
cli.Cursor.SaveCursorPosition()

def BackSpace():
global dataBuffer
cursor_y, cursor_x = cli.Cursor.CurrentCursorPosition()

if cursor_x > 1:
dataBuffer = dataBuffer[:-1]
cli.Text.BackSpaceChar()

def Delete():
cursor_y, cursor_x = cli.Cursor.CurrentCursorPosition()

if cursor_x <= len(dataBuffer):
del dataBuffer[cursor_x - 1]
cli.Text.DeleteChar()

def KeyPress():
if keyboard.is_pressed("up"):
cli.Cursor.MoveCursorUp(1)
elif keyboard.is_pressed("right"):
cli.Cursor.MoveCursorRight(1)
elif keyboard.is_pressed("left"):
cli.Cursor.MoveCursorLeft(1)
elif keyboard.is_pressed("down"):
cli.Cursor.MoveCursorDown(1)
elif keyboard.is_pressed("ctrl+x"):
cli.Screen.ClearScreen()
cli.Cursor.SetCursorPositionToHome()
exit(0)
elif keyboard.is_pressed("ctrl+o"):
WriteOut(dataBuffer)
else:
key_ = keyboard.read_event()
if not key_.event_type == keyboard.KEY_UP:
AddData(key_)

Start_SuperCLI()
StatusLabel()
while True:
KeyPress()
43 changes: 43 additions & 0 deletions Tests/ExtensionsTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import os
import sys

sys.path.append(os.path.join(os.path.dirname(__file__), ".."))

from phardwareitk.Extensions import *
from phardwareitk.Extensions.HyperOut import *
from phardwareitk.Extensions.HyperIn import *

printH("Hello,", "This is a test!", FontEnabled=True, Font=TextFont(font_color=Color("blue")))

msgOld = input("This is a normal input!: ")
print("You wrote:", msgOld)

msg2 = inputH("This is Hyper Input: ", FontEnabled=True, Font=TextFont(font_color=Color("cyan")))
print("You wrote:", msg2)

msg = inputH("This is Hyper Input with Mask enabled: ", FontEnabled=True, Font=TextFont(font_color=Color("cyan")), mask=True)
print("You wrote:", msg)

msg = inputH("This is Hyper Input with History Enabled: ", FontEnabled=True, Font=TextFont(font_color=Color("cyan")), History=[msg, msg2, msgOld])
print("You wrote:", msg)

import time

run = True

progressH(False, (0, "cpos-3"), 0, 5)

for i in range(5):
progressH(False, (0, "cpos-3"), i + 1, 5, onMaxMsg=" : MAX reached!", First=False)

time.sleep(1)

print("Making a cache file for print function...")
result = cacheH(".\\testCache.cache", print, None)

print("Done!")

print("Loading from cache...")
result = cacheH(".\\testCache.cache")
print("Result:", result)
exitH(0, "Just a Normal Exit")
37 changes: 37 additions & 0 deletions Tests/GUITest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import os
import sys

sys.path.append(os.path.join(os.path.dirname(__file__), ".."))

from phardwareitk.GUI import gui
from phardwareitk.Extensions import *

def main() -> int:
gui.initialize()

window = gui.CreateWindow("Test")

winsurface = gui.WindowSurface(window)

icon = PIcon("./Tests/sample1.bmp")

gui.AddIcon(window, icon)

gui.SetBackgroundColor(window, Color("black", 0))

button = gui.Button(50, 50, 200, 50)
renderer = button.Draw(window)
WidgetButton = button.onClick(print, ("Hello World!", "AMAZING!"))

if isinstance(renderer, bytes):
gui.SafeExitSDL(renderer.decode(), gui.DestroyWindow, (window, icon))
return 1

gui.UpdateWindow(window)

gui.EventLoop(True, window, [WidgetButton], icon, renderer)

return 0

if __name__ == "__main__":
sys.exit(main())
12 changes: 12 additions & 0 deletions Tests/HgameTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import os
import sys
# sys.path.append(os.path.join(os.path.dirname(__file__), ".."))

from phardwareitk import HGame

print("HGAME - Details ->\n1. stdout, console\n2. stdin, window\n3. debug-stdout")

HGame.Initialize(True, "console", "window", 0)

window = HGame.Screen()
window.Loop()
15 changes: 15 additions & 0 deletions Tests/HyperPythonTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
pyCode = """helloWorld = "Hi"
helloWorldBuffer = 'H'
helloWB = True
hiiiiiiiii = 0
hellll = 0.1
"""

import sys
import os

sys.path.append(os.path.join(os.path.dirname(__file__), ".."))

from phardwareitk.Extensions.HyperPython import *

Convert(0, pyCode)
54 changes: 54 additions & 0 deletions Tests/ModuleControllerTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import sys
import os
import time

sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))

from phardwareitk.ModuleController import main

print("v0001 compiler")
compiler = main.Compiler()

compiler.set("he", "hello")
compiler.set("llo", "world")
compiler.saveToFile(True)
time.sleep(2)
compiler.getFromFile()
print(compiler.decompile_v0001())
print(compiler.get("llo"))

print("v0001 compiler [no encrypt]")
compilerOptions = main.CompilerOptions(encrypt=False)
compiler = main.Compiler(compilerOptions=compilerOptions)

compiler.set("he", "hello")
compiler.set("llo", "world")
compiler.saveToFile(True)
time.sleep(2)
compiler.getFromFile()
print(compiler.decompile_v0001())
print(compiler.get("llo"))

print("v0002 compiler")
compilerOptions = main.CompilerOptions(encrypt=True, format_="COMPILER_pheonix$phardwareitk$v0002")
compiler = main.Compiler(compilerOptions=compilerOptions)

compiler.set("he", "hello")
compiler.set("llo", "world")
compiler.saveToFile(True)
time.sleep(2)
compiler.getFromFile()
print(compiler.decompile_v0002())
print(compiler.get("llo"))

print("v0002 compiler [no encrypt]")
compilerOptions = main.CompilerOptions(encrypt=False, format_="COMPILER_pheonix$phardwareitk$v0002")
compiler = main.Compiler(compilerOptions=compilerOptions)

compiler.set("he", "hello")
compiler.set("llo", "world")
compiler.saveToFile(True)
time.sleep(2)
compiler.getFromFile()
print(compiler.decompile_v0002())
print(compiler.get("llo"))
Loading

0 comments on commit de3b8af

Please sign in to comment.