Changeset 254

Show
Ignore:
Timestamp:
06/07/07 02:16:42 (1 year ago)
Author:
Ant
Message:

better fixed gotLine/Pos with -sv

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/leds/CodeView.d

    r253 r254  
    161161    String[int] errors; 
    162162 
    163     bit autoIndent = true; 
    164     bit autoDocComments = true; 
    165  
    166     bit unitCompile = true; 
     163    bool autoIndent = true; 
     164    bool autoDocComments = true; 
     165 
     166    bool unitCompile = true; 
    167167 
    168168    Menu popupMenu; 
    169169     
    170170    long modifiedTime; 
    171     bit needsSave = false; 
     171    bool needsSave = false; 
    172172     
    173173    int[] errorLines; 
     
    178178     
    179179     
    180     bit userAllowClose = false; 
     180    bool userAllowClose = false; 
    181181     
    182182    String braceCharacters; 
     
    349349    } 
    350350 
    351     bit asking = false; 
     351    bool asking = false; 
    352352     
    353353    /** 
     
    357357     * @return  
    358358     */ 
    359     bit exposeCallback(GdkEventExpose* event, Widget widget) 
     359    bool exposeCallback(GdkEventExpose* event, Widget widget) 
    360360    { 
    361361        //setBrowserView(); 
     
    390390        bugLines.length = 0; 
    391391        int lineCount = 0; 
    392         bit newLine = true; 
     392        bool newLine = true; 
    393393        int todoMatch = 0; 
    394394        int bugMatch = 0; 
    395395        /** if the previous char is a separator */ 
    396         bit prevSep = true; 
     396        bool prevSep = true; 
    397397        // in one pass count lines and find 'todo' and 'bug' 
    398398        foreach(char c ; text.toString()) 
     
    518518     * determins if a close button shoud be visible 
    519519     */ 
    520     bit allowCloseButton() 
     520    bool allowCloseButton() 
    521521    { 
    522522        return true; 
    523523    } 
    524524 
    525     public void reloadFile(bit askPermission) 
    526     { 
    527         bit reload = true; 
     525    public void reloadFile(bool askPermission) 
     526    { 
     527        bool reload = true; 
    528528        if ( askPermission ) 
    529529        { 
     
    553553     * @return true if sucesseful 
    554554     */ 
    555     bit loadFile(String fileName) 
     555    bool loadFile(String fileName) 
    556556    in 
    557557    { 
     
    563563        this.fileName = fileName.dup; 
    564564        String input; 
    565         bit fileOK = true; 
     565        bool fileOK = true; 
    566566        try 
    567567        { 
     
    597597    } 
    598598 
    599     bit needReloadFile(String fileName) 
    600     { 
    601         bit needReload = false; 
     599    bool needReloadFile(String fileName) 
     600    { 
     601        bool needReload = false; 
    602602        if ( modifiedTime != getFileMTime(fileName) ) 
    603603        { 
     
    615615     * and if not ask the user to confirm overwrite. 
    616616     * @param fileName  
    617      * @return bit if the time is the same or the user authorized modification 
    618      */ 
    619     bit confirmModifyFile(String fileName) 
    620     { 
    621         bit okToModify = true; 
     617     * @return bool if the time is the same or the user authorized modification 
     618     */ 
     619    bool confirmModifyFile(String fileName) 
     620    { 
     621        bool okToModify = true; 
    622622        if ( modifiedTime != getFileMTime(fileName) ) 
    623623        { 
     
    635635     * @return true if the user confirmed that a new file is to be created 
    636636     */ 
    637     bit newFile(String fileName) 
     637    bool newFile(String fileName) 
    638638    { 
    639639        return true; 
     
    709709     * @return unitCompile value 
    710710     */ 
    711     bit getUnitCompile()  
     711    bool getUnitCompile()  
    712712    { 
    713713        return unitCompile; 
     
    753753     * @return true if the text was modified 
    754754     */ 
    755     bit getModified() 
     755    bool getModified() 
    756756    { 
    757757        return codeEdit.getModified(); 
     
    762762     * @return true if this instance should be loaded with a new file 
    763763     */ 
    764     bit getEmpty() 
     764    bool getEmpty() 
    765765    { 
    766766        return !getModified() && (fileName is null); 
     
    771771     * @return true if the buffer can be closed 
    772772     */ 
    773     bit allowClose(bit askUser) 
     773    bool allowClose(bool askUser) 
    774774    { 
    775775        writefln("CodeView.allowClose 1"); 
    776         bit allow = true; 
     776        bool allow = true; 
    777777        if ( !userAllowClose && getModified() ) 
    778778        { 
     
    802802     * @return true if sucesseful 
    803803     */ 
    804     bit saveFile() 
     804    bool saveFile() 
    805805    { 
    806806        if ( !confirmModifyFile(fileName) ) 
     
    11711171     * @return true if sucesseful 
    11721172     */ 
    1173     bit saveFile(String fileName) 
     1173    bool saveFile(String fileName) 
    11741174    in 
    11751175    { 
     
    12001200     * @return true if the action was processed (even if the execution failled) 
    12011201     */ 
    1202     public bit execAction(String action) 
    1203     { 
    1204         bit processed = true; 
     1202    public bool execAction(String action) 
     1203    { 
     1204        bool processed = true; 
    12051205        switch(action.toString()) 
    12061206        { 
     
    12611261    } 
    12621262     
    1263     void fastFindText(bit backwards) 
     1263    void fastFindText(bool backwards) 
    12641264    { 
    12651265        String selected = getSelected(); 
     
    12761276    } 
    12771277     
    1278     void findText(bit backwards) 
     1278    void findText(bool backwards) 
    12791279    { 
    12801280        findText(workspace.getFindText(),backwards); 
     
    13011301     * find for a temporary text string 
    13021302     */ 
    1303     void findText(char[] findStr, bit backwards) 
     1303    void findText(char[] findStr, bool backwards) 
    13041304    { 
    13051305        findText(new String(findStr), backwards); 
    13061306    } 
    1307     void findText(String findStr, bit backwards) 
     1307    void findText(String findStr, bool backwards) 
    13081308    { 
    13091309        if ( findStr is null || findStr.length == 0 ) 
     
    13871387     * // FIXME - should be in LanguageD.. 
    13881388     */ 
    1389     bit gotoElement(String elementName, int lineNumber) 
     1389    bool gotoElement(String elementName, int lineNumber) 
    13901390    in 
    13911391    { 
     
    14371437    } 
    14381438     
    1439     public int getPosition(char[] str, bit all, bit backwards) 
     1439    public int getPosition(char[] str, bool all, bool backwards) 
    14401440    { 
    14411441        return getPosition(new String(str), all, backwards); 
    14421442    } 
    1443     public int getPosition(String str, bit all, bit backwards) 
     1443    public int getPosition(String str, bool all, bool backwards) 
    14441444    { 
    14451445        int pos = codeEdit.getCurrentPos(); 
     
    14921492     * @return  
    14931493     */ 
    1494     public bit getPair(char[] brace, int position, inout int start, inout int end) 
     1494    public bool getPair(char[] brace, int position, inout int start, inout int end) 
    14951495    { 
    14961496        return getPair(new String(brace), position, start, end); 
    14971497    } 
    1498     public bit getPair(String brace, int position, inout int start, inout int end) 
     1498    public bool getPair(String brace, int position, inout int start, inout int end) 
    14991499    { 
    15001500        int pos = codeEdit.getCurrentPos(); 
     
    15551555                int cl= codeEdit.getCurrLine(); 
    15561556                int pos = codeEdit.getCurrentPos(); 
    1557                 this.exposeLine(cl, true); 
    1558                 codeEdit.gotoPos(pos); 
     1557                //this.exposeLine(cl, false); 
     1558                //codeEdit.gotoPos(pos); 
    15591559            } 
    15601560        } 
     
    19461946        String replace; 
    19471947        String[] tokens = sel.split(); 
    1948         bit newLine = true; 
     1948        bool newLine = true; 
    19491949        foreach ( String token ; tokens ) 
    19501950        { 
     
    21712171 
    21722172    /** 
    2173      * If found pastes the user short cut into the buffer 
    2174      * @return true if the shortcur is defined and the buffer was changed 
    2175      */ 
    2176     bit userShortCuts() 
    2177     { 
    2178         bit processed = false; 
     2173     * If found pastes the user shortcut into the buffer 
     2174     * @return true if the shortcut is defined and the buffer was changed 
     2175     */ 
     2176    bool userShortCuts() 
     2177    { 
     2178        bool processed = false; 
    21792179        int pos = codeEdit.getCurrentPos(); 
    21802180        String stringPrint = new String(); 
     
    22502250    } 
    22512251     
    2252     bit operatorOverload() 
     2252    bool operatorOverload() 
    22532253    { 
    22542254        String[] list; 
     
    23652365                            if ( pre[i+1..i+7] == "cursor" ) 
    23662366                            { 
    2367                                 cursorPos = pos.length
     2367                                cursorPos = pos.length-1
    23682368                                i += 6; 
    23692369                            } 
     
    25272527     * @return true if the position is inside a doc comment 
    25282528     */ 
    2529     bit isDocComment(int position, out int startComment, out int endComment) 
    2530     { 
    2531 //      bit docComment = false; 
     2529    bool isDocComment(int position, out int startComment, out int endComment) 
     2530    { 
     2531//      bool docComment = false; 
    25322532//      startComment = codeEdit.find("/**", 0, true); 
    25332533//      if ( startComment >= 0 ) 
     
    25592559        startComment = position; 
    25602560         
    2561         bit found = false; 
    2562         bit start = false; 
    2563         bit end = false; 
     2561        bool found = false; 
     2562        bool start = false; 
     2563        bool end = false; 
    25642564         
    25652565        char c = '*'; 
     
    26442644     
    26452645 
    2646     bit isDocComment(int position) 
     2646    bool isDocComment(int position) 
    26472647    { 
    26482648        int start; 
     
    26512651    } 
    26522652     
    2653     bit formatComment(int start, int end, int maxLine) 
    2654     { 
    2655         bit formatted = false; 
     2653    bool formatComment(int start, int end, int maxLine) 
     2654    { 
     2655        bool formatted = false; 
    26562656        int lineStart = codeEdit.positionFromLine(codeEdit.lineFromPosition(start)); 
    26572657        codeEdit.setCurrentPos(lineStart); 
     
    26792679     * \todo the text is processed correctly but never reaches codeEdit. 
    26802680     */ 
    2681     public bit textInserted(int position, int length, int linesAdded) 
    2682     { 
    2683         bit processed = false; 
     2681    public bool textInserted(int position, int length, int linesAdded) 
     2682    { 
     2683        bool processed = false; 
    26842684//      if ( position > 0 ) 
    26852685//      { 
     
    27092709    } 
    27102710     
    2711     bit inChange = false; 
     2711    bool inChange = false; 
    27122712     
    27132713    void setupNotifications() 
     
    27222722    } 
    27232723     
    2724     bit editAutoCSelection(int pos , String s) 
     2724    bool editAutoCSelection(int pos , String s) 
    27252725    { 
    27262726         
     
    27352735    } 
    27362736     
    2737     bit needSemiColon; 
    2738      
    2739     bit editModified(int type, String text) 
     2737    bool needSemiColon; 
     2738     
     2739    bool editModified(int type, String text) 
    27402740    { 
    27412741        switch ( type ) 
     
    28062806     * @return  
    28072807     */ 
    2808     bit editCharAdded(int ch) 
     2808    bool editCharAdded(int ch) 
    28092809    { 
    28102810        //printf("CodeView.codeEditCallback SCN_CHARADDED\n" ); 
     
    28432843             
    28442844            case ';': 
     2845                writefln("editCharAdded 1"); 
    28452846                if ( Leds.leds.getPropValue("smartSemiColon",true) ) 
    28462847                { 
     2848                writefln("editCharAdded 2"); 
    28472849                    if ( smartSemiColonLine != codeEdit.getCurrLine() ) 
    28482850                    { 
     2851                writefln("editCharAdded 3"); 
    28492852                        smartSemiColonLine = codeEdit.getCurrLine(); 
    28502853                         
     
    28522855                        if ( ! line.endsWith(";") ) 
    28532856                        { 
     2857                writefln("editCharAdded 4"); 
    28542858                            codeEdit.deleteBack(); 
    28552859                            codeEdit.lineEnd(); 
     
    28842888     * @return  
    28852889     */ 
    2886     bit editKey(int ch, int modifiers) 
     2890    bool editKey(int ch, int modifiers) 
    28872891    { 
    28882892        //printf("CodeView.editKey SCN_KEY %d -- %X\n", ch,ch ); 
     
    29072911     * @return  
    29082912     */ 
    2909     bit editMarginClick(int margin, int position) 
     2913    bool editMarginClick(int margin, int position) 
    29102914    { 
    29112915        switch ( margin ) 
     
    29382942        int lineNumber = codeEdit.lineFromPosition(position); 
    29392943  
    2940         bit found = false; 
     2944        bool found = false; 
    29412945        int i = 0; 
    29422946        int[] keys = errors.keys; 
     
    29822986     * @return  
    29832987     */ 
    2984     bit editModified() 
     2988    bool editModified() 
    29852989    { 
    29862990        //printf("CodeView.codeEditCallback SCN_MODIFIED\n" ); 
     
    29993003     * @return  
    30003004     */ 
    3001     bit editUserListSelection(int ch, int code) 
     3005    bool editUserListSelection(int ch, int code) 
    30023006    { 
    30033007        printf("seems this never gets called============================================\n"); 
     
    30233027     * @return  
    30243028     */ 
    3025     bit processControlKey(char key) 
     3029    bool processControlKey(char key) 
    30263030    { 
    30273031        debug(notify)printf("CodeView.processControlKey key = >>>%c<<<\n", key); 
    3028         bit processed = true; 
     3032        bool processed = true; 
    30293033        switch ( Leds.leds.getCommandFromKey(key) ) 
    30303034        { 
    30313035            case CodeCommand.SAVE: workspace.saveCurrent();  break; 
    30323036            case CodeCommand.SAVE_AND_MAKE: 
    3033                 bit oldUnitCompile = unitCompile; 
     3037                bool oldUnitCompile = unitCompile; 
    30343038                unitCompile = false; 
    30353039                workspace.saveCurrent(); 
  • trunk/src/leds/SourceViewEdit.d

    r253 r254  
    1919module leds.SourceViewEdit; 
    2020 
     21debug = flow; 
     22 
    2123//version(linux) 
    22 //{ 
     24//{; 
    2325 
    2426private import leds.CodeEdit; 
     
    174176     * @return  
    175177     */ 
    176     void addOnUpdateUI(bit delegate() dlg) 
     178    void addOnUpdateUI(bool delegate() dlg) 
    177179    { 
    178180        debug(flow)writefln("SourceViewEdit.addOnUpdateUI 1"); 
     
    201203    { 
    202204        debug(flow)writefln("SourceViewEdit.callUIListener"); 
    203         foreach(bit delegate() dlg; updateUIListeners) 
     205        foreach(bool delegate() dlg; updateUIListeners) 
    204206        { 
    205207            dlg(); 
    206208        } 
     209 
    207210    } 
    208211     
     
    212215     * @return  
    213216     */ 
    214     void addOnCharAdded(bit delegate(int ch) dlg) 
    215     { 
    216         //writefln("SourceViewEdit.addOnCharAdded 1"); 
     217    void addOnCharAdded(bool delegate(int ch) dlg) 
     218    { 
     219        debug(flow)writefln("SourceViewEdit.addOnCharAdded 1"); 
    217220        if ( ! charAddedSignals ) 
    218221        { 
     
    227230    { 
    228231        debug(flow)writefln("SourceViewEdit.keyPressed "); 
    229         bit processed = false; 
     232        bool processed = false; 
    230233        debug(flow)writefln("SourceViewEdit.keyPressed state = %s", event.state); 
    231234        switch ( event.state ) 
    232235        { 
    233236            case 0: 
    234                 foreach(bit delegate(int ch) dlg ; charAddedListeners) 
     237                foreach(bool delegate(int ch) dlg ; charAddedListeners) 
    235238                { 
    236239                    dlg(event.keyval); 
     
    239242                 
    240243            case 20,21,4, 5: 
    241                 foreach(bit delegate(int ch, int modifiers) dlg ; keyListeners) 
     244                foreach(bool delegate(int ch, int modifiers) dlg ; keyListeners) 
    242245                { 
    243246                    dlg(event.keyval, event.state); 
     
    259262     * @return  
    260263     */ 
    261     void addOnKey(bit delegate(int ch, int modifiers) dlg) 
     264    void addOnKey(bool delegate(int ch, int modifiers) dlg) 
    262265    { 
    263266        if ( ! keySignals ) 
     
    275278     * @return  
    276279     */ 
    277     void addOnMarginClick(bit delegate(int margin, int position) dlg) 
     280    void addOnMarginClick(bool delegate(int margin, int position) dlg) 
    278281    { 
    279282        if ( ! marginClickSignals ) 
     
    289292     * @return  
    290293     */ 
    291     void addOnModified(bit delegate(int, String) dlg) 
     294    void addOnModified(bool delegate(int, String) dlg) 
    292295    { 
    293296        if ( ! modifiedSignals ) 
     
    304307     * @return  
    305308     */ 
    306     void addOnUserListSelection(bit delegate (int ch, int code) dlg) 
     309    void addOnUserListSelection(bool delegate (int ch, int code) dlg) 
    307310    { 
    308311        if ( ! userListSelectionSignals ) 
     
    315318     * see scintilla  
    316319     */ 
    317     void addOnAutoCSelection(bit delegate (int, String) dlg) 
     320    void addOnAutoCSelection(bool delegate (int, String) dlg) 
    318321    { 
    319322 
     
    423426     * @return the position offset or -1 if not found 
    424427     */ 
    425     int find(String findStr, int flags, bit backwards=false) 
    426     { 
    427         bit found = false; 
     428    int find(String findStr, int flags, bool backwards=false) 
     429    { 
     430        bool found = false; 
    428431        insertIter(); 
    429432        TextIter iterStart = new TextIter(); 
     
    452455        if ( found ) 
    453456        { 
     457            view.scrollToIter(iterStart, 0.0, false, 0.0, 0.25); 
     458            //buffer.placeCursor(iterStart); 
     459         
    454460            TextMark mark = buffer.getInsert(); 
    455461            TextMark markSel = buffer.getMark("selection_bound"); 
     462             
     463            writefln("find positions %s %s", iterStart.getOffset(), iterEnd.getOffset()); 
     464             
    456465            buffer.moveMark(mark, iterStart); 
    457466            buffer.moveMark(markSel, iterEnd); 
     
    462471        } 
    463472 
    464         view.scrollToIter(iterStart, 0.0, false, 0.0, 0.0); 
    465          
    466473        return iterStart.getOffset(); 
    467474    } 
     
    470477     * gets the previous occurrence of a String 
    471478     */ 
    472     int lookup(String findStr, bit backwards, int position=-1) 
    473     { 
    474         bit found = false; 
     479    int lookup(String findStr, bool backwards, int position=-1) 
     480    { 
     481        bool found = false; 
    475482        TextIter iterFrom = new TextIter(); 
    476483        if ( position == -1 ) 
     
    10061013     * finds text from the current position 
    10071014     */ 
    1008     int find(char[] findStr, int flags, bit backwards) 
     1015    int find(char[] findStr, int flags, bool backwards) 
    10091016    { 
    10101017        return find(new String(findStr), flags, backwards);