.



on-line?
? ?
Ru.Board » » » SciTE - Open Source Text Editor for Windows & Linux

: gyra, Maz

Widok (23-11-2010 11:23): .    •

   

frs

Junior Member
| | | |


:
-- Alternative Code Poster
-- Version: 1
-- Autor: VladVRO, frs
---------------------------------------------------
-- Description:
-- ,
-- ( ) STYLES.
-- : C/C++, CSS, JavaScript, Lua, VB, VBscript, Properties
 
-- .properties :
--  command.name.125.*=
--  command.125.*=dofile $(SciteDefaultHome)\tools\code-poster.lua
--  command.mode.125.*=subsystem:lua,savebefore:no
 
-- :
--  - editor.LexerLanguage ( Ru-Board,
--    http://scite.ruteam.ru/scite/sborki/scite-ru-board)
---------------------------------------------------
 
-- todo --
--
--
 
-- Output to console
toconsole=true
-- Output to file
tofile=true
-- Output to clipboard
toclipboard=true
 
addcodetag=true
 
local
lang="bbcode"
-- local lang="html"
 
 
--
local STYLES = {
comment = {color="008000", no=false},
number = {color="AC00A9"},
string = {color="9999CC", no=false},
preproc = {color="7F7F00"},
operator = {color="FF0000"},
keyword = {color="0000DF"},
keyword2 = {color="0080C0"},
keyword3 = {color="8000FF"},
keyword4 = {color="FF8000"},
keyword5 = {color="660000"},
keyword6 = {color="004080"},
keyword7 = {color="408080"},
keyword8 = {color="AAAA00"},
}
 
local LFSTYLES = {
comment = {start="[I]", endd="",no=false},
number = {start="",endd=""},
string = {start="", endd="", no=false},
preproc = {start="",endd=""},
operator = {start="",endd=""},
keyword = {start="",endd=""},
keyword2 = {start="",endd=""},
keyword3 = {start="",endd=""},
keyword4 = {start="",endd=""},
keyword5 = {start="",endd=""},
keyword6 = {start="",endd=""},
keyword7 = {start="",endd=""},
keyword8 = {start="",endd=""},
}
 
STYLES.default = {
[
1] = STYLES.comment,
[
2] = STYLES.comment,
[
3] = STYLES.comment,
[
4] = STYLES.number,
[
5] = STYLES.keyword,
[
6] = STYLES.string,
[
7] = STYLES.string,
[
8] = STYLES.string,
[
9] = STYLES.preproc,
[
10] = STYLES.operator,
[
13] = STYLES.keyword2,
[
14] = STYLES.keyword3,
[
15] = STYLES.keyword4,
[
16] = STYLES.keyword5,
[
17] = STYLES.keyword6,
[
18] = STYLES.keyword7,
[
19] = STYLES.keyword8,
}
STYLES.others = {
[
1] = STYLES.comment,
[
2] = {color="0080C0", no=false},--true},
[3] = STYLES.operator,
[
4] = STYLES.preproc,
[
5] = STYLES.keyword,
}
STYLES.props = STYLES.others
STYLES.vb = {
[
1] = STYLES.comment,
[
2] = STYLES.number,
[
3] = STYLES.keyword,
[
4] = STYLES.string,
[
5] = STYLES.preproc,
[
6] = STYLES.operator,
[
8] = STYLES.number,
[
10] = STYLES.keyword2,
[
11] = STYLES.keyword3,
[
12] = STYLES.keyword4,
}
STYLES.vbscript = STYLES.vb
STYLES.css = {
[
1] = STYLES.keyword,
[
3] = STYLES.keyword2,
[
5] = STYLES.operator,
[
6] = STYLES.keyword3,
[
8] = STYLES.string,
[
9] = STYLES.comment,
[
10] = STYLES.number,
[
12] = STYLES.preproc,
[
13] = STYLES.string,
[
14] = STYLES.string,
[
15] = STYLES.keyword4,
[
16] = STYLES.keyword5,
}
STYLES.cpp = {
[
1] = STYLES.comment,
[
2] = STYLES.comment,
[
3] = STYLES.comment,
[
4] = STYLES.number,
[
5] = STYLES.keyword,
[
6] = STYLES.string,
[
7] = STYLES.string,
[
8] = STYLES.string,
[
9] = STYLES.preproc,
[
10] = STYLES.operator,
[
13] = STYLES.keyword4,
[
14] = STYLES.keyword3,
[
15] = STYLES.comment,
[
16] = STYLES.keyword2,
[
17] = STYLES.comment,
[
18] = STYLES.comment,
}
STYLES.cppnocase = STYLES.cpp
 
local LEXSTYLES
local lex = editor.LexerLanguage
if lex == nil then
LEXSTYLES = STYLES.others
else
LEXSTYLES = STYLES[lex]
if LEXSTYLES == nil then
LEXSTYLES = STYLES.default
end
end  
 
if
lang=="bbcode" then
col="[color=#"
op="["
cl="]"
ecol=""
[/color]nl="\n" -- clipboard "\r\n"
ext=".bbcode"
else
col="<font color="
op="<"
cl=">"
ecol="</font>"
nl="<br />\r\n"
ext=".htm"
end
 
 
local function
clean(txt)
if lang=="html" then
txt = string.gsub(txt, "\t", "&nbsp;&nbsp;")
else
end
txt = string.gsub(txt, "\r\n", nl)
return txt
end  
 
local
ccode=""
 
local function fill(txt,nstyle,tstart)
txt=clean(txt)
style = LEXSTYLES[nstyle]
if style ~= nil then
if
lang=="bbcode" and style.no then
ccode=ccode..""[/color][color=#FF0000]..[/color][color=#8000FF]string.gsub[/color][color=#FF0000]([/color]txt[color=#FF0000],[/color][color=#9999CC]"%[(/*)no%]"[/color][color=#FF0000],[/color][color=#9999CC]"[%1no]"[/color][color=#FF0000])..[/color][color=#9999CC]""
end
if
style.color then
ccode=ccode..col..style.color..cl..txt..ecol
end
else
ccode=ccode..txt
end
end
 
local
text = editor:GetSelText()
if text == "" then
editor:SelectAll()
text = editor:GetSelText()
elseif string.len(text) ~= editor.Length then
line = scite.SendEditor(SCI_LINEFROMPOSITION, editor.SelectionStart) + 1
end
local
pos = editor.SelectionStart
local ln=editor:LineFromPosition(pos) + 1
 
local header = ""
if props["FileNameExt"] ~= "" then
header =op.."b"..cl..col.."Blue"..cl..props["FileNameExt"]..ecol..op.."/b"..cl.." "
if ln ~= nil then
header = header..op.."b"..cl..op.."u"..cl.." "..ln..op.."/u"..cl..op.."/b"..cl..nl
end
end
curstyle=editor.StyleAt[pos]
local nstyle
local tstyle
local txt=""
local tstart=true
for
str in string.gfind(text, "%S?%s*") do
local
len = string.len(str)
tstyle=nstyle
nstyle = editor.StyleAt[pos]
if nstyle ~= curstyle then
if
txt~="" then
fill(txt,curstyle,tstart)
tstart=false
end
txt=str
else
txt=txt..str
end
fin=curstyle
curstyle=nstyle
pos=pos+len
end
 
if
txt~="" then  
fill(txt,fin)
end
 
if
lang=="bbcode" and addcodetag then
local
scode=op.."code"..cl
local ecode=op.."/code"..cl
ccode=header..scode..ccode..ecode
else
ccode=header..ccode
end
 
-- Output to console
--
if toconsole then trace(ccode) end
-- Output to file
--
if tofile then
local
path=props["SciteDefaultHome"].."\\tools\\"..props["FileNameExt"]..ext
io.output(path)
io.write(ccode)
io.close()
scite.Open (path)
end
 
-- Output to clipboard
--
if toclipboard then editor:CopyText(ccode, string.len(ccode)) end


: 35 | . 20-02-2003 | : 09:16 18-10-2007 | : frs, 03:23 25-10-2007
   


Ru.Board » » » SciTE - Open Source Text Editor for Windows & Linux
Widok (23-11-2010 11:23): .


Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.Board
© Ru.Board 2000-2020

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

.ru

.ru