?? fck_codes.js
字號(hào):
?var oEditor = window.parent.InnerDialogLoaded() ;
var FCK = oEditor.FCK ;
window.onload = function()
{
oEditor.FCKLanguageManager.TranslatePage(document) ;
window.parent.SetOkButton( true ) ;
}
function Ok()
{
var sLan = GetE('codeLan').value;
var sTxt = GetE('codeTxt').value;
if( sTxt.length> 0) {
var oCode = FCK.CreateElement('PRE');
var registered = new Object();
for(var brush in dp.sh.Brushes)
{
var aliases = dp.sh.Brushes[brush].Aliases;
if(aliases == null) continue;
for(var i=0;i<aliases.length;i++) registered[aliases[i]] = brush;
};
var ht = new dp.sh.Brushes[registered[sLan]]();
ht.Highlight(sTxt);
oCode.innerHTML = ht.div.innerHTML;
} else {
oEditor.FCKUndo.SaveUndoStep() ;
}
return true ;
}
var dp = { sh : { Utils : {}, RegexLib: {}, Brushes : {} } };
dp.SyntaxHighlighter = dp.sh;
dp.sh.RegexLib = {
MultiLineCComments : new RegExp('/\\*[\\s\\S]*?\\*/', 'gm'),
SingleLineCComments : new RegExp('//.*$', 'gm'),
SingleLinePerlComments : new RegExp('#.*$', 'gm'),
DoubleQuotedString : new RegExp('"(?:\\.|(\\\\\\")|[^\\""\\n])*"','g'),
SingleQuotedString : new RegExp("'(?:\\.|(\\\\\\')|[^\\''\\n])*'", 'g')
};
dp.sh.Match = function(value, index, css) {
this.value = value; this.index = index;
this.length = value.length; this.css = css;
}
dp.sh.Highlighter = function() {
this.tabsToSpaces = true; this.wrapColumn = 80;
}
dp.sh.Highlighter.SortCallback=function(m1,m2){if(m1.index<m2.index)return-1;else if(m1.index>m2.index)return 1;else{if(m1.length<m2.length)return-1;else if(m1.length>m2.length)return 1;}return 0;}
dp.sh.Highlighter.prototype.CreateElement = function(name) {
var result = document.createElement(name);
result.highlighter = this;
return result;
}
dp.sh.Highlighter.prototype.GetMatches = function(regex, css)
{
var index = 0;
var match = null;
while((match = regex.exec(this.code)) != null)
this.matches[this.matches.length] = new dp.sh.Match(match[0], match.index, css);
}
dp.sh.Highlighter.prototype.AddBit = function(str, css)
{
if(str == null || str.length == 0)
return;
var span = this.CreateElement('SPAN');
str = str.replace(/&/g, '&');
str = str.replace(/ /g, ' ');
str = str.replace(/</g, '<');
// str = str.replace(/</g, '<');
// str = str.replace(/>/g, '>');
// str = str.replace(/\n/gm, ' <br>');
str = str.replace(/\n/gm, '<br>');
var lastWasBlank = false;
if (str.indexOf(' ') > -1) {
for (var i = 0; i < str.length; i++) {
var isBlank = str[i] == ' ';
if (lastWasBlank && isBlank) {
// For each 2 consecutive blank spaces, replace it by one blank space and one
str = str.substring(0, i) + " " + str.substring(i + 1);
lastWasBlank = false;
}
else {
lastWasBlank = isBlank;
}
}
// Safari appears to get confused if the last char is a regular white space
if (str[str.length - 1] == ' ') {
str = str.substring(0, str.length - 1) + " "
}
}
if(css != null)
{
if((/br/gi).test(str))
{
//var lines = str.split(' <br>');
var lines = str.split('<br>');
for(var i = 0; i < lines.length; i++)
{
span = this.CreateElement('SPAN');
span.className = css;
span.innerHTML = lines[i];
this.div.appendChild(span);
if(i + 1 < lines.length)
this.div.appendChild(this.CreateElement('BR'));
}
}
else
{
span.className = css;
span.innerHTML = str;
this.div.appendChild(span);
}
}
else
{
span.innerHTML = str;
this.div.appendChild(span);
}
}
dp.sh.Highlighter.prototype.IsInside = function(match)
{
if(match == null || match.length == 0)
return false;
for(var i = 0; i < this.matches.length; i++)
{
var c = this.matches[i];
if(c == null)
continue;
if((match.index > c.index) && (match.index < c.index + c.length))
return true;
}
return false;
}
dp.sh.Highlighter.prototype.ProcessRegexList = function()
{
for(var i = 0; i < this.regexList.length; i++)
this.GetMatches(this.regexList[i].regex, this.regexList[i].css);
}
dp.sh.Highlighter.prototype.ProcessSmartTabs = function(code)
{
var lines = code.split('\n');
var result = '';
var tabSize = 4;
var tab = '\t';
function InsertSpaces(line, pos, count)
{
var left = line.substr(0, pos);
var right = line.substr(pos + 1, line.length);
var spaces = '';
for(var i = 0; i < count; i++)
spaces += ' ';
return left + spaces + right;
}
function ProcessLine(line, tabSize)
{
if(line.indexOf(tab) == -1)
return line;
var pos = 0;
while((pos = line.indexOf(tab)) != -1)
{
var spaces = tabSize - pos % tabSize;
line = InsertSpaces(line, pos, spaces);
}
return line;
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -