Changeset 278

Show
Ignore:
Timestamp:
07/17/10 22:35:53 (2 years ago)
Author:
Kuan Hsu
Message:

1. Add EOL Options
2. Fixed "Update Parser Live Full" Bugs....
3. Fixed Parser( nested extern(?)....)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/current/poseidon/CodeAnalyzer/syntax/attributes.d

    r272 r278  
    181181            case TOK.Tauto: 
    182182                globalProt = globalProt & ( D_Attribute - D_Storage ) | D_Auto; 
     183                return true; 
     184 
     185            case TOK.Textern: 
     186                globalProt = globalProt & ( D_Attribute - D_Storage ) | D_Extern; 
    183187                return true; 
    184188 
  • trunk/current/poseidon/CodeAnalyzer/syntax/nodeHsu.d

    r275 r278  
    320320 
    321321    void passChildren( CAnalyzerTreeNode[] leafs ){ children = leafs; } 
     322 
     323    void increaseLineNumber( int startNum, int adds ) 
     324    { 
     325        void _processChildren( CAnalyzerTreeNode node ) 
     326        { 
     327            foreach( CAnalyzerTreeNode t; node.children ) 
     328            { 
     329                if( t.lineNumber >= startNum ) t.lineNumber += adds; 
     330                if( t.getLeafCount > 0 ) _processChildren( t ); 
     331            } 
     332        } 
     333 
     334        if( this.lineNumber >= startNum ) this.lineNumber += adds; 
     335        _processChildren( this ); 
     336    } 
    322337 
    323338    /* 
  • trunk/current/poseidon/CodeAnalyzer/syntax/statements.d

    r272 r278  
    12641264                handle[TOK.Tinvariant] = &handleStorageClass; 
    12651265                handle[TOK.Timmutable] = &handleStorageClass; 
     1266 
     1267        assign!(AttributeDeclaration).toParse(TOK.Textern); 
     1268                //handle[TOK.Textern] = &handleStorageClass; // D 2.0 
    12661269    } 
    12671270 
  • trunk/current/poseidon/nls/english.ini

    r276 r278  
    7676view.class = &Class Browser 
    7777view.debug = &Debug 
     78view.eol = &End Of Line Symbol 
     79view.space = &Space And Tab Symbol 
    7880 
    7981; project menu 
     
    103105tools.language = Language 
    104106tools.encode = &Encode 
     107tools.seteol = &Set EOL Character 
     108tools.eol = &Convert EOL Character 
    105109tools.associate = File &Associate 
    106110tools.options = &Options... 
  • trunk/current/poseidon/poseidon/controller/actionmanager.d

    r275 r278  
    12541254    } 
    12551255 
    1256     public void actionEOL(Event e) 
    1257     { 
    1258         MenuItem mi = cast(MenuItem)e.widget; 
    1259         EditItem ei = sGUI.editor.getSelectedEditItemHSU(); 
    1260  
    1261         if( ei !is null ) 
    1262         { 
    1263             char[] text = mi.getText(); 
    1264             int mode = ei.scintilla.getEOLMode(); 
    1265  
    1266             switch( text ) 
    1267             { 
    1268                 case "Windows": 
    1269                     if( mode == 0 ) 
    1270                         return; 
    1271                     else 
    1272                     { 
    1273                         ei.scintilla.convertEOLs( 0 ); 
    1274                     } 
    1275                     break; 
    1276  
    1277                 case "Unix": 
    1278                     if( mode == 2 ) 
    1279                         return; 
    1280                     else 
    1281                         ei.scintilla.convertEOLs( 2 ); 
    1282  
    1283                 case "Macintosh": 
    1284                     if( mode == 1 ) 
    1285                         return; 
    1286                     else 
    1287                     { 
    1288                         ei.scintilla.convertEOLs( 1 ); 
    1289                     } 
    1290  
    1291                 default: 
    1292             } 
    1293         } 
    1294     }    
    1295      
    12961256    public void actionPreference(Event e) 
    12971257    { 
     
    12991259        prf.open(); 
    13001260    } 
     1261     
    13011262    public void actionAboutBox(Event e) 
    13021263    { 
  • trunk/current/poseidon/poseidon/controller/dialog/aboutbox.d

    r277 r278  
    3838        with(label = new CLabel(top, DWT.CENTER)){ 
    3939            //setText("Poseidon Editor for D v " ~ Globals.getVersionS()); 
    40             setText("Poseidon Editor for D rev.277" ); 
     40            setText("Poseidon Editor for D rev.278" ); 
    4141            setForeground(color); 
    4242        } 
  • trunk/current/poseidon/poseidon/controller/editor.d

    r276 r278  
    725725            e.doit = false; 
    726726 
    727         if( sGUI.editor.items.length == 0 ) sAutoComplete.setFileParser( null ); 
     727        if( !sGUI.editor.items.length )    sAutoComplete.setFileParser( null ); 
    728728 
    729729        /* 
     
    739739        EditItem ei = cast(EditItem) e.item; 
    740740        ei.reportErrors(); 
     741 
     742        if( sGUI.menuMan.showEOLItem.getSelection() && !ei.scintilla.getViewEOL() ) 
     743            ei.scintilla.setViewEOL( true ); 
     744        else if( !sGUI.menuMan.showEOLItem.getSelection() && ei.scintilla.getViewEOL() ) 
     745            ei.scintilla.setViewEOL( false ); 
     746 
     747        if( sGUI.menuMan.showSpaceItem.getSelection() && !ei.scintilla.getViewWS() ) 
     748            ei.scintilla.setViewWS( 1 ); 
     749        else if( !sGUI.menuMan.showSpaceItem.getSelection() && ei.scintilla.getViewWS() ) 
     750            ei.scintilla.setViewWS( 0 ); 
     751 
     752        if( sGUI.menuMan.setEOLMenuItem[0].getSelection ) 
     753            ei.scintilla.setEOLMode( 0 ); 
     754        else if( sGUI.menuMan.setEOLMenuItem[1].getSelection ) 
     755            ei.scintilla.setEOLMode( 1 ); 
     756        else if( sGUI.menuMan.setEOLMenuItem[2].getSelection ) 
     757            ei.scintilla.setEOLMode( 2 ); 
     758             
    741759        /* 
    742760        sAutoComplete.setFileParser( sAutoComplete.getParserFromProjectParser( ei.getFileName() ) ); 
  • trunk/current/poseidon/poseidon/controller/menumanager.d

    r276 r278  
    2626                        undoItem, redoItem, cutItem, copyItem, pasteItem, selectallItem, 
    2727                        togglecommentItem, streamcommentItem, boxcommentItem, nestcommentItem, 
    28                         findItem, findListItem, gotoItem, viewDebugItem, classBrowserItem, 
     28                        findItem, findListItem, gotoItem, viewDebugItem, classBrowserItem, showEOLItem, showSpaceItem, 
    2929                        compileItem, runItem, buildItem, build_runItem, rebuildItem, BudItem, cleanItem, 
    3030                        debugItem, debugbuildItem, debuginItem, debugrunItem, debugoverItem, debugreturnItem, debugstopItem, debugcleanbpsItem, 
    31                         encodeItem, registerItem, documentItem; 
     31                        encodeItem, setEOLItem, EOLItem, registerItem, documentItem; 
     32 
     33    public  MenuItem[3] setEOLMenuItem; 
    3234                         
    3335    // static properties 
     
    337339            }); 
    338340        } 
     341 
     342        with( showEOLItem = new MenuItem( menu, DWT.CHECK ) ) 
     343        { 
     344            setImage( Globals.getImage( "topic" ) ); 
     345            setData( LANG_ID, "view.eol" ); 
     346            setSelection( false ); 
     347            handleEvent( this, DWT.Selection, delegate( Event e ){ 
     348                MenuItem mi = cast(MenuItem)e.widget; 
     349                EditItem ei = sGUI.editor.getSelectedEditItemHSU(); 
     350                if( ei !is null ) 
     351                { 
     352                    if( !ei.scintilla.getViewEOL() && mi.getSelection() ) 
     353                        ei.scintilla.setViewEOL( true ); 
     354                    else if( ei.scintilla.getViewEOL() && !mi.getSelection() ) 
     355                        ei.scintilla.setViewEOL( false ); 
     356                } 
     357            }); 
     358        } 
     359 
     360        with( showSpaceItem = new MenuItem( menu, DWT.CHECK ) ) 
     361        { 
     362            setImage( Globals.getImage( "topic" ) ); 
     363            setData( LANG_ID, "view.space" ); 
     364            setSelection( false ); 
     365            handleEvent( this, DWT.Selection, delegate( Event e ){ 
     366                MenuItem mi = cast(MenuItem)e.widget; 
     367                EditItem ei = sGUI.editor.getSelectedEditItemHSU(); 
     368                 
     369                if( ei !is null ) 
     370                { 
     371                    if( !ei.scintilla.getViewWS() && mi.getSelection() ) 
     372                        ei.scintilla.setViewWS( 1 ); 
     373                    else if( ei.scintilla.getViewWS() && !mi.getSelection() ) 
     374                        ei.scintilla.setViewWS( 0 ); 
     375                } 
     376            }); 
     377        }        
    339378 
    340379        /+ 
     
    605644        } 
    606645        encodeItem.setMenu(EncodeMenu(encodeItem)); 
     646 
     647        new MenuItem(menu, DWT.SEPARATOR); 
     648 
     649        with( setEOLItem = new MenuItem(menu, DWT.CASCADE)){ 
     650            // always set the "language" string to in English 
     651            setData(LANG_ID,"tools.seteol"); 
     652            handleEvent(this, DWT.Selection, delegate(Event e){ 
     653            }); 
     654        } 
     655        setEOLItem.setMenu(setEOLMenu(setEOLItem)); 
     656         
     657        with( EOLItem = new MenuItem(menu, DWT.CASCADE)){ 
     658            // always set the "language" string to in English 
     659            setData(LANG_ID,"tools.eol"); 
     660            setEnabled( false ); 
     661            handleEvent(this, DWT.Selection, delegate(Event e){ 
     662            }); 
     663        } 
     664        EOLItem.setMenu(EOLMenu(EOLItem)); 
    607665 
    608666        new MenuItem(menu, DWT.SEPARATOR); 
     
    689747        return menu; 
    690748    } 
     749 
     750    protected Menu setEOLMenu(MenuItem item) 
     751    { 
     752        char[][] keys = ["CRLF", "CR", "LF"]; 
     753        char[][] icon = [ "windows", "mac", "linux" ]; 
     754        Menu menu = new Menu(item); 
     755 
     756        for(int i = 0; i < 3; ++ i ) 
     757        { 
     758            setEOLMenuItem[i] = new MenuItem(menu, DWT.RADIO); 
     759            setEOLMenuItem[i].setText(keys[i]); 
     760            setEOLMenuItem[i].setImage( Globals.getImage( icon[i] ) ); 
     761            setEOLMenuItem[i].handleEvent(null, DWT.Selection, delegate(Event e) 
     762            { 
     763                MenuItem mi = cast(MenuItem)e.widget; 
     764                EditItem[] eis = cast(EditItem[]) sGUI.editor.getItems; 
     765                foreach( EditItem ei; eis ) 
     766                { 
     767                    switch( mi.getText() ) 
     768                    { 
     769                        case "CRLF": 
     770                            ei.scintilla.setEOLMode( 0 ); 
     771                            break; 
     772                        case "LF": 
     773                            ei.scintilla.setEOLMode( 2 ); 
     774                            break; 
     775                        case "CR": 
     776                            ei.scintilla.setEOLMode( 1 ); 
     777                        break; 
     778                    }                    
     779                } 
     780            });          
     781        } 
     782 
     783        setEOLMenuItem[0].setSelection( true ); 
     784         
     785        return menu; 
     786    }    
     787 
     788    protected Menu EOLMenu(MenuItem item) 
     789    { 
     790        char[][] keys = ["CRLF / WINDOWS", "CR / MAC", "LF / UNIX"]; 
     791        char[][] icon = [ "windows", "mac", "linux" ]; 
     792        Menu menu = new Menu(item); 
     793        int i = 0; 
     794        foreach(char[] name; keys) 
     795        { 
     796            MenuItem mi = new MenuItem(menu, DWT.PUSH); 
     797            mi.setText(name); 
     798            mi.setImage( Globals.getImage( icon[i++] ) ); 
     799            mi.handleEvent(null, DWT.Selection, delegate(Event e) 
     800            { 
     801                MenuItem mi = cast(MenuItem)e.widget; 
     802                EditItem ei = sGUI.editor.getSelectedEditItemHSU(); 
     803 
     804                if( ei !is null ) 
     805                { 
     806                    char[] text = mi.getText(); 
     807 
     808                    switch( text ) 
     809                    { 
     810                        case "CRLF / WINDOWS": 
     811                            ei.scintilla.convertEOLs( 0 ); 
     812                            break; 
     813 
     814                        case "LF / UNIX": 
     815                            ei.scintilla.convertEOLs( 2 ); 
     816                            break; 
     817 
     818                        case "CR / MAC": 
     819                            ei.scintilla.convertEOLs( 1 ); 
     820 
     821                        default: 
     822                    } 
     823                } 
     824            }); 
     825        } 
     826        return menu; 
     827    }    
    691828 
    692829    protected Menu RegisterMenu(MenuItem item) 
  • trunk/current/poseidon/poseidon/controller/outline.d

    r276 r278  
    166166                    tItem.setData( t ); 
    167167                    treeItems ~= tItem; 
    168                     /* 
    169                     scope font = new Font( tree.getDisplay(), Editor.settings._setting.outputStyle.font, Editor.settings._setting.outputStyle.size, DWT.NORMAL ); 
    170                     tItem.setFont( font ); 
    171                     */ 
    172168                }else 
    173169                { 
     
    175171                    tItem.setData( t ); 
    176172                    treeItems ~= tItem; 
    177                     /* 
    178                     scope font = new Font( tree.getDisplay(), Editor.settings._setting.outputStyle.font, Editor.settings._setting.outputStyle.size, DWT.NORMAL ); 
    179                     tItem.setFont( font ); 
    180                     */ 
    181173                } 
    182174 
     
    263255        } 
    264256    } 
    265  
    266  
    267      
    268257 
    269258    /*** 
     
    985974    } 
    986975 
    987     /* 
    988     private void resetImageCombo() 
    989     { 
    990         if( sAutoComplete.fileParser is null ) 
    991         { 
    992             removeAllImageComboItems(); 
    993             quickFind.select( -1 ); 
    994             quickFind.setEnabled( false ); 
    995         } 
    996         else 
    997         { 
    998             removeAllImageComboItems(); 
    999             quickFind.setEnabled( true ); 
    1000             onCheckImageComboModify(); 
    1001         } 
    1002     } 
    1003     */ 
    1004  
    1005976    private void resetImageCombo( EditItem ei ) 
    1006977    { 
     
    11031074            return true;  
    11041075         
    1105  
    11061076        return bFound; 
    1107         /+ 
    1108         sGUI.outputPanel.appendLine( "Items = " ~ std.string.toString( treeItems.length ) ~ "   " ~ 
    1109         "searchIndex = " ~ std.string.toString( searchIndex ) );+/ 
    1110          
    11111077    } 
    11121078} 
  • trunk/current/poseidon/poseidon/controller/toolbarmanager.d

    r221 r278  
    460460             
    461461            sGUI.menuMan.encodeItem.setEnabled( haveDoc ); 
     462            sGUI.menuMan.EOLItem.setEnabled( haveDoc ); 
    462463        }    
    463464    } 
  • trunk/current/poseidon/poseidon/globals.d

    r276 r278  
    242242        images["searchfunction"]    = DWTResourceManager.getImage("searchfuncion.gif"); 
    243243        images["compiletarget"]     = DWTResourceManager.getImage("target.gif"); 
     244 
     245        images["windows"]       = DWTResourceManager.getImage("windows.gif"); 
     246        images["mac"]           = DWTResourceManager.getImage("mac.gif"); 
     247        images["linux"]         = DWTResourceManager.getImage("linux.gif"); 
     248        images["topic"]         = DWTResourceManager.getImage("topic.gif"); 
    244249 
    245250        // DEBUG 
  • trunk/current/poseidon/poseidon/style/dstyle.d

    r277 r278  
    21202120            try 
    21212121            { 
    2122                 //sGUI.outputPanel.appendLine( "Globals.updateParseLiveFull" ); 
     2122                int     currentPos = sc.getCurrentPos(); 
     2123                char    ch = sc.getCharAt( currentPos ); 
     2124                int     textLength = sc.getTextLength(); 
     2125                bool    bGo; 
     2126                char[]  text; 
     2127 
     2128                if( currentPos > 0 ) // 如果前一字是; 馬上分析 
     2129                { 
     2130                    if( sc.getCharAt( currentPos -1 ) == ';' ) bGo = true; 
     2131                } 
    21232132                 
    2124                 //CAnalyzerTreeNode headNode = searchFunctionHead( sc ); 
     2133                if( !bGo ) // 移動到非空白字元結尾 
     2134                { 
     2135                    while( cast(int) ch > 32 ) 
     2136                    { 
     2137                        currentPos ++; 
     2138                        if( currentPos >= textLength ) 
     2139                        { 
     2140                            bGo = true; 
     2141                            break; 
     2142                        } 
     2143                        ch = sc.getCharAt( currentPos ); 
     2144                    } 
     2145                } 
     2146 
     2147                if( !bGo ) // 如果前一字是; 馬上分析 
     2148                { 
     2149                    if( sc.getCharAt( currentPos -1 ) == ';' ) bGo = true; 
     2150                } 
     2151 
     2152                if( !bGo ) // 如果分行後一字是{ 馬上分析 
     2153                { 
     2154                    text ~= ch; 
     2155                     
     2156                    while( cast(int) ch < 33 ) 
     2157                    { 
     2158                        currentPos ++; 
     2159                        if( currentPos >= textLength ) 
     2160                        { 
     2161                            bGo = true; 
     2162                            break; 
     2163                        } 
     2164                        ch = sc.getCharAt( currentPos ); 
     2165                        if( ch == '{' ) bGo = true; 
     2166                        text ~= ch; 
     2167                    } 
     2168                } 
     2169 
     2170                 
     2171                if( !bGo ) 
     2172                { 
     2173                    if( std.string.find( text, "\n" ) < 0 ) bGo = true; 
     2174                } 
     2175 
     2176                if( !bGo ) return; 
     2177 
    21252178                char[] codeSource; 
    21262179                CAnalyzerTreeNode headNode = searchFunctionHeadAndText( sc, codeSource ); 
     
    21552208                    if( tempBlockParser is null ) return; 
    21562209 
    2157                     //sGUI.outputPanel.appendLine( codeSource ); 
    2158                      
    21592210                    //remove D_MAINROOT 
    21602211                    if( tempBlockParser.getLeafCount == 1 ) 
     
    21622213                    else 
    21632214                        return; 
    2164                 } 
    2165  
    2166                 //sGUI.outputPanel.appendLine( "function is:" ~ blockParser.identifier ); 
    2167  
    2168                 /* 
    2169                 if( blockParser !is null )  
    2170                     sGUI.outputPanel.appendLine( "GET!!!!" ); 
    2171                 else 
    2172                 { 
    2173                     sGUI.outputPanel.appendLine( "NOT GET!!!!" ); 
    2174                     return; 
    2175                 } 
    2176                 */ 
     2215                     
     2216                    //sGUI.outputPanel.appendLine( dTypeToChars( blockParser.DType ) ~ " " ~ blockParser.identifier ~ "(" ~ toString( blockParser.lineNumber ) ~ ")" ); 
     2217 
     2218                    blockParser.increaseLineNumber( 1, headNode.lineNumber - 1 ); 
     2219 
     2220                    //sGUI.outputPanel.appendLine( dTypeToChars( blockParser.DType ) ~ " " ~ blockParser.identifier ~ "(" ~ toString( blockParser.lineNumber ) ~ ")" ); 
     2221                } 
    21772222 
    21782223                CAnalyzerTreeNode       fatherNode = headNode.getRoot; 
     
    21902235                } 
    21912236 
    2192                 if( index > -1 ) fatherNode.replaceLeaf( blockParser, index ); //else sGUI.outputPanel.appendLine( "WRONG!" );               
    2193                 /+ 
    2194                 CAnalyzerTreeNode[] nodes = sAutoComplete.lookAnalyzerTree( headNode.identifier, D_UDTS | D_FUNCTION, sAutoComplete.fileParser ); 
    2195                 if( nodes.length ) 
    2196                 { 
    2197                     //sGUI.outputPanel.appendLine( "GET HEAD!" ); 
    2198                     CAnalyzerTreeNode fatherNode = nodes[0].getRoot; 
    2199                     /* 
    2200                     foreach( CAnalyzerTreeNode t; fatherNode.getAllLeaf ) 
    2201                         sGUI.outputPanel.appendLine( t.identifier ); 
    2202                     */ 
    2203  
    2204                     CAnalyzerTreeNode[]     tempChildren; 
    2205  
    2206                     int index = -1; 
    2207                      
    2208                     for( int i = 0; i < fatherNode.getLeafCount; ++ i ) 
    2209                     { 
    2210                         if( fatherNode.getLeaf( i ) == nodes[0] ) 
    2211                         { 
    2212                             index = i; 
    2213                             break; 
    2214                         } 
    2215                     } 
    2216  
    2217                     if( index > -1 ) fatherNode.replaceLeaf( blockParser, index );else sGUI.outputPanel.appendLine( "WRONG!" ); 
    2218                 } 
    2219                 +/ 
     2237                if( index > -1 ) 
     2238                { 
     2239                    fatherNode.replaceLeaf( blockParser, index ); //else sGUI.outputPanel.appendLine( "WRONG!" ); 
     2240                    //sGUI.outline.singleFileToProjectFile( sGUI.editor.getSelectedEditItemHSU() ); 
     2241                } 
    22202242            } 
    22212243            catch 
    22222244            { 
     2245                 
    22232246            } 
    22242247 
     
    29132936                    case 1: 
    29142937                        char[] finalWord = splitSemiWord[length - 1]; 
     2938                        //sGUI.outputPanel.appendLine( "finalWord: " ~ finalWord ); 
    29152939                        if( finalWord != "if" && finalWord != "while" && finalWord != "for" && finalWord != "foreach" 
    29162940                                && finalWord != "else" && finalWord != "version" && finalWord != "debug"  
    29172941                                && finalWord != "catch" && finalWord != "switch" && finalWord != "with"  
    2918                                 && finalWord != "synchronized"
     2942                                && finalWord != "synchronized" && finalWord != "delegate"
    29192943                        { 
    29202944                            // 過載運算子及建構子 
     
    33923416                    case 1: 
    33933417                        char[] finalWord = splitSemiWord[length - 1]; 
     3418                        //sGUI.outputPanel.appendLine( "@finalWord: " ~ finalWord ); 
    33943419                        if( finalWord != "if" && finalWord != "while" && finalWord != "for" && finalWord != "foreach" 
    33953420                                && finalWord != "else" && finalWord != "version" && finalWord != "debug"