Loading ...
Sorry, an error occurred while loading the content.

RE: folding out patterns [horrible hack attached]

Expand Messages
  • Vince Negri
    For anyone who s sufficiently interested, mad or desperate, I attach the following hack as a starting point. It demonstrates a few of the points from my
    Message 1 of 1 , Jun 7, 2002
    • 0 Attachment
      For anyone who's sufficiently interested, mad or
      desperate, I attach the following hack as a
      starting point. It demonstrates a few of the points from
      my previous email on the topic..

      ***NOTE*** this is a nasty hack as will be obvious from
      the following description. It has no warranty and if your vim
      dies horribly while using it, I will not only be entirely
      unsurprised but reserve the right to cackle evilly. The patch is
      just there to prove a concept.

      The effect of this hack is to make any text in the editing
      window which has the same attributes as the NonText highlight
      group disappear completely - i.e. take up no space.
      Text is never hidden on the current cursor line.

      Note the following foul properties of this hack:
      a) Text to be hidden is based on the attributes, not the syntax
      group. i.e. if NonText is set to dark blue on normal background,
      then *any* text which is also dark blue on normal background will
      be hidden!!! Obviously a "proper" implementation would need to
      check the current character's syntax group rather than attribute.

      b) Hiding cannot be turned on and off. (Option required)

      c) Screen redrawing is heavy-handed. There don't seem to be any
      mechanisms in vim at the moment for redrawing just the current
      and previous cursor lines after a cursor linewise move (which would
      also be useful for highlighting current cursor line). Such a
      mechanism is needed for efficient screen updating wrt this feature.

      Anyone who wants to chip in with improvements is most welcome...



      RCS file: /cvsroot/vim/vim/src/normal.c,v
      retrieving revision 1.90
      diff -w -c -5 -r1.90 normal.c
      *** normal.c 5 Jun 2002 06:32:47 -0000 1.90
      --- normal.c 7 Jun 2002 15:17:42 -0000
      ***************
      *** 5056,5065 ****
      --- 5056,5068 ----
      cap->oap->motion_type = MLINE;
      if (cursor_up(cap->count1, cap->oap->op_type == OP_NOP) == FAIL)
      clearopbeep(cap->oap);
      else if (cap->arg)
      beginline(BL_WHITE | BL_FIX);
      + #ifdef FEAT_HORRIBLE_HACK
      + changed_window_setting();
      + #endif
      }

      /*
      * Cursor down commands.
      * cap->arg is TRUE for CR and "+": Move cursor to first non-blank.
      ***************
      *** 5085,5094 ****
      --- 5088,5100 ----
      cap->oap->motion_type = MLINE;
      if (cursor_down(cap->count1, cap->oap->op_type == OP_NOP) ==
      FAIL)
      clearopbeep(cap->oap);
      else if (cap->arg)
      beginline(BL_WHITE | BL_FIX);
      + #ifdef FEAT_HORRIBLE_HACK
      + changed_window_setting();
      + #endif
      }
      }
      }

      #ifdef FEAT_SEARCHPATH


      ===================================================================
      RCS file: /cvsroot/vim/vim/src/screen.c,v
      retrieving revision 1.82
      diff -w -c -5 -r1.82 screen.c
      *** screen.c 13 May 2002 15:42:13 -0000 1.82
      --- screen.c 7 Jun 2002 15:15:57 -0000
      ***************
      *** 2421,2430 ****
      --- 2421,2433 ----
      #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
      int feedback_col = 0;
      int feedback_old_attr = -1;
      #endif

      + #ifdef FEAT_HORRIBLE_HACK
      + int foo_attr = hl_attr(HLF_AT);
      + #endif

      if (startrow > endrow) /* past the end already! */
      return startrow;

      row = startrow;
      ***************
      *** 3349,3358 ****
      --- 3352,3376 ----
      extra_attr = hl_attr(HLF_8);
      saved_attr2 = char_attr; /* save current attr */
      }
      }
      }
      +
      + #ifdef FEAT_HORRIBLE_HACK
      + if ((!(lnum == curwin->w_cursor.lnum)) && (char_attr ==
      foo_attr))
      + {
      + n_extra = 0;
      + //c_extra = '%';
      + c = ' '; /* just in case */
      + if (n_skip == 0)
      + n_skip = 1;
      + #ifdef FEAT_MBYTE
      + mb_utf8 = FALSE; /* don't draw as UTF-8 */
      + #endif
      + }
      + else
      + #endif

      /*
      * Handling of non-printable characters.
      */
      if (!(chartab[c] & CT_PRINT_CHAR))
    Your message has been successfully submitted and would be delivered to recipients shortly.