Voidcscriptview: initeditor (void) {S (sci_cleardocumentstyle); s (sci_setcodepage, SC _cp_utf8); // supports unicodesetastyle (style_default, black, white, 12, "fixedsys "); S (sci_styleclearall ); // copies global style to all others // set the number of styling bits to 7-The ASP/html views need a lot of styling-default is 5 // if you leave the default you will see twiggle lines instead of ASP codes (SCI _ Setstylebits, 7); // tab width S (sci_settabwidth, 4); s (sci_setfocus, true); // snooper Syntax Parsing // sendeditor (sci_setlexer, sclex_snooper_apdu_nocase ); S (sci_setlexerlanguage, 0, reinterpret_cast <lparam> ("snooper_apdu_nocase"); s (sci_setkeywords, 0, reinterpret_cast <lparam> (G ____ apdu_keywords )); // set the keyword S (sci_setkeywords, 1, reinterpret_cast <lparam> (G ____ apdu_pre_keywords); // set the keyword S (sci_setke Ywords, 2, reinterpret_cast <lparam> (G ____ apdu_function_list); // set the keyword setastyle (sce_ss_default, RGB (0x00, 0x00, 0x00 )); // default setastyle (sce_ss_comment, RGB (0x00, 0x80, 0x80); // annotation setastyle (sce_ss_label, RGB (0x00, 0x80, 0x40 ),(~ RGB (0x00, 0x80, 0x40) & 0 xffffff); // setastyle (sce_ss_hex_wrong, RGB (50,100, 45 )); /// the hex string is not an even number. // The current row highlights S (sci_setcaretlinevisible, true); // sendeditor (sci_setcaretlineback, 0xb0ffff); s (sci_setcaretlineback, RGB (226,217,232 )); // matching the color S (sci_stylesetback, style_bracelight, RGB (0x00, 0xff, 0x00); // s (sci_stylesetback, style_bracebad, RGB (0xff, 0x00, 0x00); // select the background S (sci_setselback, true, RGB (0x9f, 0xbb, 0xe8); // set margin 0 s (sci_setmargintypen, 0, SC _margin_number); // set margin 1 S (sci_setmargintypen, 1, SC _margin_symbol); // mask s (sci_setmarginmaskn, 1, 3 ); // bit 0 and bit 1 S (sci_markersetfore, 0, RGB (0xff, 0x00, 0x00); // 1-Reds (sci_markersetfore, 1, RGB (0x00, 0xff, 0x00); // 1-green S (sci_setmarginwidthn, 1, 9); // accept mouse clicks // s (sci_setmarginsensitiven, true); // s (sci_textwidth (style_linenumber, "_ 99999"); // you can specify the mouse hover time (sci_setmousedwelltime, 500 );}
After the syntax is highlighted, the code is automatically prompted and completed.
First, use scintilla to derive a class, which is called Editor. Then, create a view and embed it into the editor so that most of editor events can be processed in the view.
Code prompt, VC uses '. 'or'-> 'or': 'To call. You can use this method by yourself. to call the function list. When '(', ')' is input, the system checks whether the function is complete and prompts the parameters. Press F1 or hover the mouse over the display.
The parameter prompt completed in updateui displays the function list as long as there is a '.' on the left of the current cursor.
Case scn_updateui: // updateui (); break;
voidCScriptView::UpdateUI( void ){long lStart = s(SCI_GETCURRENTPOS, 0, 0);int ch = s( SCI_GETCHARAT, lStart - 1 );if( '.' == ch ){s( SCI_AUTOCSHOW, 0, (sptr_t)g____apdu_function_list );}
The only drawback is that there is an extra '.' And I deleted it when it was automatically completed.
Parameter prompt
The parameter prompt is calculated when the message charadded is sent. The basic process is to get the content of the current row, get the location of the current caret, and then get the location of the first caret of the line, to calculate the offset of the current caret row.
The Snoop expression is different from other expressions. functions can be nested and '(', '<', '{' have different meanings. Therefore, the computing flow is not universal.
Boolcscriptview: getfunction (INT pos_x, char * funpara, int * Start, int * End) {int line_num = S (sci_linefromposition, pos_x ); // The current row int line_length = S (sci_linelength, line_num); // The length of the current row
// The following sentence is very important. Obtain the intra-row offset.
Int pos0 = S (sci_findcolumn, line_num, 0); // obtain the start posint pos at the leftmost position of the current row; Pos = pos_x-pos0; // The offset within the row, starting from 1