Changeset 8293 for branches

Show
Ignore:
Timestamp:
10/12/11 12:24:52 (6 months ago)
Author:
westram
Message:
  • each cursor remembers the window where its located
    • removed now unneeded parameters from several member functions
Location:
branches/e4fix/EDIT4
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • branches/e4fix/EDIT4/ED4_block.cxx

    r8275 r8293  
    211211        for (CursorPositions::iterator ab = at_base.begin(); ab != at_base.end(); ++ab) { 
    212212            ED4_window *win = ab->first; 
    213             win->cursor.jump_base_pos(win->aww, ab->second, ED4_JUMP_KEEP_VISIBLE); // restore cursor at same base 
     213            win->cursor.jump_base_pos(ab->second, ED4_JUMP_KEEP_VISIBLE); // restore cursor at same base 
    214214             
    215215#if defined(DEBUG) 
  • branches/e4fix/EDIT4/ED4_cursor.cxx

    r8286 r8293  
    300300    x = del_mark; 
    301301 
    302     ED4_window *win = window(); 
    303302    win->world_to_win_coords(&x, &y); 
    304303 
     
    363362 
    364363#define EXPAND_SIZE 0 
    365     if (current_device()->reduceClipBorders(ymin-EXPAND_SIZE, ymax+1+EXPAND_SIZE, xmin-EXPAND_SIZE, xmax+1+EXPAND_SIZE)) { 
     364    if (window()->get_device()->reduceClipBorders(ymin-EXPAND_SIZE, ymax+1+EXPAND_SIZE, xmin-EXPAND_SIZE, xmax+1+EXPAND_SIZE)) { 
    366365        // refresh terminal 
    367366        int old_allowed_to_draw = allowed_to_draw; 
     
    376375 
    377376 
    378 ED4_cursor::ED4_cursor() 
    379 { 
     377ED4_cursor::ED4_cursor(ED4_window *win_) : win(win_) { 
    380378    init(); 
    381379    allowed_to_draw = 1; 
     
    384382    ctype = (ED4_CursorType)(ED4_ROOT->aw_root->awar(ED4_AWAR_CURSOR_TYPE)->read_int()%ED4_CURSOR_TYPES); 
    385383} 
    386 void ED4_cursor::init() // used by ED4_terminal-d-tor 
    387 { 
     384void ED4_cursor::init() { 
     385    // used by ED4_terminal-d-tor 
    388386    owner_of_cursor   = NULL; 
    389387    cursor_abs_x      = 0; 
    390388    screen_position   = 0; 
    391389} 
    392 ED4_cursor::~ED4_cursor() 
    393 { 
     390ED4_cursor::~ED4_cursor() { 
    394391    delete cursor_shape; 
    395392} 
    396393 
    397 ED4_window *ED4_cursor::window() const { 
    398     ED4_window *win; 
    399     for (win=ED4_ROOT->first_window; win; win=win->next) { 
    400         if (&win->cursor==this) { 
    401             break; 
    402         } 
    403     } 
    404     e4_assert(win); 
    405     return win; 
    406 } 
    407  
    408 int ED4_cursor::get_sequence_pos() const 
    409 { 
     394int ED4_cursor::get_sequence_pos() const { 
    410395    ED4_remap *remap = ED4_ROOT->root_group_man->remap(); 
    411396    size_t max_scrpos = remap->get_max_screen_pos(); 
     
    437422        if (terminal) { 
    438423            if (seq_pos == -1) seq_pos = cursor->get_sequence_pos(); 
    439             cursor->set_to_terminal(current_aww(), terminal, seq_pos, jump_type); 
     424            cursor->set_to_terminal(terminal, seq_pos, jump_type); 
    440425            return true; 
    441426        } 
     
    825810void ED4_cursor::updateAwars() 
    826811{ 
    827     AW_root     *aw_root = ED4_ROOT->aw_root; 
    828     ED4_window  *win = current_ed4w(); 
    829     int         seq_pos = get_sequence_pos(); 
     812    AW_root *aw_root = ED4_ROOT->aw_root; 
     813    int      seq_pos = get_sequence_pos(); 
    830814 
    831815    if (ED4_update_global_cursor_awars_allowed) { 
     
    947931    return cursor_abs_x - coords->window_left_clip_point; 
    948932} 
    949 void ED4_cursor::set_screen_relative_pos(AW_window *aww, int scroll_to_relpos) { 
     933void ED4_cursor::set_screen_relative_pos(int scroll_to_relpos) { 
    950934    int curr_rel_pos  = get_screen_relative_pos(); 
    951935    int scroll_amount = curr_rel_pos-scroll_to_relpos; 
     
    955939 
    956940    if (scroll_amount != 0) { 
     941        AW_window *aww = window()->aww; 
    957942        aww->set_horizontal_scrollbar_position(aww->slider_pos_horizontal + scroll_amount); 
    958943#if defined(TRACE_JUMPS) 
     
    964949 
    965950 
    966 void ED4_cursor::jump_screen_pos(AW_window *aww, int screen_pos, ED4_CursorJumpType jump_type) { 
     951void ED4_cursor::jump_screen_pos(int screen_pos, ED4_CursorJumpType jump_type) { 
    967952    if (!owner_of_cursor) { 
    968953        aw_message("First you have to place the cursor"); 
     
    984969 
    985970    ED4_terminal *term = owner_of_cursor->to_terminal(); 
    986     term->scroll_into_view(aww); // correct y-position of terminal 
     971    ED4_window   *ed4w = window(); 
     972 
     973    term->scroll_into_view(ed4w); // correct y-position of terminal 
    987974 
    988975    int cursor_diff = screen_pos-screen_position; 
     
    991978    } 
    992979 
    993     int terminal_pixel_length = aww->get_device(AW_MIDDLE_AREA)->get_string_size(ED4_G_SEQUENCES, 0, owner_of_cursor->to_text_terminal()->get_length()); 
     980    int terminal_pixel_length = ed4w->get_device()->get_string_size(ED4_G_SEQUENCES, 0, owner_of_cursor->to_text_terminal()->get_length()); 
    994981    int length_of_char        = ED4_ROOT->font_group.get_width(ED4_G_SEQUENCES); 
    995982    int abs_x_new             = cursor_abs_x+cursor_diff*length_of_char; // position in terminal 
     
    999986    } 
    1000987 
    1001     ED4_LocalWinContext uses(aww); 
    1002     ED4_coords *coords = &current_ed4w()->coords; 
     988    ED4_coords *coords = &ed4w->coords; 
    1003989 
    1004990    int screen_width  = coords->window_right_clip_point-coords->window_left_clip_point; 
     
    10461032        scroll_amount = (scroll_amount/length_of_char)*length_of_char; // align to char-size 
    10471033        if (scroll_amount != 0) { 
     1034            AW_window *aww  = ed4w->aww; 
    10481035            aww->set_horizontal_scrollbar_position(aww->slider_pos_horizontal + scroll_amount); 
    10491036#if defined(TRACE_JUMPS) 
     
    10651052} 
    10661053 
    1067 void ED4_cursor::jump_sequence_pos(AW_window *aww, int seq_pos, ED4_CursorJumpType jump_type) { 
     1054void ED4_cursor::jump_sequence_pos(int seq_pos, ED4_CursorJumpType jump_type) { 
    10681055    int screen_pos = ED4_ROOT->root_group_man->remap()->sequence_to_screen_clipped(seq_pos); 
    1069     jump_screen_pos(aww, screen_pos, jump_type); 
    1070 } 
    1071  
    1072 void ED4_cursor::jump_base_pos(AW_window *aww, int base_pos, ED4_CursorJumpType jump_type) { 
     1056    jump_screen_pos(screen_pos, jump_type); 
     1057} 
     1058 
     1059void ED4_cursor::jump_base_pos(int base_pos, ED4_CursorJumpType jump_type) { 
    10731060    int seq_pos = base2sequence_position(base_pos); 
    1074     jump_sequence_pos(aww, seq_pos, jump_type); 
     1061    jump_sequence_pos(seq_pos, jump_type); 
    10751062} 
    10761063 
     
    11231110 
    11241111        if (result == ED4_R_OK) { 
    1125             AW_pos     x_dummy, y_world; 
    1126             AW_window *aww      = current_aww(); 
    1127  
     1112            AW_pos x_dummy, y_world; 
     1113             
    11281114            owner_of_cursor->calc_world_coords(&x_dummy, &y_world); 
    11291115 
     
    11711157 
    11721158            if (target_terminal) { 
    1173                 set_to_terminal(aww, target_terminal->to_terminal(), seq_pos, ED4_JUMP_KEEP_VISIBLE); 
     1159                set_to_terminal(target_terminal->to_terminal(), seq_pos, ED4_JUMP_KEEP_VISIBLE); 
    11741160            } 
    11751161        } 
     
    12401226    switch (owner_of_cursor->get_area_level(0)) { 
    12411227        case ED4_A_TOP_AREA: { 
    1242             ED4_window *win = window(); 
    12431228            visible =  
    12441229                owner_of_cursor->is_visible(win, x1, 0, ED4_D_HORIZONTAL) || 
     
    12561241} 
    12571242 
    1258 void ED4_terminal::scroll_into_view(AW_window *aww) { // scroll y-position only 
    1259     ED4_LocalWinContext uses(aww); 
     1243void ED4_terminal::scroll_into_view(ED4_window *ed4w) { // scroll y-position only 
     1244    ED4_LocalWinContext uses(ed4w); 
    12601245 
    12611246    AW_pos termw_x, termw_y; 
     
    13001285 
    13011286    if (scroll) { 
     1287        AW_window *aww = ed4w->aww; 
     1288 
    13021289        int pic_ysize         = int(aww->get_scrolled_picture_height()); 
    13031290        int slider_pos_yrange = pic_ysize - win_ysize; 
     
    13111298} 
    13121299 
    1313 void ED4_cursor::set_to_terminal(AW_window *aww, ED4_terminal *terminal, int seq_pos, ED4_CursorJumpType jump_type) 
    1314 { 
     1300void ED4_cursor::set_to_terminal(ED4_terminal *terminal, int seq_pos, ED4_CursorJumpType jump_type) { 
    13151301    if (seq_pos == -1) seq_pos = get_sequence_pos(); 
    13161302 
    13171303    if (owner_of_cursor == terminal) { 
    1318         jump_sequence_pos(aww, seq_pos, jump_type); 
     1304        jump_sequence_pos(seq_pos, jump_type); 
    13191305    } 
    13201306    else { 
    13211307        if (owner_of_cursor) { 
    13221308            if (get_sequence_pos() != seq_pos) { 
    1323                 jump_sequence_pos(aww, seq_pos, jump_type); // position to wanted column -- scrolls horizontally 
     1309                jump_sequence_pos(seq_pos, jump_type); // position to wanted column -- scrolls horizontally 
    13241310            } 
    13251311        } 
     
    13291315 
    13301316        if (!is_partly_visible()) { 
    1331 #if defined(DEBUG) && 0 
    1332             printf("Cursor not visible in set_to_terminal (was drawn outside screen)\n"); 
    1333 #endif // DEBUG 
    1334             jump_sequence_pos(aww, seq_pos, jump_type); 
     1317            jump_sequence_pos(seq_pos, jump_type); 
    13351318        } 
    13361319    } 
     
    13541337    } 
    13551338 
    1356     target_terminal->scroll_into_view(current_aww()); 
     1339    target_terminal->scroll_into_view(current_ed4w()); 
    13571340 
    13581341    AW_pos termw_x, termw_y; 
     
    16511634    if (pairType != HELIX_NONE) { 
    16521635        int pairing_pos = helix->opposite_position(seq_pos); 
    1653         cursor->jump_sequence_pos(aww, pairing_pos, ED4_JUMP_KEEP_POSITION); 
     1636        cursor->jump_sequence_pos(pairing_pos, ED4_JUMP_KEEP_POSITION); 
    16541637    } 
    16551638    else { 
  • branches/e4fix/EDIT4/ED4_no_class.cxx

    r8290 r8293  
    219219 
    220220                if (move_cursor) { 
    221                     current_cursor().jump_sequence_pos(current_aww(), new_work_info.out_seq_position, ED4_JUMP_KEEP_VISIBLE); 
     221                    current_cursor().jump_sequence_pos(new_work_info.out_seq_position, ED4_JUMP_KEEP_VISIBLE); 
    222222                    move_cursor = 0; 
    223223                } 
     
    228228} 
    229229 
    230 static void executeKeystroke(AW_window *aww, AW_event *event, int repeatCount) { 
     230static void executeKeystroke(AW_event *event, int repeatCount) { 
    231231    e4_assert(repeatCount>0); 
    232232 
     
    307307                    error = edit_string->edit(work_info); 
    308308 
    309                     cursor->jump_sequence_pos(aww, work_info->out_seq_position, ED4_JUMP_KEEP_VISIBLE); 
     309                    cursor->jump_sequence_pos(work_info->out_seq_position, ED4_JUMP_KEEP_VISIBLE); 
    310310 
    311311                    work_info->string = 0; 
     
    329329                    // ED4_ROOT->main_manager->Show(); // original version 
    330330 
    331                     cursor->jump_sequence_pos(aww, work_info->out_seq_position, work_info->cursor_jump); 
     331                    cursor->jump_sequence_pos(work_info->out_seq_position, work_info->cursor_jump); 
    332332                } 
    333333 
     
    358358 
    359359void ED4_remote_event(AW_event *faked_event) { // keystrokes forwarded from SECEDIT 
    360     executeKeystroke(current_aww(), faked_event, 1); 
     360    executeKeystroke(faked_event, 1); 
    361361} 
    362362 
     
    388388                } 
    389389                else { // other key => execute now 
    390                     executeKeystroke(aww, &lastEvent, repeatCount); 
     390                    executeKeystroke(&lastEvent, repeatCount); 
    391391                    lastEvent = event; 
    392392                    repeatCount = 1; 
     
    398398                // sth goes wrong with OSX -> always execute keystroke 
    399399                // Xfree 4.3 has problems as well, so repeat counting is disabled completely 
    400                 executeKeystroke(aww, &lastEvent, repeatCount); 
     400                executeKeystroke(&lastEvent, repeatCount); 
    401401                repeatCount                       = 0; 
    402402#else 
     
    404404 
    405405                if (nextEventType!=KEY_RELEASED) { // no key waiting => execute now 
    406                     executeKeystroke(aww, &lastEvent, repeatCount); 
     406                    executeKeystroke(&lastEvent, repeatCount); 
    407407                    repeatCount = 0; 
    408408                } 
     
    415415 
    416416            if (nextEventType!=KEY_PRESSED && repeatCount) { // no key follows => execute keystrokes (if any) 
    417                 executeKeystroke(aww, &lastEvent, repeatCount); 
     417                executeKeystroke(&lastEvent, repeatCount); 
    418418                repeatCount = 0; 
    419419            } 
     
    657657    if (pos != -1) { 
    658658        ED4_cursor *cursor = &current_cursor(); 
    659         cursor->jump_sequence_pos(current_aww(), pos, ED4_JUMP_CENTERED); 
     659        cursor->jump_sequence_pos(pos, ED4_JUMP_CENTERED); 
    660660        awar->write_int(-1); 
    661661    } 
     
    734734    } 
    735735    else { 
    736         cursor->jump_sequence_pos(aww, pos, ED4_JUMP_CENTERED); 
     736        cursor->jump_sequence_pos(pos, ED4_JUMP_CENTERED); 
    737737    } 
    738738} 
     
    754754            } 
    755755            else { 
    756                 cursor->jump_sequence_pos(aww, pos, ED4_JUMP_CENTERED); 
     756                cursor->jump_sequence_pos(pos, ED4_JUMP_CENTERED); 
    757757            } 
    758758        } 
     
    14221422 
    14231423void ED4_compression_changed_cb(AW_root *awr) { 
    1424     ED4_remap_mode mode = (ED4_remap_mode)awr->awar(ED4_AWAR_COMPRESS_SEQUENCE_TYPE)->read_int(); 
    1425     int percent = awr->awar(ED4_AWAR_COMPRESS_SEQUENCE_PERCENT)->read_int(); 
    1426     GB_transaction transaction_var(GLOBAL_gb_main); 
     1424    ED4_remap_mode mode    = (ED4_remap_mode)awr->awar(ED4_AWAR_COMPRESS_SEQUENCE_TYPE)->read_int(); 
     1425    int            percent = awr->awar(ED4_AWAR_COMPRESS_SEQUENCE_PERCENT)->read_int(); 
     1426    GB_transaction ta(GLOBAL_gb_main); 
    14271427 
    14281428    if (ED4_ROOT->root_group_man) { 
     
    14401440        device->set_clipall();     // draw nothing 
    14411441 
    1442         ED4_expose_recalculations(); 
    1443  
    1444         cursor.jump_sequence_pos(aww, seq_pos, ED4_JUMP_KEEP_POSITION); 
    1445         cursor.set_screen_relative_pos(aww, rel_pos); 
     1442        ED4_expose_recalculations(); // @@@ do not perform for all windows 
     1443 
     1444        cursor.jump_sequence_pos(seq_pos, ED4_JUMP_KEEP_POSITION); 
     1445        cursor.set_screen_relative_pos(rel_pos); 
    14461446 
    14471447        ED4_expose_cb(aww, 0, 0); // does pop_clip_scale + refresh 
  • branches/e4fix/EDIT4/ED4_terminal.cxx

    r8289 r8293  
    762762 
    763763 
    764 ED4_terminal::~ED4_terminal() 
    765 { 
    766     if (selection_info) { 
    767         delete selection_info; 
    768     } 
     764ED4_terminal::~ED4_terminal() { 
     765    delete selection_info; 
    769766    ED4_cursor& cursor = current_cursor(); 
    770767    if (this == cursor.owner_of_cursor) { 
  • branches/e4fix/EDIT4/ED4_window.cxx

    r8275 r8293  
    403403} 
    404404 
    405 ED4_window::ED4_window(AW_window *window) { 
    406     aww                   = window; 
    407     next                  = 0; 
    408     slider_pos_horizontal = 0; 
    409     slider_pos_vertical   = 0; 
    410  
    411     id        = ++no_of_windows; 
     405ED4_window::ED4_window(AW_window *window) 
     406    : aww(window), 
     407      next(NULL), 
     408      slider_pos_horizontal(0), 
     409      slider_pos_vertical(0), 
     410      id(++no_of_windows), 
     411      is_hidden(false), 
     412      cursor(this) 
     413{ 
    412414    coords.clear(); 
    413     is_hidden = false; 
    414415 
    415416    sprintf(awar_path_for_cursor, AWAR_EDIT_SEQ_POSITION, id); 
  • branches/e4fix/EDIT4/ed4_class.hxx

    r8289 r8293  
    605605 
    606606class ED4_cursor : virtual Noncopyable { 
    607     ED4_index                  cursor_abs_x; // absolute (to terminal) x-position of cursor (absolute world coordinate of edit window) 
     607    ED4_window                *win; 
     608    ED4_index                  cursor_abs_x;    // absolute (to terminal) x-position of cursor (absolute world coordinate of edit window) 
    608609    int                        screen_position; // number of displayed characters leading the cursor 
    609     mutable ED4_base_position  base_position; // # of bases left of cursor 
     610    mutable ED4_base_position  base_position;   // # of bases left of cursor 
    610611    ED4_CursorType             ctype; 
    611612    ED4_CursorShape           *cursor_shape; 
     
    649650    void invalidate_base_position() { base_position.invalidate(); } 
    650651 
    651     void jump_screen_pos(AW_window *aww, int screen_pos, ED4_CursorJumpType jump_type); 
    652     void jump_sequence_pos(AW_window *aww, int sequence_pos, ED4_CursorJumpType jump_type); 
    653     void jump_base_pos(AW_window *aww, int base_pos, ED4_CursorJumpType jump_type); 
     652    void jump_screen_pos(int screen_pos, ED4_CursorJumpType jump_type); 
     653    void jump_sequence_pos(int sequence_pos, ED4_CursorJumpType jump_type); 
     654    void jump_base_pos(int base_pos, ED4_CursorJumpType jump_type); 
    654655 
    655656    int get_screen_relative_pos(); 
    656     void set_screen_relative_pos(AW_window *aww, int scroll_to_relpos); 
    657  
    658     void set_to_terminal(AW_window *aww, ED4_terminal *terminal, int seq_pos, ED4_CursorJumpType jump_type); 
     657    void set_screen_relative_pos(int scroll_to_relpos); 
     658 
     659    void set_to_terminal(ED4_terminal *terminal, int seq_pos, ED4_CursorJumpType jump_type); 
    659660 
    660661    void announce_deletion(ED4_base *object) { 
     
    665666    void init(); 
    666667 
    667     ED4_window *window() const; 
    668  
    669     ED4_cursor(); 
     668    ED4_window *window() const { return win; } 
     669 
     670    ED4_cursor(ED4_window *win); 
    670671    ~ED4_cursor(); 
    671672}; 
     
    674675    ED4_window(const ED4_window&); // copy-constructor not allowed 
    675676public: 
    676     AW_window              *aww; // Points to Window 
     677    AW_window              *aww;   // Points to Window 
    677678    ED4_window             *next; 
    678679    int                     slider_pos_horizontal; 
    679680    int                     slider_pos_vertical; 
    680681    ED4_scrolled_rectangle  scrolled_rect; 
    681     int                     id; // unique id in window-list 
     682    int                     id;    // unique id in window-list 
    682683    ED4_coords              coords; 
    683     static int              no_of_windows; 
     684 
     685    static int no_of_windows; 
    684686 
    685687    char awar_path_for_cursor[50];                  // position in current sequence, range = [1;len] 
     
    13521354    GB_ERROR write_sequence(const char *seq, int seq_len); 
    13531355 
    1354     void scroll_into_view(AW_window *aww); 
     1356    void scroll_into_view(ED4_window *ed4w); 
    13551357    inline bool setCursorTo(ED4_cursor *cursor, int seq_pos, bool unfoldGroups, ED4_CursorJumpType jump_type); 
    13561358