OSDN Git Service

Initial release
authorpluginfan <pluginfan@suremail.info>
Sat, 2 Apr 2016 18:01:21 +0000 (21:01 +0300)
committerpluginfan <pluginfan@suremail.info>
Sat, 2 Apr 2016 18:03:56 +0000 (21:03 +0300)
Move Caret To Word End/README [deleted file]
Move Caret To Word End/README.md [new file with mode: 0644]
PrettyPrint JSON/NEWS [new file with mode: 0644]
PrettyPrint JSON/README.md [new file with mode: 0644]
PrettyPrint JSON/TODO [new file with mode: 0644]
PrettyPrint JSON/plugin.groovy [new file with mode: 0644]
README [deleted file]
README.md [new file with mode: 0644]

diff --git a/Move Caret To Word End/README b/Move Caret To Word End/README
deleted file mode 100644 (file)
index 84e4ad2..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-Move Caret to Word End
-~~~~~~~~~~~~~~~~~~~~~~
-
-Moves all carets to the closes word end.
-
-Action:
-* Move Caret to Next Word End
-* Move Caret to Previous Word End
-
-Shortcut:
-* Ctrl+NumPad 6 -- Move Caret to Next Word End
-* Ctrl+NumPad 4 -- Move Caret to Previous Word End
diff --git a/Move Caret To Word End/README.md b/Move Caret To Word End/README.md
new file mode 100644 (file)
index 0000000..eb549bd
--- /dev/null
@@ -0,0 +1,17 @@
+# Move Caret to Word End
+
+Moves all carets to the closes word end.
+
+Action:
+
+* `Move Caret to Next Word End`
+* `Move Caret to Previous Word End`
+
+Shortcut:
+
+* <kbd>Ctrl</kbd>+<kbd>NumPad 6</kbd> -- Move Caret to Next Word End
+* <kbd>Ctrl</kbd>+<kbd>NumPad 4</kbd> -- Move Caret to Previous Word End
+
+When moving word-by-word, the IDE's builtin algorithm stops on word starts. Often you can reach the word end only by
+moving one word further then moving a couple of characters back. But this may not be an option when using multiple
+carets and there are different amounts of separators between the words.
diff --git a/PrettyPrint JSON/NEWS b/PrettyPrint JSON/NEWS
new file mode 100644 (file)
index 0000000..fe3e01d
--- /dev/null
@@ -0,0 +1,3 @@
+Version 0.0 -- April 2016
+~~~~~~~~~~~~~~~~~~~~~~~~~
+Initial release.
diff --git a/PrettyPrint JSON/README.md b/PrettyPrint JSON/README.md
new file mode 100644 (file)
index 0000000..5dc1ebb
--- /dev/null
@@ -0,0 +1,13 @@
+# PrettyPrint JSON
+
+Formats the current selection as prettified JSON.
+
+Action:
+
+* `PrettyPrint JSON`
+
+Shortcut:
+
+* <kbd>Alt</kbd>+<kbd>P</kbd> -- PrettyPrint JSON
+
+Not really related to the source code, more a helper to debug AJAX communication.
diff --git a/PrettyPrint JSON/TODO b/PrettyPrint JSON/TODO
new file mode 100644 (file)
index 0000000..257dec3
--- /dev/null
@@ -0,0 +1 @@
+* Transform it into generic prettyprinter by handling XML, YAML and maybe Groovy.
diff --git a/PrettyPrint JSON/plugin.groovy b/PrettyPrint JSON/plugin.groovy
new file mode 100644 (file)
index 0000000..478918c
--- /dev/null
@@ -0,0 +1,39 @@
+// plugin  PrettyPrint JSON
+// version 0.0
+// release April 2016
+// author  Plugin Fan
+// license GPL v 3.0
+
+// Formats the current selection as prettified JSON :
+//     - Alt-P - PrettyPrint JSON
+//
+// Not really related to the source code, more a helper to debug AJAX communication.
+
+
+import com.intellij.openapi.actionSystem.AnActionEvent
+import com.intellij.notification.NotificationType
+
+import groovy.json.*
+
+import static liveplugin.PluginUtil.*
+
+registerAction('PrettyPrint JSON', 'alt P') { AnActionEvent event ->
+    runDocumentWriteAction(event.project) {
+        currentEditorIn(event.project).with {
+            if (! selectionModel.hasSelection())
+                return
+
+            def text = selectionModel.getSelectedText().trim()
+            if (! text)
+                return
+
+            try {
+                text = JsonOutput.prettyPrint(text)
+            } catch (JsonException e) {
+                return show(e.message, '', NotificationType.ERROR)
+            }
+
+            document.replaceString(selectionModel.getSelectionStart(), selectionModel.getSelectionEnd(), text)
+        }
+    }
+}
diff --git a/README b/README
deleted file mode 100644 (file)
index 2cadccc..0000000
--- a/README
+++ /dev/null
@@ -1,6 +0,0 @@
-IntelliJ IDEA LivePlugin Plugin collection
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Plugins written in Groovy <http://groovy-lang.org/> script for IntelliJ IDEA <http://jetbrains.com/idea/> based IDE's that can be enhanced through LivePlugin <https://github.com/dkandalov/live-plugin> plugin connector.
-
-* Move Caret to Word End -- Moves all carets to the closes word end.
diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..f8296c8
--- /dev/null
+++ b/README.md
@@ -0,0 +1,6 @@
+# IntelliJ IDEA LivePlugin Plugin collection
+
+Plugins written in [Groovy](http://groovy-lang.org/) script for [IntelliJ IDEA](http://jetbrains.com/idea/) based IDE's that can be enhanced through [LivePlugin](https://github.com/dkandalov/live-plugin) plugin connector.
+
+* [Move Caret to Word End](https://osdn.jp/projects/ii-lp-script/scm/git/ii-lp-script/tree/master/Move%20Caret%20To%20Word%20End/) -- Moves all carets to the closes word end.
+* [PrettyPrint JSON](https://osdn.jp/projects/ii-lp-script/scm/git/ii-lp-script/tree/master/PrettyPrint%20JSON/) -- Formats the current selection as prettified JSON.