⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cplusmpi.java

📁 基于JAVA的并行程序编辑器研究与设计 并行编程在高性能计算领域的应用越来越广泛。国家863计划项目“网格服务环境结点建设及其支撑技术研究”的子课题 “用户开发环境研究”
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        findDialog.setLocation(230,280);
        findDialog.setVisible(true);
    };
    private boolean insertTest(char[] content){
        int tok = offset;
        String str = null;
        while(content[tok] != '\n') tok -- ;
        str = str.copyValueOf(content,tok,offset - tok);
        return true;
    };
    private int canInsert(char[] content,int begin,int end) {
        while(begin < end){
            if(content[begin] == '}')
                break;
            if(! (content[begin] == ' ' || content[begin] == '\t'))
                break;
            begin ++;
        }
        return begin;
    };
    private void highShow(){
        String str = textPane.getText();
        char[] content = DataCopy(str.toCharArray());
        int length = content.length;
        StyleConstants.setForeground(normalAttr,Color.BLACK);
        styledDoc.setCharacterAttributes(0, length, normalAttr, false);
        int tok = 0,begin,len;
        char ch = '\u0000';
        while(tok < length){
            while((ch = content[tok]) != ' ' && ch != '\n' && ch != '\t'){
                if(++ tok < length && ch == '/') {
                    ch = content[tok];
                    if(ch == '/'){
                        textPane.setForeground(new Color(0,132,0));
                        begin = tok - 1;
                        while(++ tok < length && (ch = content[tok]) != '\n');
                        styledDoc.setCharacterAttributes(begin, tok - begin,
                                commentAttr, false);
                        if(ch == '\n'){
                            textPane.setForeground(Color.BLACK);
                        }
                    } else if(ch == '*'){
                        textPane.setForeground(new Color(0,132,0));
                        begin = tok - 1;
                        while(++ tok < length){
                            ch = content[tok];
                            if(ch == '*'){
                                if(++ tok < length)
                                    ch = content[tok];
                                if(ch == '/')break;
                                else if(ch == '*')tok -- ;
                            }
                        }
                        styledDoc.setCharacterAttributes(begin, tok - begin + 1,
                                commentAttr, false);
                        if(ch == '/'){
                            textPane.setForeground(Color.BLACK);
                        }
                    }
                }else if(Character.isLetter(ch) || ch == '_'){
                    StyleConstants.setForeground(normalAttr,Color.BLACK);
                    char[] temp = new char[255];
                    int count = 0,mm = 0;
                    begin = tok - 1;
                    temp[count] = ch;
                    while(tok < length && (Character.isLetter(ch = content[tok])
                    || ch == '_')){
                        tok ++;
                        temp[++ count] = ch;
                    }
                    String st = "";
                    st = st.copyValueOf(temp,0,count + 1);
                    if(st.startsWith("MPI_")){
                        MpiKeyWordsAndFunctions mpikey = new MpiKeyWordsAndFunctions();
                        for(mm = 0; mm < mpikey.mpiKeyWords.length;mm ++)
                            if(st.equals(mpikey.mpiKeyWords[mm])) break;
                        if(mm < mpikey.mpiKeyWords.length)
                            styledDoc.setCharacterAttributes(begin, tok - begin,
                                    mpiAttr, false);
                        else{
                            for(mm = 0; mm < mpikey.mpiFunctions.length;mm ++)
                                if(st.equals(mpikey.mpiFunctions[mm])) break;
                            if(mm < mpikey.mpiFunctions.length)
                                styledDoc.setCharacterAttributes(begin,
                                        tok - begin,mpiFunctionAttr, false);
                        }
                    } else {
                        CplusKeyWords cplus = new CplusKeyWords();
                        for(mm = 0;mm < cplus.cPlusKeyWords.length; mm ++)
                            if(st.equals(cplus.cPlusKeyWords[mm])) break;
                        if(mm < cplus.cPlusKeyWords.length)
                            styledDoc.setCharacterAttributes(begin,
                                    tok - begin,
                                    keyAttr, false);
                    }
                    StyleConstants.setForeground(normalAttr,Color.BLACK);
                    tok -- ;
                }else if(ch == '#'){
                    textPane.setForeground(Color.BLACK);
                    begin = tok - 1;
                    while(tok < length && ((ch = content[tok]) == ' ' || ch == '\t')){
                        tok ++;
                        if(ch == '\n') {
                            tok --;
                            break;
                        }
                    }
                    char[] include = {'$','$','$','$','$','$','$'};
                    for(int n = 0; n < 7 && tok < length; n ++){
                        include[n] = content[tok ++];
                        if(include[n] == '\n') {
                            tok --;
                            break;
                        }
                    }
                    String in = null,de = null;
                    in = in.copyValueOf(include);
                    de = de.copyValueOf(include,0,6);
                    if((tok == length || (!Character.isLetter(content[tok])
                    && content[tok] != '_')) && in.equals("include")){
                        styledDoc.setCharacterAttributes(begin, tok - begin,
                                keyAttr, false);
                        StyleConstants.setForeground(normalAttr,Color.BLACK);
                        tok -- ;
                    }
                    if((tok == length || (!Character.isLetter(include[6])
                    && include[6] != '_')) && de.equals("define")){
                        if(include[6] == '$')
                            styledDoc.setCharacterAttributes(begin,
                                    tok - begin,keyAttr, false);
                        else
                            styledDoc.setCharacterAttributes(begin,
                                    tok - begin - 1,keyAttr, false);
                        textPane.setForeground(Color.BLACK);
                        tok -- ;
                    }
                }else tok -- ;
                break;
            }
            tok ++;
        }
    }
    private void formatControl(){
        char[] content = DataCopy(textPane.getText().toCharArray());
        Stack stack = new Stack();
        int tok = offset,begin = offset,end = offset;
        if(content[tok] == '\n')
            begin -- ;
        while (begin > 0 && content[begin] != '\n') begin -- ;
        if(content[tok] == '}'){
            tok -- ;
            while(tok >= 0 ) {
                if(content[tok] == '{') {
                    if(! stack.empty() && stack.peek() == "}")
                        stack.pop();
                    else
                        stack.push("{");
                } else if(content[tok] == '}') {
                    if(! stack.empty() && stack.peek() == "{")
                        stack.pop();
                    else stack.push("}");
                }
                tok -- ;
            } ;
            if(! stack.empty() && stack.peek() == "{"){
                int canDo = canInsert(content,begin + 1,end);
                if(canDo == offset){
                    textPane.select(offset - 1,offset);
                    textPane.replaceSelection("");
                    textPane.setCaretPosition(textPane.getCaretPosition() + 1);
                } else if(content[canDo] == '}') {
                    textPane.select(canDo - 1,canDo);
                    textPane.replaceSelection("");
                    textPane.setCaretPosition(end);
                }
                stack.pop();
            }
        } else {
            while(tok >= 0 ) {
                if(content[tok] == '{') {
                    if(! stack.empty() && stack.peek() == "}")
                        stack.pop();
                    else
                        stack.push("{");
                } else if(content[tok] == '}') {
                    if(! stack.empty() && stack.peek() == "{")
                        stack.pop();
                    else stack.push("}");
                }
                tok -- ;
            } ;
            tok = 0;
            if(! stack.empty() && stack.peek() == "{") {
                int times = 0;
                while(! stack.empty()) {
                    stack.pop();
                    times ++;
                }
                try{
                    for(int n = 0;n < times;n ++) {
                        stack.push("{");
                        textPane.requestFocus();
                        styledDoc.insertString(offset + 1,"\t",normalAttr);
                    }
                } catch(BadLocationException e) {
                    System.err.println("BadLocationException: " + e);
                }
            }
        }
    };
    protected void selectAllPerformed() {
        selectAll();
    };
    protected void searchNextPermored() {
        searchNext();
    }
    protected void replacePerformed(){
        replace();
    };
    protected void openFilePerformed(){
        textPane.requestFocus();
        String currentValue = textPane.getText();
        boolean isTextChange = (currentValue.equals(oldValue))?false:true;
        if(isTextChange){
            int saveChoose = JOptionPane.showConfirmDialog(this,
                    "您的文件尚未保存,是否保存?",
                    "提示",JOptionPane.YES_NO_CANCEL_OPTION);
            if(saveChoose == JOptionPane.YES_OPTION){
                saveFileAs();
                openFile();
            }else if(saveChoose == JOptionPane.NO_OPTION){
                openFile();
            }else{
                return;
            }
        }else{
            openFile();
        }
    };
    protected void saveFilePerformed(){
        textPane.requestFocus();
        if(isNewFile){
            saveFileAs();
        }else{
            try{
                FileWriter fw = new FileWriter(currentFile);
                BufferedWriter bfw = new BufferedWriter(fw);
                String str = textPane.getText();
                str = str.copyValueOf(DataCopy(str.toCharArray())).toString();
                bfw.write(str,0,str.length());
                bfw.flush();
                fw.close();
                oldValue = textPane.getText();
            } catch(IOException ioException){
            }
        }
    };
    protected void saveFileAsPerformed(){
        saveFileAs();
    };
    protected void exitPerformed(){
        exit();
    };
    protected void cutPerformed(){
        cut();
    };
    protected void copyPerformed(){
        copy();
    };
    protected void pastePerformed(){
        paste();
    };
    protected void searchPerformed(){
        search();
    };
    protected void newFilePerformed(){
        textPane.requestFocus();
        String currentValue = textPane.getText();
        boolean isTextChange = (currentValue.equals(oldValue))?false:true;
        if(isTextChange){
            int saveChoose = JOptionPane.showConfirmDialog(this,
                    "您的文件尚未保存,是否保存?",
                    "提示",JOptionPane.YES_NO_CANCEL_OPTION);
            if(saveChoose == JOptionPane.YES_OPTION){
                saveFilePerformed();
                newFile();
            }else if(saveChoose == JOptionPane.NO_OPTION){
                newFile();
            }else if(saveChoose == JOptionPane.CANCEL_OPTION){
                return;
            }else{
                newFile();
            }
        }else{
            newFile();
        }
    };
    protected void deletePerformed() {
        delete();
    };
    protected void redoPerformed() {
        redo();
    };
    protected void undoPerformed() {
        undo();
    };
    protected void helpPerformed() {        
        about();
    };
    protected void helpTopicsPerformed(){
        helpTopics();
    };
    protected void highShowPerformed(){
        highShow();
    };
    protected void formatControlPerformed(){
        formatControl();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -