From 7a791ae5ef7dfd5a2e07b5ed69b01a4a0b066843 Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Tue, 9 Aug 2011 08:31:16 +0200 Subject: [PATCH] use LTerm_text.stylise_parenthesis Ignore-this: 89d793e3ecb8b555d195d7cdfeed0610 darcs-hash:20110809063116-c41ad-2ac81c5f65ec52f21883c5c8cb52383f62ba7c4e --- src/uTop_console.ml | 86 +-------------------------------------------- 1 file changed, 1 insertion(+), 85 deletions(-) diff --git a/src/uTop_console.ml b/src/uTop_console.ml index f93efab..b59ad55 100644 --- a/src/uTop_console.ml +++ b/src/uTop_console.ml @@ -359,91 +359,7 @@ object(self) loop_sharp tokens; (* Parenthesis matching. *) - - if not last && Array.length styled > 0 then begin - let rec rsearch idx left right depth = - if idx >= Array.length styled then - None - else - let ch, _ = styled.(idx) in - if ch = right then - if depth = 0 then - Some idx - else - rsearch (idx + 1) left right (depth - 1) - else if ch = left then - rsearch (idx + 1) left right (depth + 1) - else - rsearch (idx + 1) left right depth - in - let rec lsearch idx left right depth = - if idx < 0 then - None - else - let ch, _ = styled.(idx) in - if ch = left then - if depth = 0 then - Some idx - else - lsearch (idx - 1) left right (depth - 1) - else if ch = right then - lsearch (idx - 1) left right (depth + 1) - else - lsearch (idx - 1) left right depth - in - let matched = - if position = Array.length styled then - false - else - let ch, _ = styled.(position) in - match - if ch = lparen then - rsearch (position + 1) lparen rparen 0 - else if ch = lbrace then - rsearch (position + 1) lbrace rbrace 0 - else if ch = lbracket then - rsearch (position + 1) lbracket rbracket 0 - else if ch = rparen then - lsearch (position - 1) lparen rparen 0 - else if ch = rbrace then - lsearch (position - 1) lbrace rbrace 0 - else if ch = rbracket then - lsearch (position - 1) lbracket rbracket 0 - else - None - with - | Some idx -> - let ch, style = styled.(idx) in - styled.(idx) <- (ch, LTerm_style.merge styles.style_paren style); - true - | None -> - false - in - if not matched && position > 0 then - let ch, style = styled.(position - 1) in - match - if ch = lparen then - rsearch (position + 1) lparen rparen 0 - else if ch = lbrace then - rsearch (position + 1) lbrace rbrace 0 - else if ch = lbracket then - rsearch (position + 1) lbracket rbracket 0 - else if ch = rparen then - lsearch (position - 2) lparen rparen 0 - else if ch = rbrace then - lsearch (position - 2) lbrace rbrace 0 - else if ch = rbracket then - lsearch (position - 2) lbracket rbracket 0 - else - None - with - | Some idx -> - styled.(position - 1) <- (ch, LTerm_style.merge styles.style_paren style); - let ch, style = styled.(idx) in - styled.(idx) <- (ch, LTerm_style.merge styles.style_paren style) - | None -> - () - end; + if not last then LTerm_text.stylise_parenthesis styled position styles.style_paren; (styled, position)