Compare commits
58 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
2fdf160ed3
|
|||
|
f15534c4d5
|
|||
|
fdbcb56b1b
|
|||
|
b9c4c6f3e7
|
|||
| 751f878a32 | |||
| 3d1d98ee7b | |||
| bf126de5b9 | |||
| 485dccdf3b | |||
| 5b9568013d | |||
| 48c2e0abd9 | |||
| ebdf464c31 | |||
| b812535366 | |||
| a52fe8dc78 | |||
| cc2a625fc1 | |||
| c7659bb44e | |||
| 16e85a3fe3 | |||
| c8aa7a9648 | |||
| cdc05c9b67 | |||
| 250384e738 | |||
| 1c749e1098 | |||
| c3756e1982 | |||
| 97777f1046 | |||
| c59fdc4430 | |||
| 8499e364ae | |||
| f9c1ac535f | |||
| 726923d589 | |||
| 365d09854b | |||
| 508fe15ff9 | |||
| 024db2edae | |||
| 3d2e0348ae | |||
| 201c73a854 | |||
| 44b8e74d56 | |||
| d4f815d1e7 | |||
|
6034304923
|
|||
|
d335a3dd80
|
|||
|
cfa433fd90
|
|||
| d472f6ac5e | |||
| 2854b9e7e9 | |||
| 86854843e8 | |||
| 2474fc05b1 | |||
| eee5475548 | |||
| 68ab7a427f | |||
| ef1b5d98ef | |||
| 77359ae842 | |||
| 3b063c74ba | |||
| 536e462d1f | |||
| 4bda32d6cd | |||
| 2b74166b70 | |||
| 3c10f531e3 | |||
| 27c36aad36 | |||
| db04a8b1aa | |||
| 4683e38fe3 | |||
| f03af67a33 | |||
| c785d221d2 | |||
| 02467170a8 | |||
| 0ba07ca47c | |||
| a6f5bee680 | |||
| 83ff39dd9f |
11
.classpath
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src/main/java"/>
|
||||
<classpathentry kind="src" path="src/main/resources"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
61
.gitea/workflows/build.yml
Normal file
@@ -0,0 +1,61 @@
|
||||
name: Build the Jar
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up JDK 20
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
java-version: '20'
|
||||
distribution: 'temurin'
|
||||
|
||||
- name: Create output directories
|
||||
run: |
|
||||
mkdir -p out/production/Calc
|
||||
mkdir -p dist
|
||||
|
||||
- name: Compile Java files
|
||||
run: |
|
||||
javac -encoding UTF-8 -cp "lib/flatlaf-3.7.jar:lib/flatlaf-extras-3.7.jar" -d out/production/Calc \
|
||||
$(find src/main/java -name "*.java")
|
||||
|
||||
- name: Copy resources
|
||||
run: |
|
||||
if [ -d "src/main/resources" ]; then
|
||||
cp -r src/main/resources/* out/production/Calc/ 2>/dev/null || true
|
||||
fi
|
||||
|
||||
- name: Extract FlatLaf library
|
||||
run: |
|
||||
cd out/production/Calc
|
||||
jar xf ../../../lib/flatlaf-3.7.jar
|
||||
# Remove META-INF to avoid conflicts
|
||||
rm -rf META-INF
|
||||
cd ../../..
|
||||
|
||||
- name: Create manifest
|
||||
run: |
|
||||
echo "Manifest-Version: 1.0" > manifest.txt
|
||||
echo "Main-Class: dev.sillyangel.calc.Calculator" >> manifest.txt
|
||||
|
||||
- name: Create fat JAR
|
||||
run: |
|
||||
cd out/production/Calc
|
||||
jar cfm ../../../dist/CalcShortforCalculator.jar ../../../manifest.txt .
|
||||
cd ../../..
|
||||
|
||||
- name: Upload JAR artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: CalcShortforCalculator
|
||||
path: dist/CalcShortforCalculator.jar
|
||||
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
/bin/
|
||||
bin
|
||||
*.class
|
||||
out
|
||||
|
||||
10
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Ignored default folder with query files
|
||||
/queries/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
6
.idea/copilot.data.migration.agent.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AgentMigrationStateService">
|
||||
<option name="migrationStatus" value="COMPLETED" />
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/copilot.data.migration.ask.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AskMigrationStateService">
|
||||
<option name="migrationStatus" value="COMPLETED" />
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/copilot.data.migration.ask2agent.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Ask2AgentMigrationStateService">
|
||||
<option name="migrationStatus" value="COMPLETED" />
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/copilot.data.migration.edit.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EditMigrationStateService">
|
||||
<option name="migrationStatus" value="COMPLETED" />
|
||||
</component>
|
||||
</project>
|
||||
7
.idea/discord.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="APPLICATION" />
|
||||
<option name="description" value="" />
|
||||
</component>
|
||||
</project>
|
||||
13
.idea/libraries/lib.xml
generated
Normal file
@@ -0,0 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="lib">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/flatlaf-3.7.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/flatlaf-extras-3.7.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/flatlaf-extras-3.7-sources.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/flatlaf-3.7-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
6
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_20" project-jdk-name="temurin-20" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/Calc.iml" filepath="$PROJECT_DIR$/Calc.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
28
.project
@@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>CalculatorButBetter</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1762972468245</id>
|
||||
<name></name>
|
||||
<type>30</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
</projectDescription>
|
||||
@@ -1,2 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
||||
@@ -1,12 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=20
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=20
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=20
|
||||
15
Calc.iml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.gitea" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.idea" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="lib" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,2 +1,4 @@
|
||||
you need java 20 to run this, THIS IS NONTHING BAD JUST A CALCULATOR NOTHING MUCH :sob:
|
||||
anyway, this might be the best or the worst calculator you have ever seen!?1
|
||||
|
||||

|
||||
BIN
lib/flatlaf-3.7-javadoc.jar
Normal file
BIN
lib/flatlaf-3.7-sources.jar
Normal file
BIN
lib/flatlaf-3.7.jar
Normal file
BIN
lib/flatlaf-extras-3.7-javadoc.jar
Normal file
BIN
lib/flatlaf-extras-3.7-sources.jar
Normal file
BIN
lib/flatlaf-extras-3.7.jar
Normal file
BIN
screenshot.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
138
src/main/java/dev/sillyangel/calc/CalculatorHistory.java
Normal file
@@ -0,0 +1,138 @@
|
||||
package dev.sillyangel.calc;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Manages calculation history for the calculator application.
|
||||
* Stores calculations in a file and provides methods to retrieve and manage history.
|
||||
*/
|
||||
public class CalculatorHistory {
|
||||
private final List<String> calculationHistory = new ArrayList<>();
|
||||
private final Path historyFilePath;
|
||||
private static final String HISTORY_DIR = System.getProperty("user.home") + File.separator + ".calculator";
|
||||
private static final String HISTORY_FILE = "calc_history.txt";
|
||||
private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
public CalculatorHistory() {
|
||||
historyFilePath = Paths.get(HISTORY_DIR, HISTORY_FILE);
|
||||
initializeHistoryFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the history file and directory structure.
|
||||
* Creates the directory and file if they don't exist, and loads existing history.
|
||||
*/
|
||||
private void initializeHistoryFile() {
|
||||
try {
|
||||
// Create directory if it doesn't exist
|
||||
Path dir = Paths.get(HISTORY_DIR);
|
||||
if (!Files.exists(dir)) {
|
||||
Files.createDirectories(dir);
|
||||
System.out.println("Created history directory: " + HISTORY_DIR);
|
||||
}
|
||||
|
||||
// Create file if it doesn't exist
|
||||
if (!Files.exists(historyFilePath)) {
|
||||
Files.createFile(historyFilePath);
|
||||
System.out.println("Created history file: " + historyFilePath);
|
||||
}
|
||||
|
||||
// Load existing history
|
||||
loadHistory();
|
||||
} catch (IOException e) {
|
||||
System.err.println("Error initializing history file: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a calculation to the history file.
|
||||
* @param calculation The calculation string to save (e.g., "5 + 3 = 8")
|
||||
*/
|
||||
public void saveToHistory(String calculation) {
|
||||
try {
|
||||
String timestamp = LocalDateTime.now().format(formatter);
|
||||
String entry = "[" + timestamp + "] " + calculation;
|
||||
|
||||
// Add to memory list
|
||||
calculationHistory.add(entry);
|
||||
|
||||
// Append to file
|
||||
Files.write(historyFilePath,
|
||||
(entry + System.lineSeparator()).getBytes(),
|
||||
StandardOpenOption.APPEND);
|
||||
|
||||
System.out.println("Saved to history: " + entry);
|
||||
} catch (IOException e) {
|
||||
System.err.println("Error saving to history: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads history from the file into memory.
|
||||
*/
|
||||
private void loadHistory() {
|
||||
try {
|
||||
if (Files.exists(historyFilePath)) {
|
||||
List<String> lines = Files.readAllLines(historyFilePath);
|
||||
calculationHistory.addAll(lines);
|
||||
System.out.println("Loaded " + lines.size() + " history entries");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.err.println("Error loading history: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a copy of all calculation history entries.
|
||||
* @return A list of history entries with timestamps
|
||||
*/
|
||||
public List<String> getCalculationHistory() {
|
||||
return new ArrayList<>(calculationHistory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the most recent N history entries.
|
||||
* @param count The number of entries to return
|
||||
* @return A list of the most recent history entries
|
||||
*/
|
||||
public List<String> getRecentHistory(int count) {
|
||||
int size = calculationHistory.size();
|
||||
int fromIndex = Math.max(0, size - count);
|
||||
return new ArrayList<>(calculationHistory.subList(fromIndex, size));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all history entries from memory and file.
|
||||
*/
|
||||
public void clearHistory() {
|
||||
try {
|
||||
calculationHistory.clear();
|
||||
Files.write(historyFilePath, new byte[0], StandardOpenOption.TRUNCATE_EXISTING);
|
||||
System.out.println("History cleared");
|
||||
} catch (IOException e) {
|
||||
System.err.println("Error clearing history: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of history entries.
|
||||
* @return The count of history entries
|
||||
*/
|
||||
public int getHistoryCount() {
|
||||
return calculationHistory.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path to the history file.
|
||||
* @return The file path as a string
|
||||
*/
|
||||
public String getHistoryFilePath() {
|
||||
return historyFilePath.toString();
|
||||
}
|
||||
}
|
||||
|
||||
12
src/main/java/dev/sillyangel/calc/CalculatorModes.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package dev.sillyangel.calc;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
|
||||
public class CalculatorModes extends JFrame {
|
||||
public static void Scientific() {
|
||||
|
||||
}
|
||||
public static void DateCalculation() {
|
||||
|
||||
}
|
||||
}
|
||||
20
src/main/java/dev/sillyangel/calc/themes/MacDarkBlue.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package dev.sillyangel.calc.themes;
|
||||
|
||||
import com.formdev.flatlaf.themes.FlatMacDarkLaf;
|
||||
|
||||
public class MacDarkBlue extends FlatMacDarkLaf {
|
||||
public static final String NAME = "MacDarkBlue";
|
||||
|
||||
public static boolean setup() {
|
||||
return setup( new MacDarkBlue() );
|
||||
}
|
||||
|
||||
public static void installLafInfo() {
|
||||
installLafInfo( NAME, MacDarkBlue.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return NAME;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
# base theme (light, dark, intellij, darcula, maclight or macdark); only used by theme editor
|
||||
@baseTheme = macdark
|
||||
|
||||
@accentColor = #0e59c3ff
|
||||
20
src/main/java/dev/sillyangel/calc/themes/MacDarkRed.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package dev.sillyangel.calc.themes;
|
||||
|
||||
import com.formdev.flatlaf.themes.FlatMacDarkLaf;
|
||||
|
||||
public class MacDarkRed extends FlatMacDarkLaf {
|
||||
public static final String NAME = "MacDarkRed";
|
||||
|
||||
public static boolean setup() {
|
||||
return setup( new MacDarkRed() );
|
||||
}
|
||||
|
||||
public static void installLafInfo() {
|
||||
installLafInfo( NAME, MacDarkRed.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return NAME;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
@baseTheme = macdark
|
||||
@accentColor = #a83e32
|
||||
20
src/main/java/dev/sillyangel/calc/themes/MacLightBlue.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package dev.sillyangel.calc.themes;
|
||||
|
||||
import com.formdev.flatlaf.themes.FlatMacLightLaf;
|
||||
|
||||
public class MacLightBlue extends FlatMacLightLaf {
|
||||
public static final String NAME = "MacLightBlue";
|
||||
|
||||
public static boolean setup() {
|
||||
return setup( new MacLightBlue() );
|
||||
}
|
||||
|
||||
public static void installLafInfo() {
|
||||
installLafInfo( NAME, MacLightBlue.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return NAME;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
# base theme (light, dark, intellij, darcula, maclight or macdark); only used by theme editor
|
||||
@baseTheme = macdark
|
||||
|
||||
@accentColor = #0e59c3ff
|
||||
20
src/main/java/dev/sillyangel/calc/themes/MacLightRed.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package dev.sillyangel.calc.themes;
|
||||
|
||||
import com.formdev.flatlaf.themes.FlatMacLightLaf;
|
||||
|
||||
public class MacLightRed extends FlatMacLightLaf {
|
||||
public static final String NAME = "MacLightRed";
|
||||
|
||||
public static boolean setup() {
|
||||
return setup( new MacLightRed() );
|
||||
}
|
||||
|
||||
public static void installLafInfo() {
|
||||
installLafInfo( NAME, MacLightRed.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return NAME;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
@baseTheme = macdark
|
||||
@accentColor = #a83e32
|
||||
|
Before Width: | Height: | Size: 451 B |
|
Before Width: | Height: | Size: 451 B |
BIN
src/main/resources/images/appIcon1024.png
Normal file
|
After Width: | Height: | Size: 74 KiB |
BIN
src/main/resources/images/appIcon16.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
src/main/resources/images/appIcon256.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
src/main/resources/images/appIcon32.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
src/main/resources/images/appIcon48.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
src/main/resources/images/appIcon512.png
Normal file
|
After Width: | Height: | Size: 36 KiB |