aboutsummaryrefslogtreecommitdiff
path: root/ide
diff options
context:
space:
mode:
authorGuillaume Melquiond2019-07-26 15:25:07 +0200
committerGuillaume Melquiond2019-07-26 15:25:07 +0200
commit0d5b3272afefe1b417edbdf1258849b758648eb3 (patch)
tree6a52372aaf5b452836d0ad01d12cb804995fcb73 /ide
parent9b7b34702f1134841f7f9408db27074b5479e07d (diff)
Remove underscores from inserted texts.
Underscores are used as prefix for accelerators in gtk. In particular, double underscores are used to escape them. So, when applying a template, underscores should be cleaned from the inserted text.
Diffstat (limited to 'ide')
-rw-r--r--ide/coqide.ml18
1 files changed, 14 insertions, 4 deletions
diff --git a/ide/coqide.ml b/ide/coqide.ml
index 8d95dcee27..b91a5612c1 100644
--- a/ide/coqide.ml
+++ b/ide/coqide.ml
@@ -881,10 +881,20 @@ let no_under = Util.String.map (fun x -> if x = '_' then '-' else x)
let alpha_items menu_name item_name l =
let mk_item text =
let text' =
- let last = String.length text - 1 in
- if text.[last] = '.'
- then text ^"\n"
- else text ^" "
+ let len = String.length text in
+ let buf = Buffer.create (len + 1) in
+ let escaped = ref false in
+ String.iter (fun c ->
+ if !escaped then
+ let () = Buffer.add_char buf c in
+ escaped := false
+ else if c = '_' then escaped := true
+ else Buffer.add_char buf c
+ ) text;
+ if text.[len - 1] = '.'
+ then Buffer.add_char buf '\n'
+ else Buffer.add_char buf ' ';
+ Buffer.contents buf
in
let callback _ =
on_current_term (fun sn -> sn.buffer#insert_interactive text')