sort by column

Scott Woodford woodford at crystal.cirrus.com
Wed Nov 15 16:45:17 CET 2006


Joerg Fischer wrote:

  

> I've been meaning to make a macro to sort by the column chosen by a 
> mouse click, but haven't figured out yet how to wait for the position of 
> a mouse click in a macro.
    

This isn't difficult. For example to bind such a macro to, say,
Ctrl + rigth click  you put the following into your .Xdefaults

nedit*text.Translations: #override \n\
 Ctrl~Shift~Meta~Alt<Btn3Down> : mark(9) grab_focus() macro_menu_command("MyMac
ro") goto_mark(9)\n

The macro is located at the Macro Menu with name "MyMacro" and uses
the current cursor position, that is, the one at the moment the
macro is called. So, the macro would start with the line
pos = $cursor
to store the position because the cursor is set back to its previous
position immediately.
  

I like the idea, but its not exactly what I had in mind.  I want to do the foll
owing:

1. select a section of text to be sorted
2. start the sort_by_column() macro, which waits for a mouse click on a column:

define sort_by_column
{
   pos = my_wait_for_mouse_click_in_window()
   col = my_get_column(pos)
   filter_selection("sort -k" col)
}

Is it even possible to wait for a key press or mouse click event during a macro
?

Thanks,
Scott


More information about the Discuss mailing list