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

From: Lance Larsen <lance.c.larsen.att.gmail.com>
Date: Mon, 16 Mar 2015 23:54:41 -0600

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
-- 
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 - 01:54:41 EDT

This archive was generated by hypermail 2.2.0 : Tue 17 Mar 2015 - 06:46:56 EDT