Re: [code][textadept] Set bookmark by clicking in margin

From: Mitchell <m.att.foicica.com>
Date: Tue, 17 Mar 2015 10:55:09 -0400 (EDT)

Hi Lance,

On Mon, 16 Mar 2015, Lance Larsen wrote:

> I just started working with textadept a short time ago. I have been using
> notepad++ as a text editor for quite a while, but needed for capability and
> textadept is incredibly flexible.
>
> One feature I have used a lot in notepad++ was clicking in the margin to
> set bookmarks. When I am examining code, I often jump around and bookmarks
> are a gsimple way to get back to code your were examining. Since clicking
> in the margin to toggle a bookmark is not supported by default. I went to
> add it in. I noticed that there is a MARGIN_CLICK event that gives you the
> position at the start of the line where you click, and a way to get the
> line number from the position, but there is no command to toggle the margin
> by line number. I modified the bookmark.toggle command to accept an
> optional line number as a second argument. I hope you will consider
> including in the code. I would also love to see clicking in the margin to
> toggle bookmarks included, but maybe others don't fidn this as useful as I
> do.
>
> ---
> -- Toggles the bookmark on the current or specified line unless *on* is
> given.
> -- If *on* is `true` or `false`, adds or removes the bookmark, respectively.
> -- @param on Optional flag indicating whether to add or remove a bookmark
> on the
> -- line. The default value is `nil`, toggling a bookmark.
> -- @param line Optional line number where toggle command is applied. The
> default
> -- is the current line.
> -- @name toggle
> function M.toggle(on, line)
> line = line or buffer:line_from_position(buffer.current_pos)
> local f = on and buffer.marker_add or buffer.marker_delete
> if on == nil then -- toggle
> local bit, marker_mask = 2^M.MARK_BOOKMARK, buffer:marker_get(line)
> if bit32.band(marker_mask, bit) == 0 then f = buffer.marker_add end
> end
> f(buffer, line, M.MARK_BOOKMARK)
> end

Thanks! I will commit this. I prefer not to include a default margin-click
handler for toggling bookmarks though, as it may interfere with other
user-specified marker functionality.

Cheers,
Mitchell

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Tue 17 Mar 2015 - 10:55:09 EDT

This archive was generated by hypermail 2.2.0 : Wed 18 Mar 2015 - 06:41:18 EDT