~ubuntu-branches/debian/sid/neovim/sid

« back to all changes in this revision

Viewing changes to src/nvim/screen.c

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2016-04-18 21:42:19 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20160418214219-1e6d4o1fwqarzk46
Tags: 0.1.3-1
* New upstream release.  (Closes: #820562)
* debian/control:
  + Remove unnecessary luarocks Build-Depends
  + Add libkvm-dev Build-Depends for kfreebsd-*
  + Add python(3)-neovim to Recommends.  (Closes: #812737)
  + Declare compiance with policy 3.9.8, no changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2184
2184
  int prev_c1 = 0;                      /* first composing char for prev_c */
2185
2185
  int did_line_attr = 0;
2186
2186
 
 
2187
  bool has_bufhl = false;                // this buffer has highlight matches
 
2188
  int bufhl_attr = 0;                   // attributes desired by bufhl
 
2189
  bufhl_lineinfo_T bufhl_info;          // bufhl data for this line
 
2190
 
2187
2191
  /* draw_state: items that are drawn in sequence: */
2188
2192
#define WL_START        0               /* nothing done yet */
2189
2193
# define WL_CMDLINE     WL_START + 1    /* cmdline window column */
2199
2203
  int syntax_seqnr    = 0;
2200
2204
  int prev_syntax_id  = 0;
2201
2205
  int conceal_attr    = hl_attr(HLF_CONCEAL);
2202
 
  int is_concealing   = FALSE;
2203
 
  int boguscols       = 0;              /* nonexistent columns added to force
2204
 
                                           wrapping */
2205
 
  int vcol_off        = 0;              /* offset for concealed characters */
2206
 
  int did_wcol        = FALSE;
 
2206
  int is_concealing   = false;
 
2207
  int boguscols       = 0;              ///< nonexistent columns added to
 
2208
                                        ///< force wrapping
 
2209
  int vcol_off        = 0;              ///< offset for concealed characters
 
2210
  int did_wcol        = false;
 
2211
  int match_conc      = false;          ///< cchar for match functions
 
2212
  int has_match_conc  = false;          ///< match wants to conceal
2207
2213
  int old_boguscols = 0;
2208
2214
# define VCOL_HLC (vcol - vcol_off)
2209
2215
# define FIX_FOR_BOGUSCOLS \
2242
2248
    }
2243
2249
  }
2244
2250
 
 
2251
  if (bufhl_start_line(wp->w_buffer, lnum, &bufhl_info)) {
 
2252
    has_bufhl = true;
 
2253
    extra_check = true;
 
2254
  }
 
2255
 
2245
2256
  /* Check for columns to display for 'colorcolumn'. */
2246
2257
  color_cols = wp->w_buffer->terminal ? NULL : wp->w_p_cc_cols;
2247
2258
  if (color_cols != NULL)
2430
2441
    }
2431
2442
  }
2432
2443
 
2433
 
  /* find start of trailing whitespace */
2434
 
  if (wp->w_p_list && lcs_trail) {
2435
 
    trailcol = (colnr_T)STRLEN(ptr);
2436
 
    while (trailcol > (colnr_T)0 && ascii_iswhite(ptr[trailcol - 1]))
2437
 
      --trailcol;
2438
 
    trailcol += (colnr_T) (ptr - line);
2439
 
    extra_check = TRUE;
 
2444
  if (wp->w_p_list) {
 
2445
    if (lcs_space || lcs_trail) {
 
2446
      extra_check = true;
 
2447
    }
 
2448
    // find start of trailing whitespace
 
2449
    if (lcs_trail) {
 
2450
      trailcol = (colnr_T)STRLEN(ptr);
 
2451
      while (trailcol > (colnr_T)0 && ascii_iswhite(ptr[trailcol - 1])) {
 
2452
        trailcol--;
 
2453
      }
 
2454
      trailcol += (colnr_T) (ptr - line);
 
2455
    }
2440
2456
  }
2441
2457
 
2442
2458
  /*
2633
2649
    extra_check = true;
2634
2650
  }
2635
2651
 
2636
 
  /*
2637
 
   * Repeat for the whole displayed line.
2638
 
   */
 
2652
  // Repeat for the whole displayed line.
2639
2653
  for (;; ) {
2640
 
    /* Skip this quickly when working on the text. */
 
2654
    has_match_conc = false;
 
2655
    // Skip this quickly when working on the text.
2641
2656
    if (draw_state != WL_LINE) {
2642
2657
      if (draw_state == WL_CMDLINE - 1 && n_extra == 0) {
2643
2658
        draw_state = WL_CMDLINE;
2884
2899
                shl->endcol = tmp_col;
2885
2900
              }
2886
2901
              shl->attr_cur = shl->attr;
 
2902
              if (cur != NULL && syn_name2id((char_u *)"Conceal")
 
2903
                  == cur->hlg_id) {
 
2904
                has_match_conc = true;
 
2905
                match_conc = cur->conceal_char;
 
2906
              } else {
 
2907
                has_match_conc = match_conc = false;
 
2908
              }
2887
2909
            } else if (v == (long)shl->endcol) {
2888
2910
              shl->attr_cur = 0;
 
2911
              prev_syntax_id = 0;
2889
2912
 
2890
2913
              next_search_hl(wp, shl, lnum, (colnr_T)v, cur);
2891
2914
              pos_inprogress = !(cur == NULL || cur->pos.cur == 0);
3201
3224
        }
3202
3225
 
3203
3226
      }
3204
 
      ++ptr;
3205
 
 
3206
 
      // 'list': change char 160 to lcs_nbsp and space to lcs_space.
3207
 
      if (wp->w_p_list
3208
 
          && (((c == 160 || (mb_utf8 && (mb_c == 160 || mb_c == 0x202f)))
3209
 
               && lcs_nbsp)
3210
 
              || (c == ' ' && lcs_space && ptr - line <=  trailcol))) {
3211
 
        c = (c == ' ') ? lcs_space : lcs_nbsp;
3212
 
        if (area_attr == 0 && search_attr == 0) {
3213
 
          n_attr = 1;
3214
 
          extra_attr = hl_attr(HLF_8);
3215
 
          saved_attr2 = char_attr;           /* save current attr */
3216
 
        }
3217
 
        mb_c = c;
3218
 
        if (enc_utf8 && (*mb_char2len)(c) > 1) {
3219
 
          mb_utf8 = TRUE;
3220
 
          u8cc[0] = 0;
3221
 
          c = 0xc0;
3222
 
        } else
3223
 
          mb_utf8 = FALSE;
3224
 
      }
 
3227
      ptr++;
3225
3228
 
3226
3229
      if (extra_check) {
3227
3230
        bool can_spell = true;
3341
3344
            char_attr = hl_combine_attr(spell_attr, char_attr);
3342
3345
        }
3343
3346
 
 
3347
        if (has_bufhl && v > 0) {
 
3348
          bufhl_attr = bufhl_get_attr(&bufhl_info, (colnr_T)v);
 
3349
          if (bufhl_attr != 0) {
 
3350
            if (!attr_pri) {
 
3351
              char_attr = hl_combine_attr(char_attr, bufhl_attr);
 
3352
            } else {
 
3353
              char_attr = hl_combine_attr(bufhl_attr, char_attr);
 
3354
            }
 
3355
          }
 
3356
        }
 
3357
 
3344
3358
        if (wp->w_buffer->terminal) {
3345
3359
          char_attr = hl_combine_attr(char_attr, term_attrs[vcol]);
3346
3360
        }
3368
3382
          }
3369
3383
        }
3370
3384
 
 
3385
        // 'list': change char 160 to lcs_nbsp and space to lcs_space.
 
3386
        if (wp->w_p_list
 
3387
            && (((c == 160
 
3388
                  || (mb_utf8 && (mb_c == 160 || mb_c == 0x202f)))
 
3389
                 && lcs_nbsp)
 
3390
                || (c == ' ' && lcs_space && ptr - line <= trailcol))) {
 
3391
          c = (c == ' ') ? lcs_space : lcs_nbsp;
 
3392
          if (area_attr == 0 && search_attr == 0) {
 
3393
            n_attr = 1;
 
3394
            extra_attr = hl_attr(HLF_8);
 
3395
            saved_attr2 = char_attr;  // save current attr
 
3396
          }
 
3397
          mb_c = c;
 
3398
          if (enc_utf8 && (*mb_char2len)(c) > 1) {
 
3399
            mb_utf8 = true;
 
3400
            u8cc[0] = 0;
 
3401
            c = 0xc0;
 
3402
          } else {
 
3403
            mb_utf8 = false;
 
3404
          }
 
3405
        }
 
3406
 
3371
3407
        if (trailcol != MAXCOL && ptr > line + trailcol && c == ' ') {
3372
3408
          c = lcs_trail;
3373
3409
          if (!attr_pri) {
3602
3638
        }
3603
3639
      }
3604
3640
 
3605
 
      if (   wp->w_p_cole > 0
3606
 
             && (wp != curwin || lnum != wp->w_cursor.lnum ||
3607
 
                 conceal_cursor_line(wp))
3608
 
             && (syntax_flags & HL_CONCEAL) != 0
3609
 
             && !(lnum_in_visual_area
3610
 
                  && vim_strchr(wp->w_p_cocu, 'v') == NULL)) {
 
3641
      if (wp->w_p_cole > 0
 
3642
          && (wp != curwin || lnum != wp->w_cursor.lnum ||
 
3643
              conceal_cursor_line(wp))
 
3644
          && ((syntax_flags & HL_CONCEAL) != 0 || has_match_conc)
 
3645
          && !(lnum_in_visual_area
 
3646
               && vim_strchr(wp->w_p_cocu, 'v') == NULL)) {
3611
3647
        char_attr = conceal_attr;
3612
3648
        if (prev_syntax_id != syntax_seqnr
3613
 
            && (syn_get_sub_char() != NUL || wp->w_p_cole == 1)
 
3649
            && (syn_get_sub_char() != NUL || match_conc
 
3650
                || wp->w_p_cole == 1)
3614
3651
            && wp->w_p_cole != 3) {
3615
 
          /* First time at this concealed item: display one
3616
 
           * character. */
3617
 
          if (syn_get_sub_char() != NUL)
 
3652
          // First time at this concealed item: display one
 
3653
          // character.
 
3654
          if (match_conc) {
 
3655
            c = match_conc;
 
3656
          } else if (syn_get_sub_char() != NUL) {
3618
3657
            c = syn_get_sub_char();
3619
 
          else if (lcs_conceal != NUL)
 
3658
          } else if (lcs_conceal != NUL) {
3620
3659
            c = lcs_conceal;
3621
 
          else
 
3660
          } else {
3622
3661
            c = ' ';
 
3662
          }
3623
3663
 
3624
3664
          prev_syntax_id = syntax_seqnr;
3625
3665
 
6740
6780
    if (Recording
6741
6781
        && edit_submode == NULL             /* otherwise it gets too long */
6742
6782
        ) {
6743
 
      MSG_PUTS_ATTR(_("recording"), attr);
6744
 
      need_clear = TRUE;
 
6783
      recording_mode(attr);
 
6784
      need_clear = true;
6745
6785
    }
6746
6786
 
6747
6787
    mode_displayed = TRUE;
6780
6820
  msg_row = Rows - 1;
6781
6821
}
6782
6822
 
6783
 
/*
6784
 
 * Delete mode message.  Used when ESC is typed which is expected to end
6785
 
 * Insert mode (but Insert mode didn't end yet!).
6786
 
 * Caller should check "mode_displayed".
6787
 
 */
6788
 
void unshowmode(int force)
 
6823
/// Delete mode message.  Used when ESC is typed which is expected to end
 
6824
/// Insert mode (but Insert mode didn't end yet!).
 
6825
/// Caller should check "mode_displayed".
 
6826
void unshowmode(bool force)
6789
6827
{
6790
 
  /*
6791
 
   * Don't delete it right now, when not redrawing or inside a mapping.
6792
 
   */
6793
 
  if (!redrawing() || (!force && char_avail() && !KeyTyped))
6794
 
    redraw_cmdline = TRUE;              /* delete mode later */
6795
 
  else {
 
6828
  // Don't delete it right now, when not redrawing or inside a mapping.
 
6829
  if (!redrawing() || (!force && char_avail() && !KeyTyped)) {
 
6830
    redraw_cmdline = true;  // delete mode later
 
6831
  } else {
6796
6832
    msg_pos_mode();
6797
 
    if (Recording)
6798
 
      MSG_PUTS_ATTR(_("recording"), hl_attr(HLF_CM));
 
6833
    if (Recording) {
 
6834
      recording_mode(hl_attr(HLF_CM));
 
6835
    }
6799
6836
    msg_clr_eos();
6800
6837
  }
6801
6838
}
6802
6839
 
 
6840
static void recording_mode(int attr)
 
6841
{
 
6842
  MSG_PUTS_ATTR(_("recording"), attr);
 
6843
  if (!shortmess(SHM_RECORDING)) {
 
6844
    char_u s[4];
 
6845
    vim_snprintf((char *)s, ARRAY_SIZE(s), " @%c", Recording);
 
6846
    MSG_PUTS_ATTR(s, attr);
 
6847
  }
 
6848
}
 
6849
 
6803
6850
/*
6804
6851
 * Draw the tab pages line at the top of the Vim window.
6805
6852
 */