[vitunes] Re: [PATCH] add visual mode to vitunes

  • From: Daniel Walter <sahne@xxxxxxx>
  • To: vitunes@xxxxxxxxxxxxx
  • Date: Fri, 11 Feb 2011 11:33:04 +0000

Hi all,

I gave your implementation a second thought and I've come up with
a few issues we should discuss.

If we use your posted approach, I think we would need to modify the 
KeyActionHandler struct with a bool to state if this command can
be used while in visual mode.

e.g.: One must not switch windows while in visual, or display the
file meta-data. a shell or a command may make sense if it supports
piping the selected files, but for now it would not make much sense.

If we use my approach, we would have to duplicate too much code for
key handling, so I'd say this is a no-go.

Since I'm currently not that familiar with the implications of adding a 
bool to the KeyActionHandler struct, I'd like to know what you think about
it. As far as I can see this would be the easiest way to check if a
given action can handle visual mode (eg. yank, cut, scrolling, jump, etc)
or not (switching windows, media_*, shell, command, seek_*, toggle,etc.)

I'll post a patch with a modified KeyActionHandler and the needed changes
to keybinding.c later today for review.

comments, suggestions, critics are welcome.

daniel

On Fri, Feb 11, 2011 at 07:34:07AM +0000, Daniel Walter wrote:
> On Thu, Feb 10, 2011 at 08:13:12PM -0500, Ryan Flannery wrote:
> > On Thu, Feb 10, 2011 at 8:03 PM, Ryan Flannery <ryan.flannery@xxxxxxxxx> 
> > wrote:
> > > Hi Daniel,
> > >
> > > On Thu, Feb 10, 2011 at 7:40 PM, Ryan Flannery <ryan.flannery@xxxxxxxxx> 
> > > wrote:
> > >> Hi Daniel!
> > >>
> > >> On Thu, Feb 10, 2011 at 7:18 PM, Daniel Walter <sahne> wrote:
> > >>> Hi all,
> > >>>
> > >>> I've hacked a visual mode patch for vitunes, which allows you to vim 
> > >>> like select files within a playlist and
> > >>> copy or delete/cut them.
> > >>
> > >> Sweeeeet! ?I've been wanting something like this for a while!
> > >>
> > >>> It basically works like visual mode in vim, so you enable it via 'V' 
> > >>> and use either 'UP'/'DOWN' or 'j'/'k' to
> > >>> select the files you like to copy or delete.
> > >>>
> > >>> In this first version the is no support for jumping to the beginning or 
> > >>> end of a list, but I'm planning to
> > >>> integrate this within a few days.
> > >>
> > >> Hmm.. I'm thinking there might be an easier way to add support for all
> > >> of these (like gg, G, ^u, ^d, 123G, etc.), in one shot.
> > >>
> > >> What about the following:
> > >>
> > >> In the kba_visual, just do:
> > >> if (visual_selection_start == -1)
> > >> ? ? visual_selection_start = ui.active->voffset + ui.active->crow;
> > >> else
> > >> ? ? visual_selection_start = -1;
> > >>
> > >>
> > >> The visual_selection_end, I think, could always just be:
> > >> ? ? ui.active->voffset + ui.active->crow;
> > >> so I wouldn't even track that.... just let the other keybinding
> > >> handlers modify that as they normally do.
> > >>
> > >>
> > >> In the paint code, a row gets the A_REVERSE wattron'd if and only if
> > >> the row is between
> > >> ? ? visual_selection_start
> > >> and
> > >> ? ? ui.active->voffset + ui.active->crow;
> > >> and the visual_selection_start is != -1 of course.
> > >>
> > >>
> > >> With that, yank could then be updated to use the
> > >> visual_selection_start (if != -1) and current row to get the
> > >> yank-portion.
> > >>
> > >>
> > >> Thoughts?
> > >>
> > >
> > > Attached is a diff with just the tracking and painting, which is
> > > rough, but I think it illustrates what I'm talking about.
> > >
> > 
> > And it appears freelists.org stripped my patch....  Here it is:
> > 
> > 
> > 
> Hi,
> 
> hmm, okay so I did it way too complicated ;)
> I like your patch, since it seems to be a much nicer way to
> integrate all other commands, like scrolling down the hole page, etc.
> I'll spend some time on it, when I'm back home, but I could see any 
> problems on the first, quick look.
> 
> 
> daniel
> 

Other related posts: