Changeset a046a0c50b4c83eaa0a435fb80e302aaf11bacc2

Show
Ignore:
Timestamp:
01/06/07 23:44:58 (6 years ago)
Author:
Philipp Kern <phil@…>
Parents:
0c7664e2841ae18fc47cb025ca4721a561ecdc99
Children:
f12139424c8680cd7a834d6fb2297156c9a582dd
git-committer:
Philipp Kern <phil@0x539.de> / 2007-01-06T22:44:58Z+0000
Message:

[project @ Column returns the real column of the text not just the nth character]

Original author: Armin Burgmeier <armin@…>
Date: 2005-07-26 17:25:00+00:00

Files:
2 modified

Legend:

Unmodified
Added
Removed
  • inc/document.hpp

    rf764263 ra046a0c  
    145145        /** Obby signal handlers. 
    146146         */ 
    147         void on_obby_insert(const obby::insert_record& record); 
    148         void on_obby_delete(const obby::delete_record& record); 
     147        void on_obby_insert_before(const obby::insert_record& record); 
     148        void on_obby_insert_after(const obby::insert_record& record); 
     149        void on_obby_delete_before(const obby::delete_record& record); 
     150        void on_obby_delete_after(const obby::delete_record& record); 
    149151 
    150152        void on_obby_change_before(); 
  • src/document.cpp

    rf764263 ra046a0c  
    169169        row = iter.get_line(); 
    170170        col = iter.get_line_offset(); 
     171 
     172        // Add tab characters to col 
     173        if(m_doc.get_document() && is_subscribed() ) 
     174        { 
     175                const std::string& line = m_doc.get_document()->get_line(row); 
     176                unsigned int tabs = m_preferences.editor.tab_width; 
     177 
     178                // col chars 
     179                std::string::size_type chars = col; col = 0; 
     180                for(std::string::size_type i = 0; i < chars; ++ i) 
     181                { 
     182                        unsigned int width = 1; 
     183                        if(line[i] == '\t') 
     184                        { 
     185                                width = (tabs - col % tabs) % tabs; 
     186                                if(width == 0) width = tabs; 
     187                        } 
     188                        col += width; 
     189                } 
     190        } 
    171191} 
    172192 
     
    206226} 
    207227 
     228bool Gobby::Document::is_subscribed() const 
     229{ 
     230        return m_subscribed; 
     231} 
     232 
    208233bool Gobby::Document::get_modified() const 
    209234{ 
     
    259284} 
    260285 
    261 void Gobby::Document::on_obby_insert(const obby::insert_record& record) 
     286void Gobby::Document::on_obby_insert_before(const obby::insert_record& record) 
    262287{ 
    263288        if(m_editing) return; 
     
    289314} 
    290315 
    291 void Gobby::Document::on_obby_delete(const obby::delete_record& record) 
     316void Gobby::Document::on_obby_insert_after(const obby::insert_record& record) 
     317{ 
     318} 
     319 
     320void Gobby::Document::on_obby_delete_before(const obby::delete_record& record) 
    292321{ 
    293322        if(m_editing) return; 
     
    305334                buffer->get_iter_at_line_index(erow, ecol) 
    306335        ); 
     336 
    307337        m_editing = false; 
    308338} 
    309339 
     340void Gobby::Document::on_obby_delete_after(const obby::delete_record& record) 
     341{ 
     342} 
     343 
    310344void Gobby::Document::on_obby_change_before() 
    311345{ 
     
    314348void Gobby::Document::on_obby_change_after() 
    315349{ 
    316         // Document changed 
     350        if(m_editing) return; 
     351 
     352        // Content may have changed / cursor have been moved 
     353        m_signal_cursor_moved.emit(); 
    317354        m_signal_content_changed.emit(); 
    318         // Cursor may have moved 
    319         m_signal_cursor_moved.emit(); 
    320355} 
    321356 
     
    345380        // Install signal handlers 
    346381        doc.insert_event().before().connect( 
    347                 sigc::mem_fun(*this, &Document::on_obby_insert) ); 
     382                sigc::mem_fun(*this, &Document::on_obby_insert_before) ); 
     383        doc.insert_event().after().connect( 
     384                sigc::mem_fun(*this, &Document::on_obby_insert_after) ); 
    348385        doc.delete_event().before().connect( 
    349                 sigc::mem_fun(*this, &Document::on_obby_delete) ); 
     386                sigc::mem_fun(*this, &Document::on_obby_delete_before) ); 
     387        doc.delete_event().after().connect( 
     388                sigc::mem_fun(*this, &Document::on_obby_delete_after) ); 
    350389        doc.change_event().before().connect( 
    351390                sigc::mem_fun(*this, &Document::on_obby_change_before) ); 
     
    691730        set_margin(m_preferences.view.margin_pos); 
    692731        get_buffer()->set_check_brackets(m_preferences.view.bracket_highlight); 
     732 
     733        // Cursor position may have changed because tab width may have changed 
     734        m_signal_cursor_moved.emit(); 
    693735} 
    694736