Skip to content

Commit

Permalink
Merge pull request #3 from zohaibanwer984/development
Browse files Browse the repository at this point in the history
Merging to main
  • Loading branch information
zohaibanwer984 authored Jan 8, 2024
2 parents 3234af9 + 77af0ae commit c7ece17
Show file tree
Hide file tree
Showing 32 changed files with 1,430 additions and 908 deletions.
10 changes: 10 additions & 0 deletions App.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#Sun Jan 07 12:18:17 PKT 2024
BracketMatching=true
CodeFolding=true
DEV=true
HighlightCurrentLine=true
LineNumbers=true
LineWrap=false
editorTheme=default
fontSize=16
lookAndFeel=com.formdev.flatlaf.FlatLightLaf
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ BitCode IDE is a lightweight Java Integrated Development Environment designed fo

## Features

- **Bulit-in Console:** Output of files will be run insice the IDE
- **Syntax Highlighting:** Supports syntax highlighting for Java code.
- **Bulit-in Console:** Output of files will be run inside the IDE
- **Syntax Highlighting:** Supports syntax highlighting for Java code using the Rsyntaxtextarea library.
- **Code Compilation:** Compiles Java code using the bundled OpenJDK.
- **Code Execution:** Runs compiled Java programs.
- **Undo/Redo:** Provides undo and redo functionality for text edits.
Expand All @@ -18,13 +18,13 @@ BitCode IDE is a lightweight Java Integrated Development Environment designed fo
## Screenshots

### Tabbed Editor
![Tabbed Editor](/screenshots/tabbed_editor.png)
<img src="/screenshots/tabbed_editor.png" alt="Tabbed Editor" width="700" height="auto">

### Syntax Highlighting
![Syntax Highlighting](/screenshots/syntax_highlighting.png)
### Syntax And Themes
<img src="/screenshots/Themes.png" alt="Syntax And Themes" width="700" height="auto">

### Code Compilation
![Code Compilation](/screenshots/code_compilation.png)
<img src="/screenshots/consoleOutput.png" alt="Code Compilation" width="700" height="auto">

# Getting Started

Expand Down Expand Up @@ -58,9 +58,8 @@ Contributions, bug reports, and feature requests are welcome! See the [issues](h

## Thanks

Special thanks to [FlatLaf](https://github.com/JFormDesigner/FlatLaf) for providing the FlatLaf theme library, enhancing the visual appeal of BitCode IDE.
Special thanks to [FlatLaf](https://github.com/JFormDesigner/FlatLaf) for providing the FlatLaf theme library, enhancing the visual appeal of BitCode IDE. Additionally, thanks to [Rsyntaxtextarea](https://github.com/bobbylight/RSyntaxTextArea) for enabling syntax highlighting in the textarea.

## License

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.

27 changes: 27 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@
<artifactId>flatlaf-intellij-themes</artifactId>
<version>3.2.5</version>
</dependency>
<dependency>
<groupId>com.fifesoft</groupId>
<artifactId>rsyntaxtextarea</artifactId>

</dependency>
<dependency>
<groupId>com.fifesoft</groupId>
<artifactId>autocomplete</artifactId>
<version>3.3.0</version>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -80,4 +90,21 @@
</plugins>
</pluginManagement>
</build>


<dependencyManagement>


<dependencies>


<dependency>
<groupId>com.fifesoft</groupId>
<artifactId>rsyntaxtextarea</artifactId>
<version>3.3.0</version>
</dependency>

</dependencies>

</dependencyManagement>
</project>
Binary file added screenshots/Themes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed screenshots/code_compilation.png
Binary file not shown.
Binary file added screenshots/consoleOutput.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed screenshots/syntax_highlighting.png
Binary file not shown.
Binary file modified screenshots/tabbed_editor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 40 additions & 16 deletions src/main/java/com/zam/components/Editor/EditorTabPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

import javax.swing.Icon;
import javax.swing.JTabbedPane;
import javax.swing.JTextPane;
import javax.swing.UIManager;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;

import com.zam.ui.App;

Expand All @@ -16,7 +17,7 @@
*
* Responsibilities:
* - Handling the creation and removal of code editor tabs.
* - Associating each tab with a LineNumberPane and JTextPane.
* - Associating each tab with a CodeTextArea.
* - Customizing tab appearance and behavior, including tab closing.
*
* Usage:
Expand All @@ -25,23 +26,23 @@
*
* Example:
* ```java
* EditorTabPane editorTabPane = new EditorTabPane(lineNumberPanes, mainApp);
* EditorTabPane editorTabPane = new EditorTabPane(mainApp);
* editorTabPane.addCodeAreaTab("Untitled", icon, "tooltip", "Initial content");
* ```
*
* @author Muhammed Zohaib
* @version 1.0
* @version 1.0.2
* @since 2023-11-29
*/
public class EditorTabPane extends JTabbedPane {

private List<LineNumberPane> lineNumberPanes;
private List<CodeTextArea> codeAreaPanes;
private App mainApp;

/**
* Constructor for the EditorTabPane.
*
* @param parent The main App instance.
* @param parent The main App instance.
*/
public EditorTabPane(App parent) {
this.mainApp = parent;
Expand All @@ -52,7 +53,7 @@ public EditorTabPane(App parent) {
UIManager.put("TabbedPane.closeHoverBackground", new Color(0, true));
UIManager.put("TabbedPane.showTabSeparators", true);

this.lineNumberPanes = mainApp.lineNumberPanes;
this.codeAreaPanes = mainApp.codeAreaPanes;

// Enable tab closing and set tab layout policy
this.putClientProperty("JTabbedPane.tabClosable", true);
Expand All @@ -64,7 +65,7 @@ public EditorTabPane(App parent) {
if (getTitleAt(tabIndex).startsWith("untitled")) {
mainApp.menuBar.fileMenu.untitledCount--;
}
lineNumberPanes.remove((int) tabIndex);
codeAreaPanes.remove((int) tabIndex);
this.remove(tabIndex);
});
}
Expand All @@ -78,13 +79,36 @@ public EditorTabPane(App parent) {
* @param content The initial content of the code editor.
*/
public void addCodeAreaTab(String title, Icon icon, String tooltip, String content) {
lineNumberPanes.add(new LineNumberPane(mainApp));
JTextPane codePane = lineNumberPanes.get(this.getTabCount()).codetextPane;
codePane.setFont(App.font);
codePane.setText(content);
LineNumberPane lineNumberPane = lineNumberPanes.get(lineNumberPanes.size() - 1);
this.insertTab(title, icon, lineNumberPane, tooltip, this.getTabCount());
this.setSelectedIndex(this.getTabCount() - 1);
codePane.requestFocus();
codeAreaPanes.add(new CodeTextArea(mainApp));
CodeTextArea codePanel = codeAreaPanes.get(codeAreaPanes.size() - 1);
this.insertTab(title, icon, codePanel, tooltip, this.getTabCount());
setSelectedIndex(this.getTabCount()-1);
codePanel.codeTextArea.setText(content);
codePanel.codeTextArea.discardAllEdits();
codePanel.codeTextArea.setCaretPosition(codePanel.codeTextArea.getDocument().getLength() - 2);
codePanel.codeTextArea.requestFocus();
addListener(codePanel);
this.updateUI();
}

/**
* Adds a document listener to track changes in the code editor.
*
* @param codeTextArea The CodeTextArea instance to attach the listener to.
*/
private void addListener(CodeTextArea codeTextArea){
codeTextArea.codeTextArea.getDocument().addDocumentListener(new DocumentListener() {
public void insertUpdate(DocumentEvent e) {
mainApp.tabbedEditorPane.setIconAt(App.currentTabIndex, App.jRedImage);
}

public void removeUpdate(DocumentEvent e) {
mainApp.tabbedEditorPane.setIconAt(App.currentTabIndex, App.jRedImage);
}

public void changedUpdate(DocumentEvent e) {
mainApp.tabbedEditorPane.setIconAt(App.currentTabIndex, App.jRedImage);
}
});
}
}
187 changes: 0 additions & 187 deletions src/main/java/com/zam/components/Editor/LineNumberPane.java

This file was deleted.

Loading

0 comments on commit c7ece17

Please sign in to comment.