diff options
author | rxi <rxi@users.noreply.github.com> | 2020-06-14 11:57:46 +0100 |
---|---|---|
committer | rxi <rxi@users.noreply.github.com> | 2020-06-14 11:57:46 +0100 |
commit | 1d4b264e2988fe91b7071e0f86a22f97983da280 (patch) | |
tree | 5e272dfeb95ec31de65514d971b54471375299d2 | |
parent | 349aae592e75924089c0700387017529a494f1cc (diff) | |
parent | 34bb3bde792d53e4faa1d82702a9e17a5ca227cd (diff) | |
download | lite-xl-plugins-1d4b264e2988fe91b7071e0f86a22f97983da280.tar.gz lite-xl-plugins-1d4b264e2988fe91b7071e0f86a22f97983da280.zip |
Merge branch 'master' of https://github.com/rxi/lite-plugins
-rw-r--r-- | README.md | 1 | ||||
-rwxr-xr-x | plugins/linecopypaste.lua | 45 |
2 files changed, 46 insertions, 0 deletions
@@ -53,6 +53,7 @@ Plugin | Description [`language_wren`](plugins/language_wren.lua?raw=1) | Syntax for the [Wren](http://wren.io/) programming language [`lfautoinsert`](plugins/lfautoinsert.lua?raw=1) | Automatically inserts indentation and closing bracket/text after newline [`lineguide`](plugins/lineguide.lua?raw=1) | Displays a line-guide at the line limit offset *([screenshot](https://user-images.githubusercontent.com/3920290/81476159-2cf70000-9208-11ea-928b-9dae3884c477.png))* +[`linecopypaste`](plugins/linecopypaste.lua?raw=1) | Copy, cut and paste the current line when nothing is selected [`linter`](https://github.com/drmargarido/linters)* | Linters for multiple languages [`macmodkeys`](plugins/macmodkeys.lua?raw=1) | Remaps mac modkeys `command/option` to `ctrl/alt` [`markers`](plugins/markers.lua?raw=1) | Add markers to docs and jump between them quickly *([screenshot](https://user-images.githubusercontent.com/3920290/82252149-5faaa200-9946-11ea-9199-bea2efb7ee23.png))* diff --git a/plugins/linecopypaste.lua b/plugins/linecopypaste.lua new file mode 100755 index 0000000..eb6f375 --- /dev/null +++ b/plugins/linecopypaste.lua @@ -0,0 +1,45 @@ +local core = require "core"
+local command = require "core.command"
+
+local function doc()
+ return core.active_view.doc
+end
+
+local line_in_clipboard = false
+
+local doc_copy = command.map["doc:copy"].perform
+command.map["doc:copy"].perform = function()
+ if doc():has_selection() then
+ doc_copy()
+ line_in_clipboard = false
+ else
+ local line = doc():get_selection()
+ system.set_clipboard(doc().lines[line])
+ line_in_clipboard = true
+ end
+end
+
+local doc_cut = command.map["doc:cut"].perform
+command.map["doc:cut"].perform = function()
+ if doc():has_selection() then
+ doc_cut()
+ line_in_clipboard = false
+ else
+ local line = doc():get_selection()
+ system.set_clipboard(doc().lines[line])
+ doc():remove(line, 1, line+1, 1)
+ doc():set_selection(line, 1)
+ line_in_clipboard = true
+ end
+end
+
+local doc_paste = command.map["doc:paste"].perform
+command.map["doc:paste"].perform = function()
+ if line_in_clipboard == false then
+ doc_paste()
+ else
+ local line, col = doc():get_selection()
+ doc():insert(line, 1, system.get_clipboard():gsub("\r", ""))
+ doc():set_selection(line+1, col)
+ end
+end
|