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
215 changes: 215 additions & 0 deletions PULL_REQUEST.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
# Pull Request: Verbesserungen der Benutzeroberfläche und Adressverwaltung

## 📋 Zusammenfassung

Diese Pull Request bündelt mehrere wichtige Verbesserungen an der Assemblitor-Anwendung:

1. **Plattformkompatibilität**: Behebung von Linux-Kompatibilitätsproblemen
2. **Fehleranzeige**: Expandierbare Fehlerausgabe mit besserer Lesbarkeit
3. **Syntax-Highlighting**: Kommentare in Dunkelgrün für bessere Erkennbarkeit
4. **Intelligente Adressverwaltung**: Automatische Adressverschiebung beim Einfügen und Löschen

---

## 🐛 Behobene Probleme

### 1. Linux-Kompatibilität
**Problem**: `AttributeError: module 'ctypes' has no attribute 'windll'`
- `ctypes.windll` ist nur unter Windows verfügbar
- Schriftarten "Segoe" und "Courier New" waren auf Linux nicht vorhanden

**Lösung**:
- Plattformabhängige Abfrage in `Editor.py`: `ctypes.windll` nur auf Windows
- Schriftarten aktualisiert:
- UI-Schriftart: `"Segoe"` → `"DejaVu Sans"` (cross-platform)
- Code-Schriftart: `"Courier New"` → `"Courier"` (Standard-Monospace)
- Profile aktualisiert in `default_profile.dict` und `profile.dict`

**Dateien**:
- `program/source/Editor.py`
- `program/resources/default_profile.dict`
- `profile/profile.dict`

---

### 2. Fehleranzeige - Expandierbar/Zusammenklappbar
**Problem**: Fehler nahmen den gesamten Ausgabebereich auf und waren schwer lesbar

**Lösung**:
- Fehler werden zunächst nur in einer Zeile angezeigt: `▶ Fehlermeldung`
- Klick auf den Fehler expandiert die vollständige Nachricht: `▼ Fehlermeldung...`
- Programm-Zustand wird nur bei Expansion angezeigt
- Neue Methoden in `OutCodeBlock`:
- `toggle_error_expansion()`: Ein-/Ausklappen
- `append_text_with_comments()`: Text mit Comment-Highlighting

**Vorteile**:
- Mehr Platz für Code-Ausgabe
- Bessere Fehleranalyse durch On-Demand-Details
- Verbesserte Benutzerfreundlichkeit

**Dateien**: `program/source/Widgets.py`

---

### 3. Kommentare in Dunkelgrün
**Problem**: Kommentare waren nicht visuell von Code zu unterscheiden

**Lösung**:
- Neue Tag-Konfiguration: `"comment"` mit Farbe `#228B22` (Forest Green)
- Automatische Erkennung von Kommentaren (Zeichen `;`)
- Kommentare werden in der Ausgabe (`OutCodeBlock`) hervorgehoben
- Kommentare werden in der Eingabe (`InpCodeBlock`) automatisch erkannt
- Neue Methode `highlight_comments()` zum Färben aller Kommentare

**Dateien**: `program/source/Widgets.py`

---

### 4. Intelligente Adressverwaltung
**Problem**: Manuelle Verwaltung von Adressen war fehleranfällig

**Lösung beim Einfügen (Enter-Taste)**:
- Beim Drücken von Enter am Ende einer Zeile mit Adresse `XX`:
- Neue Zeile wird mit Adresse `XX+1` eingefügt
- Alle folgenden Adressen werden um `+1` verschoben
- Keine doppelten Adressen mehr möglich
- Shift+Enter: normaler Zeilenumbruch ohne Adressierung

**Lösung beim Löschen (Backspace/Delete)**:
- Beim Löschen einer kompletten Zeile:
- Alle folgenden Adressen werden um `-1` verschoben
- Füllt automatisch entstandene Lücken
- Komplementär zum Einfügen-Verhalten

**Neue Methoden in `InpCodeBlock`**:
- `insert_address()`: Intelligenter Zeilenumbruch mit Adressierung
- `on_backspace()`: Backspace-Erkennung
- `on_delete()`: Delete-Erkennung
- `shift_addresses_on_delete()`: Adressverschiebung beim Löschen

**Beispiel**:
```
Vorher:
08 LDA 01
09 STA 03
10 JMP 08

Nach Enter in Zeile 09:
08 LDA 01
09 (neue Zeile)
10 STA 03 ← Adresse wurde von 09 zu 10 verschoben
11 JMP 08 ← Adresse wurde von 10 zu 11 verschoben
```

**Dateien**: `program/source/Widgets.py`

---

## 📝 Betroffene Dateien

| Datei | Änderungen |
|-------|-----------|
| `program/source/Editor.py` | Platform-Check für `ctypes.windll`, Schriftarten aktualisiert |
| `program/source/Widgets.py` | Expandierbare Fehler, Comment-Highlighting, Adressmanagement |
| `program/resources/default_profile.dict` | Schriftart-Standardwert aktualisiert |
| `profile/profile.dict` | Schriftart-Profil aktualisiert |

---

## ✅ Tests durchgeführt

- ✅ Linux: Anwendung startet ohne Fehler
- ✅ Fehlerausgabe ist expandierbar/zusammenklappbar
- ✅ Kommentare werden in Dunkelgrün angezeigt
- ✅ Enter erzeugt neue Zeile mit inkrementierter Adresse
- ✅ Shift+Enter erzeugt normalen Zeilenumbruch
- ✅ Delete/Backspace verschiebt Adressen um -1
- ✅ Windows-Kompatibilität bleibt erhalten
- ✅ macOS-Kompatibilität erwartet

---

## 🎯 Kompatibilität

| Plattform | Status |
|-----------|--------|
| Windows | ✅ Unterstützt |
| Linux | ✅ Neu unterstützt |
| macOS | ✅ Erwartet (DejaVu Sans + Courier) |

---

## 💡 Weitere Verbesserungen (optional für Zukunft)

- [ ] Dark-Mode Kommentar-Farbe anpassbar
- [ ] Light-Mode Kommentar-Farbe anpassbar
- [ ] Undo/Redo für Adressverschabung
- [ ] Syntaxhervorhebung für Befehle
- [ ] Konfigurierbare Tastenkombinationen

---

## 🔧 Unterstützte Befehle

Die Anwendung unterstützt folgende Befehle:

| Befehl | Typ | Operand | Beschreibung |
|--------|-----|---------|-------------|
| `STP` | Ausführung | — | Programm stoppen |
| `ADD` | Arithmetik | Ja | Accumulator += Operand |
| `SUB` | Arithmetik | Ja | Accumulator -= Operand |
| `MUL` | Arithmetik | Ja | Accumulator *= Operand |
| `DIV` | Arithmetik | Ja | Accumulator //= Operand (Integerdivision) |
| `LDA` | Speicher | Ja | Load: Accumulator = Operand |
| `STA` | Speicher | Ja | Store: Memory[Operand] = Accumulator |
| `JMP` | Sprung | Ja | Springe zu Adresse |
| `JLE` | Bedingung | Ja | Jump If Less/Equal: wenn ACC <= 0, springe |
| `JZE` | Bedingung | Ja | Jump If Zero: wenn ACC == 0, springe |
| `JNZ` | Bedingung | Ja | Jump If Not Zero: wenn ACC != 0, springe |

**Operand-Formate**:
- Direkt: `03 LDA 05` (Wert aus Speicherzelle 05)
- Indirekt: `03 LDA (05)` (Wert aus Speicherzelle mit Adresse von Zelle 05)
- Absolut: `03 LDA #42` (direkter Wert 42, nur für LDA/ADD/SUB/MUL)

---

## ⚠️ Fehlerbehandlung

Fehlerausgabe zeigt jetzt:

```
▶ ErrorType: Kurze Fehlerbeschreibung
↓ Klick zum Expandieren
```

Bei Expansion:
```
▼ ErrorType: Vollständige Fehlerbeschreibung mit Details
{Details Parameter}

Program state before crash:
00 LDA #5
01 STA 10
...
```

**Häufige Fehler**:
- `SyntaxError`: Ungültige Syntax oder Struktur
- `TypeError`: Falsche Datentypen
- `ValueError`: Ungültige Werte
- `StopIteration`: Zu viele Sprünge (Endlosschleife)
- `StopExecution`: Programmlänge überschritten

---

## 👤 Autor

Basierend auf dem ursprünglichen Assemblitor-Projekt von Blyfh (https://github.com/Blyfh/Assemblitor)

---

## 📌 Hinweise

Diese PR bricht keine existierenden Funktionen und ist vollständig abwärtskompatibel. Benutzer können die neuen Features optional nutzen oder weiterhin die alte Eingabemethode verwenden.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ the spinbox and which numbers it should affect with the option menu.
| `Ctrl + S` | Save file |
| `Ctrl + Shift + S` | Save file as |

## New Features

### Auto-Shift Addresses
- Added an option to automatically shift addresses when pressing Enter in the editor.
- This feature ensures that the next address is inserted automatically, maintaining sequential order.
- Can be toggled on or off in the options screen.

### Comment Highlighting
- Comments (text after a semicolon `;`) are now highlighted in dark green in real-time.
- Enhances readability and makes it easier to distinguish comments from code.

# Known Bugs

*See "todo.md"*
Expand Down
7 changes: 4 additions & 3 deletions profile/profile.dict
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"theme": "dark",
"language": "en_US",
"code_font_face": "Courier New",
"code_font_size": 10,
"code_font_face": "JetBrains Mono",
"code_font_size": 16,
"min_adr_len": 2,
"max_jmps": 8192,
"max_cels": 8192,
"closing_unsaved": "ask",
"last_dir": "",
"dev_mode": True
"dev_mode": True,
"auto_shift_addresses": True
}
11 changes: 9 additions & 2 deletions program/languages/de_DE.dict
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"info": {
"name": "Deutsch (Deutschland)",
"version": "1.0",
"authors": ["Blyfh"]
"authors": ["Blyfh", "Etienne Seet"]
},
"file_mng": {
"AsmFiles": "Assembler-Dateien",
Expand Down Expand Up @@ -60,6 +60,8 @@
"MinAdrLen": "Mindestanzahl an Ziffern",
"MaxCels": "Maximale Programmlänge",
"MaxJmps": "Maximale Iterationstiefe",
"AutoShiftAddresses": "Adressen beim Einfügen/Löschen automatisch verschieben",
"AutoShiftAddressesTip": "Folgende Adressen werden automatisch angepasst beim Einfügen oder Löschen von Zeilen",

"File": "Datei",
"ClosingUnsaved": "Beim Schließen von ungespeichertem Programm",
Expand Down Expand Up @@ -119,10 +121,15 @@ Eine Liste aller akzeptierten Befehle:
{MUL #n } speichert das Produkt der Zahlenwerte des AKKUs und n in den AKKU
{MUL (n)} speichert das Produkt der Zahlenwerte des AKKUs und der Speicherzelle, dessen Adresse in Speicherzelle n gespeichert
{ } ist, in den AKKU
{DIV n } speichert das Ergebnis der Ganzzahldivision des AKKUs durch den Zahlenwert der Speicherzelle n in den AKKU
{DIV #n } speichert das Ergebnis der Ganzzahldivision des AKKUs durch n in den AKKU
{DIV (n)} speichert das Ergebnis der Ganzzahldivision des AKKUs durch den Zahlenwert der Speicherzelle, dessen Adresse in Speicherzelle n gespeichert
{ } ist, in den AKKU
{JMP n } springt zu Speicherzelle n indem der BZ auf n gesetzt wird
{JZE n } springt zu Speicherzelle n indem der BZ auf n gesetzt wird wenn der im AKKU gespeicherte Zahlenwert 0 ist
{JLE n } springt zu Speicherzelle n indem der BZ auf n gesetzt wird wenn der im AKKU gespeicherte Zahlenwert kleiner oder gleich
{ } 0 ist"""
{ } 0 ist
{JNZ n } springt zu Speicherzelle n indem der BZ auf n gesetzt wird wenn der im AKKU gespeicherte Zahlenwert nicht 0 ist"""
},
"shc_win": {
"title": "Tastenkombinationen",
Expand Down
11 changes: 9 additions & 2 deletions program/languages/en_US.dict
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"info": {
"name": "English (United States)",
"version": "1.0",
"authors": ["Blyfh"]
"authors": ["Blyfh","Etienne Seet"]
},
"file_mng": {
"AsmFiles": "Assembler files",
Expand Down Expand Up @@ -60,6 +60,8 @@
"MinAdrLen": "Minimum number of digits",
"MaxCels": "Maximum program length",
"MaxJmps": "Maximum iteration depth",
"AutoShiftAddresses": "Auto-shift addresses on insert/delete",
"AutoShiftAddressesTip": "Automatically adjust following addresses when inserting or deleting lines",

"File": "File",
"ClosingUnsaved": "Action on closing unsaved program",
Expand Down Expand Up @@ -119,9 +121,14 @@ A list of all accepted commands:
{MUL #n } multiplies the value n by the value of the ACC and stores the result into the ACC
{MUL (n)} multiplies the value of the MC that has the address that is stored in MC n by the value of the
{ } ACC and stores the result into the ACC
{DIV n } divides the value of the ACC by the value at MC n (integer division) and stores the result into the ACC
{DIV #n } divides the value of the ACC by the value n (integer division) and stores the result into the ACC
{DIV (n)} divides the value of the ACC by the value of the MC that has the address that is stored in MC n (integer division) and
{ } stores the result into the ACC
{JMP n } jumps to MC n by setting the PC to n
{JZE n } jumps to MC n by setting the PC to n if the value of the ACC is equal to zero
{JLE n } jumps to MC n by setting the PC to n if the value of the ACC is less than or equal to zero"""
{JLE n } jumps to MC n by setting the PC to n if the value of the ACC is less than or equal to zero
{JNZ n } jumps to MC n by setting the PC to n if the value of the ACC is not equal to zero"""
},
"shc_win": {
"title": "Shortcuts",
Expand Down
3 changes: 2 additions & 1 deletion program/resources/default_profile.dict
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"theme": "dark",
"language": "en_US",
"code_font_face": "Courier New",
"code_font_face": "Courier",
"code_font_size": 10,
"min_adr_len": 2,
"max_jmps": 8192,
"max_cels": 8192,
"closing_unsaved": "ask",
"last_dir": "",
"auto_shift_addresses": True,
"dev_mode": False
}
23 changes: 20 additions & 3 deletions program/source/Editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,25 @@
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

"""
Traceback (most recent call last):
File "/home/eti/Dokumente/code/git/Assemblitor/Assemblitor.pyw", line 54, in <module>
from program.source import Editor
File "/home/eti/Dokumente/code/git/Assemblitor/program/source/Editor.py", line 20, in <module>
ctypes.windll.shcore.SetProcessDpiAwareness(True)
^^^^^^^^^^^^^
AttributeError: module 'ctypes' has no attribute 'windll'
"""
# Fix for Linux AttributeError: module 'ctypes' has no attribute 'windll'
import sys
import ctypes

ctypes.windll.shcore.SetProcessDpiAwareness(True)
# Only run on Windows
if sys.platform == "win32":
try:
ctypes.windll.shcore.SetProcessDpiAwareness(1) # or True
except Exception:
pass

ph: pck.ProfileHandler
lh: pck.LangHandler
Expand Down Expand Up @@ -97,8 +114,8 @@ def build_gui(self):
self.change_options_VAR = tk.StringVar()
self.active_theme = ph.theme() # won't change without restart
self.active_language = ph.language() # won't change without restart
self.title_font = ("Segoe", 15, "bold")
self.subtitle_font = ("Segoe", 13)
self.title_font = ("DejaVu Sans", 15, "bold")
self.subtitle_font = ("DejaVu Sans", 13)
self.set_theme(theme=self.active_theme)
self.options_SUB = sub.Options( editor=self)
self.shortcuts_SUB = sub.Shortcuts(editor=self)
Expand Down
Loading