<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12


      前提條件:

      • 官網下載Qscintilla庫,并使用QtCreator構建出靜態庫。

      • 將Qsci文件夾和生成的庫拷到準備使用的項目文件下


      正文

      1. 實現自己的customqscintilla

         // 自動縮進
         editor->setTabWidth(4);
         editor->setIndentationWidth(4);
         editor->setIndentationsUseTabs(false);
         editor->setAutoIndent(true);
        
         // 當前行高亮
         editor->setCaretLineVisible(true);
         editor->setCaretLineBackgroundColor(QColor("#E8E8FF"));
         editor->setCaretWidth(3);
        
         // 詞法分析器
         auto textLexer = new QsciLexerMat(editor);
         editor->setLexer(textLexer);
        
         // 行號
         editor->setMarginLineNumbers(1, true);
         editor->setMarginWidth(1, "000");
        
         // 代碼折疊
         editor->setFolding(QsciScintilla::BoxedTreeFoldStyle);
         editor->setMarginSensitivity(2, true); // 確保可以點擊邊距進行折疊
         editor->setMarginType(2, QsciScintilla::SymbolMargin);
        
         auto api = new QsciAPIs(textLexer);
         // 讀取關鍵字文件
         if (!api->load("C:/Users/12117/Desktop/QtWidgetsApplication1/QtWidgetsApplication1/QtWidgetsApplication1/apis.txt"))
         {
             QMessageBox::warning(this, "Warning", "Load Failed");
         }
         else
         {
             api->prepare();
         }
        
         // 自動補全
         editor->setAutoCompletionSource(QsciScintilla::AcsAll);
         editor->setAutoCompletionCaseSensitivity(true);
         editor->setAutoCompletionReplaceWord(true);
         editor->setAutoCompletionUseSingle(QsciScintilla::AcusNever);
         editor->setAutoCompletionThreshold(1)
        

      1. 繼承QsciLexerCustom實現自己的自定義詞法分析器

         class QsciLexerMat : public QsciLexerCustom
         {
         Q_OBJECT
        
         public:
           QsciLexerMat(QObject* parent);
           ~QsciLexerMat();
        
        
         virtual void styleText(int start, int end);
         virtual const char* language() const;
         virtual QString description(int style) const;
         QColor defaultColor(int style) const;
         virtual const char* keywords(int set) const;
        
        
         enum {
         	SCE_C_DEFAULT = 0,
         	SCE_C_COMMENTLINE,
         	SCE_C_STRING,
         	SCE_C_NUMBER,
         	SCE_C_KEYWORD,
         	SCE_C_IDENTIFIER
         };
        };  
        

      1. 重點實現styleText函數(以下代碼僅作示例)

         ///----省略----////
         auto handleString = [&]() {
             QChar delimiter = text[pos];
             styleBuffer[pos] = SCE_C_STRING;
             ++pos;
             while (pos < length) {
                 if (text[pos] == '\\') { // 轉義字符
                     if (pos + 1 < length) {
                         styleBuffer[pos] = SCE_C_STRING;
                         styleBuffer[pos + 1] = SCE_C_STRING;
                         pos += 2;
                     }
                     else {
                         break;
                     }
                 }
                 else if (pos < length && text[pos] == delimiter) {
                     styleBuffer[pos] = SCE_C_STRING;
                     ++pos;
                     inString = false;
                     break;
                 }
                 else if (pos < length) {
                     styleBuffer[pos] = SCE_C_STRING;
                     ++pos;
                 }
                 else {
                     break;
                 }
             }
             };  
         ///----省略----////
         while (pos < length) {
         QChar ch = text.at(pos);
        
         // 處理字符串,注釋,關鍵字和標識符,數字
         if (!inString && (ch == '\'' || ch == '"')) {
             inString = true;
             handleString();
             continue;
         }  
        
         ////----省略----////  
        
         // 應用樣式  
           startStyling(start);
           int currentBytePos = start;
           int currentStyle = -1;
           int count = 0;
           QTextCodec* codec = QTextCodec::codecForName("UTF-8");
           if (!codec) {
               qWarning("Failed to get UTF-8 codec");
               return;
           }
        
           QByteArray byteArray;
           for (int i = 0; i < styleBuffer.size(); ++i) {
               if (styleBuffer[i] != currentStyle) {
                   if (count > 0) {
                       byteArray = codec->fromUnicode(text.mid(i - count, count));
                       setStyling(byteArray.length(), currentStyle); // 設置相同樣式的字符
                       currentBytePos += byteArray.length();
                   }
                   currentStyle = styleBuffer[i];
                   count = 0;
               }
               count++;
           }
           if (count > 0) {
               byteArray = codec->fromUnicode(text.mid(text.length() - count, count));
               setStyling(byteArray.length(), currentStyle); // 設置最后一段相同樣式的字符
               currentBytePos += byteArray.length();
           }
        
       posted on 2025-02-27 22:33  哈哈哈119  閱讀(260)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 精品不卡一区二区三区| 久久99久国产精品66| 中文字幕一区二区久久综合| 亚洲av第三区国产精品| 欧美色欧美亚洲另类二区| 桃花岛亚洲成在人线AV| 久久久久国产精品人妻| 午夜国产理论大片高清| 熟女少妇精品一区二区| av天堂亚洲天堂亚洲天堂| 人妻丝袜无码专区视频网站| 国产91特黄特色A级毛片| 国产69成人精品视频免费| 巨胸美乳无码人妻视频漫画| 静安区| 奇台县| 一色桃子中出欲求不满人妻| 成人网站免费观看永久视频下载| 国产精品乱一区二区三区| 狠狠做五月深爱婷婷伊人| 激情伊人五月天久久综合| 亚洲国产精品自产在线播放| 日韩中文字幕人妻一区| 国产视频一区二区三区视频| japanese无码中文字幕| 东京热一精品无码av| 国产激情文学亚洲区综合| 成人亚洲av免费在线| 免费 黄 色 人成 视频 在 线| 久久国产乱子伦免费精品无码| 午夜A理论片在线播放| 亚洲人成电影在线天堂色| 国产午夜精品一区二区三区漫画| 精品中文人妻在线不卡| 日韩高清在线亚洲专区不卡| 亚洲a∨无码一区二区三区| 色综合久久综合中文综合网| 午夜高清福利在线观看| 美女高潮黄又色高清视频免费| 苍井空浴缸大战猛男120分钟| 国产国拍精品av在线观看|