Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,6 @@
<module>testideas-websockets</module>
<module>testideas-sgbd</module>
<module>testideas-jersey</module>
<module>testideas-terminalEmulator</module>
</modules>
</project>
41 changes: 41 additions & 0 deletions testideas-terminalEmulator/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="test" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
1 change: 1 addition & 0 deletions testideas-terminalEmulator/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target/
23 changes: 23 additions & 0 deletions testideas-terminalEmulator/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>testideas-terminalEmulator</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
90 changes: 90 additions & 0 deletions testideas-terminalEmulator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
Test Ideas : Terminal Emulator

A complete Unix/Linux terminal emulator implemented in Java 8 with Swing GUI. (2 versions !)

## Version 1

Features:
- Virtual file system with directories and text files
- 14+ Unix-like commands (ls, cd, pwd, cat, echo, touch, mkdir, rm, rmdir, cp, mv, clear, help, exit)
- Minimalist scripting language with variables, conditions, and loops
- Swing-based graphical user interface
- Command history with up/down arrow navigation
- Basic tab completion
- Comprehensive unit and integration tests (JUnit 5)

Usage:
1. Compile: javac -d bin src/com/terminal/emulator/**/*.java
2. Run: java -cp bin com.terminal.emulator.Main
3. Type 'help' for available commands
4. Type 'exit' to quit

Project Structure:
com.terminal/
- Main.java (entry point)
- TerminalState.java (global state)
- gui/ (Swing GUI classes)
- filesystem/ (Directory, TerminalFile, FileNode)
- commands/ (Command interface and implementations)
- script/ (ScriptEngine, ScriptParser, ScriptContext)

tests/
- filesystem/ (FileSystemTest, DirectoryTest)
- commands/ (CommandParserTest, LsCommandTest, CdCommandTest, CommandFactoryTest)
- TerminalStateTest.java
- ScriptEngineTest.java
- IntegrationTest.java

```
Commands Available:
ls [OPTIONS] [FILE...] - List directory contents
cd [DIR] - Change directory
pwd - Print working directory
cat [FILE...] - Concatenate and print files
echo [STRING...] - Display a line of text
touch [FILE...] - Create empty files
mkdir [DIRECTORY...] - Create directories
rm [FILE...] - Remove files
rmdir [DIRECTORY...] - Remove empty directories
cp SOURCE DEST - Copy files
mv SOURCE DEST - Move or rename files
clear - Clear the terminal screen
help [COMMAND] - Display help information
exit - Exit the terminal

Scripting Language:
# Variables
set var=value
echo $var

# Conditions
if [ "$var" = "value" ]
echo Equal
fi

# File tests
if [ -f "file.txt" ]
echo File exists
fi

# While loops
set count=0
while [ "$count" != "5" ]
echo $count
# Note: Manual incrementation needed in this version
set count=1
done

# For loops
for item in a b c
echo $item
done

Note: The scripting engine is minimal and does not support all Unix shell features.
```

## Version 2

Adding rediretiuons, pipes, better scripting... !

...
111 changes: 111 additions & 0 deletions testideas-terminalEmulator/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>gabywald</groupId>
<artifactId>testideas</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>testideas-terminalEmulator</artifactId>
<packaging>jar</packaging>
<name>testideas-terminalEmulator</name>
<description>Unix/Linux terminal emulator in Java 8 with Swing</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<junit.version>5.8.2</junit.version>
</properties>
<dependencies>

<!-- Source: https://mvnrepository.com/artifact/info.picocli/picocli -->
<dependency>
<groupId>info.picocli</groupId>
<artifactId>picocli</artifactId>
<version>4.7.7</version>
<scope>compile</scope>
</dependency>

<!-- junit 5, unit test -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<includes>
<include>**/*</include>
</includes>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<archive>
<manifest>
<mainClass>gabywald.launchers.TerminalEmulatorLaunchers</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<archive>
<manifest>
<!-- Your main class -->
<mainClass>gabywald.launchers.TerminalEmulatorLaunchers</mainClass>
<!-- ClassPath / CP -->
<addClasspath>true</addClasspath>
</manifest>
</archive>
<descriptorRefs>
<!--Bundles all dependencies -->
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Loading