feat: added empty buffer creation and submenu section

This commit is contained in:
zaaarf 2023-11-16 13:13:43 +01:00
parent d75fb75b3c
commit 1228f786b7
No known key found for this signature in database
GPG key ID: 6445A5CD15E5B40C
4 changed files with 47 additions and 11 deletions

View file

@ -10,14 +10,14 @@ import org.jetbrains.annotations.NotNull;
import java.io.IOException;
public class ConnectAction extends AnAction {
static {
/*try {
NativeUtils.loadLibraryFromJar("/resources/libHelloJNI.so");
} catch(IOException e) {
throw new RuntimeException(e);
}*/
System.load("O:/dev/IRL/Rust/codemp/client/intellij/target/debug/codemp_intellij.dll");
System.load("/home/zaaarf/dev/irl/rust/codemp/client/intellij/target/debug/libcodemp_intellij.so");
//System.load("O:/dev/IRL/Rust/codemp/client/intellij/target/debug/codemp_intellij.dll");
}
@Override
@ -29,7 +29,7 @@ public class ConnectAction extends AnAction {
try {
CodeMPHandler.connect(url);
//Messages.showInfoMessage(String.format("Connected to %s!", url), "CodeMP");
System.out.printf("Connected to %s!%n", url);
System.out.printf("Connected to %s!\n", url);
} catch(Exception ex) {
Messages.showErrorDialog(String.format("Failed to connect to %s: %s!", url, ex.getMessage()), "CodeMP");
}

View file

@ -24,7 +24,6 @@ import com.intellij.ui.JBColor;
import org.jetbrains.annotations.NotNull;
import java.awt.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@ -70,7 +69,7 @@ public class JoinAction extends AnAction {
h.dispose();
System.out.printf(
"Cursor moved by user %s! Start pos: x%d y%d; end pos: x%d y%d with buffer %s%n\n",
"Cursor moved by user %s! Start pos: x%d y%d; end pos: x%d y%d with buffer %s!\n",
event.getUser(),
event.getStartCol(), event.getStartCol(),
event.getEndRow(), event.getEndCol(),

View file

@ -0,0 +1,28 @@
package com.codemp.intellij.actions.buffer;
import com.codemp.intellij.jni.CodeMPHandler;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.ui.Messages;
import org.jetbrains.annotations.NotNull;
public class BufferCreateAction extends AnAction {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
String buffer = Messages.showInputDialog(
"Buffer name:",
"Create CodeMP Buffer",
Messages.getQuestionIcon());
try {
CodeMPHandler.create(buffer);
//Messages.showInfoMessage(String.format("Created buffer %s!", url), "Create CodeMP Buffer" );
System.out.printf("Created buffer %s!\n", buffer);
} catch(Exception ex) {
Messages.showErrorDialog(String.format(
"Failed to create buffer with name %s: %s!",
buffer, ex.getMessage()), "Create CodeMP Buffer");
}
}
}

View file

@ -23,12 +23,21 @@
<depends>com.intellij.modules.platform</depends>
<actions>
<action id="codemp-connect" class="com.codemp.intellij.actions.ConnectAction" text="CodeMP Connect">
<add-to-group group-id="ToolsMenu" anchor="first"></add-to-group>
<group id="codemp" text="CodeMP" popup="true">
<add-to-group group-id="ToolsMenu" anchor="first"/>
<action id="codemp.connect" class="com.codemp.intellij.actions.ConnectAction" text="Connect...">
<add-to-group group-id="ToolsMenu" anchor="first"/>
</action>
<action id="codemp-join" class="com.codemp.intellij.actions.JoinAction" text="CodeMP Join">
<add-to-group group-id="ToolsMenu" anchor="first"></add-to-group>
<action id="codemp.join" class="com.codemp.intellij.actions.JoinAction" text="Join...">
<add-to-group group-id="ToolsMenu" anchor="first"/>
</action>
<group id="codemp.buffer" text="Buffer" popup="true">
<action id="codemp.buffer.create" class="com.codemp.intellij.actions.buffer.BufferCreateAction"
text="Create Buffer">
<add-to-group group-id="ToolsMenu" anchor="first"/>
</action>
</group>
</group>
</actions>
<!-- Extension points defined by the plugin.