Changeset 71db57df5f3df49a8805a14783f6c09f30c2350b

Show
Ignore:
Timestamp:
11/05/08 23:53:19 (5 years ago)
Author:
Armin Burgmeier <armin@…>
Parents:
3841c97f73b9283df816e998739bd742cffce0b5
Children:
2589612557ec8e5888f7b574a3a08fe748dc11e5
git-committer:
Armin Burgmeier <armin@arbur.net> / 2008-11-05T23:53:19Z+0100
Message:

Added a hack to re-enable scrolling to position of undo/redo

2008-11-05 Armin Burgmeier <armin@…>

  • code/commands/edit-commands.cpp: Added a (hopefully) temporary hack to set the cursor position to the place where a Undo/Redo has occurred. This stopped to work with the latest changes in libinfinity (which in turn fix other caret stuff, such as no longer moving the caret around on block indent/unindent, or allowing to paste text over a selected area). This can be properly implemented as soon as libinfinity supports caret-aware requests.
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r3841c97 r71db57d  
     12008-11-05  Armin Burgmeier  <armin@arbur.net> 
     2 
     3        * code/commands/edit-commands.cpp: Added a (hopefully) temporary hack 
     4        to set the cursor position to the place where a Undo/Redo has 
     5        occurred. This stopped to work with the latest changes in libinfinity 
     6        (which in turn fix other caret stuff, such as no longer moving the  
     7        caret around on block indent/unindent, or allowing to paste text 
     8        over a selected area). This can be properly implemented as soon as 
     9        libinfinity supports caret-aware requests. 
     10 
    1112008-10-18  Armin Burgmeier  <armin@arbur.net> 
    212 
  • code/commands/edit-commands.cpp

    r4d4ee96 r71db57d  
    300300} 
    301301 
     302// TODO: The following is basically a hack to set the cursor to the position 
     303// where a Undo/Redo has happened. This can be properly fixed as soon as 
     304// libinfinity supports caret-aware requests, by generating undo-caret and 
     305// redo-caret requests. 
     306namespace { 
     307        bool check_set = false; 
     308        GtkTextIter check; 
     309 
     310        void recaret_i(GtkTextBuffer* buffer, 
     311                       GtkTextIter* location, 
     312                       gchar* text, 
     313                       gint len, 
     314                       gpointer user_data) 
     315        { 
     316                check = *location; 
     317                check_set = true; 
     318        } 
     319 
     320        void recaret_e(GtkTextBuffer* buffer, 
     321                       GtkTextIter* start, 
     322                       GtkTextIter* end, 
     323                       gpointer user_data) 
     324        { 
     325                check = *start; 
     326                check_set = true; 
     327        } 
     328} 
     329 
    302330void Gobby::EditCommands::on_undo() 
    303331{ 
    304332        g_assert(m_current_document != NULL); 
     333 
     334        gulong i_ = g_signal_connect_after(m_current_document->get_text_buffer(), "insert-text", G_CALLBACK(recaret_i), NULL); 
     335        gulong e_ = g_signal_connect_after(m_current_document->get_text_buffer(), "delete-range", G_CALLBACK(recaret_e), NULL); 
    305336 
    306337        inf_adopted_session_undo( 
     
    309340        ); 
    310341 
     342        g_signal_handler_disconnect(m_current_document->get_text_buffer(), i_); 
     343        g_signal_handler_disconnect(m_current_document->get_text_buffer(), e_); 
     344 
     345        if(check_set) 
     346                gtk_text_buffer_select_range(GTK_TEXT_BUFFER(m_current_document->get_text_buffer()), &check, &check); 
     347        check_set = false; 
    311348        m_current_document->scroll_to_cursor_position(0.0); 
    312349} 
     
    315352{ 
    316353        g_assert(m_current_document != NULL); 
     354 
     355        gulong i_ = g_signal_connect_after(m_current_document->get_text_buffer(), "insert-text", G_CALLBACK(recaret_i), NULL); 
     356        gulong e_ = g_signal_connect_after(m_current_document->get_text_buffer(), "delete-range", G_CALLBACK(recaret_e), NULL); 
    317357 
    318358        inf_adopted_session_redo( 
     
    321361        ); 
    322362 
     363        g_signal_handler_disconnect(m_current_document->get_text_buffer(), i_); 
     364        g_signal_handler_disconnect(m_current_document->get_text_buffer(), e_); 
     365 
     366        if(check_set) 
     367                gtk_text_buffer_select_range(GTK_TEXT_BUFFER(m_current_document->get_text_buffer()), &check, &check); 
     368        check_set = false; 
    323369        m_current_document->scroll_to_cursor_position(0.0); 
    324370}