se

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

move_selection_with_cursor.h (1005B)


      1 #ifndef MOVE_SELECTION_WITH_CURSOR_H_
      2 #define MOVE_SELECTION_WITH_CURSOR_H_
      3 
      4 static int
      5 move_selection(struct window_buffer* wb, enum cursor_reason callback_reason)
      6 {
      7 	struct file_buffer* fb = get_fb(wb);
      8 	if (fb->mode & FB_SELECTION_ON) {
      9         if (fb->mode & FB_LINE_SELECT) {
     10             int twice = 2;
     11             while (twice--) {
     12                     if (fb_is_selection_start_top_left(fb)) {
     13                         fb->s2o = fb_seek_char(fb, wb->cursor_offset, '\n');
     14                         fb->s1o = fb_seek_char_backwards(fb, fb->s1o, '\n');
     15                     } else {
     16                         fb->s2o = fb_seek_char_backwards(fb, wb->cursor_offset, '\n');
     17                         fb->s1o = fb_seek_char(fb, fb->s1o, '\n');
     18                 }
     19             }
     20         } else {
     21             fb->s2o = wb->cursor_offset;
     22         }
     23 
     24 	}
     25     return 0;
     26 }
     27 
     28 static const struct extension move_selection_with_cursor = {
     29     .wb_cursor_movement = move_selection,
     30 };
     31 
     32 #endif // MOVE_SELECTION_WITH_CURSOR_H_