summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-05-19 20:38:11 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-05-19 20:38:11 -0700
commit9148406941f6633916d9f297dbde07459d30714c (patch)
tree18c9f0df18b305434be38bcb8c8caea4a881a785
parent1f8bf765519f3245fd646046f593ffd8ac215061 (diff)
downloadtxr-9148406941f6633916d9f297dbde07459d30714c.tar.gz
txr-9148406941f6633916d9f297dbde07459d30714c.tar.bz2
txr-9148406941f6633916d9f297dbde07459d30714c.zip
Implement listener variable for selection style.
* parser.c (listener_sel_inclusive_p_s): New symbol variable. (repl): Install current value of *listener-sel-inclusive-p* variable into linenoise. (parse_init): Initialize the symbol variable and register the Lisp special variable. * txr.1: Documented special variable and selection mode semantics.
-rw-r--r--parser.c7
-rw-r--r--txr.159
2 files changed, 49 insertions, 17 deletions
diff --git a/parser.c b/parser.c
index d876a4fa..e8c5f9d4 100644
--- a/parser.c
+++ b/parser.c
@@ -53,7 +53,7 @@
#endif
val parser_s, unique_s;
-val listener_hist_len_s, listener_multi_line_p_s;
+val listener_hist_len_s, listener_multi_line_p_s, listener_sel_inclusive_p_s;
val intr_s;
static val stream_parser_hash;
@@ -667,6 +667,7 @@ val repl(val bindings, val in_stream, val out_stream)
val old_sig_handler = set_sig_handler(num(SIGINT), func_n2(repl_intr));
val hist_len_var = lookup_global_var(listener_hist_len_s);
val multi_line_var = lookup_global_var(listener_multi_line_p_s);
+ val sel_inclusive_var = lookup_global_var(listener_sel_inclusive_p_s);
reg_varl(result_hash_sym, result_hash);
@@ -693,7 +694,7 @@ val repl(val bindings, val in_stream, val out_stream)
lino_hist_set_max_len(ls, c_num(cdr(hist_len_var)));
lino_set_multiline(ls, cdr(multi_line_var) != nil);
-
+ lino_set_selinclusive(ls, cdr(sel_inclusive_var) != nil);
reg_varl(counter_sym, counter);
reg_varl(var_counter_sym, var_counter);
line_u8 = linenoise(ls, prompt_u8);
@@ -818,6 +819,7 @@ void parse_init(void)
intr_s = intern(lit("intr"), user_package);
listener_hist_len_s = intern(lit("*listener-hist-len*"), user_package);
listener_multi_line_p_s = intern(lit("*listener-multi-line-p*"), user_package);
+ listener_sel_inclusive_p_s = intern(lit("*listener-sel-inclusive-p*"), user_package);
unique_s = gensym(nil);
prot1(&stream_parser_hash);
prot1(&unique_s);
@@ -825,4 +827,5 @@ void parse_init(void)
parser_l_init();
reg_var(listener_hist_len_s, num_fast(500));
reg_var(listener_multi_line_p_s, nil);
+ reg_var(listener_sel_inclusive_p_s, nil);
}
diff --git a/txr.1 b/txr.1
index 39b363ee..7f46dd02 100644
--- a/txr.1
+++ b/txr.1
@@ -42046,9 +42046,8 @@ While in visual selection mode, it is possible to move around using
the usual movement commands. The ending point of the selection
tracks the movement. The ending point of the selection is also
the position immediately to the left of the current character.
-Thus the selection excludes the rightmost character. The selection
-consists of the text between these two positions, whether or not
-they are reversed. The selected text is displayed in reverse video.
+
+The selected text is displayed in reverse video.
Typing Ctrl-S again while in visual selection mode cancels
the mode.
@@ -42056,18 +42055,23 @@ the mode.
Tab completion, history navigation, history search and editing in an external
editor all cancel visual selection mode.
-Note: the semantics of visual mode selection in the \*(TX listener differs from
-that of some text editors. In some text editors, a visual selection always
-includes the "character under the cursor", and thus is never empty.
-This works intuitively with block or underline cursors.
-The \*(TX selection semantics pairs excellently with the terminal
-cursor shape being configured to a vertical line or "I-beam" which appears
-between the characters. The selection then simply spans the region
-between the original I-beam position and the current I-beam position.
-When these positions coincide, the selection is empty. If an I-beam style
-cursor is configured, there is no apparent "character under the cursor".
-Editing concepts that involve the "character under the cursor" pair best with
-an underline or block cursor.
+By default, the the selection excludes the character which lies to the right of
+the rightmost end-point. Thus, the selection simply consists of the text
+between these two positions, whether or not they are reversed. This style of
+selection pairs excellently with an I-beam style cursor, and has clear
+semantics. The end-points are referenced to the positions between the
+characters, and everything between them is selected.
+
+The selection behavior may be altered using the Boolean configuration variable
+.codn *listener-sel-inclusive-p* .
+This variable is
+.code nil
+by default. If it is changed to true, then the selection includes the
+character to the right of the rightmost endpoint, if there is such a
+character within the current line. This style of selection
+pair well with a block-shaped cursor. It creates the apparent semantics that
+the end-points of the election are characters, rather than points
+between characters, and that these characters are included in the selection.
.NP* Selection Endpoint Toggle
@@ -42335,6 +42339,31 @@ If multi-line mode is toggled interactively from within the listener,
the variable is updated to reflect the latest state. This happens
when the command is submitted for evaluation.
+.coNP Special variable @ *listener-sel-inclusive-p*
+.desc
+This Boolean variable controls the behavior of visual selection.
+It is
+.code nil
+by default.
+
+A visual selection is determined by end-points, which are abstract positions
+understood as being between characters. When a visual selection begins,
+it marks an end-point immediately to the left of a block-shaped cursor,
+or precisely at the in-between position of an I-beam cursor.
+The end of the visual selection is similarly determined from the ending
+cursor position. The selection consists of those characters which lie
+between these positions. This style of selection pairs well with an I-beam
+style cursor shape.
+
+If the
+.code *listener-sel-inclusive-p*
+variable is set true, then the selection also includes one more
+character to the right of the rightmost endpoint, if there is
+such a character within the current line, giving rise to the appearance
+that the selection is determined by the starting and ending character,
+and includes them. This type of selection pairs well with a block-shaped
+cursor.
+
.SH* SETUID/SETGID OPERATION
On platforms with the Unix filesystem and process security model, \*(TX has