forked from Johnson336/LotJPlugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLotJ_Copy_colour_codes.xml
More file actions
118 lines (84 loc) · 2.84 KB
/
LotJ_Copy_colour_codes.xml
File metadata and controls
118 lines (84 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Plugin "CopyScript" generated by Plugin Wizard -->
<!-- Amended slightly by Nick Gammon, from Worstje's version, on 17 Feb 2008 -->
<muclient>
<plugin
name="Copy_Colour_Output"
author="Nick Gammon"
id="04d9e64f835452b045b427a7"
language="Lua"
purpose="Copies output with colour codes"
save_state="n"
date_written="2008-07-28"
requires="4.00"
version="1.1"
>
<description trim="y">
Copies text from the output window to the clipboard, with
Aardwolf colour codes.
To use: highlight text and then:
Ctrl+D copy (like Ctrl+C but different)
or: Ctrl + Left-click and select "Copy with Colour"
</description>
</plugin>
<aliases>
<alias
match="Copy_With_Colour:04d9e64f835452b045b427a7"
enabled="y"
omit_from_output="y"
sequence="100"
script="CopyScript"
name="Copy_With_Colour"
menu="y"
>
</alias>
</aliases>
<!-- Script -->
<script>
<![CDATA[
-- functions for handling Aardwolf color codes
dofile (GetPluginInfo (GetPluginID(), 20) .. "lotj_colors.lua")
require "tprint"
-- Thank you, Shaun Biggs, for taking your time to write the CopyScript
-- (formerly Copy2) function below. It was slightly altered by me to suit
-- my usage (wordwrapped lines and no \r\n at start of selection). -- Nick Gammon
-- And then I ripped out its heart. :) -- Fiendish
function CopyScript(name, line, wildcs)
-- find selection in output window, if any
local first_line, last_line = GetSelectionStartLine(),
math.min (GetSelectionEndLine(), GetLinesInBufferCount ())
local first_column, last_column = GetSelectionStartColumn(), GetSelectionEndColumn()
-- nothing selected, do normal copy
if first_line <= 0 then
DoCommand("copy")
return
end -- if nothing to copy from output window
cpstr = ""
-- iterate to build up copy text
for line = first_line, last_line do
if line < last_line then
cpstr = cpstr..StylesToColoursOneLine (GetStyleInfo(line), first_column, GetLineInfo(line).length)
first_column = 1
-- Is this a new line or merely the continuation of a paragraph?
if GetLineInfo (line, 3) then
cpstr = cpstr .. "\r\n"
end -- new line
else
cpstr = cpstr..StylesToColoursOneLine (GetStyleInfo(line), first_column, last_column)
end -- if
end -- for loop
-- Get rid of a spurious extra new line at the start.
if cpstr:sub (1, 2) == "\r\n" then
cpstr = cpstr:sub (3)
end -- if newline at start
if cpstr:sub (-2) ~= "&w" then
cpstr = cpstr .. "&w"
end -- if newline at start
-- finally can set clipboard contents
SetClipboard(cpstr)
end -- function CopyScript
AcceleratorTo ("Ctrl+D", "CallPlugin ('04d9e64f835452b045b427a7', 'CopyScript', '')", sendto.script)
]]>
</script>
</muclient>