代码拉取完成,页面将自动刷新
class XSourceEditor : DocumentView {
public QScintilla _sci;
static const int
MARK_BREAKPOINT = 9,
MARK_POINTER = 8,
MARK_MODIFIED = 12,
MARK_SAVED = 13,
ERRORPOINT_INDEX = 14,
WARNING_INDEX = 15;
QComboBox domaincmb = new QComboBox(), objectscmb = new QComboBox();
bool intellisense_modified = false;
QTreeWidget autoWnd;
QTreeWidget debugWnd;
CodeTips __tipsWnd = XStudioApp._theApp.__tipsWnd;
Map<String, long> watchs = new Map<String, long>();
bool bClosed = false;
XIntelliSense.XIntelliResult[] current_autocmp;
bool autoCompShow, debugWndShow;
long auto_position, last_autopos;
XWorkspace _mdi_area;
bool sciisHand = false;
int lastCursor = 0;
String strpretext;
int current_modify_mark, reserve_modify_mark;
QMenu contextMenu = new QMenu();
static QAction [] editor_actions = nilptr;
Map<String, long> autoCompMap = new Map<String, long>();
DebugValueParser __dvp = new DebugValueParser("debug");
static QScintilla.QSciPrinter g_printer;
QLabel statbar;
static const int INDIC_TIPS = 1, INDIC_ERROR = 2, INDIC_WARNING = 5;
static const int INDIC_FIND = 3, INDIC_SELECTED = 4;
XIntelliSense.XIntelliResult []lastxis;
public String defaultCharset = nilptr;
String loadAsCharset = nilptr;
onOverviewListener disableOverview = nilptr;
bool bCmbInit = false;
enum ReadResp{
NO_READONLY = 0,
NO_CHARSET = 1
};
public static class onOverviewListener{
public bool isOverviewEnabled(){
return false;
}
public String preprocessKeyword(String keyword){
return keyword;
}
};
ReadResp readonlyResp = ReadResp.NO_READONLY;
public void setOverviewListener(onOverviewListener bd){
disableOverview = bd;
}
public XSourceEditor(XWorkspace _mdi) {
_mdi_area = _mdi;
}
static String [] codepages = {
"Unicode / UTF-8",
"Unicode / UTF-16BE",
"Unicode / UTF-16LE",
"Unicode / UTF-32BE",
"Unicode / UTF-32LE",
"Unicode / X-ISO-10646-UCS-4-34121",
"Unicode / X-ISO-10646-UCS-4-21431",
"(阿拉伯语)Arabic / ISO-8859-6",
"(阿拉伯语)Arabic / WINDOWS-1256",
"(保加利亚)Bulgarian / ISO-8859-5",
"(保加利亚)Bulgarian / WINDOWS-1251",
"(中文)Chinese / ISO-2022-CN",
"(中文繁体)Chinese / BIG5",
"(中文台湾)Chinese / EUC-TW",
"(中文简体)Chinese / GB18030",
"(中文)Chinese / HZ-GB-2312",
"(丹麦)Danish / ISO-8859-1",
"(丹麦)Danish / ISO-8859-15",
"(丹麦)Danish / WINDOWS-1252",
"(英语)English / ASCII",
"(世界语)Esperanto / ISO-8859-3",
"(法语)French / ISO-8859-1",
"(法语)French / ISO-8859-15",
"(法语)French / WINDOWS-1252",
"(德语)German / ISO-8859-1",
"(德语)German / WINDOWS-1252",
"(希腊语)Greek / ISO-8859-7",
"(希腊语)Greek / WINDOWS-1253",
"(希伯来语)Hebrew / ISO-8859-8",
"(希伯来语)Hebrew / WINDOWS-1255",
"(匈牙利语)Hungarian / ISO-8859-2",
"(匈牙利语)Hungarian / WINDOWS-1250",
"(日语)Japanese / ISO-2022-JP",
"(日语)Japanese / SHIFT_JIS",
"(日语)Japanese / EUC-JP",
"(韩语)Korean / ISO-2022-KR",
"(韩语)Korean / EUC-KR",
"(俄语)Russian / ISO-8859-5",
"(俄语)Russian / KOI8-R",
"(俄语)Russian / WINDOWS-1251",
"(俄语)Russian / MAC-CYRILLIC",
"(俄语)Russian / IBM866",
"(俄语)Russian / IBM855",
"(西班牙语)Spanish / ISO-8859-1",
"(西班牙语)Spanish / ISO-8859-15",
"(西班牙语)Spanish / WINDOWS-1252",
"(泰语)Thai / TIS-620",
"(泰语)Thai / ISO-8859-11",
"(土耳其)Turkish / ISO-8859-3",
"(土耳其)Turkish / ISO-8859-9",
"(越南)Vietnamese / VISCII",
"(越南)Vietnamese / Windows-1258",
"其他 / WINDOWS-1252"
};
static String []cpid = {"UTF-8", "UTF-16BE", "UTF-16LE", "UTF-32BE", "UTF-32LE", "X-ISO-10646-UCS-4-34121", "X-ISO-10646-UCS-4-21431", "ISO-8859-6",
"WINDOWS-1256","ISO-8859-5","WINDOWS-1251","ISO-2022-CN","BIG5","EUC-TW","GB18030","HZ-GB-2312","ISO-8859-1","ISO-8859-15","WINDOWS-1252",
"ASCII","ISO-8859-3","ISO-8859-1","ISO-8859-15","WINDOWS-1252","ISO-8859-1","WINDOWS-1252","ISO-8859-7","WINDOWS-1253","ISO-8859-8",
"WINDOWS-1255","ISO-8859-2","WINDOWS-1250","ISO-2022-JP","SHIFT_JIS","EUC-JP","ISO-2022-KR","EUC-KR","ISO-8859-5","KOI8-R","WINDOWS-1251",
"MAC-CYRILLIC","IBM866","IBM855","ISO-8859-1","ISO-8859-15","WINDOWS-1252","TIS-620","ISO-8859-11","ISO-8859-3","ISO-8859-9","VISCII",
"Windows-1258","WINDOWS-1252"};
String szKeywords1=
"break case catch char class " +
"const continue default do float double else final finally cdecl for " +
"if import interface stdcall fastcall pascal operator " +
"new package include using require synchronized_read synchronized_write " +
"return static super switch synchronized this throws throw " +
"try void while @Declare @NotNilptr public private protected override bool byte long char int long short String _system_ " +
"Thread nilptr Exception Vector Map List Iterator Timer TimerTask true false enum finalize" ;
String szKeywords2 = "";
static const int BREAKPOINT_INDEX = 0,
LINENUMBER_INDEX = 1,
DEBUGPOINT_INDEX = 2,
MODIFIMARK_INDEX = 3,
MARGIN_FOLD_INDEX = 4;
void setHighlightKeyWord(String keyword) {
_sci.sendEditor(QScintilla.SCI_SETKEYWORDS, 1, keyword);
_sci.update();
}
public TextEditorPlugin _textplugins;
public TextEditorController _controller = new TextEditorController() {
String getPath() {
return getFilePath();
}
String getTitle() {
return XSourceEditor.this.getTitle();
}
bool save() {
return saveFile();
}
void reload(String asCharset) {
reloadFile(asCharset);
}
void postreload(String asCharset) {
runOnUi(new Runnable() {
void run() {
reloadFile(asCharset);
}
});
}
void stopFileWatch() {
pauseWatch();
}
void continueFileWatch() {
continueWatch();
}
bool gotoLine(long line, long column) {
goto(line,column);
return true;
}
bool gotoPos(long pos) {
goto(pos);
return true;
}
bool select(long start, long end) {
_sci.setSelect(start,end);
return true;
}
bool gotoAndSelect(long start, long end) {
XSourceEditor.this.gotoAndSelect(start, end);
return true;
}
bool setBreakOn(long line, long column, bool set, bool bActive) {
breakOn(line, column, set, bActive, false);
return true;
}
bool activeEditor() {
XWorkspace.workspace.setActiveSubWindow(XSourceEditor.this);
return true;
}
void clearBreakOn() {
XSourceEditor.this.clearBreakOn();
}
bool toggleBreakpoint(long pos, bool bSet) {
int line = _sci.positionToLine(pos);
BreakPointWnd.toggleBreakPoint(XSourceEditor.this, getFilePath(), line, testMark(line, MARK_BREAKPOINT) == false);
return true;
}
bool toggleBreakpointAtLine(long line, bool bSet) {
BreakPointWnd.toggleBreakPoint(XSourceEditor.this, getFilePath(), line, testMark(line, MARK_BREAKPOINT) == false);
return true;
}
String getText(long start, long end) {
return _sci.getText(start,end);
}
String getText() {
return _sci.getText();
}
long getCurrentPosition() {
return _sci.getCurrentPosition();
}
long getCurrentLine() {
return _sci.getCurrentLine();
}
void triggeInteliSence(){
requestInteliSence();
}
};
public TextEditorController getController() {
return _controller;
}
public static String getEditingContent(@NotNilptr String file) {
DocumentView wnd = findDocumentWindow(nilptr, file, false);
if (wnd != nilptr) {
if (wnd.instanceOf(XSourceEditor)){
return ((XSourceEditor)wnd).getTextContent();
}
}
return nilptr;
}
public static bool openForFileInfo(@NotNilptr XWorkspace parent,@NotNilptr String source,int line, int column, String title, String Tips) {
DocumentView wnd = findDocumentWindow(parent, source, true);
if (wnd != nilptr) {
parent.setActiveSubWindow(wnd);
wnd.goto(line -1, column);
wnd.setFocus();
if (Tips != nilptr) {
wnd.showTips(line - 1, column, title,Tips);
}
return true;
}else
if (QMessageBox.Question("提示", "无法找到源代码文件:" + source + ",是否浏览文件?", QMessageBox.Yes | QMessageBox.No, QMessageBox.No ) == QMessageBox.Yes) {
String filename = source.findFilenameAndExtension();
if (filename.length() == 0) {
filename = source;
}
String file = QFileDialog.getOpenFileName("打开文件:" + filename, source, getDocumentExtension(), XWorkspace.workspace);
if (file != nilptr && file.length() > 0) {
wnd = findDocumentWindow(XWorkspace.workspace, file, true);
if (wnd != nilptr) {
parent.setActiveSubWindow(wnd);
wnd.goto(line -1, column);
wnd.setFocus();
if (Tips != nilptr) {
wnd.showTips(line - 1, column, title, Tips);
}
return true;
}
}
}
return false;
}
public void setSelection(int pos, int len) {
_sci.gotoPos(pos);
_sci.sendEditor(QScintilla.SCI_SETSELECTIONSTART, pos);
_sci.sendEditor(QScintilla.SCI_SETSELECTIONEND, pos + len);
}
public static bool openForFile(@NotNilptr XWorkspace parent,@NotNilptr String sourcepath) {
DocumentView wnd = findDocumentWindow(parent, sourcepath, true);
if (wnd != nilptr) {
parent.setActiveSubWindow(wnd);
return true;
}
return false;
}
public static bool closeAllWindows() {
Map.Iterator<String, DocumentView> iterator = editorMgr.iterator();
while (iterator.hasNext()) {
DocumentView wnd = iterator.getValue();
if (wnd != nilptr && wnd.requestClose() == false) {
return false;
}
iterator.next();
}
return true;
}
public bool isTipsShow(){
return __tipsWnd.isVisible();
}
public void showTips(int line, int column,String title, String content) override{
int position = _sci.getPosition(line) + column;
QPoint qt = _sci.positionToPoint(position);
qt.y += /*domaincmb.height() +*/ _sci.getLineHeight();
qt = _sci.mapToGlobal(qt.x,qt.y);
qt = _mdi_area.mainWindow.mapFromGlobal(qt.x,qt.y);
__tipsWnd.showTips(getFilePath(), qt/*_sci.mapToGlobal(qt.x,qt.y)*/, title, content);
}
public void showTips(int position, String title, String content) override {
QPoint qt = _sci.positionToPoint(position);
qt.y += /*domaincmb.height() +*/ _sci.getLineHeight();
qt = _sci.mapToGlobal(qt.x,qt.y);
qt = _mdi_area.mainWindow.mapFromGlobal(qt.x,qt.y);
__tipsWnd.showTips(getFilePath(),qt/*_sci.mapToGlobal(qt.x,qt.y)*/, title, content);
}
public bool requestClose() override{
bool bclose = false;
_mdi_area.setActiveSubWindow(this);
if (_sci.isModified()) {
int rt = QMessageBox.Question("提示","文档[" + getTitle() + "]有未保存的更改, 是否在关闭前保存文件?", QMessageBox.Cancel | QMessageBox.No | QMessageBox.Save, QMessageBox.Save);
if (rt == QMessageBox.Save) {
saveFile();
bclose = true;
} else if (rt == QMessageBox.No) {
bclose = true;
}
} else {
bclose = true;
}
return bclose;
}
public void reload(){
reloadFile(loadAsCharset);
}
public void goto(int line, int column) {
_sci.goto(line, column);
setActive(true);
}
public void goto(int pos) {
_sci.gotoPos(pos);
setActive(true);
}
public void gotoAndSelect(int line, int column) {
int pos = _sci.sendEditor(QScintilla.SCI_POSITIONFROMLINE, line) + column - 1;
_sci.gotoPos(pos);
_sci.setSelect(pos, pos);
_sci.setFocus();
setActive(true);
}
public void breakOn(int line, int column, bool set, bool active, bool onlyActive) {
if (set) {
_sci.goto(line, 1);
if (onlyActive == false) {
_sci.sendEditor(QScintilla.SCI_MARKERADD, line, MARK_POINTER);
}
setActive(true);
if (active) {
_mdi_area.setActiveSubWindow(this);
}
} else if (onlyActive == false) {
_sci.sendEditor(QScintilla.SCI_MARKERDELETE, line, MARK_POINTER);
}
}
public void clearBreakOn() {
_sci.sendEditor( QScintilla.SCI_MARKERDELETEALL, MARK_POINTER);
}
public void findAgain() {
if (false == _sci.findNext()) {
StatusBarMgr.showStatusMessage("找不到指定文本.");
}
}
public void setIntellisense(XIntelliSense.XIntelliResult [] names) {
lastxis = names;
preProcessXIntellisense();
}
public void setFileSymbols(XIntelliSense.XIntelliResult [] names) {
Vector<String> domains = new Vector<String>();
Vector<String> objects = new Vector<String>();
Vector<XIntelliSense.XIntelliResult> domains_link = new Vector<XIntelliSense.XIntelliResult>();
Vector<XIntelliSense.XIntelliResult> objects_link = new Vector<XIntelliSense.XIntelliResult>();
for (int i = 0, c = names.length; i < c; i++){
XIntelliSense.XIntelliResult it = names[i];
String label = it.get_name();
int line = it.get_line(), row = it.get_row();
if (it.get_type() == 31 || it.get_type() == 28) {
domains.add(label);
domains_link.add(it);
}else
if (it.get_type() == 23){
String descr = "";
XIntelliSense.XIntelliResult classtype = it.get_class();
if (classtype != nilptr){
descr = descr + classtype.get_name() + " ";
}
descr = descr + label + "(";
XIntelliSense.XIntelliResult[] params = it.get_params();
if (params != nilptr){
for (int x = 0; x < params.length; x ++) {
XIntelliSense.XIntelliResult param = params[x];
if (param != nilptr){
XIntelliSense.XIntelliResult param_class = param.get_class();
if (param_class != nilptr){
descr = descr + param_class.get_name() + " " + param.get_name();
}else{
descr = descr + "? " + param.get_name();
}
if (x + 1 < params.length) {
descr = descr + ", ";
}
}
}
}
descr = descr + ")";
objects.add(descr);
objects_link.add(it);
}else
if (it.get_type() != 18){
objects.add(label);
objects_link.add(it);
}
}
runOnUi(new Runnable(){
void run() override{
if (bClosed) {
return ;
}
domaincmb.setTag(domains_link);
objectscmb.setTag(objects_link);
bCmbInit = true;
domaincmb.addItems(domains.toArray(new String[0]));
objectscmb.addItems(objects.toArray(new String[0]));
bCmbInit = false;
}
});
}
public void preProcessXIntellisense() {
XIntelliSense.XIntelliResult[] _lastis = lastxis;
if (_lastis == nilptr || _lastis.length == 0) {
return ;
}
int count = 0;
XIntelliSense.XIntelliResult [] names = new XIntelliSense.XIntelliResult[_lastis.length];
if (strpretext != nilptr) {
String prekey = strpretext.upper();
if (prekey.length() > 0 && isTriggedChar(prekey.charAt(0)) == false) {
String patternkey = ".*";
for (int i = 0, c = prekey.length(); i < c; i++) {
patternkey = patternkey + prekey.substring(i, i + 1) + ".*";
}
try{
for (int i = 0, c = _lastis.length; i < c; i++) {
if (Pattern.test(_lastis[i].get_name().upper(), patternkey, 0, false)) {
names[count] = _lastis[i];
count++;
}
}
}catch(Exception e){
}
} else {
count = _lastis.length;
names = _lastis;
}
} else {
count = _lastis.length;
names = _lastis;
}
if (count > 0) {
runOnUi(new Runnable() {
void run()override {
if (bClosed) {
return ;
}
showComplete(names, count);
}
});
}
}
XIntelliSense.XIntelliResult [] moreData = nilptr;
int morecount = 0;
public void loadAutoComplate(long mitem) {
XIntelliSense.XIntelliResult[] result = moreData;
int c = morecount;
morecount = 0;
moreData = nilptr;
autoWnd.removeItem(mitem);
for (int i = 50; i < c; i ++) {
long item = 0;
XIntelliSense.XIntelliResult names = result[i];
if (names == nilptr ) {
return ;
}
XIntelliSense.XIntelliResult _class = names.get_class();
if (_class == nilptr) {
return ;
}
String _class_name = _class.get_name();
String label = names.get_name();
if (names.get_type() == 23) {
if (names.hasProp('S')) {
item = autoWnd.addItem("res/toolbar/methodstatic.png", label);
} else {
if (names.get_visibility() == 0x40){
item = autoWnd.addItem("res/toolbar/method.png", label);
}else{
item = autoWnd.addItem("res/toolbar/methodprivate.png", label);
}
}
String descr = label + "(";
XIntelliSense.XIntelliResult[] params = names.get_params();
if (params != nilptr){
for (int x = 0; x < params.length; x ++) {
XIntelliSense.XIntelliResult param = params[x];
if (param != nilptr){
XIntelliSense.XIntelliResult param_class = param.get_class();
if (param_class != nilptr){
descr = descr + param_class.get_name() + " " + param.get_name();
}else{
descr = descr + "? " + param.get_name();
}
if (x + 1 < params.length) {
descr = descr + ", ";
}
}
}
}
descr = descr + ")";
autoWnd.setItemText(item, 1, _class_name);
autoWnd.setItemText(item, 2, descr);
autoWnd.setItemColor(item, 1, 0xff7f7f7f);
autoWnd.setItemColor(item, 2, 0xff7f7f7f);
} else {
if (names.hasProp('C')) {
item = autoWnd.addItem("res/toolbar/const.png", label);
} else if (names.hasProp('S')) {
item = autoWnd.addItem("res/toolbar/static.png", label);
} else {
item = autoWnd.addItem("res/toolbar/member.png", label);
}
autoWnd.setItemText(item, 1, _class_name);
autoWnd.setItemColor(item, 1, 0xff7f7f7f);
}
String uname = label.upper();
autoWnd.setItemTag(item, 0, i);
autoCompMap.put(uname, item);
}
}
public void showComplete(XIntelliSense.XIntelliResult[] result, int c) {
if (bClosed) {
return ;
}
autoWnd.clear();
autoCompMap.clear();
long curpos = _sci.currentPosition();
String entenedText = _sci.getText(auto_position, curpos).upper();
bool bMore = false;
if (c > 100) {
moreData = result;
morecount = c;
bMore = true;
c = 50;
}
long selitem = 0;
for (int i = 0; i < c; i ++) {
long item = 0;
XIntelliSense.XIntelliResult names = result[i];
if (names == nilptr){
continue;
}
current_autocmp = result;
if (names.get_type() == 23) {
if (names.hasProp('S')) {
item = autoWnd.addItem("res/toolbar/staticfunction.png", names.get_name());
} else {
item = autoWnd.addItem("res/toolbar/function.png", names.get_name());
}
String descr = names.get_name() + "(";
XIntelliSense.XIntelliResult [] params = names.get_params();
if (params != nilptr){
for (int x = 0; x < params.length; x ++) {
XIntelliSense.XIntelliResult param = params[x];
if (param != nilptr){
XIntelliSense.XIntelliResult pclass = param.get_class();
if (pclass != nilptr){
descr = descr + pclass.get_name() + " " + param.get_name();
}else{
descr = descr + "? " + param.get_name();
}
if (x + 1 < params.length) {
descr = descr + ", ";
}
}
}
}
descr = descr + ")";
XIntelliSense.XIntelliResult pclass = names.get_class();
if (pclass != nilptr){
autoWnd.setItemText(item, 1, pclass.get_name());
}else{
autoWnd.setItemText(item, 1, "?");
}
autoWnd.setItemText(item, 2, descr);
autoWnd.setItemColor(item, 1, 0xff7f7f7f);
autoWnd.setItemColor(item, 2, 0xff7f7f7f);
} else {
if (names.hasProp('C')) {
item = autoWnd.addItem("res/toolbar/const.png", names.get_name());
} else if (names.hasProp('S')) {
item = autoWnd.addItem("res/toolbar/static.png", names.get_name());
} else {
item = autoWnd.addItem("res/toolbar/member.png", names.get_name());
}
XIntelliSense.XIntelliResult pclass = names.get_class();
if (pclass != nilptr){
autoWnd.setItemText(item, 1, pclass.get_name());
}else{
autoWnd.setItemText(item, 1, "?");
}
autoWnd.setItemColor(item, 1, 0xff7f7f7f);
}
String uname = names.get_name().upper();
if (selitem == 0) {
if (uname.startsWith(entenedText)) {
selitem = item;
}
}
autoWnd.setItemTag(item, 0, i);
autoCompMap.put(uname, item);
}
//XSourceEditor.this.autoCompleteChange();
if (bMore) {
autoWnd.addItem(nilptr, "<更多...>");
}
showAutoWnd(auto_position);
if (selitem != 0) {
autoWnd.setCurrentItem(selitem);
}
}
public void showDebugWnd(int position, JsonObject obj){
int x = _sci.xFromPosition(position);
int y = _sci.yFromPosition(position);
QPoint pt = _sci.mapTo(_mdi_area.mainWindow, x, y);
debugWnd.move(pt.x, pt.y + _sci.getLineHeight());
__dvp.sendCommand(new Object[]{DebugValueParser.COMMAND.CMD_DISPLAYWATCH, debugWnd, watchs, obj});
debugWnd.show();
debugWnd.raise();
debugWnd.setFocus();
//setFocus();
synchronized(__dvp){
debugWndShow = true;
}
}
public void showAutoWnd(int position) {
int x = _sci.xFromPosition(position);
int y = _sci.yFromPosition(position);
QPoint pt = _sci.mapTo(_mdi_area.mainWindow, x, y);
autoWnd.move(pt.x, pt.y + _sci.getLineHeight());
autoWnd.show();
autoWnd.raise();
//setFocus();
autoCompShow = true;
}
public void hideDebugWnd(){
synchronized(__dvp){
if (debugWndShow) {
debugWnd.hide();
__dvp.clear(debugWnd);
watchs.clear();
debugWndShow = false;
}
}
}
public void hideAutoWnd() {
if (autoCompShow) {
autoWnd.hide();
autoWnd.clear();
autoCompMap.clear();
strpretext = "";
autoCompShow = false;
}
}
class DebugWndFocus : onFocusEventListener{
bool isFocused, blocked = false;
void onFocusIn(QObject obj, bool focus, int reson) {
if (blocked == false){
isFocused = true;
}
}
void onFocusOut(QObject obj, bool focus, int reson) {
if (blocked == false){
if (isFocused) {
XSourceEditor.this.hideDebugWnd();
}
}
}
public void setBlocked(bool b){
blocked = b;
}
};
public void createDebugWnd(){
debugWnd = new QTreeWidget();
debugWnd.create(_mdi_area.mainWindow);
debugWnd.hide();
debugWnd.resize(600, 200);
debugWnd.setFullRowSelection(true);
debugWnd.setColumnAutoResize(true);
debugWnd.setSortEnable(false);
debugWnd.setTextElidMode(Constant.ElideNone);
String [] columns = {"名称", "类型", "值", "ID"};
debugWnd.setColumns(columns);
debugWnd.setHeaderVisible(false);
DebugWndFocus __ofe = new DebugWndFocus();
debugWnd.setOnFocusEventListener(__ofe);
QOCallback __calback = new QOCallback(){
void callback(JsonObject obj){
runOnUi(new Runnable(){
void run(){
if (bClosed) {
return ;
}
synchronized(__dvp){
if (debugWndShow){
__dvp.sendCommand(new Object[]{DebugValueParser.COMMAND.CMD_LOADOBJECT, debugWnd, obj});
}
}
}
});
}
};
debugWnd.setOnTreeViewItemEvent( new onTreeViewItemEvent(){
TextDetail __td = nilptr;
public void onItemExpanded(QTreeWidget tree,long item)override{
__dvp.expandItem(tree, item, __calback);
}
public void onItemDoubleClicked(QTreeWidget tree,long item, int column)override{
long objectId = 0;
if (column == 2){
objectId = tree.getItemTag(item, 2);
}
String caption = tree.getItemText(item, 0);
String sztype = tree.getItemText(item, 1);
if (objectId != 0 && (sztype.equals("String") || sztype.equals("JsonObject") || sztype.equals("JsonArray"))){
XWorkspace.workspace.debuggee.queryObject("detail:" + caption , "" + objectId, __dvp.getIdentifier(), 0, 0, __calback);
}else
if (__td == nilptr){
String text = tree.getItemText(item, column);
if (text.length() > 0){
__td = new TextDetail(new TextDetail.closeListener(){
void onCreate(){
__ofe.setBlocked(true);
}
void onClose(String text, bool updated){
debugWnd.setFocus();
__ofe.setBlocked(false);
__td = nilptr;
}
});
__td.create(caption, text.replace(" ↩ ", "\n")
.replace(" ↵ ", "\r")
.replace(" ⇥ ", "\t")
.replace(" ⇤ ", "\b"), nilptr, true);
}
}
}
});
}
public void createAutoCompWindow() {
autoWnd = new QTreeWidget();
autoWnd.create(_mdi_area.mainWindow);
autoWnd.hide();
autoWnd.resize(600, 200);
autoWnd.setFullRowSelection(true);
autoWnd.setColumnAutoResize(true);
autoWnd.setSortEnable(true);
autoWnd.setTextElidMode(Constant.ElideNone);
String [] columns = {"名称", "描述", "类型"};
autoWnd.setColumns(columns);
autoWnd.setHeaderVisible(false);
autoWnd.setOnFocusEventListener(new onFocusEventListener () {
bool isFocused;
void onFocusIn(QObject obj, bool focus, int reson) {
isFocused = true;
}
void onFocusOut(QObject obj, bool focus, int reson) {
if (isFocused) {
XSourceEditor.this.hideAutoWnd();
}
}
});
autoWnd.setOnTreeViewItemEvent(new onTreeViewItemEvent() {
void onItemDoubleClicked(QTreeWidget,long item, int column)override {
XSourceEditor.this.autoCompleteDone();
}
});
}
public void showHoverInformation(String texts, int position) {
if (texts != nilptr){
JsonObject root = new JsonObject(texts);
if (root.has("contents")){
JsonObject content = (JsonObject)root.get("contents");
if (content != nilptr){
if (content.has("value")){
String kind = nilptr;
if (content.has("value")){
kind = content.getString("kind");
}
String value = content.getString("value");
if (value != nilptr){
if (kind == "markdown"){
value = value.parseMarkdown();
}
runOnUi(new Runnable(){
void run() override{
if (bClosed) {
return ;
}
showTips(position,"提示:", value);
}
});
}
}
}
}
}
}
int mouse_wait_loop = 0;
void breakHover(){
mouse_wait_loop = -2;
}
public void setSciEvent() {
QWidget viewport = _sci.viewPort();
if (viewport != nilptr){
viewport.setOnMouseEventListener(new onMouseEventListener() {
ICompileInfo tipsci = nilptr;
long __coord = 0;
int __curpos = 0;
Thread tips_thread = nilptr;
Object tips_lock = new Object();
bool button_pressed = false;
void onMouseButtonPress(QObject obj, int Button, int x, int y, int flags, int source)override {
button_pressed = true;
XSourceEditor.this.hideAutoWnd();
__tipsWnd.hide(false);
}
void onMouseButtonRelease(QObject obj, int Button, int x, int y, int flags, int source)override {
button_pressed = false;
onSciMouseButtonPress(Button, x, y, flags, source);
}
void onMouseMove(QObject obj, int Button, int _x, int _y, int flags, int source)override {
if (button_pressed ){
return;
}
mouse_wait_loop = 0;
__coord = _x;
__coord <<= 32;
__coord |= _y;
synchronized (tips_lock) {
if (tips_thread != nilptr){
return;
}
tips_thread = new Thread(){
void run()override{
long coords = __coord;
while (mouse_wait_loop++ < 10){
_system_.sleep(100);
if (mouse_wait_loop < 0){
break;
}
if (coords != __coord){
coords = __coord;
mouse_wait_loop = 0;
}
}
if (mouse_wait_loop >= 10){
runOnUi(new Runnable(){
void run() {
if (bClosed) {
return ;
}
onMouseHover((coords >> 32) & 0xffffffff, coords & 0xffffffff);
}
});
}
synchronized (tips_lock) {
tips_thread = nilptr;
}
}
};
tips_thread.start();
}
}
});
}
}
public void onMouseHover(int _x, int _y){
if (XWorkspace.workspace.isDebugging()) {
if (ThreadManager.isCurrentInterrupt()) {
if (disableOverview != nilptr){
if (disableOverview.isOverviewEnabled() == false){
return ;
}
}
if (debugWndShow == false){
int pos = _sci.positionFromPoint(_x, _y);
showRuntimeInfo(pos);
}
}
}else
if(isTipsShow() == false){
int pos = _sci.positionFromPoint(_x, _y);
int indic = _sci.IndicForPosition(pos);
int _line = _sci.positionToLine(pos);
int _column = pos - _sci.getPosition(_line);
if (((indic & (1 << INDIC_ERROR) )!= 0) || ((indic & (1 << INDIC_WARNING) )!= 0)){
Map.Iterator<long, ICompileInfo> iter = __hoverhelps.findLower(pos,false);
if (iter != nilptr){
ICompileInfo tipsci = iter.getValue();
if (tipsci != nilptr){
new Thread(){
void run()override{
runOnUi(new Runnable(){
void run() {
if (bClosed) {
return ;
}
int line = tipsci.getLine() - 1;
int ipos = _sci.getPosition(line) + tipsci.getRow() - 1;
int iclen = tipsci.getLength();
if (iclen < 1){
iclen = 1;
}
if (pos >= ipos && pos < (ipos + iclen)){
showTips(pos,"诊断信息:",tipsci.getTips());
}
}
});
}
}.start();
}
}else{
showHoverInfor(pos, _line, _column);
}
}else{
showHoverInfor(pos, _line, _column);
}
}
}
public void showHoverInfor(int pos, int _line, int _column){
new Thread(){
void run(){
_mdi_area.hoverDocument(XSourceEditor.this, getFilePath(), getTextContent(), pos, _line, _column);
}
}.start();
}
public void showRuntimeInfo(int pos) {
if (pos < 0){
return;
}
int start = _sci.sendEditor(QScintilla.SCI_WORDSTARTPOSITION, pos, 0);
int end = _sci.sendEditor(QScintilla.SCI_WORDENDPOSITION, pos, 0);
String thekey = _sci.getText(start, end).trim(true);
if (thekey.length() > 0) {
if (isKeyWord(thekey) == false && isDebugWord(thekey) == false){
return;
}
if (disableOverview != nilptr){
thekey = disableOverview.preprocessKeyword(thekey);
}
if (thekey != nilptr && thekey.length() > 0){
new Thread(){
void run(){
watchs.clear();
watchs.put(thekey,debugWnd.addItem(nilptr,thekey));
JsonObject json = XWorkspace.workspace.debuggee.queryObjectByName(ThreadManager.currentThreadId, ThreadManager.currentFrameId, thekey);
if (json != nilptr) {
JsonArray watches;
try {
watches = (JsonArray)json.get("watch");
} catch(Exception e) {
}
if (watches != nilptr) {
if (watches.length() > 0) {
showRtInfos(pos, watches);
}
}
}
}
}.start();
}
}
}
public void showRtInfos(int pos, @NotNilptr JsonArray watches) {
JsonObject obj = (JsonObject)watches.get(0);
if (obj != nilptr) {
runOnUi(new Runnable() {
void run() {
if (bClosed) {
return ;
}
showDebugWnd(pos, obj);
}
});
}
}
public bool testMark(int line, int id) {
if (line < 0) {
return false;
}
int n = _sci.sendEditor(QScintilla.SCI_MARKERGET, line, id);
if ((n & (0x1 << id)) != 0) {
return true;
}
return false;
}
public void toggleBreakpoint() {
long pos = _sci.currentPosition();
int line = _sci.positionToLine(pos);
BreakPointWnd.toggleBreakPoint(this, getFilePath(), line, testMark(line, MARK_BREAKPOINT) == false);
}
public void toggleBreakPoint(int line, bool set) {
if (set) {
if (testMark(line, MARK_BREAKPOINT) == false) {
_sci.sendEditor(QScintilla.SCI_MARKERADD, line, MARK_BREAKPOINT);
}
} else {
if (testMark(line, MARK_BREAKPOINT) == true) {
_sci.sendEditor(QScintilla.SCI_MARKERDELETE, line, MARK_BREAKPOINT);
}
}
}
public void createContextMenu() {
if (editor_actions == nilptr) {
String [] menus = {
"actionundo",
"actionredo",
"-",
"actiontoback",
"actiontofront",
"-",
"actionoverride",
"-",
"actioncut",
"-",
"actioncopy",
"actionpaste",
"-",
"actiondelete",
"actiondelcurline",
"-",
"actionbreakpoint",
"-",
"actiongotodef",
"actionfindreference",
"actionrename",
"-",
"actionupper",
"actionlower",
"-",
"actionmatchbrace",
"actionfind",
"actionreplace",
"actionfindagain",
"-",
"actiongoto"
};
editor_actions = new QAction[menus.length];
for (int i =0; i < menus.length; i++) {
if (menus[i].equals("-")) {
editor_actions[i] = new QAction();
editor_actions[i].create(this);
editor_actions[i].setSeparator(true);
} else {
editor_actions[i] = (QAction)_mdi_area.mainWindow.findByName(menus[i]);
}
}
}
__nilptr_safe(editor_actions);
_sci.addActions(editor_actions);
_sci.setContextMenuPolicy(Constant.ActionsContextMenu);
}
public void gotoCursordef() override {
locationObject(_sci.getCurrentPosition());
}
Thread autoThread = nilptr;
public void matchBrace() {
int lStart = _sci.sendEditor(QScintilla.SCI_GETCURRENTPOS, 0, 0);
int lEnd = _sci.sendEditor(QScintilla.SCI_BRACEMATCH, lStart - 1, 0);
if (lEnd >= 0) {
_sci.gotoPos(lEnd + 1);
}
}
void optimizeCompletion(@NotNilptr QScintilla sci, long position){
String content = sci.getText();
int cur_line = _sci.positionToLine(position);
int column = position - sci.getPosition(cur_line);
_mdi_area.XIntelliSenseL(XSourceEditor.this, getFilePath(), content, cur_line, column);
}
public void continueAutocomp(int pos) {
if (autoCompShow) {
if (pos < auto_position){
hideAutoWnd();
return;
}
Project proj = _mdi_area.getCurrentProject();
if (proj != nilptr) {
if (proj.hasCompletionFilter()){
optimizeCompletion(_sci, pos);
return;
}
}
if (pos != last_autopos) {
last_autopos = pos;
} else {
return ;
}
if (lastxis != nilptr && strpretext != nilptr) {
String content = _sci.getText();
long tl = content.length();
if (auto_position < tl && pos <= tl) {
strpretext = content.substring(auto_position, pos);
if (strpretext.length() == 0 || Pattern.test(strpretext, "^[A-Za-z0-9_]+$", Pattern.NOTEMPTY, true)) {
synchronized(XSourceEditor.this) {
if (autoThread == nilptr) {
autoThread = new Thread() {
void run() {
preProcessXIntellisense();
synchronized(XSourceEditor.this) {
autoThread = nilptr;
}
}
};
autoThread.start();
}
}
} else {
hideAutoWnd();
}
} else {
hideAutoWnd();
}
}
}
}
public bool isspace(int c) {
return (c == ' ' ||c == '\t' ||c == '\r' ||c == '\n' ||c == '\v' ||c == '\f');
}
public void identguide(@NotNilptr QScintilla sci, int lastChar) {
long pos = sci.currentPosition();
int line = sci.positionToLine(pos);
//如果最后输入的字符是右括号的话就自动让当前行缩进和它匹配的左括号所在行一致
if (("})>]".indexOf(lastChar) != -1) && isspace(sci.sendEditor(QScintilla.SCI_GETCHARAT,pos - 2))) {
//找前一个单词起始位置,这里用它来确定右括号左边是否全是空白字符
if(pos > 0){
int startpos = sci.sendEditor(sci.SCI_WORDSTARTPOSITION,pos - 1,0);
int linepos = sci.sendEditor(sci.SCI_POSITIONFROMLINE,line);
if(startpos == linepos) {
int othpos = sci.sendEditor(QScintilla.SCI_BRACEMATCH,pos - 1); //得到对应的左括号所在的位置
int othline = sci.sendEditor(QScintilla.SCI_LINEFROMPOSITION, othpos); //左括号所在行
int nIndent = sci.sendEditor(QScintilla.SCI_GETLINEINDENTATION, othline);//左括号所在行的缩进值
// 替换右括号前面的空白字符,使之与左括号缩进一致
String space = String.fill(' ', 1024);
sci.sendEditor(QScintilla.SCI_SETTARGETSTART, startpos);
sci.sendEditor(QScintilla.SCI_SETTARGETEND, pos - 1);
sci.sendEditor(QScintilla.SCI_REPLACETARGET, nIndent, space);
}
}
}
if (lastChar == '\n') {
if(line > 0) {
// 得到上一行缩进设置
int nIndent = sci.sendEditor(QScintilla.SCI_GETLINEINDENTATION, line - 1);
// 查找上一行最后一个有效字符(非空白字符)
int nPrevLinePos = sci.sendEditor(QScintilla.SCI_POSITIONFROMLINE, line - 1);
int c = ' ';
for(int p = pos - 2; p >= nPrevLinePos && isspace(c); ) {
p--;
c = sci.sendEditor(QScintilla.SCI_GETCHARAT, p);
}
// 如果是左括号,就多缩进四格
if(c != 0 && "{([<".indexOf(c) != -1) {
nIndent += 4;
}
// 缩进...
String space = String.fill(' ', nIndent);
sci.sendEditor(QScintilla.SCI_REPLACESEL, 0, space);
}
}
}
WordRecognizer recongnizer = nilptr;
bool reconGeted = false;
public bool isTriggedChar(char c){
if (reconGeted == false){
recongnizer = _mdi_area.getWordRecognizer(getFilePath());
reconGeted = true;
}
if (recongnizer != nilptr){
return recongnizer.isTriggedChar(c);
}
return false;
}
public bool isDocument(String ext){
if (reconGeted == false){
recongnizer = _mdi_area.getWordRecognizer(getFilePath());
reconGeted = true;
}
if (recongnizer != nilptr){
return recongnizer.isDocument(ext);
}
return false;
}
public bool isDebugWord(String word){
if (word == nilptr || word.length() == 0){
return false;
}
if (word.startsWith("$") || word.isDigit()){
return true;
}
return false;
}
public bool isKeyWord(String word){
if (word == nilptr || word.length() == 0){
return false;
}
for (int i = 0, c = word.length(); i < c; i++){
if (isInWord(word.charAt(i),i == 0) == false){
return false;
}
}
return true;
}
public bool isInWord(char c, bool b){
if (reconGeted == false){
recongnizer = _mdi_area.getWordRecognizer(getFilePath());
reconGeted = true;
}
if (recongnizer != nilptr){
return recongnizer.isWord(c, b);
}
return false;
}
SciEventListener sci_listener = new SciEventListener() {
int lastAddedChar;
void ON_MARGINCLICK(@NotNilptr QScintilla sci, int position, int modifiers, int margin)override {
breakHover();
if (margin == BREAKPOINT_INDEX) {
int line = _sci.positionToLine(position);
BreakPointWnd.toggleBreakPoint(XSourceEditor.this, getFilePath(), line, testMark(line, MARK_BREAKPOINT) == false);
} else if (margin == MARGIN_FOLD_INDEX) {
int line = _sci.positionToLine(position);
_sci.sendEditor(QScintilla.SCI_TOGGLEFOLD, line);
} else if (margin == DEBUGPOINT_INDEX) {
int line = _sci.positionToLine(position);
try{
ICompileInfo iif = __marginhelps.get(line);
if (iif != nilptr){
showTips(position,"诊断信息:",iif.getTips());
}
}catch(Exception e){
}
}
}
void ON_UPDATEUI(@NotNilptr QScintilla sci, int updated)override {
int position = sci.sendEditor(QScintilla.SCI_GETCURRENTPOS, 0, 0);
XWorkspace.recordAction(getFilePath(), position);
displayInfo(position);
int cstyle = sci.getStyleAtPosition(position);
if (cstyle == QScintilla.SCE_C_COMMENT || cstyle == QScintilla.SCE_C_COMMENTLINE || cstyle == QScintilla.SCE_C_COMMENTDOC
|| cstyle == QScintilla.SCE_C_STRING || cstyle == QScintilla.SCE_C_CHARACTER) {
return ;
}
if (position > 0){
long oppos = position - 1;
int lEnd = sci.sendEditor(QScintilla.SCI_BRACEMATCH, oppos, 0);
if (lEnd >= 0) {
sci.sendEditor(QScintilla.SCI_BRACEHIGHLIGHT, oppos, lEnd);
} else {
sci.sendEditor(QScintilla.SCI_BRACEHIGHLIGHT, -1, -1);
}
int start = sci.sendEditor(QScintilla.SCI_WORDSTARTPOSITION, position, 0);
int end = sci.sendEditor(QScintilla.SCI_WORDENDPOSITION, position, 0);
String curKeyWord = _sci.getText(start, end);
XSourceEditor.this.setHighlightKeyWord(curKeyWord.trim(true));
}
if (lastAddedChar != 0 && Setting.isAutoIdent()) {
identguide(sci, lastAddedChar);
lastAddedChar = 0;
}
if (autoCompShow) {
int line = sci.positionToLine(position);
int autoline = sci.positionToLine(auto_position);
if (line != autoline) {
hideAutoWnd();
}
}
}
void QON_SELCHANGED(@NotNilptr QScintilla sci, bool yes) {
XMenuManager.setStatusSel(yes);
}
void ON_MODIFIED(@NotNilptr QScintilla sci,
int position, int modType,
@NotNilptr String text, int length,
int linesAdded, int line,
int foldLevelNow, int foldLevelPrev,
int token, int annotationLinesAdded) {
int cstyle = sci.getStyleAtPosition(position);
if (cstyle == QScintilla.SCE_C_COMMENT || cstyle == QScintilla.SCE_C_COMMENTLINE || cstyle == QScintilla.SCE_C_COMMENTDOC
/*|| cstyle == QScintilla.SCE_C_STRING*/ || cstyle == QScintilla.SCE_C_CHARACTER) {
return ;
}
if ((modType & (QScintilla.SC_MOD_INSERTTEXT | QScintilla.SC_MOD_DELETETEXT | QScintilla.SC_PERFORMED_UNDO | QScintilla.SC_PERFORMED_REDO | QScintilla.SC_MULTISTEPUNDOREDO | QScintilla.SC_LASTSTEPINUNDOREDO | QScintilla.SC_MULTILINEUNDOREDO)) != 0) {
int linep = sci.positionToLine(position);
breakHover();
if ((modType & QScintilla.SC_MOD_INSERTTEXT) != 0){
int lineto = sci.positionToLine(position + length);
for (int i = linep; i < lineto + 1; i++){
sci.sendEditor(QScintilla.SCI_MARKERDELETE, i, reserve_modify_mark);
sci.sendEditor(QScintilla.SCI_MARKERADD, i, current_modify_mark);
}
}else{
sci.sendEditor(QScintilla.SCI_MARKERDELETE, linep, reserve_modify_mark);
sci.sendEditor(QScintilla.SCI_MARKERADD, linep, current_modify_mark);
}
//if (pos >= auto_position) {
if (position > 0 && (modType & QScintilla.SC_MOD_DELETETEXT) == QScintilla.SC_MOD_DELETETEXT) {
continueAutocomp(position - 1);
}
XSourceEditor.this.intellisense_modified = true;
}
}
void ON_CHARADDED(@NotNilptr QScintilla sci,int charadded)override {
lastAddedChar = charadded;
long position = sci.currentPosition();
int cstyle = sci.getStyleAtPosition(position);
bool invalidArea = true;
if (cstyle == QScintilla.SCE_C_COMMENT || cstyle == QScintilla.SCE_C_COMMENTLINE || cstyle == QScintilla.SCE_C_COMMENTDOC
|| cstyle == QScintilla.SCE_C_STRING || cstyle == QScintilla.SCE_C_CHARACTER) {
invalidArea = false;
}
if (invalidArea) {
if (isTriggedChar(charadded)) {
String content = sci.getText();
strpretext = String.format("%c",charadded);
int line = sci.positionToLine(position);
int column = position - sci.getPosition(line);
if (_mdi_area.XIntelliSense(XSourceEditor.this, getFilePath(), content, position, line, column)) {
auto_position = position;
last_autopos = -1;
}
} else if (autoCompShow == false) {
if (isInWord(lastAddedChar, true)) {
String content = sci.getText();
int cur_line = _sci.positionToLine(position);
int p = position;
while (p > 0) {
char c = content.charAt(p - 1);
if (false == isInWord(c, true)) {
break;
}
p--;
}
auto_position = p;
last_autopos = -1;
strpretext = content.substring(auto_position, position);
int column = position - sci.getPosition(cur_line);
_mdi_area.XIntelliSenseL(XSourceEditor.this, getFilePath(), content, cur_line, column);
}
} else {
if (false == isInWord(lastAddedChar, true)) {
hideAutoWnd();
} else {
continueAutocomp(position);
}
}
}else{
continueAutocomp(position);
}
if (Setting.isMatchBrace()) {
char next_char = sci.getChar(position);
bool next_isword = false;
if (isInWord(next_char, false)) {
next_isword = true;
}
switch(charadded) {
case '(':
if (next_isword == false) {
sci.insertText(position, ")");
}
break;
case '[':
if (next_isword == false) {
sci.insertText(position, "]");
}
break;
case '{':
if (next_isword == false) {
sci.insertText(position, "}");
}
break;
case '"':
if (sci.getChar(position) == charadded) {
sci.selectAndReplace(position,position + 1,"");
} else if (next_isword == false) {
sci.insertText(position, "\"");
}
break;
case '\'':
if (sci.getChar(position) == charadded) {
sci.selectAndReplace(position,position + 1,"");
} else if (next_isword == false) {
sci.insertText(position, "'");
}
break;
case '}':
case ')':
case ']':
if (sci.getChar(position) == charadded) {
sci.selectAndReplace(position,position + 1,"");
}
break;
}
}
}
};
public bool deleteBrace(int pos) {
int c = _sci.getChar(pos);
switch(c) {
case '(':
if (_sci.getChar(pos + 1) == ')') {
_sci.selectAndReplace(pos,pos + 2,"");
return false;
}
break;
case ')':
if (_sci.getChar(pos - 1) == '(') {
_sci.selectAndReplace(pos - 1,pos + 1,"");
return false;
}
break;
case '[':
if (_sci.getChar(pos + 1) == ']') {
_sci.selectAndReplace(pos,pos + 2,"");
return false;
}
break;
case ']':
if (_sci.getChar(pos - 1) == '[') {
_sci.selectAndReplace(pos - 1,pos + 1,"");
return false;
}
break;
/*case '{':
if (_sci.getChar(pos + 1) == '}') {
_sci.selectAndReplace(pos,pos + 2,"");
return false;
}
break;
case '}':
if (_sci.getChar(pos - 1) == '{') {
_sci.selectAndReplace(pos - 1,pos + 1,"");
return false;
}
break;*/
case '\'':
if (_sci.getChar(pos + 1) == '\'') {
_sci.selectAndReplace(pos,pos + 2,"");
return false;
} else if (_sci.getChar(pos - 1) == '\'') {
_sci.selectAndReplace(pos - 1,pos + 1,"");
return false;
}
break;
case '"':
if (_sci.getChar(pos + 1) == '"') {
_sci.selectAndReplace(pos,pos + 2,"");
return false;
} else if (_sci.getChar(pos - 1) == '"') {
_sci.selectAndReplace(pos - 1,pos + 1,"");
return false;
}
break;
}
return true;
}
public bool create(@NotNilptr QWidget parent) {
if (super.create(parent)) {
QWidget frame = new QWidget();
frame.create();
frame.setName("editorframe");
QWidget domainframe = new QWidget();
domainframe.create();
QHBoxLayout globalarea = new QHBoxLayout();
globalarea.create(domainframe);
onComboBoxEventListener _cmb_listener = new onComboBoxEventListener(){
public void onItemSelected(QObject obj, int id) {
if (bCmbInit){
return;
}
try{
QComboBox qc = (QComboBox)obj;
Vector<XIntelliSense.XIntelliResult> _link_list = (Vector<XIntelliSense.XIntelliResult>)qc.getTag();
if (_link_list != nilptr){
XIntelliSense.XIntelliResult it = _link_list.get(id);
if (it != nilptr){
goto(it.get_line(),it.get_row());
_sci.setFocus();
}
}
}catch(Exception e){
}
}
};
domaincmb.create(domainframe);
objectscmb.create(domainframe);
domaincmb.setOnComboBoxEventListener(_cmb_listener);
objectscmb.setOnComboBoxEventListener(_cmb_listener);
globalarea.addWidget(domaincmb);
globalarea.addWidget(objectscmb);
globalarea.setContentsMargins(0,0,0,0);
globalarea.setSpacing(0);
domainframe.setLayout(globalarea);
QVBoxLayout qhl = new QVBoxLayout();
qhl.create(frame);
_sci = new QScintilla();
if (_sci.create(frame) == false) {
return false;
}
statbar = new QLabel();
statbar.create(frame);
statbar.setName("editstatus");
statbar.show();
statbar.setAlignment(Constant.AlignRight);
statbar.setText("状态栏");
qhl.addWidget(domainframe);
qhl.addWidget(_sci);
qhl.addWidget(statbar);
frame.setLayout(qhl);
qhl.setSpacing(0);
qhl.setContentsMargins(0,0,0,0);
_sci.unbindInternalShortcut(Constant.ControlModifier | Constant.Key_D);
_sci.unbindInternalShortcut(Constant.ControlModifier | Constant.Key_C);
_sci.unbindInternalShortcut(Constant.ControlModifier | Constant.ShiftModifier | Constant.Key_U);
_sci.unbindInternalShortcut(Constant.ControlModifier | Constant.Key_U);
//_sci.updateInternalShortcut(QScintilla.SCI_LINEDELETE, ControlModifier | Key_D);
//_sci.clearInternalShortcuts();
/*setOnActivateListener(new onActivateListener() {
void onWindowDeactivate(QObject obj) override{
}
void onWindowActivate(QObject )override{
}
});*/
setOnStatusListener(new onStatusListener(){
public void onWindowStateChange(QObject obj, int oldState, int state) {
if ((state & Constant.WindowActive) == Constant.WindowActive){
updateInformationPoint();
}else{
hideAutoWnd();
hideDebugWnd();
_sci.cancelTips();
}
}
});
setSciEvent();
createAutoCompWindow();
createDebugWnd();
setWindowIcon("res/toolbar/source.png");
createContextMenu();
_sci.setOnSciEventListener(sci_listener);
updateTitle();
setWidget(frame);
_textplugins = _mdi_area.getEditorPlugin();
updateConfig();
_sci.show();
setMaximized(true);
_sci.setOnKeyEventListener(new onKeyEventListener() {
bool onKeyPress(QObject obj, int key, bool repeat, int count, String text, int scanCode, int virtualKey, int modifier)override {
if (autoCompShow) {
if (key == Constant.Key_Up) {
XSourceEditor.this.autoCompleteUp();
return false;
}
if (key == Constant.Key_Down) {
XSourceEditor.this.autoCompleteDown();
return false;
}
if (key == Constant.Key_Enter || key == Constant.Key_Return) {
XSourceEditor.this.autoCompleteDone();
return false;
}
if (key == Constant.Key_Escape || key == Constant.Key_Delete || key == Constant.Key_Home || key == Constant.Key_End|| key == Constant.Key_PageUp|| key == Constant.Key_PageDown || key == Constant.Key_HomePage) {
XSourceEditor.this.hideAutoWnd();
hideDebugWnd();
if (key != Constant.Key_Delete){
__tipsWnd.hide();
}
return true;
}
}
if (Setting.isMatchBrace()) {
if (key == Constant.Key_Delete || key == Constant.Key_Backspace) {
int start = _sci.getSelectStart();
int end = _sci.getSelectEnd();
if (start == end) {
return deleteBrace(key == Constant.Key_Delete ? start : start - 1);
}
}
}
if (Setting.isAutoIdent()) {
if (key == Constant.Key_Return || key == Constant.Key_Enter) {
_sci.replaceSelect("");
int pos = _sci.getCurrentPosition();
int c = _sci.getChar(pos);
if (c == '}') {
String tabs = "";
if (Setting.isUseTabstop()) {
tabs = "\t";
} else {
tabs = String.fill(' ',Setting.getTabWidth());
}
_sci.insertText(pos,"\n\n");
_sci.gotoPos(pos + 1);
identguide(_sci, '\n' );
pos = _sci.getCurrentPosition();
_sci.gotoPos(pos + 1);
identguide(_sci, '\n' );
_sci.insertText(pos,tabs);
_sci.gotoPos(pos + tabs.length());
return false;
}
}
}
if (key == Constant.Key_Tab || key == Constant.Key_Enter || key == Constant.Key_Return) {
if (_sci.getSelectStart() == _sci.getSelectEnd()){
hideAutoWnd();
int pos = _sci.getCurrentPosition();
_sci.setIndicCurrent(INDIC_TIPS);
int[] ind = getNextIndic(pos);
if (ind != nilptr) {
if (ind.length > 0) {
_sci.gotoPos(ind[1]);
}
return false;
}
return true;
}
}
if (key == Constant.Key_Control) {
lastCursor = _sci.getCursor();
_sci.setCursor(QScintilla.cursorHand);
sciisHand = true;
}
return true;
}
bool onKeyRelease(QObject obj, int key, bool repeat, int count, String text, int scanCode, int virtualKey, int modifier)override {
if (isModified() == false) {
setModified(_sci.isModified());
if (isModified()) {
XSourceEditor.this.updateTitle();
}
}
if (key == Constant.Key_Control ) {
_sci.setCursor(QScintilla.cursorText);
sciisHand = false;
}
return true;
}
});
_sci.setOnFocusEventListener(new onFocusEventListener() {
void onFocusIn(QObject obj, bool focus, int reson) {
sciisHand = false;
XFindDlg.findinOutput = false;
_sci.setCursor(QScintilla.cursorText);
}
void onFocusOut(QObject obj, bool focus, int reson) {
sciisHand = false;
_sci.setCursor(QScintilla.cursorText);
_sci.cancelTips();
if (autoCompShow) {
if (autoWnd.hasFocus() == false) {
hideAutoWnd();
}
}
}
void onFocusAboutToChange(QObject obj, bool focus, int reson) {
}
});
return true;
}
return false;
}
void displayInfo(int curpos){
int line = _sci.positionToLine(curpos);
int column = curpos - _sci.getPosition(line);
int total = _sci.getLength();
int countOfLine = _sci.countOfLine();
statbar.setText("行:" + (line + 1)+ " 字:" + (column + 1 )+ " 文件长度:" + total + " 总行数:" + countOfLine + " 编码:" + ( (defaultCharset == nilptr) ? "UTF-8" : defaultCharset) + " ");
}
public void onTextEditorCreated() {
IXPlugin plugin = _mdi_area.getCurrentProjectPlugin();
if (plugin != nilptr) {
plugin.onTextEditorCreated(_controller);
}
}
public void onTextEditorClosed() {
IXPlugin plugin = _mdi_area.getCurrentProjectPlugin();
if (plugin != nilptr) {
plugin.onTextEditorClosed(_controller);
}
}
public bool requestPluginClose() {
if (_textplugins != nilptr) {
return _textplugins.requestClose(_controller);
}
return true;
}
public String mapType(@NotNilptr String type) {
int t = type.parseInt();
switch(t) {
case 18:
return "变量/常量";
break;
case 25:
case 23:
return "方法";
break;
case 28:
return "包";
break;
case 27:
return "Native方法";
break;
case 30:
return "接口";
break;
case 31:
return "类";
break;
case 33:
return "匿名类";
break;
}
return "对象";
}
public int [] getNextIndic(int pos) {
int start = _sci.getIndicStart(INDIC_TIPS, pos);
if (start == 0) {
return nilptr;
}
int end = _sci.getIndicEnd(INDIC_TIPS, start);
int[] ret = {start, end};
int dic = _sci.IndicForPosition(start);
if ((dic & (1 << INDIC_TIPS)) == 0) {
if (end == _sci.getLength()) {
int del_len = clearIndic();
_sci.clearIndic(0, _sci.getLength());
_sci.gotoPos(pos + 1 - del_len);
return new int[0];
}
if (end >= 0){
return getNextIndic(end);
}
}
return ret;
}
public void clearInformationPoint(){
__hoverhelps.clear();
__marginhelps.clear();
_sci.setIndicCurrent(INDIC_ERROR);
_sci.clearIndic(0,_sci.getLength());
_sci.setIndicCurrent(INDIC_WARNING);
_sci.clearIndic(0,_sci.getLength());
}
public void clearSelectedMark(){
_sci.setIndicCurrent(INDIC_SELECTED);
_sci.clearIndic(0,_sci.getLength());
}
public void clearFoundMark(){
_sci.setIndicCurrent(INDIC_FIND);
_sci.clearIndic(0,_sci.getLength());
}
public int clearIndic() {
//bool bclr = true;
int start = 0, end = 0;
int del_len = 0;
do {
start = _sci.getIndicStart(INDIC_TIPS, start);
end = _sci.getIndicEnd(INDIC_TIPS, start);
if (end == 0) {
return del_len;
}
int dic = _sci.IndicForPosition(start);
if ((dic & (1 << INDIC_TIPS)) != 0) {
del_len += (end - start);
_sci.selectAndReplace(start, end, "");
} else {
start = end;
}
} while (end != _sci.getLength());
return del_len;
}
/***
@brief 查询重写方法
@param pos 编辑器中的位置
如果代码结构比较复杂则 XISQueryM 可能会耗时导致界面停止响应
所以开新线程处理,然后将处理结果交给UI线程处理
*/
public void overrideObject() {
// 获取当前行
int pos = _sci.currentPosition();
int line = _sci.positionToLine(pos);
int column = pos - _sci.getPosition(line);
// 开一个线程去查询
new Thread() {
void run()override {
// 执行查询
XIntelliSense.XIntelliResult [] res = _mdi_area.XISQueryM(getFilePath(), line);
//将查询结果交还UI线程处理
runOnUi(new Runnable() {
void run()override {
if (bClosed == false) {
if (res != nilptr && res.length > 0) {
OverrideDlg.requesOverrideObject(XSourceEditor.this, pos, res);
} else {
ProgressView pv = ProgressView.showWait(1000);
if (pv != nilptr){
pv.centerScreen();
pv.showResult(true, false);
pv.setTitleText("找不到对象");
pv.dismissAfter(1000);
}
}
}
}
});
}
} .start();
}
public void locationObject(int pos) {
if (pos <0 ){
return ;
}
int start = _sci.sendEditor(QScintilla.SCI_WORDSTARTPOSITION, pos, 0);
int end = _sci.sendEditor(QScintilla.SCI_WORDENDPOSITION, pos, 0);
int line = _sci.positionToLine(start);
String curKeyWord = _sci.getText(start, end).trim(true);
int column = start - _sci.getPosition(line);
String content = _sci.getText();
if (curKeyWord.length() > 0) {
new Thread() {
void run()override {
updateXIntellisence(getFilePath(), content);
XIntelliSense.XIntelliResult [] res = _mdi_area.XISQuery(getFilePath(), line, column, curKeyWord);
runOnUi(new Runnable() {
void run()override {
if (bClosed == false) {
if (res != nilptr && res.length > 0) {
sciisHand = false;
_sci.setCursor(QScintilla.cursorText);
if (res.length == 1) {
localtion(res[0].get_source(), res[0].get_line(), res[0].get_row());
} else {
XFinder.FindResult fres = new XFinder.FindResult();
for (int i = 0; i < res.length; i++) {
String rsrc = res[i].get_source();
if (rsrc != nilptr && rsrc.length() > 0) {
fres.add(new XFinder.FindItem(res[i].get_source(), res[i].get_line(), res[i].get_row(), 1, mapType("" + res[i].get_type())));
}
}
XFindresWnd.ShowResult(fres);
}
} else {
ProgressView pv = ProgressView.showWait(1000);
if (pv != nilptr){
pv.centerScreen();
pv.showResult(true, false);
pv.setTitleText("找不到对象");
pv.dismissAfter(1000);
}
}
}
}
});
}
} .start();
}
}
public void onSciMouseButtonPress(int Button, int x, int y,int flags, int source) {
if (sciisHand && Button == 1) {
String filePath = getFilePath();
if (filePath.length() > 0 && filePath.startsWith("#") == false) {
int pos = _sci.positionFromPoint(x, y);
locationObject(pos);
}
}
}
public static void localtion(String source, int line, int row) {
if (source == nilptr){
return ;
}
DocumentView editor = findDocumentWindow(XWorkspace.workspace, source, true);
if (editor != nilptr) {
editor.gotoAndSelect(line, row);
XWorkspace.workspace.setActiveSubWindow(editor);
} else {
ProgressView pv = ProgressView.showWait(1000);
if (pv != nilptr){
pv.centerScreen();
pv.showResult(true, false);
pv.setTitleText("对象不在源代码中");
pv.dismissAfter(1000);
}
}
}
public static void localtion(@NotNilptr String source, int pos) {
DocumentView editor = findDocumentWindow(XWorkspace.workspace, source, true);
if (editor != nilptr) {
editor.goto(pos);
XWorkspace.workspace.setActiveSubWindow(editor);
}
}
public String getTextContent() {
return _sci.getText();
}
public String getSelectedText() {
return _sci.getSelectedText();
}
public bool isIntellisense_modified() {
return intellisense_modified;
}
public bool onCloseDocument()override {
if (_sci.isModified()) {
bool bclose = false;
int rt = QMessageBox.Question("提示","该文档有未保存的更改, 是否在关闭前保存文件?", QMessageBox.Cancel | QMessageBox.No | QMessageBox.Save, QMessageBox.Save);
if (rt == QMessageBox.Save) {
saveFile();
bclose = true;
} else if (rt == QMessageBox.No) {
bclose = true;
} else if (rt == QMessageBox.Cancel) {
bclose = false;
}
if (bclose) {
bclose = requestPluginClose();
}
if (bclose == false) {
return false;
}
}
Project proj = XWorkspace.workspace.getCurrentProject();
if (proj != nilptr){
proj.didCloseFile(getFilePath());
}
bClosed = true;
onTextEditorClosed();
return true;
}
public void autoCompleteUp() {
if (autoCompShow) {
int id = autoWnd.getCurrentRow();
if (id > 0) {
id--;
} else {
id = 0;
}
autoWnd.setCurrentIndex(id, 0);
}
}
public void autoCompleteDown() {
if (autoCompShow) {
int id = autoWnd.getCurrentRow();
int count = autoWnd.getTopLevelCount();
if ((id + 1) < count) {
id++;
} else {
id = count - 1;
}
autoWnd.setCurrentIndex(id, 0);
}
}
public void autoCompleteDone() {
if (autoCompShow) {
long item = autoWnd.getSelItem();
autoCompShow = false;
if (item != 0) {
String text = autoWnd.getItemText(item, 0);
if (text.equals("<更多...>")) {
autoCompShow = true;
loadAutoComplate(item);
return;
}
String tips = autoWnd.getItemText(item, 2);
long curpos = _sci.currentPosition();
int id = autoWnd.getItemTag(item, 0);
if (current_autocmp != nilptr && id < current_autocmp.length) {
XIntelliSense.XIntelliResult names = current_autocmp[id];
if (names != nilptr && names.get_type() == 23) {
IXIntelliSense.InputDescription input = names.makeInputText();
if (input != nilptr){
_sci.selectAndReplace(auto_position, curpos, input.getInsertText());
int [][] current_idincs = input.getTipsDescription();
if (current_idincs != nilptr){
_sci.setIndicCurrent(1);
for (int i = 0; i < current_idincs.length; i++) {
_sci.applyIndic(auto_position + current_idincs[i][0], current_idincs[i][1] - current_idincs[i][0]);
}
_sci.gotoPos(auto_position + current_idincs[0][1]);
}
}
/**/
} else {
_sci.selectAndReplace(auto_position, curpos, text);
}
if (names != nilptr){
names.accept();
}
} else {
_sci.selectAndReplace(auto_position, curpos, text);
}
if (tips.length() != 0) {
showTips(auto_position, "助手:",autoWnd.getItemText(item, 1) + " " + tips);
}
}
autoCompShow = true;
hideAutoWnd();
_sci.setFocus();
}
}
public void autoCompleteChange() {
if (autoCompShow) {
long curpos = _sci.currentPosition();
if (curpos > auto_position) {
String entenedText = _sci.getText(auto_position, curpos).upper();
/* 获取输入的文字 选取一个和已输入部分匹配的 */
Map.Iterator<String,long> iter = autoCompMap.iterator();
long selItem = 0;
while (iter.hasNext()) {
String key = iter.getKey();
if (key != nilptr && key.startsWith(entenedText)) {
selItem = iter.getValue();
break;
}
iter.next();
}
if (selItem != 0) {
autoWnd.setCurrentItem(selItem);
}
}
if (curpos < auto_position) {
hideAutoWnd();
}
}
}
public void switchSaveMark() {
_sci.sendEditor(QScintilla.SCI_MARKERSETFORE,current_modify_mark,0xff3cc215);
_sci.sendEditor(QScintilla.SCI_MARKERSETBACK,current_modify_mark,0xff3cc215);
_sci.sendEditor(QScintilla.SCI_MARKERSETFORE,reserve_modify_mark,0xff00d8ff);
_sci.sendEditor(QScintilla.SCI_MARKERSETBACK,reserve_modify_mark,0xff00d8ff);
int swap = current_modify_mark;
current_modify_mark = reserve_modify_mark;
reserve_modify_mark = swap;
}
public void replaceText(int start, int len,@NotNilptr String text) {
_sci.sendEditor(QScintilla.SCI_SETTARGETSTART, start);
_sci.sendEditor(QScintilla.SCI_SETTARGETEND, start + len);
_sci.sendEditor(QScintilla.SCI_REPLACETARGET, text.length(), text);
setModified();
}
public void updateConfig() {
bool darkStyle = Setting.isDarkStyle();
_sci.setIndicStyle(INDIC_TIPS, QScintilla.INDIC_BOX);
_sci.setIndicStyle(INDIC_ERROR, QScintilla.INDIC_SQUIGGLE);
_sci.setIndicStyle(INDIC_WARNING, QScintilla.INDIC_SQUIGGLE);
_sci.setIndicStyle(INDIC_FIND, QScintilla.INDIC_ROUNDBOX);
_sci.setIndicStyle(INDIC_SELECTED, QScintilla.INDIC_CONTAINER);
bool updatesuccess = false;
if (_textplugins != nilptr) {
szKeywords1 = _textplugins.getKeyWords();
if (szKeywords1 == nilptr) {
szKeywords1 = "";
}
if (Setting.isCustomColor()){
updatesuccess = true;
_sci.sendEditor(QScintilla.SCI_CLEARDOCUMENTSTYLE, 0, 0);
_sci.sendEditor(QScintilla.SCI_SETLEXER, QScintilla.SCLEX_CPP, 0);
_sci.sendEditor(QScintilla.SCI_SETCODEPAGE, QScintilla.SC_CP_UTF8);
_sci.sendEditor(QScintilla.SCI_STYLESETBACK, QScintilla.STYLE_DEFAULT, Setting.getColorRef("defaultbackcolor"));
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.STYLE_DEFAULT, Setting.getColorRef("defaultforecolor"));
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, 75, Setting.getColorRef("defaultforecolor"));
//_sci.sendEditor(QScintilla.STYLE_LINENUMBER, 1, 0);
//bool bmac = (_system_.getPlatformId() == 2);
_sci.sendEditor(QScintilla.SCI_STYLESETFONT, QScintilla.STYLE_DEFAULT,Setting.getEditorFont());
_sci.sendEditor(QScintilla.SCI_STYLESETSIZEFRACTIONAL, QScintilla.STYLE_DEFAULT,Setting.getEditorFontSize());
_sci.sendEditor(QScintilla.SCI_STYLECLEARALL, 0, 0);
_sci.sendEditor(QScintilla.SCI_SETSELBACK,1,Setting.getColorRef("selectedbackcolor"));
_sci.sendEditor(QScintilla.SCI_SETSELFORE,0,Setting.getColorRef("selectedforecolor"));
//C++语法解析
_sci.sendEditor(QScintilla.SCI_SETLEXER, QScintilla.SCLEX_CPP, 0);
_sci.sendEditor(QScintilla.SCI_SETKEYWORDS, 0, szKeywords1);//设置关键字
_sci.sendEditor(QScintilla.SCI_SETKEYWORDS, 1, szKeywords2);//设置关键字
// 下面设置各种语法元素风格
_sci.sendEditor(QScintilla.SCI_SETEOLMODE, 1, 0);
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, MARK_BREAKPOINT, 0);
_sci.sendEditor(QScintilla.SCI_MARKERSETBACK, MARK_BREAKPOINT,Setting.getColorRef("breakpointbackcolor"));
_sci.sendEditor(QScintilla.SCI_MARKERSETFORE, MARK_BREAKPOINT,Setting.getColorRef("breakpointforecolor"));
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, MARK_POINTER,4);
_sci.sendEditor(QScintilla.SCI_MARKERSETFORE, MARK_POINTER,Setting.getColorRef("markpointbackcolor"));
_sci.sendEditor(QScintilla.SCI_MARKERSETBACK, MARK_POINTER,Setting.getColorRef("markpointforecolor"));
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE,MARK_MODIFIED,25);
_sci.sendEditor(QScintilla.SCI_MARKERSETFORE,MARK_MODIFIED,Setting.getColorRef("modifiedmarkforecolor"));
_sci.sendEditor(QScintilla.SCI_MARKERSETBACK,MARK_MODIFIED,Setting.getColorRef("modifiedmarkbackcolor"));
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE,MARK_SAVED,25);
_sci.sendEditor(QScintilla.SCI_MARKERSETFORE,MARK_SAVED,Setting.getColorRef("savedmarkforecolor"));
_sci.sendEditor(QScintilla.SCI_MARKERSETBACK,MARK_SAVED,Setting.getColorRef("savedmarkbackcolor"));
current_modify_mark = MARK_MODIFIED;
reserve_modify_mark = MARK_SAVED;
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN,BREAKPOINT_INDEX, 15);
_sci.sendEditor(QScintilla.SCI_SETMARGINSENSITIVEN,BREAKPOINT_INDEX, 1);
if (Setting.isIndentGuide()) {
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.STYLE_INDENTGUIDE, Setting.getColorRef("indentguidecolor"));
_sci.sendEditor(QScintilla.SCI_SETINDENTATIONGUIDES, QScintilla.SC_IV_LOOKBOTH);
} else {
_sci.sendEditor(QScintilla.SCI_SETINDENTATIONGUIDES, QScintilla.SC_IV_NONE);
}
if (Setting.isShowLineNumber()) {
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN,LINENUMBER_INDEX, 40);
} else {
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN,LINENUMBER_INDEX, 0);
}
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN,DEBUGPOINT_INDEX, 15);
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN,MODIFIMARK_INDEX, 3);
//_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN,4, 0);
_sci.sendEditor(QScintilla.SCI_SETMARGINTYPEN, BREAKPOINT_INDEX, QScintilla.SC_MARGIN_SYMBOL);
_sci.sendEditor(QScintilla.SCI_SETMARGINMASKN, BREAKPOINT_INDEX, 1 << MARK_BREAKPOINT);
_sci.sendEditor(QScintilla.SCI_SETMARGINTYPEN, LINENUMBER_INDEX, QScintilla.SC_MARGIN_NUMBER);
_sci.sendEditor(QScintilla.SCI_SETMARGINMASKN, LINENUMBER_INDEX, 0);
_sci.sendEditor(QScintilla.SCI_SETMARGINTYPEN, DEBUGPOINT_INDEX, QScintilla.SC_MARGIN_SYMBOL);
_sci.sendEditor(QScintilla.SCI_SETMARGINMASKN, DEBUGPOINT_INDEX, 1 << MARK_POINTER);
_sci.sendEditor(QScintilla.SCI_SETMARGINTYPEN, MODIFIMARK_INDEX, QScintilla.SC_MARGIN_SYMBOL);
_sci.sendEditor(QScintilla.SCI_SETMARGINMASKN, MODIFIMARK_INDEX, (1 << MARK_MODIFIED) | (1 << MARK_SAVED));
_sci.sendEditor(QScintilla.SCI_STYLESETBACK, QScintilla.STYLE_LINENUMBER, Setting.getColorRef("linenumberbackcolor"));
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.STYLE_LINENUMBER, Setting.getColorRef("linenumberforecolor"));
_sci.sendEditor(QScintilla.SCI_SETMARGINLEFT, 0, 0);
_sci.sendEditor(QScintilla.SCI_STYLESETBOLD, QScintilla.STYLE_BRACELIGHT, 1);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.STYLE_BRACELIGHT, Setting.getColorRef("matchedbraceforecolor"));
_sci.sendEditor(QScintilla.SCI_STYLESETBACK, QScintilla.STYLE_BRACEBAD, Setting.getColorRef("matchedbracebackcolor"));
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_COMMENTDOCKEYWORD, Setting.getColorRef("doccommentkeyforecolor"));
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_COMMENTDOCKEYWORDERROR, Setting.getColorRef("doccommenterrforeforecolor"));
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_GLOBALCLASS, Setting.getColorRef("globalclassforecolor"));
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_OPERATOR, Setting.getColorRef("operatorforecolor"));
_sci.sendEditor(QScintilla.SCI_STYLESETBACK, QScintilla.SCE_C_STRINGEOL, Setting.getColorRef("stringeolcolor"));
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_WORD, Setting.getColorRef("wordforecolor"));
//_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_WORD2, Setting.getColorRef("word2forecolor"));
//_sci.sendEditor(QScintilla.SCI_STYLESETBOLD, QScintilla.SCE_C_WORD2, 1);
_sci.sendEditor(QScintilla.SCI_STYLESETBACK, QScintilla.SCE_C_WORD2, Setting.getColorRef("word2backcolor"));
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_STRING, Setting.getColorRef("stringforecolor"));
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_NUMBER, Setting.getColorRef("numberforecolor"));
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_CHARACTER, Setting.getColorRef("charforecolor"));
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_PREPROCESSOR, Setting.getColorRef("preprocessorforecolor"));
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_COMMENT, Setting.getColorRef("commentforecolor"));
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_COMMENTLINE, Setting.getColorRef("commentlineforecolor"));
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_COMMENTDOC, Setting.getColorRef("doccommentforecolor"));
_sci.sendEditor(QScintilla.SCI_CALLTIPSETBACK, Setting.getColorRef("calltipsbackcolor"));
_sci.sendEditor(QScintilla.SCI_CALLTIPSETFORE, Setting.getColorRef("calltipsforecolor"));
//_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_COMMENTDOC, 0xff504f4f);
_sci.sendEditor(QScintilla.SCI_SETCARETFORE,Setting.getColorRef("caretcolor"),0);
_sci.sendEditor(QScintilla.SCI_SETCARETLINEVISIBLE, 1);
_sci.sendEditor(QScintilla.SCI_SETCARETLINEBACK, Setting.getColorRef("caretlinebackcolor"));
_sci.sendEditor(QScintilla.SCI_SETCARETLINEFRAME, 2);
_sci.sendEditor(QScintilla.SCI_SETTABWIDTH, 4);
_sci.sendEditor(QScintilla.SCI_SETEOLMODE, QScintilla.SC_EOL_LF, 0);
_sci.setIndicForeColor(INDIC_TIPS, Setting.getColorRef("indicforecolor"));
_sci.setIndicUnder(INDIC_TIPS, true);
if (Setting.isShowFolding()) {
_sci.sendEditor(QScintilla.SCI_SETPROPERTY,"fold","1");
_sci.sendEditor(QScintilla.SCI_SETPROPERTY,"fold.comment","1");
_sci.sendEditor(QScintilla.SCI_SETMARGINTYPEN, MARGIN_FOLD_INDEX, QScintilla.SC_MARGIN_SYMBOL);//页边类型
_sci.sendEditor(QScintilla.SCI_SETMARGINMASKN, MARGIN_FOLD_INDEX, QScintilla.SC_MASK_FOLDERS); //页边掩码
_sci.sendEditor(QScintilla.SCI_SETFOLDMARGINCOLOUR, 1, Setting.getColorRef("foldmargincolor"));
_sci.sendEditor(QScintilla.SCI_SETFOLDMARGINHICOLOUR, 1, Setting.getColorRef("foldmarginhicolor"));
setFoldHighLight(Setting.getColorRef("foldhicolor"));
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN, MARGIN_FOLD_INDEX, 11); //页边宽度
_sci.sendEditor(QScintilla.SCI_SETMARGINSENSITIVEN, MARGIN_FOLD_INDEX, 1); //响应鼠标消息
// 折叠标签样式 //折叠页边颜色
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDER, QScintilla.SC_MARK_BOXPLUS);
_sci.sendEditor(QScintilla.SCI_MARKERSETFORE,QScintilla.SC_MARKNUM_FOLDER,Setting.getColorRef("folderforecolor"));
_sci.sendEditor(QScintilla.SCI_MARKERSETBACK,QScintilla.SC_MARKNUM_FOLDER,Setting.getColorRef("folderbackcolor"));
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDEROPEN, QScintilla.SC_MARK_BOXMINUS);
setMarginColor(QScintilla.SC_MARKNUM_FOLDEROPEN,Setting.getColorRef("folderopenforecolor"), Setting.getColorRef("folderopenbackcolor"));
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDEREND, QScintilla.SC_MARK_BOXPLUSCONNECTED);
setMarginColor(QScintilla.SC_MARKNUM_FOLDEREND,Setting.getColorRef("folderendforecolor"), Setting.getColorRef("folderendbackcolor"));
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDEROPENMID, QScintilla.SC_MARK_BOXMINUSCONNECTED);
setMarginColor(QScintilla.SC_MARKNUM_FOLDEROPENMID,Setting.getColorRef("foldermidforecolor"), Setting.getColorRef("foldermidbackcolor"));
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDERMIDTAIL, QScintilla.SC_MARK_TCORNER);
setMarginColor(QScintilla.SC_MARKNUM_FOLDERMIDTAIL,Setting.getColorRef("foldermidtailforecolor"), Setting.getColorRef("foldermidtailbackcolor"));
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDERSUB, QScintilla.SC_MARK_VLINE);
setMarginColor(QScintilla.SC_MARKNUM_FOLDERSUB,Setting.getColorRef("foldersubforecolor"), Setting.getColorRef("foldersubbackcolor"));
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDERTAIL, QScintilla.SC_MARK_LCORNER);
setMarginColor(QScintilla.SC_MARKNUM_FOLDERTAIL,Setting.getColorRef("foldertailforecolor"), Setting.getColorRef("foldertailbackcolor"));
} else {
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN, MARGIN_FOLD_INDEX, 0); //页边宽度
}
}
else{
SyntaxHighlighting colorConfig = _textplugins.getColorConfigure(darkStyle ? "dark" : "light");
if (colorConfig != nilptr) {
updatesuccess = true;
_sci.sendEditor(QScintilla.SCI_CLEARDOCUMENTSTYLE, 0, 0);
_sci.sendEditor(QScintilla.SCI_SETLEXER, QScintilla.SCLEX_CPP, 0);
_sci.sendEditor(QScintilla.SCI_SETCODEPAGE, QScintilla.SC_CP_UTF8);
_sci.sendEditor(QScintilla.SCI_STYLESETBACK, QScintilla.STYLE_DEFAULT, colorConfig.getDefaultBackColor());
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.STYLE_DEFAULT, colorConfig.getDefaultForeColor());
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, 75, colorConfig.getDefaultForeColor());
//_sci.sendEditor(QScintilla.STYLE_LINENUMBER, 1, 0);
//bool bmac = (_system_.getPlatformId() == 2);
_sci.sendEditor(QScintilla.SCI_STYLESETFONT, QScintilla.STYLE_DEFAULT,Setting.getEditorFont());
_sci.sendEditor(QScintilla.SCI_STYLESETSIZEFRACTIONAL, QScintilla.STYLE_DEFAULT,Setting.getEditorFontSize());
_sci.sendEditor(QScintilla.SCI_STYLECLEARALL, 0, 0);
_sci.sendEditor(QScintilla.SCI_SETSELBACK,1,colorConfig.getSelectedBackColor());
_sci.sendEditor(QScintilla.SCI_SETSELFORE,0,colorConfig.getSelectedForeColor());
//C++语法解析
_sci.sendEditor(QScintilla.SCI_SETLEXER, QScintilla.SCLEX_CPP, 0);
_sci.sendEditor(QScintilla.SCI_SETKEYWORDS, 0, szKeywords1);//设置关键字
_sci.sendEditor(QScintilla.SCI_SETKEYWORDS, 1, szKeywords2);//设置关键字
// 下面设置各种语法元素风格
_sci.sendEditor(QScintilla.SCI_SETEOLMODE, 1, 0);
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, MARK_BREAKPOINT, 0);
_sci.sendEditor(QScintilla.SCI_MARKERSETBACK, MARK_BREAKPOINT,colorConfig.getBreakPointBackColor());
_sci.sendEditor(QScintilla.SCI_MARKERSETFORE, MARK_BREAKPOINT,colorConfig.getBreakPointForeColor());
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, MARK_POINTER,4);
_sci.sendEditor(QScintilla.SCI_MARKERSETFORE, MARK_POINTER,colorConfig.getMarkPointBackColor());
_sci.sendEditor(QScintilla.SCI_MARKERSETBACK, MARK_POINTER,colorConfig.getMarkPointForeColor());
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE,MARK_MODIFIED,25);
_sci.sendEditor(QScintilla.SCI_MARKERSETFORE,MARK_MODIFIED,colorConfig.getModifiedMarkForeColor());
_sci.sendEditor(QScintilla.SCI_MARKERSETBACK,MARK_MODIFIED,colorConfig.getModifiedMarkBackColor());
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE,MARK_SAVED,25);
_sci.sendEditor(QScintilla.SCI_MARKERSETFORE,MARK_SAVED,colorConfig.getSavedMarkForeColor());
_sci.sendEditor(QScintilla.SCI_MARKERSETBACK,MARK_SAVED,colorConfig.getSavedMarkBackColor());
current_modify_mark = MARK_MODIFIED;
reserve_modify_mark = MARK_SAVED;
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN,BREAKPOINT_INDEX, 15);
_sci.sendEditor(QScintilla.SCI_SETMARGINSENSITIVEN,BREAKPOINT_INDEX, 1);
if (Setting.isIndentGuide()) {
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.STYLE_INDENTGUIDE, colorConfig.getIndentGuideColor());
_sci.sendEditor(QScintilla.SCI_SETINDENTATIONGUIDES, QScintilla.SC_IV_LOOKBOTH);
} else {
_sci.sendEditor(QScintilla.SCI_SETINDENTATIONGUIDES, QScintilla.SC_IV_NONE);
}
if (Setting.isShowLineNumber()) {
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN,LINENUMBER_INDEX, 40);
} else {
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN,LINENUMBER_INDEX, 0);
}
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN,DEBUGPOINT_INDEX, 15);
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN,MODIFIMARK_INDEX, 3);
//_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN,4, 0);
_sci.sendEditor(QScintilla.SCI_SETMARGINTYPEN, BREAKPOINT_INDEX, QScintilla.SC_MARGIN_SYMBOL);
_sci.sendEditor(QScintilla.SCI_SETMARGINMASKN, BREAKPOINT_INDEX, 1 << MARK_BREAKPOINT);
_sci.sendEditor(QScintilla.SCI_SETMARGINTYPEN, LINENUMBER_INDEX, QScintilla.SC_MARGIN_NUMBER);
_sci.sendEditor(QScintilla.SCI_SETMARGINMASKN, LINENUMBER_INDEX, 0);
_sci.sendEditor(QScintilla.SCI_SETMARGINTYPEN, DEBUGPOINT_INDEX, QScintilla.SC_MARGIN_SYMBOL);
_sci.sendEditor(QScintilla.SCI_SETMARGINMASKN, DEBUGPOINT_INDEX, (1 << MARK_POINTER));
_sci.sendEditor(QScintilla.SCI_SETMARGINTYPEN, MODIFIMARK_INDEX, QScintilla.SC_MARGIN_SYMBOL);
_sci.sendEditor(QScintilla.SCI_SETMARGINMASKN, MODIFIMARK_INDEX, (1 << MARK_MODIFIED) | (1 << MARK_SAVED) );
_sci.sendEditor(QScintilla.SCI_STYLESETBACK, QScintilla.STYLE_LINENUMBER, colorConfig.getLineNumberBackColor());
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.STYLE_LINENUMBER, colorConfig.getLineNumberForeColor());
_sci.sendEditor(QScintilla.SCI_SETMARGINLEFT, 0, 0);
_sci.sendEditor(QScintilla.SCI_STYLESETBOLD, QScintilla.STYLE_BRACELIGHT, 1);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.STYLE_BRACELIGHT, colorConfig.getMatchedBraceForeColor());
_sci.sendEditor(QScintilla.SCI_STYLESETBACK, QScintilla.STYLE_BRACEBAD, colorConfig.getMatchedBraceBackColor());
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_COMMENTDOCKEYWORD, colorConfig.getDocCommentKeyForeColor());
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_COMMENTDOCKEYWORDERROR, colorConfig.getDocCommentErrForeForeColor());
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_GLOBALCLASS, colorConfig.getGlobalClassForeColor());
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_OPERATOR, colorConfig.getOperatorForeColor()/* 0xff859dd6 0xffFEE7Bf*/);
_sci.sendEditor(QScintilla.SCI_STYLESETBACK, QScintilla.SCE_C_STRINGEOL, colorConfig.getStringEOLColor());
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_WORD, colorConfig.getWordForeColor());
_sci.sendEditor(QScintilla.SCI_STYLESETBOLD, QScintilla.SCE_C_WORD, 1);
//_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_WORD2, colorConfig.getWord2ForeColor());
//_sci.sendEditor(QScintilla.SCI_STYLESETBOLD, QScintilla.SCE_C_WORD2, 1);
_sci.sendEditor(QScintilla.SCI_STYLESETBACK, QScintilla.SCE_C_WORD2, colorConfig.getWord2BackColor());
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_STRING, colorConfig.getStringForeColor());
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_NUMBER, colorConfig.getNumberForeColor());
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_CHARACTER, colorConfig.getCharForeColor());
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_PREPROCESSOR, colorConfig.getPreprocessorForeColor());
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_COMMENT, colorConfig.getCommentForeColor());
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_COMMENTLINE, colorConfig.getCommentLineForeColor());
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_COMMENTDOC, colorConfig.getDocCommentForeColor());
_sci.sendEditor(QScintilla.SCI_CALLTIPSETBACK, colorConfig.getCallTipsBackColor());
_sci.sendEditor(QScintilla.SCI_CALLTIPSETFORE, colorConfig.getCallTipsForeColor());
//_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_COMMENTDOC, 0xff504f4f);
_sci.sendEditor(QScintilla.SCI_SETCARETFORE,colorConfig.getCaretColor(),0);
_sci.sendEditor(QScintilla.SCI_SETCARETLINEVISIBLE, 1);
_sci.sendEditor(QScintilla.SCI_SETCARETLINEBACK, colorConfig.getCaretLineBackColor());
_sci.sendEditor(QScintilla.SCI_SETCARETLINEFRAME, 2);
_sci.sendEditor(QScintilla.SCI_SETTABWIDTH, 4);
_sci.sendEditor(QScintilla.SCI_SETEOLMODE, QScintilla.SC_EOL_LF, 0);
_sci.setIndicForeColor(INDIC_TIPS, colorConfig.getIndicForeColor());
_sci.setIndicUnder(INDIC_TIPS, true);
if (Setting.isShowFolding()) {
_sci.sendEditor(QScintilla.SCI_SETPROPERTY,"fold","1");
_sci.sendEditor(QScintilla.SCI_SETPROPERTY,"fold.comment","1");
_sci.sendEditor(QScintilla.SCI_SETMARGINTYPEN, MARGIN_FOLD_INDEX, QScintilla.SC_MARGIN_SYMBOL);//页边类型
_sci.sendEditor(QScintilla.SCI_SETMARGINMASKN, MARGIN_FOLD_INDEX, QScintilla.SC_MASK_FOLDERS); //页边掩码
_sci.sendEditor(QScintilla.SCI_SETFOLDMARGINCOLOUR, 1, colorConfig.getFoldMarginColor());
_sci.sendEditor(QScintilla.SCI_SETFOLDMARGINHICOLOUR, 1, colorConfig.getFoldMarginHIColor());
setFoldHighLight(colorConfig.getFoldHIColor());
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN, MARGIN_FOLD_INDEX, 11); //页边宽度
_sci.sendEditor(QScintilla.SCI_SETMARGINSENSITIVEN, MARGIN_FOLD_INDEX, 1); //响应鼠标消息
// 折叠标签样式 //折叠页边颜色
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDER, QScintilla.SC_MARK_BOXPLUS);
_sci.sendEditor(QScintilla.SCI_MARKERSETFORE,QScintilla.SC_MARKNUM_FOLDER,colorConfig.getFolderForeColor());
_sci.sendEditor(QScintilla.SCI_MARKERSETBACK,QScintilla.SC_MARKNUM_FOLDER,colorConfig.getFolderBackColor());
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDEROPEN, QScintilla.SC_MARK_BOXMINUS);
setMarginColor(QScintilla.SC_MARKNUM_FOLDEROPEN,colorConfig.getFolderOpenForeColor(), colorConfig.getFolderOpenBackColor());
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDEREND, QScintilla.SC_MARK_BOXPLUSCONNECTED);
setMarginColor(QScintilla.SC_MARKNUM_FOLDEREND,colorConfig.getFolderEndForeColor(), colorConfig.getFolderEndBackColor());
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDEROPENMID, QScintilla.SC_MARK_BOXMINUSCONNECTED);
setMarginColor(QScintilla.SC_MARKNUM_FOLDEROPENMID,colorConfig.getFolderMidForeColor(), colorConfig.getFolderMidBackColor());
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDERMIDTAIL, QScintilla.SC_MARK_TCORNER);
setMarginColor(QScintilla.SC_MARKNUM_FOLDERMIDTAIL,colorConfig.getFolderMidTailForeColor(), colorConfig.getFolderMidTailBackColor());
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDERSUB, QScintilla.SC_MARK_VLINE);
setMarginColor(QScintilla.SC_MARKNUM_FOLDERSUB,colorConfig.getFolderSubForeColor(), colorConfig.getFolderSubBackColor());
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDERTAIL, QScintilla.SC_MARK_LCORNER);
setMarginColor(QScintilla.SC_MARKNUM_FOLDERTAIL,colorConfig.getFolderTailForeColor(), colorConfig.getFolderTailBackColor());
} else {
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN, MARGIN_FOLD_INDEX, 0); //页边宽度
}
}
}
}
_sci.sendEditor(QScintilla.SCI_SETMARGINSENSITIVEN, DEBUGPOINT_INDEX, 1); //响应鼠标消息
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE,ERRORPOINT_INDEX,23);
_sci.sendEditor(QScintilla.SCI_MARKERSETFORE,ERRORPOINT_INDEX,0xff0000ff);
_sci.sendEditor(QScintilla.SCI_MARKERSETBACK,ERRORPOINT_INDEX,0xff0000ff);
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE,WARNING_INDEX,23);
_sci.sendEditor(QScintilla.SCI_MARKERSETFORE,WARNING_INDEX,0xff0088ff);
_sci.sendEditor(QScintilla.SCI_MARKERSETBACK,WARNING_INDEX,0xff0088ff);
_sci.sendEditor(QScintilla.SCI_SETMARGINMASKN, DEBUGPOINT_INDEX, (1 << MARK_POINTER) | (1 << WARNING_INDEX) | (1 << ERRORPOINT_INDEX));
_sci.setIndicForeColor(INDIC_WARNING, 0x0088FF);
_sci.setIndicForeColor(INDIC_FIND, 0xffff00);
_sci.setIndicUnder(INDIC_FIND, true);
//_sci.setIndicAlpha(INDIC_FIND, 255);
//_sci.setIndicOutlineAlpha(INDIC_FIND, 255);
_sci.setIndicForeColor(INDIC_SELECTED, 0xff0000);
_sci.setIndicUnder(INDIC_SELECTED, true);
if (updatesuccess == false) {
_sci.setIndicForeColor(INDIC_TIPS, 0xff00ffff);
_sci.setIndicUnder(INDIC_TIPS, true);
syntaxForXlang();
}
if (_textplugins != nilptr){
_textplugins.configEditor(_mdi_area.getCurrentProject(), getFilePath(), _sci, darkStyle);
}
_sci.setIndentationsUseTabs(Setting.isUseTabstop());
_sci.sendEditor(QScintilla.SCI_SETTABWIDTH, Setting.getTabWidth());
_sci.setIndicCurrent(INDIC_TIPS);
_sci.setWrap(Setting.isEditWrap());
_sci.sendEditor(QScintilla.SCI_COLOURISE, 0, -1);
_sci.setLinespacing(1.28f);
_sci.enableScrollBarMarker(true);
_sci.setScrollBarMarker(MARK_MODIFIED, 0, 0xffffd800);
_sci.setScrollBarMarker(MARK_SAVED, 0, 0xff15c23c);
_sci.setScrollBarMarker(ERRORPOINT_INDEX, 1, 0xffff0000);
_sci.setScrollBarMarker(WARNING_INDEX, 1, 0xffff8800);
_sci.setScrollBarMarker(MARK_BREAKPOINT, 2, 0xff8B4C79);
/*_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_COMMENT | 64,0xffeeeeee);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_COMMENTLINE | 64,0xffeeeeee);
*/
/*
WIN32=1 WIN32_LEAN_AND_MEAN NOGDI=0 SCI_SETLEXERLANGUAGE
scintilla.Styles[Style.Cpp.Default + 64].BackColor = Color.LightGray;
scintilla.Styles[Style.Cpp.Comment + 64].BackColor = Color.LightGray;
*/
updateInformationPoint();
}
Map<long, ICompileInfo> __hoverhelps = new Map<long,ICompileInfo>();
Map<long, ICompileInfo> __marginhelps = new Map<long, ICompileInfo>();
public void updateInformationPoint(){
resetInformationPoint();
Vector<ICompileInfo> ii = XWndInfor.GetDocumentPoint(_mdi_area.getCurrentProject(), getFilePath(), ICompileInfo.ERROR);
mergeDiagnosis(ii);
processDiagnosisInfor(ii.toArray(new ICompileInfo[ii.size()]));
}
public void processDiagnosisInfor(ICompileInfo [] ii){
for (int i = 0; i < ii.length; i++){
ICompileInfo ci = ii[i];
int line = ci.getLine() - 1;
int pos = _sci.getPosition(line) + ci.getRow() - 1;
__hoverhelps.put(pos,ci);
if (ci.getType() == ICompileInfo.ERROR){
updateErrorPoint(pos, ci.getLength());
}else
if (ci.getType() == ICompileInfo.WARNING){
updateWarningPoint(pos, ci.getLength());
}
}
}
static class DocumentICompileInfo : ICompileInfo{
DiagnosisInformation di;
String file;
int length;
public DocumentICompileInfo(String f, DiagnosisInformation d, int len){
file = f;
length = len;
di = d;
}
public int getType(){
return di.getType();
}
public String getFile(){
return file;
}
public int getLine(){
return di.getLine(false);
}
public int getLength(){
return length;
}
public int getRow(){
return di.getCharacter(false);
}
public @NotNilptr String getTips(){
return di.getMessage();
}
public @NotNilptr String getTitle(){
return "诊断信息:";
}
};
public void mergeDiagnosis(Vector<ICompileInfo> list){
String file = getFilePath();
DiagnosisInformation [] info = _mdi_area.getDiagnosisInformation(file);
if (info != nilptr){
for (int i = 0; i < info.length ; i++){
int startline = info[i].getLine(false);
int startcolumn = info[i].getCharacter(false);
int endline = info[i].getLine(true);
int endcolumn = info[i].getCharacter(true);
int startpos = _sci.getPosition(startline) + startcolumn;
int endpos = _sci.getPosition(endline) + endcolumn;
list.add(new DocumentICompileInfo(file, info[i], endpos - startpos + 1));
}
}
}
public void updateErrorPoint(int pos, int length){
int line = _sci.positionToLine(pos);
_sci.sendEditor(QScintilla.SCI_MARKERADD, line, ERRORPOINT_INDEX);
_sci.setIndicCurrent(INDIC_ERROR);
_sci.applyIndic(pos, length > 0 ? length : 1);
}
public void updateWarningPoint(int pos, int length){
int line = _sci.positionToLine(pos);
_sci.sendEditor(QScintilla.SCI_MARKERADD, line, WARNING_INDEX);
_sci.setIndicCurrent(INDIC_WARNING);
_sci.applyIndic(pos, length > 0 ? length : 1);
}
public void markSelected(int pos, int length){
_sci.setIndicCurrent(INDIC_SELECTED);
_sci.applyIndic(pos, length > 0 ? length : 1);
}
public void markFound(int pos, int length){
_sci.setIndicCurrent(INDIC_FIND);
_sci.applyIndic(pos, length > 0 ? length : 1);
}
public String contentToString()override{
return _sci.getText();
}
public void setFoldHighLight(int color){
_sci.sendEditor(QScintilla.SCI_MARKERENABLEHIGHLIGHT,1);
_sci.sendEditor(QScintilla.SCI_MARKERSETBACKSELECTED, QScintilla.SC_MARKNUM_FOLDER, color);
_sci.sendEditor(QScintilla.SCI_MARKERSETBACKSELECTED, QScintilla.SC_MARKNUM_FOLDEROPEN, color);
_sci.sendEditor(QScintilla.SCI_MARKERSETBACKSELECTED, QScintilla.SC_MARKNUM_FOLDEREND, color);
_sci.sendEditor(QScintilla.SCI_MARKERSETBACKSELECTED, QScintilla.SC_MARKNUM_FOLDEROPENMID, color);
_sci.sendEditor(QScintilla.SCI_MARKERSETBACKSELECTED, QScintilla.SC_MARKNUM_FOLDERMIDTAIL, color);
_sci.sendEditor(QScintilla.SCI_MARKERSETBACKSELECTED, QScintilla.SC_MARKNUM_FOLDERSUB, color);
_sci.sendEditor(QScintilla.SCI_MARKERSETBACKSELECTED, QScintilla.SC_MARKNUM_FOLDERTAIL, color);
}
public void syntaxForXlangDark() {
//_sci.sendEditor(QScintilla.SCI_STYLECLEARALL, 0, 0);
_sci.sendEditor(QScintilla.SCI_CLEARDOCUMENTSTYLE, 0, 0);
_sci.sendEditor(QScintilla.SCI_SETLEXER, QScintilla.SCLEX_CPP, 0);
_sci.sendEditor(QScintilla.SCI_SETCODEPAGE, QScintilla.SC_CP_UTF8);
_sci.sendEditor(QScintilla.SCI_STYLESETBACK, QScintilla.STYLE_DEFAULT, 0xff222827);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.STYLE_DEFAULT, 0xffefefef);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, 75, 0xffefefef);
//_sci.sendEditor(QScintilla.STYLE_LINENUMBER, 1, 0);
//bool bmac = (_system_.getPlatformId() == 2);
_sci.sendEditor(QScintilla.SCI_STYLESETFONT, QScintilla.STYLE_DEFAULT,Setting.getEditorFont());
_sci.sendEditor(QScintilla.SCI_STYLESETSIZEFRACTIONAL, QScintilla.STYLE_DEFAULT,Setting.getEditorFontSize());
_sci.sendEditor(QScintilla.SCI_STYLECLEARALL, 0, 0);
_sci.sendEditor(QScintilla.SCI_SETSELBACK,1,0xff3e4849);
_sci.sendEditor(QScintilla.SCI_SETSELFORE,0,0);
//C++语法解析
_sci.sendEditor(QScintilla.SCI_SETLEXER, QScintilla.SCLEX_CPP, 0);
_sci.sendEditor(QScintilla.SCI_SETKEYWORDS, 0, szKeywords1);//设置关键字
_sci.sendEditor(QScintilla.SCI_SETKEYWORDS, 1, szKeywords2);//设置关键字
// 下面设置各种语法元素风格
_sci.sendEditor(QScintilla.SCI_SETEOLMODE, 1, 0);
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, MARK_BREAKPOINT, 0);
_sci.sendEditor(QScintilla.SCI_MARKERSETBACK, MARK_BREAKPOINT,0xff0000ff);
_sci.sendEditor(QScintilla.SCI_MARKERSETFORE, MARK_BREAKPOINT,0xffffffff);
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, MARK_POINTER,4);
_sci.sendEditor(QScintilla.SCI_MARKERSETFORE, MARK_POINTER,0xff7f7f00);
_sci.sendEditor(QScintilla.SCI_MARKERSETBACK, MARK_POINTER,0xffcee7ce);
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE,MARK_MODIFIED,25);
_sci.sendEditor(QScintilla.SCI_MARKERSETFORE,MARK_MODIFIED,0xff00d8ff);
_sci.sendEditor(QScintilla.SCI_MARKERSETBACK,MARK_MODIFIED,0xff00d8ff);
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE,MARK_SAVED,25);
_sci.sendEditor(QScintilla.SCI_MARKERSETFORE,MARK_SAVED,0xff00d8ff);
_sci.sendEditor(QScintilla.SCI_MARKERSETBACK,MARK_SAVED,0xff00d8ff);
current_modify_mark = MARK_MODIFIED;
reserve_modify_mark = MARK_SAVED;
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN,BREAKPOINT_INDEX, 15);
_sci.sendEditor(QScintilla.SCI_SETMARGINSENSITIVEN,BREAKPOINT_INDEX, 1);
if (Setting.isIndentGuide()) {
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.STYLE_INDENTGUIDE, 0xff464849);
_sci.sendEditor(QScintilla.SCI_SETINDENTATIONGUIDES, QScintilla.SC_IV_LOOKBOTH);
} else {
_sci.sendEditor(QScintilla.SCI_SETINDENTATIONGUIDES, QScintilla.SC_IV_NONE);
}
if (Setting.isShowLineNumber()) {
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN,LINENUMBER_INDEX, 40);
} else {
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN,LINENUMBER_INDEX, 0);
}
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN,DEBUGPOINT_INDEX, 15);
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN,MODIFIMARK_INDEX, 3);
//_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN,4, 0);
_sci.sendEditor(QScintilla.SCI_SETMARGINTYPEN, BREAKPOINT_INDEX, QScintilla.SC_MARGIN_SYMBOL);
_sci.sendEditor(QScintilla.SCI_SETMARGINMASKN, BREAKPOINT_INDEX, 1 << MARK_BREAKPOINT);
_sci.sendEditor(QScintilla.SCI_SETMARGINTYPEN, LINENUMBER_INDEX, QScintilla.SC_MARGIN_NUMBER);
_sci.sendEditor(QScintilla.SCI_SETMARGINMASKN, LINENUMBER_INDEX, 0);
_sci.sendEditor(QScintilla.SCI_SETMARGINTYPEN, DEBUGPOINT_INDEX, QScintilla.SC_MARGIN_SYMBOL);
_sci.sendEditor(QScintilla.SCI_SETMARGINMASKN, DEBUGPOINT_INDEX, 1 << MARK_POINTER);
_sci.sendEditor(QScintilla.SCI_SETMARGINTYPEN, MODIFIMARK_INDEX, QScintilla.SC_MARGIN_SYMBOL);
_sci.sendEditor(QScintilla.SCI_SETMARGINMASKN, MODIFIMARK_INDEX, (1 << MARK_MODIFIED) | (1 << MARK_SAVED));
_sci.sendEditor(QScintilla.SCI_STYLESETBACK, QScintilla.STYLE_LINENUMBER, 0xff222827);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.STYLE_LINENUMBER, 0xffaf912b);
_sci.sendEditor(QScintilla.SCI_SETMARGINLEFT, 0, 0);
_sci.sendEditor(QScintilla.SCI_STYLESETBOLD, QScintilla.STYLE_BRACELIGHT, 1);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.STYLE_BRACELIGHT, 0xff00ffff);
_sci.sendEditor(QScintilla.SCI_STYLESETBACK, QScintilla.STYLE_BRACEBAD, 0xffff00ff);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_COMMENTDOCKEYWORD, 0xffA06030);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_COMMENTDOCKEYWORDERROR, 0xff204080);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_GLOBALCLASS, 0xff0099dd);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_OPERATOR, 0xff6e28ed/* 0xff859dd6 0xffFEE7Bf*/);
_sci.sendEditor(QScintilla.SCI_STYLESETBACK, QScintilla.SCE_C_STRINGEOL, 0xffE0C0E0);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_WORD, 0xffF0D964);
//_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_WORD2, 0xff2ae27f);
//_sci.sendEditor(QScintilla.SCI_STYLESETBOLD, QScintilla.SCE_C_WORD2, 1);
_sci.sendEditor(QScintilla.SCI_STYLESETBACK, QScintilla.SCE_C_WORD2, 0xff6f3d11);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_STRING, 0xff73DBE6);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_NUMBER, 0xffc563bd/*0xffA8CEB5*/);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_CHARACTER, 0xff73DBE6);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_PREPROCESSOR, 0x00808080);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_COMMENT, 0xff666666);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_COMMENTLINE, 0xff666666);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_COMMENTDOC, 0x00008000);
_sci.sendEditor(QScintilla.SCI_CALLTIPSETBACK, 0xff454242);
_sci.sendEditor(QScintilla.SCI_CALLTIPSETFORE, 0xffefefef);
//_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_COMMENTDOC, 0xff504f4f);
_sci.sendEditor(QScintilla.SCI_SETCARETFORE,0xffffffff,0);
_sci.sendEditor(QScintilla.SCI_SETCARETLINEVISIBLE, 1);
_sci.sendEditor(QScintilla.SCI_SETCARETLINEBACK, 0xff202020);
_sci.sendEditor(QScintilla.SCI_SETCARETLINEFRAME, 2);
_sci.sendEditor(QScintilla.SCI_SETTABWIDTH, 4);
_sci.sendEditor(QScintilla.SCI_SETEOLMODE, QScintilla.SC_EOL_LF, 0);
if (Setting.isShowFolding()) {
_sci.sendEditor(QScintilla.SCI_SETPROPERTY,"fold","1");
_sci.sendEditor(QScintilla.SCI_SETPROPERTY,"fold.comment","1");
_sci.sendEditor(QScintilla.SCI_SETMARGINTYPEN, MARGIN_FOLD_INDEX, QScintilla.SC_MARGIN_SYMBOL);//页边类型
_sci.sendEditor(QScintilla.SCI_SETMARGINMASKN, MARGIN_FOLD_INDEX, QScintilla.SC_MASK_FOLDERS); //页边掩码
_sci.sendEditor(QScintilla.SCI_SETFOLDMARGINCOLOUR, 1, 0xff222827);
_sci.sendEditor(QScintilla.SCI_SETFOLDMARGINHICOLOUR, 1, 0xff404142);
setFoldHighLight(0xffffffff);
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN, MARGIN_FOLD_INDEX, 11); //页边宽度
_sci.sendEditor(QScintilla.SCI_SETMARGINSENSITIVEN, MARGIN_FOLD_INDEX, 1); //响应鼠标消息
// 折叠标签样式 //折叠页边颜色
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDER, QScintilla.SC_MARK_BOXPLUS);
_sci.sendEditor(QScintilla.SCI_MARKERSETFORE,QScintilla.SC_MARKNUM_FOLDER,0xff222827);
_sci.sendEditor(QScintilla.SCI_MARKERSETBACK,QScintilla.SC_MARKNUM_FOLDER,0xff7f7f7f);
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDEROPEN, QScintilla.SC_MARK_BOXMINUS);
setMarginColor(QScintilla.SC_MARKNUM_FOLDEROPEN,0xff222827, 0xff7f7f7f);
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDEREND, QScintilla.SC_MARK_BOXPLUSCONNECTED);
setMarginColor(QScintilla.SC_MARKNUM_FOLDEREND,0xff222827, 0xff7f7f7f);
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDEROPENMID, QScintilla.SC_MARK_BOXMINUSCONNECTED);
setMarginColor(QScintilla.SC_MARKNUM_FOLDEROPENMID,0xff222827, 0xff7f7f7f);
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDERMIDTAIL, QScintilla.SC_MARK_TCORNER);
setMarginColor(QScintilla.SC_MARKNUM_FOLDERMIDTAIL,0xff222827, 0xff7f7f7f);
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDERSUB, QScintilla.SC_MARK_VLINE);
setMarginColor(QScintilla.SC_MARKNUM_FOLDERSUB,0xff222827, 0xff7f7f7f);
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDERTAIL, QScintilla.SC_MARK_LCORNER);
setMarginColor(QScintilla.SC_MARKNUM_FOLDERTAIL,0xff222827, 0xff7f7f7f);
} else {
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN, MARGIN_FOLD_INDEX, 0); //页边宽度
}
// 折叠标签颜色
}
public void setMarginColor(int id, int fore, int back) {
_sci.sendEditor(QScintilla.SCI_MARKERSETFORE, id, fore);
_sci.sendEditor(QScintilla.SCI_MARKERSETBACK, id, back);
}
public static void reconfig() {
Map.Iterator<String, DocumentView> iterator = editorMgr.iterator();
while (iterator.hasNext()) {
DocumentView wnd = iterator.getValue();
if (wnd != nilptr){
wnd.updateConfig();
}
iterator.next();
}
}
public void syntaxForXlang() {
if (Setting.isDarkStyle()) {
syntaxForXlangDark();
return ;
}
//_sci.sendEditor(QScintilla.SCI_STYLECLEARALL, 0, 0);
_sci.sendEditor(QScintilla.SCI_CLEARDOCUMENTSTYLE, 0, 0);
_sci.sendEditor(QScintilla.SCI_SETLEXER, QScintilla.SCLEX_CPP, 0);
_sci.sendEditor(QScintilla.SCI_SETCODEPAGE, QScintilla.SC_CP_UTF8);
_sci.sendEditor(QScintilla.SCI_STYLESETBACK, QScintilla.STYLE_DEFAULT, 0xffffffff);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.STYLE_DEFAULT, 0xff222827);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, 75, 0xff222827);
//_sci.sendEditor(QScintilla.STYLE_LINENUMBER, 1, 0);
_sci.sendEditor(QScintilla.SCI_STYLESETFONT, QScintilla.STYLE_DEFAULT,Setting.getEditorFont());
_sci.sendEditor(QScintilla.SCI_STYLESETSIZEFRACTIONAL, QScintilla.STYLE_DEFAULT,Setting.getEditorFontSize());
_sci.sendEditor(QScintilla.SCI_STYLECLEARALL, 0, 0);
_sci.sendEditor(QScintilla.SCI_SETSELBACK,1,0xfff1ebe5);
_sci.sendEditor(QScintilla.SCI_SETSELFORE,0,0);
//C++语法解析
_sci.sendEditor(QScintilla.SCI_SETLEXER, QScintilla.SCLEX_CPP, 0);
_sci.sendEditor(QScintilla.SCI_SETKEYWORDS, 0, szKeywords1);//设置关键字
_sci.sendEditor(QScintilla.SCI_SETKEYWORDS, 1, szKeywords2);//设置关键字
// 下面设置各种语法元素风格
_sci.sendEditor(QScintilla.SCI_SETEOLMODE, 1, 0);
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, MARK_BREAKPOINT, 0);
_sci.sendEditor(QScintilla.SCI_MARKERSETBACK, MARK_BREAKPOINT,0xff0000ff);
_sci.sendEditor(QScintilla.SCI_MARKERSETFORE, MARK_BREAKPOINT,0xffffffff);
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, MARK_POINTER,4);
_sci.sendEditor(QScintilla.SCI_MARKERSETFORE, MARK_POINTER,0xff7f7f00);
_sci.sendEditor(QScintilla.SCI_MARKERSETBACK, MARK_POINTER,0xffcee7ce);
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE,MARK_MODIFIED,25);
_sci.sendEditor(QScintilla.SCI_MARKERSETFORE,MARK_MODIFIED,0xff00d8ff);
_sci.sendEditor(QScintilla.SCI_MARKERSETBACK,MARK_MODIFIED,0xff00d8ff);
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE,MARK_SAVED,25);
_sci.sendEditor(QScintilla.SCI_MARKERSETFORE,MARK_SAVED,0xff00d8ff);
_sci.sendEditor(QScintilla.SCI_MARKERSETBACK,MARK_SAVED,0xff00d8ff);
current_modify_mark = MARK_MODIFIED;
reserve_modify_mark = MARK_SAVED;
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN,BREAKPOINT_INDEX, 15);
_sci.sendEditor(QScintilla.SCI_SETMARGINSENSITIVEN,BREAKPOINT_INDEX, 1);
if (Setting.isIndentGuide()) {
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.STYLE_INDENTGUIDE, 0xff464849);
_sci.sendEditor(QScintilla.SCI_SETINDENTATIONGUIDES, QScintilla.SC_IV_LOOKBOTH);
} else {
_sci.sendEditor(QScintilla.SCI_SETINDENTATIONGUIDES, QScintilla.SC_IV_NONE);
}
if (Setting.isShowLineNumber()) {
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN,LINENUMBER_INDEX, 40);
} else {
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN,LINENUMBER_INDEX, 0);
}
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN,DEBUGPOINT_INDEX, 15);
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN,MODIFIMARK_INDEX, 3);
//_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN,4, 0);
_sci.sendEditor(QScintilla.SCI_SETMARGINTYPEN, BREAKPOINT_INDEX, QScintilla.SC_MARGIN_SYMBOL);
_sci.sendEditor(QScintilla.SCI_SETMARGINMASKN, BREAKPOINT_INDEX, 1 << MARK_BREAKPOINT);
_sci.sendEditor(QScintilla.SCI_SETMARGINTYPEN, LINENUMBER_INDEX, QScintilla.SC_MARGIN_NUMBER);
_sci.sendEditor(QScintilla.SCI_SETMARGINMASKN, LINENUMBER_INDEX, 0);
_sci.sendEditor(QScintilla.SCI_SETMARGINTYPEN, DEBUGPOINT_INDEX, QScintilla.SC_MARGIN_SYMBOL);
_sci.sendEditor(QScintilla.SCI_SETMARGINMASKN, DEBUGPOINT_INDEX, 1 << MARK_POINTER);
_sci.sendEditor(QScintilla.SCI_SETMARGINTYPEN, MODIFIMARK_INDEX, QScintilla.SC_MARGIN_SYMBOL);
_sci.sendEditor(QScintilla.SCI_SETMARGINMASKN, MODIFIMARK_INDEX, (1 << MARK_MODIFIED) | (1 << MARK_SAVED));
_sci.sendEditor(QScintilla.SCI_STYLESETBACK, QScintilla.STYLE_LINENUMBER, 0xffefefef);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.STYLE_LINENUMBER, 0xffaf912b);
_sci.sendEditor(QScintilla.SCI_SETMARGINLEFT, 0, 0);
_sci.sendEditor(QScintilla.SCI_STYLESETBOLD, QScintilla.STYLE_BRACELIGHT, 1);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.STYLE_BRACELIGHT, 0xffff00ff);
_sci.sendEditor(QScintilla.SCI_STYLESETBACK, QScintilla.STYLE_BRACEBAD, 0xff00ffff);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_COMMENTDOCKEYWORD, 0xffA06030);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_COMMENTDOCKEYWORDERROR, 0xff204080);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_GLOBALCLASS, 0xff0099dd);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_OPERATOR, 0xffed286e/* 0xff859dd6 0xffFEE7Bf*/);
_sci.sendEditor(QScintilla.SCI_STYLESETBACK, QScintilla.SCE_C_STRINGEOL, 0xffE0C0E0);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_WORD, 0xffd69c56);
//_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_WORD2, 0xff2ae27f);
//_sci.sendEditor(QScintilla.SCI_STYLESETBOLD, QScintilla.SCE_C_WORD2, 1);
_sci.sendEditor(QScintilla.SCI_STYLESETBACK, QScintilla.SCE_C_WORD2, 0xffE4D5CB);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_STRING, 0xffc56cbd);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_NUMBER, 0xff6e28ed/*0xffA8CEB5*/);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_CHARACTER, 0xff73DBE6);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_PREPROCESSOR, 0x00808080);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_COMMENT, 0xffaaccaa);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_COMMENTLINE, 0xffaaccaa);
_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_COMMENTDOC, 0x00008000);
/*_sci.sendEditor(QScintilla.SCI_CALLTIPSETBACK, 0xff454242);
_sci.sendEditor(QScintilla.SCI_CALLTIPSETFORE, 0xffefefef);*/
//_sci.sendEditor(QScintilla.SCI_STYLESETFORE, QScintilla.SCE_C_COMMENTDOC, 0xff504f4f);
_sci.sendEditor(QScintilla.SCI_SETCARETFORE,0xff000000,0);
_sci.sendEditor(QScintilla.SCI_SETCARETLINEVISIBLE, 1);
_sci.sendEditor(QScintilla.SCI_SETCARETLINEBACK, 0xffefefef);
_sci.sendEditor(QScintilla.SCI_SETCARETLINEFRAME, 2);
_sci.sendEditor(QScintilla.SCI_SETTABWIDTH, 4);
_sci.sendEditor(QScintilla.SCI_SETEOLMODE, QScintilla.SC_EOL_LF, 0);
//-----------------------
if (Setting.isShowFolding()) {
_sci.sendEditor(QScintilla.SCI_SETPROPERTY,"fold","1");
_sci.sendEditor(QScintilla.SCI_SETMARGINTYPEN, MARGIN_FOLD_INDEX, QScintilla.SC_MARGIN_SYMBOL);//页边类型
_sci.sendEditor(QScintilla.SCI_SETMARGINMASKN, MARGIN_FOLD_INDEX, QScintilla.SC_MASK_FOLDERS); //页边掩码
_sci.sendEditor(QScintilla.SCI_SETFOLDMARGINCOLOUR, 1, 0xffefefef);
_sci.sendEditor(QScintilla.SCI_SETFOLDMARGINHICOLOUR, 1, 0xffffffff);
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN, MARGIN_FOLD_INDEX, 11); //页边宽度
_sci.sendEditor(QScintilla.SCI_SETMARGINSENSITIVEN, MARGIN_FOLD_INDEX, 1); //响应鼠标消息
// 折叠标签样式 //折叠页边颜色
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDER, QScintilla.SC_MARK_BOXPLUS);
_sci.sendEditor(QScintilla.SCI_MARKERSETFORE,QScintilla.SC_MARKNUM_FOLDER,0xffefefef);
_sci.sendEditor(QScintilla.SCI_MARKERSETBACK,QScintilla.SC_MARKNUM_FOLDER,0xff9c9c9c);
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDEROPEN, QScintilla.SC_MARK_BOXMINUS);
setMarginColor(QScintilla.SC_MARKNUM_FOLDEROPEN,0xffefefef,0xff9c9c9c);
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDEREND, QScintilla.SC_MARK_BOXPLUSCONNECTED);
setMarginColor(QScintilla.SC_MARKNUM_FOLDEREND,0xffefefef,0xff9c9c9c);
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDEROPENMID, QScintilla.SC_MARK_BOXMINUSCONNECTED);
setMarginColor(QScintilla.SC_MARKNUM_FOLDEROPENMID,0xffefefef,0xff9c9c9c);
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDERMIDTAIL, QScintilla.SC_MARK_TCORNER);
setMarginColor(QScintilla.SC_MARKNUM_FOLDERMIDTAIL,0xffefefef,0xff9c9c9c);
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDERSUB, QScintilla.SC_MARK_VLINE);
setMarginColor(QScintilla.SC_MARKNUM_FOLDERSUB, 0xffefefef,0xff9c9c9c);
_sci.sendEditor(QScintilla.SCI_MARKERDEFINE, QScintilla.SC_MARKNUM_FOLDERTAIL, QScintilla.SC_MARK_LCORNER);
setMarginColor(QScintilla.SC_MARKNUM_FOLDERTAIL, 0xffefefef,0xff9c9c9c);
} else {
_sci.sendEditor(QScintilla.SCI_SETMARGINWIDTHN, MARGIN_FOLD_INDEX, 0); //页边宽度
}
}
String lastIntellisence_content = "";
public void updateXIntellisence(String _path, String content){
if (isIntellisense_modified()){
String ext = getFilePath().findExtension();
if (isDocument(ext)) {
if (content != nilptr) {
if (lastIntellisence_content.equals(content) == false){
lastIntellisence_content = content;
_mdi_area.UpdateIntelliSense(_path, content);
}
}
}
}
intellisense_modified = false;
}
public void UpdateCodepage(){
MultiSelectDialog.requestSelect(new InputDialog.onInputListener(){
bool onInputOk(@NotNilptr String text)override{ return true;}
bool onInputCancel()override{ return true;}
bool onSelectOk(int id){
try{
defaultCharset = cpid[id];
if (QMessageBox.Yes == QMessageBox.Question("注意","将以新的编码重新载入文件, 对此文档的改动将丢失!",QMessageBox.Yes | QMessageBox.No,QMessageBox.No)){
reloadFile(defaultCharset);
}
/*String content = _sci.getText();
String newtext = new String(content.getBytes(), defaultCharset);
_sci.setText(newtext);*/
return true;
}catch(Exception e){
}
QMessageBox.Critical("注意","选择的编码不正确",QMessageBox.Ok,QMessageBox.Ok);
return false;
}
String getTitle()override{return "选择编码";}
String getTips()override{return "选择编码";}
String getDefault()override{
return "0";
}
},codepages);
}
public void convertCharset(){
MultiSelectDialog.requestSelect(new InputDialog.onInputListener(){
bool onInputOk(@NotNilptr String text)override{ return true;}
bool onInputCancel()override{ return true;}
bool onSelectOk(int id){
try{
defaultCharset = cpid[id];
QMessageBox.Information("注意","该文件将以新的编码 [" + defaultCharset + "] 进行储存",QMessageBox.Ok,QMessageBox.Ok);
return true;
}catch(Exception e){
}
QMessageBox.Critical("注意","选择的编码不正确",QMessageBox.Ok,QMessageBox.Ok);
return false;
}
String getTitle()override{return "选择编码";}
String getTips()override{return "选择编码";}
String getDefault()override{
if (defaultCharset != nilptr){
for (int i = 0; i < cpid.length; i++){
if (cpid[i].equalsIgnoreCase(defaultCharset)){
return "" + i;
}
}
}
return "0";
}
},codepages);
}
public void setEditorText(String fullpath,@NotNilptr byte [] data, String asCharset){
bool readOnly = false;
String content = "";
String charset = asCharset;
if (charset == nilptr){
charset = loadAsCharset;
}
if (charset == nilptr){
charset = getCharsetCache(fullpath);
}
if (charset == nilptr){
try{
charset = String.detectCharset(data, 0, data.length);
}catch(Exception e){
}
}
try{
bool retry = false, bMana = false;
do{
retry = false;
if (charset == nilptr || (charset.equals("UTF-8") == false && charset.equals("ASCII") == false)){
if (charset != nilptr){
defaultCharset = charset;
try{
content = new String(data, charset);
if (asCharset != nilptr){
loadAsCharset = asCharset;
addToCharset(fullpath, loadAsCharset);
}
}catch(Exception e){
bMana = true;
}
}else{
bMana = true;
}
if (bMana){
QMessageBox.Information("注意","无法识别此文件编码,请手动选择一个文件编码尝试载入",QMessageBox.Ok,QMessageBox.Ok);
retry = MultiSelectDialog.requestSelect(new InputDialog.onInputListener(){
bool onInputOk(@NotNilptr String text)override{ return true;}
bool onInputCancel()override{
retry = false;
return true;
}
bool onSelectOk(int id){
try{
charset = cpid[id];
retry = true;
return true;
}catch(Exception e){
}
QMessageBox.Critical("注意","选择的编码不正确",QMessageBox.Ok,QMessageBox.Ok);
return false;
}
String getTitle()override{return "选择编码";}
String getTips()override{return "选择编码";}
String getDefault()override{
if (charset != nilptr){
for (int i = 0; i < cpid.length; i++){
if (cpid[i].equalsIgnoreCase(charset)){
return "" + i;
}
}
}
return "0";
}
},codepages) == 1;
if (!retry){
content = new String(data, 0, data.length, "RAW");
QMessageBox.Critical("注意","未选择有效的编码,文件将锁定为只读,保存或者编辑将使文件损坏.",QMessageBox.Ok,QMessageBox.Ok);
readOnly = true;
setModified(false);
readonlyResp = ReadResp.NO_CHARSET;
}
}
}else{
content = new String(data);
}
}while (retry);
}catch(Exception e){
content = new String(data);
}
_sci.setText(content);
if (readOnly){
_sci.clearUndo();
resetAllModified();
_sci.setSavePoint();
_sci.setReadOnly(true);
}
}
public void setText(String text){
_sci.setText(text);
}
public void requestInteliSence(){
long position = _sci.currentPosition();
String content = _sci.getText();
int line = _sci.positionToLine(position);
int column = position - _sci.getPosition(line);
if (_mdi_area.XIntelliSense(XSourceEditor.this, getFilePath(), content, position, line, column)) {
auto_position = position;
last_autopos = -1;
}
}
public void reloadFile(String asCharset) {
try {
FileInputStream fis = new FileInputStream(getFilePath());
byte [] data = fis.read();
try {
int line = _sci.getFirstVisibleLine();
long pos = _sci.currentPosition();
if (data != nilptr){
setEditorText(getFilePath(), data, asCharset);
}
_sci.setSavePoint();
resetAllModified();
fis.close();
_sci.setFirstVisibleLine(line);
_sci.update();
_sci.gotoPos(pos);
} catch(Exception e) {
}
updateInformationPoint();
} catch(Exception e) {
Critical("注意", "找不到该文件或者文件正被其他程序使用:" + getFilePath(), QMessageBox.Ok, QMessageBox.Ok);
}
}
public bool loadFile(@NotNilptr String file, String asCharset) {
try {
FileInputStream fis = new FileInputStream(file);
try {
byte [] data = fis.read();
if (data != nilptr){
setEditorText(file, data, asCharset);
}
String filePath = String.formatPath(file,false).replace("\\","/");
setFilePath(filePath);
_sci.setSavePoint();
_sci.clearUndo();
_sci.update();
updateTitle();
resetAllModified();
_mdi_area.updateDocumentStatus();
XWorkspace.workspace.closeIndexPage();
Project proj = XWorkspace.workspace.getCurrentProject();
if (proj != nilptr){
proj.didOpenFile(file);
}
if (_textplugins != nilptr) {
_textplugins.configEditor(_mdi_area.getCurrentProject(), filePath, _sci, Setting.isDarkStyle());
}
updateInformationPoint();
_mdi_area.XIntelliSenseFile(XSourceEditor.this, getFilePath(), "");
return true;
} catch(Exception e) {
Critical("注意", "载入文件时发生错误:" + file, QMessageBox.Ok, QMessageBox.Ok);
} finally {
fis.close();
}
} catch(Exception e) {
Critical("注意", "找不到该文件或者文件正被其他程序使用:" + file, QMessageBox.Ok, QMessageBox.Ok);
}
return false;
}
void resetInformationPoint(){
clearInformationPoint();
_sci.sendEditor(QScintilla.SCI_MARKERDELETEALL,ERRORPOINT_INDEX);
_sci.sendEditor(QScintilla.SCI_MARKERDELETEALL,WARNING_INDEX);
}
public bool saveFile() {
if (isModified() == false) {
return true;
}
if (readonlyResp == ReadResp.NO_CHARSET){
QMessageBox.Critical("注意","未选择有效的编码,文件将锁定为只读,保存或者编辑将使文件损坏.",QMessageBox.Ok,QMessageBox.Ok);
return false;
}
clearIndic();
resetInformationPoint();
String savepath = getFilePath();
bool saved = false;
while (saved == false) {
if (savepath != nilptr && savepath.startsWith("#")) {
while (saved == false) {
String file = QFileDialog.getSaveFileName("保存文件", savepath, getDocumentExtension(), this);
if (file != nilptr && file.length() > 0) {
//另存
saved = saveAs(file);
} else {
//取消保存
return false;
}
}
} else
if (savepath != nilptr){
pauseWatch();
try {
String content = _sci.getText();
byte [] data = nilptr;
if (defaultCharset != nilptr){
try{
data = content.getBytes(defaultCharset);
}catch(Exception e){
QMessageBox.Warning("注意","文件不能以编码 " + defaultCharset + " 进行保存, 将存储为 UTF-8 编码.",QMessageBox.Ok,QMessageBox.Ok);
defaultCharset = nilptr;
data = content.getBytes();
}
}else{
data = content.getBytes();
}
FileOutputStream fis = new FileOutputStream(savepath);
fis.write(data);
fis.close();//必须close 不然GC 关闭文件的时候在watch之后 , watch 会报告被更改
_sci.setSavePoint();
removeAllModified();
updateTitle();
saved = true;
String ext = savepath.findExtension();
if (isDocument(ext)) {
updateXIntellisence(savepath, content);
}
} catch(Exception e) {
//保存失败 跳到另存
Critical("注意", "文件无法在此位置保存,或者此文件正被其他程序使用,请重新选择路径", QMessageBox.Ok, QMessageBox.Ok);
savepath = "#";
}
continueWatch();
}
}
return saved;
}
public void removeAllModified() {
setModified(false);
_sci.sendEditor(QScintilla.SCI_MARKERDELETEALL,reserve_modify_mark);
switchSaveMark();
}
public void resetAllModified() {
_sci.sendEditor(QScintilla.SCI_MARKERDELETEALL,MARK_MODIFIED);
_sci.sendEditor(QScintilla.SCI_MARKERDELETEALL,MARK_SAVED);
}
public void saveFileAs() {
if (readonlyResp == ReadResp.NO_CHARSET){
QMessageBox.Critical("注意","未选择有效的编码,文件将锁定为只读,保存或者编辑将使文件损坏.",QMessageBox.Ok,QMessageBox.Ok);
return;
}
String file = QFileDialog.getSaveFileName("保存文件", getFilePath(), getDocumentExtension(), this);
if (file != nilptr && file.length() > 0) {
saveAs(file);
}
}
public bool saveAs(@NotNilptr String path) {
pauseWatch();
try {
FileOutputStream fis = new FileOutputStream(path);
try {
String content = _sci.getText();
byte [] data;
if (defaultCharset != nilptr){
try{
data = content.getBytes(defaultCharset);
}catch(Exception e){
QMessageBox.Warning("注意","文件不能以编码 " + defaultCharset + " 进行保存, 将存储为 UTF-8 编码.",QMessageBox.Ok,QMessageBox.Ok);
data = content.getBytes();
}
}else{
data = content.getBytes();
}
fis.write(data);
fis.close();//必须close 不然GC 关闭文件的时候在watch之后 , watch 会报告被更改
_sci.setSavePoint();
removeAllModified();
setFilePath(String.formatPath(path,false).replace("\\","/"));
continueWatch();
return true;
} catch(Exception e) {
}
} catch(Exception e) {
Critical("注意", "文件无法在此位置保存,或者此文件正被其他程序使用,请重新选择路径", QMessageBox.Ok, QMessageBox.Ok);
}
continueWatch();
return false;
}
public void UnDo() {
_sci.Undo();
}
public void ReDo() {
_sci.Redo();
}
public void insertNewLine() {
int curpos = _sci.getCurrentPosition();
int line = _sci.positionToLine(curpos);
int start = _sci.getPosition(line);
_sci.insertText(start,"\n");
_sci.gotoPos(start);
if (Setting.isAutoIdent()) {
identguide(_sci, '\n');
}
}
public void appendNewLine() {
int curpos = _sci.getCurrentPosition();
int line = _sci.positionToLine(curpos);
int start = _sci.getEndOfLine(line);
_sci.insertText(start,"\n");
_sci.gotoPos(start + 1);
if (Setting.isAutoIdent()) {
identguide(_sci, '\n');
}
}
public int getContentLength ()override{return _sci.getLength();}
public int getSelectStart()override{return _sci.getSelectStart();}
public int getSelectEnd()override{return _sci.getSelectEnd();}
public QPoint getSelectMarkRange()override{
int start = 0, end = 0;
int contentlen = _sci.getLength();
do {
start = _sci.getIndicStart(INDIC_SELECTED, start);
end = _sci.getIndicEnd(INDIC_SELECTED, start);
if (end == 0) {
return nilptr;
}
int dic = _sci.IndicForPosition(start);
if ((dic & (1 << INDIC_SELECTED)) != 0) {
return new QPoint(start, end);
} else {
start = end;
}
} while (end != contentlen);
return nilptr;
}
public String getText(int s,int e)override{return _sci.getText(s,e);}
public void Copy() {
if (_sci.getSelectStart() == _sci.getSelectEnd()) {
int curpos = _sci.getCurrentPosition();
int line = _sci.positionToLine(curpos);
int start = _sci.getPosition(line);
int end = _sci.getEndOfLine(line);
_sci.setSelect(start,end);
_sci.Copy();
_sci.gotoPos(curpos);
} else {
_sci.Copy();
}
}
public void Paste() {
_sci.Paste();
}
public void Cut() {
_sci.Cut();
}
public void Delete() {
if (Setting.isMatchBrace()) {
if (deleteBrace(_sci.getCurrentPosition())) {
_sci.Delete();
}
} else {
_sci.Delete();
}
}
public void DeleteCurLine() {
_sci.sendEditor(QScintilla.SCI_LINEDELETE,0);
}
public static void clearBreakInfo(@NotNilptr Map<long, XStackInfor.BreakPosition> breakList) {
Map.Iterator<long, XStackInfor.BreakPosition> iter = breakList.iterator();
while (iter.hasNext()) {
XStackInfor.BreakPosition bp = iter.getValue();
if (bp != nilptr){
DocumentView wnd = findDocumentWindow(nilptr, bp.file, false);
if (wnd != nilptr) {
//wnd.breakOn(bp.line, bp.row, false, bp.active);
wnd.clearBreakOn();
}
}
iter.next();
}
}
public static void removeBreak(@NotNilptr XStackInfor.BreakPosition bp) {
DocumentView wnd = findDocumentWindow(nilptr, bp.file, false);
if (wnd != nilptr) {
wnd.breakOn(bp.line, bp.row, false, bp.active, false);
}
}
public static void setBreak(@NotNilptr XStackInfor.BreakPosition bp, bool onlyActive, bool bSender) {
DocumentView wnd = findDocumentWindow(XWorkspace.workspace, bp.file, bp.active);
if (wnd != nilptr) {
wnd.breakOn(bp.line, bp.row, true, bp.active, onlyActive);
} else
if (bp.file != nilptr){
if (bSender && QMessageBox.Question("提示", "无法找到源代码文件:" + bp.file + ",是否浏览文件?", QMessageBox.Yes | QMessageBox.No, QMessageBox.No ) == QMessageBox.Yes) {
String filename = bp.file.findFilenameAndExtension();
if (filename.length() == 0) {
filename = bp.file;
}
String file = QFileDialog.getOpenFileName("打开文件:" + filename, bp.file, getDocumentExtension(), XWorkspace.workspace);
if (file != nilptr && file.length() > 0) {
wnd = findDocumentWindow(XWorkspace.workspace, file, bp.active);
if (wnd != nilptr) {
wnd.breakOn(bp.line, bp.row, true, bp.active, onlyActive);
updateDocumentTo(file, bp.file);
}
}
}
}
}
public void CursorUp() {
_sci.sendEditor(QScintilla.SCI_LINEUP, 0);
}
public void CursorLeft() {
_sci.gotoPos(_sci.getCurrentPosition() - 1);
}
public void CursorRight() {
_sci.gotoPos(_sci.getCurrentPosition() + 1);
}
public void CursorDown() {
_sci.sendEditor(QScintilla.SCI_LINEDOWN, 0);
}
public void CursorLineBegin() {
_sci.sendEditor(QScintilla.SCI_VCHOME, 0);
}
public void CursorLineEnd() {
_sci.sendEditor(QScintilla.SCI_LINEEND, 0);
}
public void CursorPrevPage() {
_sci.sendEditor(QScintilla.SCI_PAGEUP, 0);
}
public void CursorNextPage() {
_sci.sendEditor(QScintilla.SCI_PAGEDOWN, 0);
}
public void CursortoTop() {
_sci.gotoPos(0);
}
public void CursortoBottom() {
_sci.gotoPos(_sci.getLength() - 1);
}
public void setUpper() {
_sci.sendEditor(QScintilla.SCI_UPPERCASE, 0);
}
public void doPrint(){
if (g_printer == nilptr){
g_printer = new QScintilla.QSciPrinter();
}
if (g_printer != nilptr){
QPrintDialog printdlg = new QPrintDialog(this, g_printer);
if (printdlg.exec() != 0){
g_printer.printRange(_sci, -1, -1);
}
}
}
public void setLower() {
_sci.sendEditor(QScintilla.SCI_LOWERCASE, 0);
}
/*static void updateBreakInfo(Map<int, XStackInfor.BreakPosition> breakList){
Map.Iterator<int, XStackInfor.BreakPosition> iter = breakList.iterator();
while (iter.hasNext()){
XStackInfor.BreakPosition bp = iter.getValue();
if (bp.isUpdated()){
XSourceEditor wnd = findDocumentWindow(XWorkspace.workspace, bp.file, bp.active);
if (wnd != nilptr){
wnd.breakOn(bp.line, bp.row, true, bp.active);
}
}
iter.next();
}
}*/
};
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。