Menu

#109 Convert into simple Swing component

none
open
nobody
None
5
2024-03-14
2024-03-11
No

Could this be made into a simple extension of JTextArea? It could be called VimTextArea. Then other applications can easily incorporate it into any Swing app. Or maybe a set of key bindings for JTextArea? This could be a new project.

Discussion

  • Ernie Rael

    Ernie Rael - 2024-03-11

    Check out the jVi source, see https://sourceforge.net/p/jvi/code/, and in the top level directory do

    ./gradlew run
    

    This brings up a JEditorPane (JTextArea isn't enough) with jVi installed. This is built from the jvi-cmd directory, using the jars from jvi-core and jvi-swing.

    This is minimal.

    Also see README.

     
    👍
    1
  • Bill Chatfield

    Bill Chatfield - 2024-03-12

    I can't get it to build with openjdk 8, 11, 17, or 21. The README mentions 11 - 15 & 19. The build output mentions 8 & 11. It's not clear what is required to build it. This is the output of the build with 21:

    [bill@smilodon-gracilis jvi-code]$ ./gradlew run 
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    A problem occurred configuring root project 'jvi'.
    > Could not resolve all artifacts for configuration ':classpath'.
    > Could not resolve com.raelity.gradle.namedservicesmerge:namedservices-merge:0.5.0.
    Required by:
    project : > com.raelity.namedservices-merge:com.raelity.namedservices-merge.gradle.plugin:0.5.0
    > No matching variant of com.raelity.gradle.namedservicesmerge:namedservices-merge:0.5.0 was found. The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally but:
              - Variant 'apiElements' capability com.raelity.gradle.namedservicesmerge:namedservices-merge:0.5.0 declares a library, packaged as a jar, and its dependencies declared externally:
                  - Incompatible because this component declares an API of a component compatible with Java 11 and the consumer needed a runtime of a component compatible with Java 8
              - Variant 'javadocElements' capability com.raelity.gradle.namedservicesmerge:namedservices-merge:0.5.0 declares a runtime of a component, and its dependencies declared externally:
                  - Incompatible because this component declares documentation and the consumer needed a library
                  - Other compatible attributes:
                      - Doesn't say anything about its target Java version (required compatibility with Java 8)
                      - Doesn't say anything about its elements (required them packaged as a jar)
              - Variant 'runtimeElements' capability com.raelity.gradle.namedservicesmerge:namedservices-merge:0.5.0 declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
                  - Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8
              - Variant 'sourcesElements' capability com.raelity.gradle.namedservicesmerge:namedservices-merge:0.5.0 declares a runtime of a component, and its dependencies declared externally:
                  - Incompatible because this component declares documentation and the consumer needed a library
                  - Other compatible attributes:
                      - Doesn't say anything about its target Java version (required compatibility with Java 8)
                      - Doesn't say anything about its elements (required them packaged as a jar)
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Get more help at https://help.gradle.org
    
    BUILD FAILED in 1s
    
     
  • Ernie Rael

    Ernie Rael - 2024-03-13

    That's weird. The plugin, and instructions on how to use it are at
    https://plugins.gradle.org/plugin/com.raelity.namedservices-merge

    I'll take a look.

     
  • Ernie Rael

    Ernie Rael - 2024-03-13

    There's https://sourceforge.net/p/jvi/raelity-gradle/ which is the source I used to build the plugin. But the following would indicate that you can ignore that.

    I just tried moving aside
    1. ~/.gradle
    2. <mvn-repo>/com/raelity/namedservices-merge
    3, <mvn-repo>/com/raelity/gradle
    4. <mvn-repo>/org/frgaal

    Downloaded fresh source from http://hg.code.sf.net/p/jvi/code into jvi-code

    did

    JAVA_HOME=/ref/openjdk/jdk-11 ./gradlew run

    The first time I tried, I didn't set JAVA_HOME and ran into trouble (but something different from what you saw; tried again from scratch).

    It works OK here, I'm not sure what else I might have locally that would come into play. In ~/.gradle, after building, I see that namedservices-merge is download into the gradle cache, with a bunch of files by doing
    find ~/.gradle | grep '/named'

    The output is

    err@harmony:/junk/repo/jvi-dev/JUNK/jvi-code
    $ JAVA_HOME=/ref/openjdk/jdk-11 ./gradlew run 
    Downloading https://services.gradle.org/distributions/gradle-6.8.3-bin.zip
    ..........10%..........20%..........30%...........40%..........50%..........60%..........70%...........80%..........90%..........100%
    
    Welcome to Gradle 6.8.3!
    
    Here are the highlights of this release:
     - Faster Kotlin DSL script compilation
     - Vendor selection for Java toolchains
     - Convenient execution of tasks in composite builds
     - Consistent dependency resolution
    
    For more details see https://docs.gradle.org/6.8.3/release-notes.html
    
    Starting a Gradle Daemon (subsequent builds will be faster)
    
    > Configure project :jvi-cmd
    namedservicesMerge-1: project ':jvi-cmd' 'jVi/init/com.raelity.jvi.ViInitialization'
    
    > Configure project :jvi-swing
    namedservicesMerge-1: project ':jvi-swing' 'jVi/init/com.raelity.jvi.ViInitialization'
    
    > Task :jvi-core:compileJava
    Note: Some input files use preview features of Java SE 19.
    Note: Recompile with -Xlint:preview for details.
    
    > Task :jvi-swing:compileJava
    Note: /junk/repo/jvi-dev/JUNK/jvi-code/jvi-swing/src/main/java/com/raelity/jvi/swing/ui/options/EnumSetPropertyEditor.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    Note: /junk/repo/jvi-dev/JUNK/jvi-code/jvi-swing/src/main/java/com/raelity/jvi/swing/SwingFactory.java uses preview features of Java SE 19.
    Note: Recompile with -Xlint:preview for details.
    
    > Task :jvi-swing:namedservicesMerge-1
    namedservicesMerge-1: add 2 items from /junk/repo/jvi-dev/JUNK/jvi-code/jvi-swing/build/classes/java/main/META-INF/namedservices/jVi/init/com.raelity.jvi.ViInitialization
    namedservicesMerge-1: add 18 items from /junk/repo/jvi-dev/JUNK/jvi-code/jvi-swing/build/tmp/expandedArchives/jvi-core-2.1.0-SNAPSHOT.jar_956b41cfa8a14890b7421d3e6a8b25c0/META-INF/namedservices/jVi/init/com.raelity.jvi.ViInitialization
    
    > Task :jvi-swing:jar
    jar: project ':jvi-swing' adding META-INF/namedservices/jVi/init/com.raelity.jvi.ViInitialization
    
    > Task :jvi-cmd:run
    L&F: Metal
    L&F: Nimbus
    L&F: CDE/Motif
    L&F: GTK+
    Java verion: 11.0.17
    ...
    
     
  • Bill Chatfield

    Bill Chatfield - 2024-03-14

    O-kay, so when I ran the build again today, it just worked. I didn't make any changes. It displayed the test window and everything. Thanks for your help.

     
  • Ernie Rael

    Ernie Rael - 2024-03-14

    ran the build again today, it just worked

    Cool. Note that the jvi build produces jar files that run under jdk-11, but language constructs from jdk-19 can be used (frgaal magic).

    Note that you can do java -jar dist/jvi.jar to bring up the test window.

    jvi.jar should have everything needed to link/build against. It contains the jvi-core and jvi-swing jars along with various jars. Depending on your needs you might want to use individual jars, rather than the bundle.

    To get started, depending on your needs, you could copy the source in jvi-cmd to your own tree/packages. And use that with jvi.jar.

     
  • Ernie Rael

    Ernie Rael - 2024-03-14

    I'm wrong about library jars being included in jvi.jar. Everything in is the jvi-code/dist directory, the libraries are in jvi-code/dist/lib

     

Log in to post a comment.