aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--FAQ.md12
-rw-r--r--doc/manual.md12
-rw-r--r--properties.lua1
-rw-r--r--src/textadept.c21
4 files changed, 32 insertions, 14 deletions
diff --git a/FAQ.md b/FAQ.md
index 641d71c9..408dbedf 100644
--- a/FAQ.md
+++ b/FAQ.md
@@ -107,6 +107,18 @@ Please see the LuaDoc on [compile and run commands][].
- - -
**Q:**
+In Linux, middle-clicking in the curses version does not paste the primary
+selection and selecting text does copy to the primary selection. All other
+terminal apps support this functionality, why not Textadept?
+
+**A:**
+It does; use the `Shift` modifier key with your middle-clicking and text
+selecting. Textadept interprets non-`Shift`ed mouse events like a GUI
+application.
+
+- - -
+
+**Q:**
The curses version does not support feature _x_ the GUI version does. Is this a
bug?
diff --git a/doc/manual.md b/doc/manual.md
index 36dc0157..8a68fb2a 100644
--- a/doc/manual.md
+++ b/doc/manual.md
@@ -610,16 +610,14 @@ cursor over ranges of text creates multiple selections. Holding "Control" and
then clicking without dragging places an additional caret at the clicked
position. Textadept mirrors any typed text at each selection.
-Textadept curses does not support creating multiple selections with the mouse.
-
### Rectangular Selection
Rectangular selections are a more structured form of multiple selections. A
rectangular selection spanning multiple lines allows typing on each line.
Holding `Alt+Shift` (`⌥⇧` on Mac OSX | `M-S-` in curses) and then pressing the
arrow keys creates a rectangular selection. Holding the `Alt` modifier key
-(`Super` on Linux) and then clicking and dragging the mouse cursor also creates
-a rectangular selection.
+(`Super` on Linux, and `Ctrl+Alt` in curses) and then clicking and dragging the
+mouse cursor also creates a rectangular selection.
![Rectangular Selection](images/rectangularselection.png)
    
@@ -632,9 +630,6 @@ usually defines the `Super` modifier key as the left "Windows" key.) If you
prefer to use `Alt`, change [`buffer.rectangular_selection_modifier`][] in your
[preferences](#Buffer.Settings).
-Textadept curses does not support creating rectangular selections with the
-mouse.
-
[`buffer.rectangular_selection_modifier`]: api.html#buffer.rectangular_selection_modifier
### Select to Matching Brace
@@ -1803,13 +1798,14 @@ non-existant graphics capabilities:
* Edge lines may be obscured by text.
* Extra line ascent or descent renders improperly.
* No fold lines.
+* No hotspot underlines on mouse hover.
* No indentation guides.
* No indicators other than `INDIC_ROUNDBOX` and `INDIC_STRAIGHTBOX`, although
neither has translucent drawing and `INDIC_ROUNDBOX` does not have rounded
corners.
* When scrolling to the right, long lines overwrite margins.
* No marker symbols other than `MARK_CHARACTER`.
-* No mouse interactions, cursor types, or hotspots.
+* No mouse cursor types.
* Only up to 16 colors recognized, regardless of how many colors the terminal
supports. They are: black (`0x000000`), red (`0x800000`), green (`0x008000`),
yellow (`0x808000`), blue (`0x000080`), magenta (`0x800080`), cyan
diff --git a/properties.lua b/properties.lua
index 87b682ac..43bc5d30 100644
--- a/properties.lua
+++ b/properties.lua
@@ -10,6 +10,7 @@ buffer.additional_selection_typing = true
-- buffer.VS_USERACCESSIBLE
buffer.rectangular_selection_modifier = (WIN32 or OSX) and buffer.MOD_ALT or
buffer.MOD_SUPER
+-- Note: rectangular selection modifier for CURSES is always ctrl + alt.
--buffer.additional_carets_blink = false
--buffer.additional_carets_visible = false
diff --git a/src/textadept.c b/src/textadept.c
index 4d433087..1225d574 100644
--- a/src/textadept.c
+++ b/src/textadept.c
@@ -31,6 +31,7 @@
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/select.h>
+#include <sys/time.h>
#include <termios.h>
#else
#undef main
@@ -2276,6 +2277,7 @@ int main(int argc, char **argv) {
#elif CURSES
#if !_WIN32
ta_tk = termkey_new(0, 0);
+ printf("\033[?1003h"); // enable mouse mode
#endif
setlocale(LC_CTYPE, ""); // for displaying UTF-8 characters properly
initscr(); // raw()/cbreak() and noecho() are taken care of in libtermkey
@@ -2371,7 +2373,7 @@ int main(int argc, char **argv) {
#endif
Scintilla *view = focused_view;
- int c = 0;
+ int c = 0, button = 0, event = 0, y = 0, x = 0, millis = 0;
#if _WIN32
int keysyms[] = {0,SCK_DOWN,SCK_UP,SCK_LEFT,SCK_RIGHT,SCK_HOME,SCK_BACK,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,SCK_DELETE,SCK_INSERT,0,0,0,0,0,0,SCK_NEXT,SCK_PRIOR,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,SCK_END};
int shift_keysyms[] = {SCK_TAB,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,SCK_DELETE,0,0,SCK_END,0,0,0,SCK_HOME,SCK_INSERT,0,SCK_LEFT,0,0,0,0,0,0,0,0,SCK_RIGHT,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,SCK_UP,SCK_DOWN};
@@ -2400,7 +2402,7 @@ int main(int argc, char **argv) {
TermKeyResult res;
TermKeyKey key;
int keysyms[] = {0,SCK_BACK,SCK_TAB,SCK_RETURN,SCK_ESCAPE,0,SCK_BACK,SCK_UP,SCK_DOWN,SCK_LEFT,SCK_RIGHT,0,0,SCK_INSERT,SCK_DELETE,0,SCK_PRIOR,SCK_NEXT,SCK_HOME,SCK_END};
- while ((res = textadept_waitkey(ta_tk, &key)) != TERMKEY_RES_EOF) {
+ while ((c = 0, res = textadept_waitkey(ta_tk, &key)) != TERMKEY_RES_EOF) {
if (res == TERMKEY_RES_ERROR) continue;
if (key.type == TERMKEY_TYPE_UNICODE)
c = key.code.codepoint;
@@ -2419,15 +2421,21 @@ int main(int argc, char **argv) {
lua_pushinteger(lua, args[i]), lua_rawseti(lua, -2, i + 1);
lL_event(lua, "csi", LUA_TNUMBER, cmd, LUA_TTABLE,
luaL_ref(lua, LUA_REGISTRYINDEX), -1);
- refresh_all();
- continue;
+ } else if (key.type == TERMKEY_TYPE_MOUSE) {
+ termkey_interpret_mouse(ta_tk, &key, (TermKeyMouseEvent*)&event, &button,
+ &y, &x), y--, x--;
+ struct timeval time = {0, 0};
+ gettimeofday(&time, NULL);
+ millis = time.tv_sec * 1000 + time.tv_usec / 1000;
} else continue; // skip unknown types
int shift = key.modifiers & TERMKEY_KEYMOD_SHIFT;
int ctrl = key.modifiers & TERMKEY_KEYMOD_CTRL;
int alt = key.modifiers & TERMKEY_KEYMOD_ALT;
#endif
- if (!lL_event(lua, "keypress", LUA_TNUMBER, c, LUA_TBOOLEAN, shift,
- LUA_TBOOLEAN, ctrl, LUA_TBOOLEAN, alt, -1))
+ if (!c || c == KEY_MOUSE)
+ scintilla_send_mouse(view, event, millis, button, y, x, shift, ctrl, alt);
+ else if (!lL_event(lua, "keypress", LUA_TNUMBER, c, LUA_TBOOLEAN, shift,
+ LUA_TBOOLEAN, ctrl, LUA_TBOOLEAN, alt, -1))
scintilla_send_key(view, c, shift, ctrl, alt);
if (quit && lL_event(lua, "quit", -1)) {
l_close(lua);
@@ -2449,6 +2457,7 @@ int main(int argc, char **argv) {
}
endwin();
#if !_WIN32
+ printf("\033[?1003l"); // disable mouse mode
termkey_destroy(ta_tk);
#endif
#endif