Skip to content

Commit

Permalink
initial changes
Browse files Browse the repository at this point in the history
  • Loading branch information
fletchthefletch committed Aug 8, 2021
1 parent 5710b71 commit 93f2ea6
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 22 deletions.
6 changes: 0 additions & 6 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,5 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
9 changes: 8 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>nz.ac.massey.cs</groupId>
<artifactId>nz.ac.massey.cs.flackpad</artifactId>
<version>0.4.1</version>
<version>0.4.4</version>

<properties>
<javaVersion>1.8</javaVersion>
Expand All @@ -14,6 +14,13 @@
</properties>

<dependencies>

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

<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/nz/ac/massey/cs/flackpad/FileIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static String getFileMIME(File file) {
String fileMIME = null;
try {
fileMIME = tika.detect(file);
} catch (IOException e) {
} catch (Exception e) {
return fileMIME;
}
return fileMIME;
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/nz/ac/massey/cs/flackpad/TextArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
import javax.swing.JTextArea;
import javax.swing.text.BadLocationException;

import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;

@SuppressWarnings("serial")
class TextArea extends JTextArea {
class TextArea extends RSyntaxTextArea {

private Window window;
private int fontSize;
Expand Down
33 changes: 20 additions & 13 deletions src/main/java/nz/ac/massey/cs/flackpad/Window.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import javax.swing.event.DocumentListener;
import javax.swing.text.Element;

import org.fife.ui.rsyntaxtextarea.SyntaxConstants;


@SuppressWarnings("serial")
class Window extends JFrame {
Expand Down Expand Up @@ -75,11 +77,15 @@ class Window extends JFrame {

Font currentfont = config.getFont();
Font linefont = currentfont.deriveFont(currentfont.getSize());
Color linesBackgroundColorHover = Color.decode("#222222");
Color linesBackgroundColor = Color.decode("#383838");

lines.setFont(linefont);
lines.setBorder(BorderFactory.createCompoundBorder(lines.getBorder(), BorderFactory.createEmptyBorder(5, 10, 5, 5)));
lines.setBackground(Color.decode("#eeeeee")); // change to get from config
lines.setForeground(Color.decode("#888888")); // change to get from config
lines.setBackground(linesBackgroundColor); // change to get from config
lines.setForeground(textArea.getSelectionColor()); // change to get from config



lines.addMouseListener(new MouseListener() {

Expand All @@ -100,12 +106,12 @@ public void mouseReleased(MouseEvent e) {

@Override
public void mouseEntered(MouseEvent e) {
lines.setBackground(Color.decode("#bbbbbb")); // change to get from config
lines.setBackground(linesBackgroundColorHover); // change to get from config
}

@Override
public void mouseExited(MouseEvent e) {
lines.setBackground(Color.decode("#eeeeee")); // change to get from config
lines.setBackground(linesBackgroundColor); // change to get from config
}

});
Expand Down Expand Up @@ -134,13 +140,20 @@ public void removeUpdate(DocumentEvent de) {
lines.setText(getText());
}
});
scrollPaneItem.getViewport().add(textArea);
// Get initial cursor focus from the user
textArea.requestFocus();
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); // specify language here !!!
textArea.setCodeFoldingEnabled(true);
textArea.setFontWithZoom(config.getFont());

// Set line height to that of the text area
scrollPaneItem.getViewport().add(textArea);
scrollPaneItem.setRowHeaderView(lines);
//scrollPaneItem.setBorder(null);


frame.setLocationRelativeTo(null);
frame.add(scrollPaneItem);
frame.add(scrollPaneItem);


// Add key bindings to instance
new KeyBinder(this);
Expand All @@ -149,12 +162,6 @@ public void removeUpdate(DocumentEvent de) {
frame.setSize(1000, 500);
frame.setVisible(true);
frame.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

// Set configuration
textArea.setFontWithZoom(config.getFont());

// Get initial cursor focus from the user
textArea.requestFocus();
}

void newDoc() {
Expand Down

0 comments on commit 93f2ea6

Please sign in to comment.