Keyword Purpose Example
ignite Start program execution ignite
shutdown End program execution shutdown
summon Display output/print values summon "Hello World"
ask Get user input for a variable ask username
if x > 10
if/elif/else/endif Conditional statements summon "Large"
endif
for 5 times
for/while/do/eloop Loop structures summon "Loop"
eloop
sloop Break/exit from loop sloop
num Declare integer/number variable num age = 25
text Declare string/text variable text name = "John"
flag Declare boolean variable flag is_active = true
Data Types Table
Data Type Description Example
num Integer or floating-point numbers num price = 19.99
text String/text values (with quotes) text msg = "Welcome"
flag Boolean values (true/false) flag logged_in = false
Operators Table
Operator Purpose Example
+-*/ Arithmetic operations num result = 10 + 5
== != < > Comparison operators if x == y
<= >= Comparison operators if score >= 90
&& || Logical AND/OR if (x > 0 && y < 10)
= Assignment operator num x = 10
ignite
num counter = 1
while counter <= 5
summon "Count: " + counter
counter = counter + 1
eloop
summon "Loop finished!"
shutdown
ignite
for 5 times
summon "JarkProg is fun!"
eloop
shutdown
**JarkProg CodeEditor - Whole Code Explanation (Ilonggo Version):**
## **PART 1: Variable Declarations**
```java
private int untitledCounter = 1;
```
- Ini ang **untitledCounter** nga nagatrack sang pila na ka "Untitled" nga files ang
nahimo. Paagi sa `= 1`, nagsugod sya sa number 1.
```java
private final HashMap<Component, File> tabFileMap = new HashMap<>();
```
- Diri naghimo kita **HashMap** nga nagamapa (nagaconnect) sang **Component**
(ang tab) sa **File** (ang actual file sa computer). Pareho ini sa paglista kung diin
ang kada code file naka-store.
```java
private Player mp3Player;
```
- Ini ang **mp3Player** object para sa background music. Ang Player class gikan sa
javazoom library para sa music playback.
```java
private final UndoManager undoManager = new UndoManager();
```
- Naghimo kita **UndoManager** nga nagatrack sang tanan nga changes sa text
editor para pwede mag-undo kag mag-redo.
```java
private boolean isDarkTheme = false;
```
- Ang **isDarkTheme** boolean variable nagatrack kung naka-dark theme ba o light
theme ang GUI. Nagsugod sa `false` meaning light theme una.
## **PART 2: Constructor (Main Setup)**
```java
public CodeEditor() {
initComponents();
setLocationRelativeTo(null);
initCustomListeners();
applyDefaultTheme();
clearProjectTree();
enableLineNumbering(jScrollPane2);
}
```
- Una, ginatawag ang **initComponents()** para mahimo ang tanan nga GUI
components (buttons, text areas, etc.).
- **setLocationRelativeTo(null)** nagabutang sang window sa tunga-tunga sang
screen.
- **initCustomListeners()** nagasetup sang mga custom event handlers.
- **applyDefaultTheme()** nagaset sang default (light) theme colors.
- **clearProjectTree()** nagaclear sang project tree display.
- **enableLineNumbering(jScrollPane2)** nagadugang sang line numbers sa sidebar.
## **PART 3: SAVE FUNCTION (Detailed Ilonggo Explanation)**
```java
private void saveActionPerformed([Link] evt) {
// 1. Get the current tab's scroll pane
JScrollPane currentScroll = (JScrollPane) [Link]();
// 2. Get the text area inside it
JTextArea currentText = getCurrentTextArea();
// 3. Check if both are valid
if (currentScroll == null || currentText == null) return;
// 4. Look for existing file in our map
File loc = [Link](currentScroll);
// 5. If file doesn't exist yet (untitled file)
if (loc == null) {
// Show file chooser dialog
JFileChooser chooser = new JFileChooser();
// 6. If user clicks Save button
if ([Link](this) == JFileChooser.APPROVE_OPTION) {
// Get selected file
loc = [Link]();
// 7. Check if filename has extension
if (![Link]().contains(".")) {
// Add .jark extension if missing
loc = new File([Link]() + ".jark");
}
// 8. Store in our map for future reference
[Link](currentScroll, loc);
// 9. Update tab title with filename
[Link]([Link](), [Link]());
} else {
// 10. User cancelled, exit function
return;
}
}
// 11. Save the actual file
try {
// Convert text to bytes and write to file
[Link]([Link](), [Link]().getBytes());
// 12. Show success message
[Link](this, "Saved!");
} catch (IOException ex) {
// 13. Show error if saving fails
[Link](this, "Error saving: " + [Link]());
}
}
```
## **PART 4: RUN FUNCTION (Code Execution)**
```java
private void runActionPerformed([Link] evt) {
// 1. Kunin ang current text area
JTextArea currentArea = getCurrentTextArea();
if (currentArea == null) {
[Link](this, "No code to run!");
return;
}
String code = [Link]();
// 2. Clear previous output and switch to Output tab
[Link]("");
[Link](0);
// 3. Run in background thread para indi mag-freeze ang GUI
new Thread(() -> {
try {
JarkInterpret interpreter = new JarkInterpret();
// 4. Connect output: Kunin ang tanan nga print statements
[Link]((String message) -> {
[Link](() -> {
[Link](message + "\n");
// Auto-scroll to bottom
[Link]([Link]().getLength());
});
});
// 5. Connect input: Para sa 'ask' commands
[Link]((String prompt) -> {
return [Link](this, prompt);
});
// 6. Execute the JarkProg code
[Link](code);
} catch (Exception e) {
[Link](() -> {
[Link]("\nCRITICAL ERROR: " + [Link]());
});
}
}).start();
}
```
## **PART 5: THEME SWITCHING FUNCTION**
```java
private void changethemeActionPerformed([Link] evt) {
if (isDarkTheme) {
// Switch to light theme
stopBackgroundMusic(); // Para magstop ang music
// Change background panel visibility and color
[Link](true);
[Link](Color.DARK_GRAY);
// Change editor colors to white background
[Link]([Link]);
[Link]([Link]);
// Change output area colors
[Link]([Link]);
[Link]([Link]);
// Change project tree colors
[Link]([Link]);
[Link]([Link]);
// Update menu text
[Link]("Switch to Jark Mode");
} else {
// Switch to dark (Jark) theme
playBackgroundMusic(); // Para magplay ang music
// Hide default background
[Link](false);
// Change to dark blue colors
[Link](new Color(0, 0, 51));
[Link]([Link]);
[Link](new Color(0, 0, 51));
[Link]([Link]);
[Link](new Color(102, 255, 255));
[Link]([Link]);
// Update menu text
[Link]("Back to Default");
}
// Toggle the theme state
isDarkTheme = !isDarkTheme;
// Refresh the GUI
[Link]();
}
```
## **PART 6: NEW FILE FUNCTION**
```java
private void newfileActionPerformed([Link] evt) {
// Create new JTextPane (better than JTextArea for syntax highlighting)
JTextPane newPane = new JTextPane();
// Set font and colors
[Link](new Font("Monospaced", [Link], 14));
[Link](new Color(0, 0, 51));
[Link]([Link]);
[Link]([Link]);
// Attach syntax highlighter
JarkHighlight highlighter = new JarkHighlight(newPane);
// Add document listener for real-time highlighting
[Link]().addDocumentListener(new
[Link]() {
public void insertUpdate([Link] e)
{ [Link](); }
public void removeUpdate([Link] e)
{ [Link](); }
public void changedUpdate([Link] e)
{ [Link](); }
});
// Wrap in scroll pane
JScrollPane scroll = new JScrollPane(newPane);
// Add undo/redo support
[Link]().addUndoableEditListener(e ->
[Link]([Link]()));
// Add to tabbed pane with auto-generated name
[Link]("Untitled-" + untitledCounter++, scroll);
[Link](scroll);
// Update colors for all tabs based on current theme
for (int i = 0; i < [Link](); i++) {
Component tab = [Link](i);
if (tab instanceof JScrollPane jScrollPane) {
JViewport viewport = [Link]();
Component editor = [Link]();
[Link](isDarkTheme ? [Link] : new Color(0, 0, 51));
[Link](isDarkTheme ? [Link] : [Link]);
}
}
}
```
## **PART 7: Helper Functions**
### **getCurrentTextArea()**
```java
private JTextArea getCurrentTextArea() {
if ([Link]() instanceof JScrollPane scroll) {
return (JTextArea) [Link]().getView();
}
return null;
}
```
- Diri ginakuha naton ang **current active text area** gikan sa selected tab. Ang
`instanceof` nagacheck kung ang selected component kay **JScrollPane**, dayon
ang `getViewport().getView()` nagakuha sang actual nga JTextArea sulod sa scroll
pane.
### **enableLineNumbering()**
```java
private void enableLineNumbering(JScrollPane scrollPane) {
JTextArea textArea = (JTextArea) [Link]().getView();
JTextArea lines = new JTextArea("1");
[Link](Color.LIGHT_GRAY);
[Link]([Link]);
[Link](false);
// Document listener para ma-update ang line numbers
[Link] updateNumbers = new
[Link]() {
private void update() {
[Link](() -> {
int lineCount = [Link]();
StringBuilder sb = new StringBuilder();
for (int i = 1; i <= lineCount; i++) {
[Link](i).append("\n");
}
[Link]([Link]());
});
}
};
[Link]().addDocumentListener(updateNumbers);
[Link](lines);
}
```
- Nagahimo sang separate nga JTextArea para sa line numbers.
- Ang **DocumentListener** nagamonitor sang tanan nga changes sa text.
- Ang `[Link]()` nagagarantiya nga ang GUI update mangin safe
kag smooth.
- Ang `setRowHeaderView()` nagabutang sang line numbers sa left side.
## **PART 8: Project Tree Functions**
### **createTreeNodes()**
```java
private void createTreeNodes(File fileRoot, DefaultMutableTreeNode node) {
File[] files = [Link]();
if (files == null) return;
for (File file : files) {
DefaultMutableTreeNode childNode = new
DefaultMutableTreeNode([Link]());
[Link](childNode);
if ([Link]()) {
createTreeNodes(file, childNode); // RECURSIVE CALL
}
}
}
```
- Ginakuha ang tanan nga files kag folders sa directory.
- Para sa kada file/folder, nagahimo sang **DefaultMutableTreeNode**.
- Kon ang file kay **directory** (folder), ginatawag liwat ang function (**recursive**)
para ma-explore ang sulod sang subfolder.
## **PART 9: Context Menu**
```java
private void showTabContextMenu([Link] evt, int tabIndex) {
JPopupMenu menu = new JPopupMenu();
JMenuItem closeItem = new JMenuItem("Close");
[Link](e -> {
[Link]([Link](tabIndex));
[Link](tabIndex);
});
JMenuItem renameItem = new JMenuItem("Rename");
[Link](e -> {
String name = [Link](this, "New Name:");
if (name != null && ![Link]().isEmpty()) {
[Link](tabIndex, name);
}
});
[Link](closeItem);
[Link](renameItem);
[Link]([Link](), [Link](), [Link]());
}
```
- Nagahimo sang popup menu para sa right-click sa tab.
- Ang **Close** menu item nagaremove sang tab gikan sa tabFileMap kag sa tabbed
pane.
- Ang **Rename** menu item nagapakita sang input dialog para baguhon ang tab
title.
## **PART 10: Main Method**
```java
public static void main(String args[]) {
try {
// Set Nimbus look and feel
for ([Link] info : [Link]()) {
if ("Nimbus".equals([Link]())) {
[Link]([Link]());
break;
}
}
} catch (Exception ex) {}
// Create and show the editor in event dispatch thread
[Link](() -> new CodeEditor().setVisible(true));
}
```
- Ginaset ang **Nimbus** look and feel para modern ang appearance.
- Ang `[Link]()` nagagarantiya nga ang GUI mahimo sa
proper thread.
**Ang bug-os nga CodeEditor amo ini ang integrated development environment
para sa JarkProg language nga nagatugot sa user nga mag-create, mag-edit, mag-
save, kag mag-run sang JarkProg code sa isa ka visual interface.**