GithubHelp home page GithubHelp logo

joshdreamland / joshedit Goto Github PK

View Code? Open in Web Editor NEW
7.0 4.0 4.0 462 KB

A lightweight code editor for use in Java applications.

Home Page: www.dreamland.im/JoshEdit

License: GNU General Public License v3.0

Java 99.38% Lex 0.62%

joshedit's Introduction

JoshEdit

This repository hosts the code editing control used by LateralGM.

Building

This project can be built with Maven:

mvn package

For testing, the org.lateralgm.joshedit.Runner class contains an entry point which displays an instance of the control in a window:

java -cp target/classes org.lateralgm.joshedit.Runner 

joshedit's People

Contributors

cybershadow avatar ismavatar avatar joshdreamland avatar robertbcolton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

joshedit's Issues

Component Popup Listener

There is a fundamental flaw in most Swing applications with the way popup menu's are handled. If you for instance, right click in Visual Studio, Eclipse or any brand name software even CodeBlocks, on a tree or in a code editor, the right mouse click is interpreted as a left click.

Basically, if I right click somewhere in a code editor, my mouse cursor should be moved on pressed, just as if it would be on left click, and on mouse released a popup menu should appear, I should also be able to right click the items in the popup menu and not just left click them. This is standard with any GUI framework as well as the Scintilla syntax highlighting component. JoshEdit however only interprets the left mouse click as a selection change.
https://github.com/JoshDreamland/JoshEdit/blob/master/org/lateralgm/joshedit/JoshText.java#L1493
Attempting to add the right mouse button to that line results in quite a few glitches.

Shift+Tab Exception

This is not a regression and exists in lgm1.8.2

  • In eclipse, tab with a selection will delete your selection and insert a space
  • In eclipse, shift tab with a selection will maintain your selection and unindent the current line
  • Notepad++ will change the selection to just the left most caret position, the start in other words, and continue unindenting the cursor until it is just before the first character on the line and then begins to unindent the line. Tab will behave as it does in Eclipse and delete your selection and replace it with a space.
  • GM8.1 and Studio the selected line is indented and unindented while maintaining the selection

The issue is rooted in the following line, the selection is being increased regardless of whether the line was actually indented/unindented.
https://github.com/JoshDreamland/JoshEdit/blob/master/org/lateralgm/joshedit/JoshText.java#L2145

  1. Select part of a line of code
    Tab Selection
  2. Hold shift+tab and the selection will be maintained and the line will be unindented
  3. Once it can no longer unindent the line will stay the same but the selection will continue moving to the right until it goes out of bounds
  4. Press enter for a new line
    Tab Select OOB
Stack trace:
java.lang.StringIndexOutOfBoundsException
    at java.lang.AbstractStringBuilder.delete(Unknown Source)
    at java.lang.StringBuilder.delete(Unknown Source)
    at org.lateralgm.joshedit.Selection.deleteSel(Selection.java:330)
    at org.lateralgm.joshedit.JoshText.processKeyTyped(JoshText.java:2048)
    at org.lateralgm.joshedit.JoshText.processComponentKeyEvent(JoshText.java:2509)
    at javax.swing.JComponent.processKeyEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$400(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

Text mangling on Linux

This was reported by Salabasama in IRC and I have also experienced it myself before but was unable to reproduce it right now on Windows 10 with Java 8. He stated that one look and feel seemed to help ameliorate the mangling a little bit but it still happened. However he did also state that the room editor and game info editor and basically all editors, even those using built in Swing text components like the error message dialog, have the problem. So it is likely just a Java bug.

Text Mangling

Feature: Multiple selection

Our selection system is powerful, but it's missing multiple selection (instead offering only rectangle selection). It would be good to have control serve as multiple selection and [control-]alt serve as rectangle selection. These should be configurable.

Repainting Exception

First, create a new script, on the first line put '{' then add a new line and then the '}' symbol. Then right click and select all the text, then right click again and hit cut, exception will occur resulting from an attempt to paint the second brace on an out of range line.

This bug was patched over in LateralGM's repository.
IsmAvatar/LateralGM@2bfb695
This issue further extends to undo/redo
IsmAvatar/LateralGM@1c0d63a

Feature: Selected identifier marker

Most IDE code editors offer a feature in which selecting a variable highlights all occurrences of it. While highlighting specifically occurrences of that exact variable is outside the scope of JoshEdit, a feature should be added which marks all whole-word occurrences of the given selection. It should be simple for an IDE to extend this with an iterable of token occurrences.

setText does not repaint

It should fire a repaint/revalidate the layout. If the window isn't focused and you call set text it won't appear until you focus JoshEdit.

Horizantal Scrolling in Code Editor

This issue is carried over from enigma-dev/enigma-dev#964 and I have experienced it myself with the undo/redo. You can't scroll right (scrollbar may not even be visible) to see the text until you close and reopen the code editor.

Frogg also managed to find a way to reproduce it consistently and I successfully did so too. Just keep holding tab down on a new script window in LGM and the horizontal scrollbar never appears. This is also not a regression as it also occurs in LGM 1.8.2.

(Posted by FroggestSpirit on the ENIGMA forums)

When you have a long line of code, the Horizantal scroll bar appears, however it is not proportionate with the line of code, meaning the longer the line, the more of it gets cut off.

Check Undo Status

JoshEdit currently has no canUndo/hasUndo canRedo/hasRedo interface though it is perfectly capable of providing that. It should be implemented so that the undo/redo actions can be grayed letting the user they have no available undo's/redo's. All other LGM editors currently do this for the undo/redo buttons except for those related to JoshEdit.

Requests

This is a list of my suggested features.

  • Different encoding options like Scintilla
  • Style sheets
  • Different margins than just line numbers, such as breakpoints and codefolding

Missing Cursor

A Portuguese user by the name of manokara showed up on IRC and mentioned that after they edit a script using JoshEdit and then reopen the script, the cursor is not visible (not the mouse pointer, the text cursor).

openjdk version "1.8.0_51-internal"

He also stated he was using a fairly new Linux distribution called Solus. He did not file a bug because he is unable to reproduce the issue consistently. A restart apparently corrects the issue.

I would venture that it's likely because he's using OpenJDK, which I've discussed at great length. As much as I love open source, at this point in time, I still find the Oracle JDk to be more stable with Swing.

Anti-aliasing and desktop hints

This is just a heads up. The way JoshEdit is getting the AA hints may not be the best. For LGM's HintTextField for the search bar I used SwingUtilities2.paintString which respects other system properties regarding the fonts. However, JoshEdit is properly respecting LGM's preference to override and force AA on or off.

Object map = Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints"); //$NON-NLS-1$

https://github.com/IsmAvatar/LateralGM/blob/600ab444e0ecd284a71eede02460cc65cd5acc22/org/lateralgm/main/LGM.java#L2084

Update: SwingUtilities2 is apparently deprecated and not public API.
http://www.coderanch.com/t/428503/GUI/java/SwingUtilities-deprecated-alternative
On JDK 8u60 however I can still use it to paint the HintTextField for LateralGM with the current system AA settings. This was used because Swing uses it internally for LabelUI.

FindDialog is no longer centered

Press CTRL+F the FindDialog will now be at 0,0 at the top left of your screen, even when executed from the runner and not from LGM. This is a regression introduced by just recent changes and does not exist in LateralGM 1.8.6, I have yet to track down the issue.
https://github.com/JoshDreamland/JoshEdit/blob/61efabef19c8dd649127cfc3859eb4b662fd271b/org/lateralgm/joshedit/FindDialog.java

I do however have a temporary fix. Add the following line to where JoshText shows the FindDialog, this is the fix going into the current LGM build.
https://github.com/JoshDreamland/JoshEdit/blob/master/org/lateralgm/joshedit/JoshText.java#L901

findDialog.setLocationRelativeTo(this);

Feature: Focus boxes for code completion and refactor

Eclipse has the ability to create focus boxes which can quickly be switched between for code completion purposes. The boxes can be assigned to have identical content or to be switched between.

Examples:

  1. Declaring a variable: Both the inferred type and the variable name are given a box.
  2. Renaming a variable: All occurrences of the variable share a box, including the declaration.
  3. For loops: A box is created for each of the three loop parameters, and the loop body is given focus afterward.

Feature Request: Exception Handling

Back in #37 I attempted to add exception handling by encapsulating what should be done in an interface. I am starting to think this was not the best way to address this in lieu of my recent software engineering experience. I think it would probably be better if JoshEdit just rethrow the exceptions instead of sinking them. I would be interested to know @JoshDreamland's opinion on the matter.

Horizontal Scrollbar Selection Glitch

The frame will keep glitching and the line number panel for that line will be a garbled mess. You can also reproduce it by just starting the selection on the last line and dragging below the code window if the vertical scrollbar is active. I would love if we could fix this bug because it makes doing selections a real pain.

Selection Exception

Continuing from #19 even with the latest changes there is a new issue just about the same as before.

  1. Indent a line of code
  2. Select empty white space before the code line
  3. Shift+Tab and the selection will keep going left out of bounds
  4. Hit enter to insert a new line, and bam, exception
Stack trace:
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
    at java.lang.AbstractStringBuilder.delete(Unknown Source)
    at java.lang.StringBuilder.delete(Unknown Source)
    at org.lateralgm.joshedit.Selection.deleteSel(Selection.java:330)
    at org.lateralgm.joshedit.JoshText.processKeyTyped(JoshText.java:2035)
    at org.lateralgm.joshedit.JoshText.processComponentKeyEvent(JoshText.java:2512)
    at javax.swing.JComponent.processKeyEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$400(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

Set the Visible Line

Visible Line
Currently JoshEdit has very little means of focusing the caret. setCaret works to a limited degree but there is not option for instance to center the view around the new line, like the search feature wants to open the frame and then focus the line for the search result the user selected. The solution was to use SwingUtilities and thread the setCaret call, but it still has the same issue. Additionally as reported by egofree, if the horizontal scrollbar is visible it will cover up the selected line.

http://enigma-dev.org/forums/index.php?topic=2269.msg23595#new

Keybindings not Swing Compatible

I believe you wrote your input map stuff because you didn't know the power of Java, so let me inform you @JoshDreamland

I used Swing's getKeyStroke format to let me move all of LGM's keyboard shortcuts into a properties file while still allowing multiple (more than 2) key combination masks and events as well as modifiers.
http://docs.oracle.com/javase/7/docs/api/javax/swing/KeyStroke.html#getKeyStroke%28java.lang.String%29

The implementation is effectively resolving IsmAvatar/LateralGM#147 with the following file for comparison to the JoshEdit implementation.
https://github.com/IsmAvatar/LateralGM/blob/master/org/lateralgm/messages/keyboard.properties

Move vs Copy Selected Text

When drag and dropping the currently selected text JoshEdit will always make a copy and leave the original. If you experiment with Notepad++ or any other source code editor it should be a move. Holding the control button in Notepad++ will perform a copy. JoshEdit always does a copy and ignores move. This ticket was originally filed on the LGM tracker. IsmAvatar/LateralGM#75

Preferences Bugs

Ok, since you were unaware, I figured I should take the time to point out the issues to you.

  • Keyboard preferences are all disabled, can't change any of them.
  • Some of the built in syntax schemes are disabled.
  • Switching the combo box to some schemes stops the UI from repainting.

For these reasons I have decided to hide the JoshEdit preferences in the next LGM release until they are finished. I did not even bother to test a posteriori if the serialization works because of the UI bugs.

Feature: Highlight All

In popular code editors like Scintilla I can select a statement or expression or token of some sort and all occurrences are automatically highlighted. I use this feature so much in Notepad++ and Eclipse, it is a really intuitive way of searching without even having to open a dialog over and over. It's just about as useful if not more so than showing me my matching brace/bracket/parenthesis.

Clipboard Bug

So I had selected text and somehow my cursor got right in the middle of my selected text, and every character after where the cursor was turned to a question mark.

So let's say this was my selection, and the @ symbol is my cursor.
ABCDEFG@SDJJIEOOIJOI
This is what the text turned into after I cut it on the clipboard and then hit undo.
ABCDEFG@????????????

Flickering Scrollbars

This is not a regression and exists in LGM 1.8.2 and is also currently present in the runner. When downsizing the code editor the scrollbars will flicker on and off, it's really annoying and glitchy. It most likely has to do with the preferred size.

Code Completion Cursor Movement

Just trying to dig up why a user had a bug with LGM IsmAvatar/LateralGM#25 and I can't find anything. But I did manage to find in JoshEdit when the code completion window is open, if you press left or right, it is ignored. In Eclipse you are allowed to move the cursor with the completion window open and it will update, closing if you leave the current symbol. Notepad++ almost always closes the window on left/right. Not necessarily a bug in JoshEdit, possibly a feature request. I think the Eclipse behavior is the best.

Selection OOB

Hold CTRL while selecting and you can select OOB during which the caret position does not match the selection either.

Print Support

LateralGM has recently fixed its printing capabilities (IsmAvatar/LateralGM#155) on two frames. JoshEdit should seriously have a .print() function like that which was added to Java 1.6

Painting Exception Loading Empty Text File

As long as the text file has 1 character this does not occur. Saving an empty JoshEdit frame works fine, this issue also exists in LGM master.

AWT-EventQueue-0: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.rangeCheck(Unknown Source)
    at java.util.ArrayList.get(Unknown Source)
    at org.lateralgm.joshedit.Code.getsb(Code.java:91)
    at org.lateralgm.joshedit.JoshText.line_wid_at(JoshText.java:1343)
    at org.lateralgm.joshedit.Caret.repaint(Caret.java:126)
    at org.lateralgm.joshedit.Caret.actionPerformed(Caret.java:114)
    at javax.swing.Timer.fireActionPerformed(Unknown Source)
    at javax.swing.Timer$DoPostEvent.run(Unknown Source)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$400(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

Caret Focus Horizontal Scrollbar

Create a really long script like 47 lines or so, and on the last line create a really long match such as "varrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr" then do a search in resources and double click the result. If the horizontal scrollbar is visible the frame will open and the line will be directly under the scrollbar, if you click the search result node again it will then focus the caret correctly positioning the horizontal scrollbar just below the last line.
https://github.com/IsmAvatar/LateralGM/blob/master/org/lateralgm/main/LGM.java#L1835

Startup Exception

I almost didn't notice this one because it's buried as soon as the application starts for some reason, even in the runner The result of the exception is the call on the following line.
https://github.com/JoshDreamland/JoshEdit/blob/master/org/lateralgm/joshedit/JoshText.java#L393
You can't pass null as a FocusEvent object I guess. I believe this may be causing #15

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at org.lateralgm.joshedit.JoshText.focusGained(JoshText.java:3553)
    at org.lateralgm.joshedit.JoshText.<init>(JoshText.java:402)
    at org.lateralgm.joshedit.JoshTextPanel.<init>(JoshTextPanel.java:55)
    at org.lateralgm.joshedit.JoshTextPanel.<init>(JoshTextPanel.java:49)
    at org.lateralgm.joshedit.Runner.showCodeWindow(Runner.java:81)
    at org.lateralgm.joshedit.Runner.createAndShowGUI(Runner.java:75)
    at org.lateralgm.joshedit.Runner$4.run(Runner.java:222)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$400(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

Enter New Line

Holding enter on a new script eventually hides the currently selected line, this is a regression and does not appear in 1.8.6

Enter New Line

Control Drag Select Bug

Hold control then left click with the mouse and select text and move it around, eventually your cursor will get really huge and be off centered like in the following screenshot.

A similar issue happens when entering ALT+256 for the NULL character, the cursor will be way far off from where the text starts typing again.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.