From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,15b10874b8da3199 X-Google-Attributes: gid103376,public From: Rolf Ebert Subject: Re: TextColors in Ada Date: 1997/05/26 Message-ID: X-Deja-AN: 244072909 References: <33892959.5B47@rz-nov2.rz.fh-weingarten.de> Organization: Rolf Ebert from home Newsgroups: comp.lang.ada Date: 1997-05-26T00:00:00+00:00 List-Id: >>>>> "Markus" == Markus Voelter P writes: Markus> Hi Ada, i'm currently trying to write a Ada Editor with syntax Markus> highlighting, ( especially as an exercise for me, to learn Ada Markus> ). Therefore i need to know the following things: - How can I Markus> get keys like ALT-A or Ctrl-F - how can I display different Markus> Textcolors All this i try under Linux, Gnat, no X11 Have a look at the recently published packet ncurses-4.1. Curses is a kind of standard Unix library for writing programs with user interaction in a terminal independant way. Ncurses supports colours and the latest version contains a complete Ada binding. As for colouring syntactic Ada contructs I include the regular expressions used in the Emacs Ada mode. Even without knowing Lisp, you should get the idea what it does. Mail me if I can help you. Markus> regards Markus voelter@rz-nov2.rz.fh-weingarten.de Rolf ebert@waporo.muc.de ;;;--------------------------------------------------- ;;; support for font-lock ;;;--------------------------------------------------- ;; Strings are a real pain in Ada because a single quote character is ;; overloaded as a string quote and type/instance delimiter. By default, a ;; single quote is given punctuation syntax in `ada-mode-syntax-table'. ;; So, for Font Lock mode purposes, we mark single quotes as having string ;; syntax when the gods that created Ada determine them to be. sm. (defconst ada-font-lock-syntactic-keywords ;; Mark single quotes as having string quote syntax in 'c' instances. '(("\\(\'\\).\\(\'\\)" (1 (7 . ?\')) (2 (7 . ?\'))))) (defconst ada-font-lock-keywords-1 (list ;; ;; handle "type T is access function return S;" ;; (list "\\<\\(function[ \t]+return\\)\\>" '(1 font-lock-keyword-face) ) ;; ;; accept, entry, function, package (body), protected (body|type), ;; pragma, procedure, task (body) plus name. (list (concat "\\<\\(" "accept\\|" "entry\\|" "function\\|" "package[ \t]+body\\|" "package\\|" "pragma\\|" "procedure\\|" "protected[ \t]+body\\|" "protected[ \t]+type\\|" "protected\\|" ;; "p\\(\\(ackage\\|rotected\\)\\(\\|[ \t]+\\(body\\|type\\)\\)\ ;;\\|r\\(agma\\|ocedure\\)\\)\\|" "task[ \t]+body\\|" "task[ \t]+type\\|" "task" ;; "task\\(\\|[ \t]+body\\)" "\\)\\>[ \t]*" "\\(\\sw+\\(\\.\\sw*\\)*\\)?") '(1 font-lock-keyword-face) '(2 font-lock-function-name-face nil t))) "Subdued level highlighting for Ada mode.") (defconst ada-font-lock-keywords-2 (append ada-font-lock-keywords-1 (list ;; ;; Main keywords, except those treated specially below. (concat "\\<\\(" ; ("abort" "abs" "abstract" "accept" "access" "aliased" "all" ; "and" "array" "at" "begin" "case" "declare" "delay" "delta" ; "digits" "do" "else" "elsif" "entry" "exception" "exit" "for" ; "generic" "if" "in" "is" "limited" "loop" "mod" "not" ; "null" "or" "others" "private" "protected" ; "range" "record" "rem" "renames" "requeue" "return" "reverse" ; "select" "separate" "tagged" "task" "terminate" "then" "until" ; "while" "xor") "a\\(b\\(ort\\|s\\(\\|tract\\)\\)\\|cce\\(pt\\|ss\\)\\|" "l\\(iased\\|l\\)\\|nd\\|rray\\|t\\)\\|begin\\|case\\|" "d\\(e\\(clare\\|l\\(ay\\|ta\\)\\)\\|igits\\|o\\)\\|" "e\\(ls\\(e\\|if\\)\\|ntry\\|x\\(ception\\|it\\)\\)\\|for\\|" "generic\\|i[fns]\\|l\\(imited\\|oop\\)\\|mod\\|n\\(ot\\|ull\\)\\|" "o\\(r\\|thers\\|ut\\)\\|pr\\(ivate\\|otected\\)\\|" "r\\(a\\(ise\\|nge\\)\\|e\\(cord\\|m\\|names\\|queue\\|turn\\|verse\\)\\)\\|" "se\\(lect\\|parate\\)\\|" "t\\(agged\\|erminate\\|hen\\)\\|until\\|" ; task removed "wh\\(ile\\|en\\)\\|xor" ; "when" added "\\)\\>") ;; ;; Anything following end and not already fontified is a body name. '("\\<\\(end\\)\\>\\([ \t]+\\)?\\([a-zA-Z0-9_\\.]+\\)?" (1 font-lock-keyword-face) (3 font-lock-function-name-face nil t)) ;; ;; Variable name plus optional keywords followed by a type name. Slow. ; (list (concat "\\<\\(\\sw+\\)\\>[ \t]*:?[ \t]*" ; "\\(access\\|constant\\|in\\|in[ \t]+out\\|out\\)?[ \t]*" ; "\\(\\sw+\\)?") ; '(1 font-lock-variable-name-face) ; '(2 font-lock-keyword-face nil t) '(3 font-lock-type-face nil t)) ;; ;; Optional keywords followed by a type name. (list (concat ; ":[ \t]*" "\\<\\(access\\|constant\\|in[ \t]+out\\|in\\|out\\)\\>" "[ \t]*" "\\(\\sw+\\)?") '(1 font-lock-keyword-face nil t) '(2 font-lock-type-face nil t)) ;; ;; Keywords followed by a type or function name. (list (concat "\\<\\(" "new\\|of\\|subtype\\|type" "\\)\\>[ \t]*\\(\\sw+\\)?[ \t]*\\((\\)?") '(1 font-lock-keyword-face) '(2 (if (match-beginning 4) font-lock-function-name-face font-lock-type-face) nil t)) ;; ;; Keywords followed by a (comma separated list of) reference. (list (concat "\\<\\(goto\\|raise\\|use\\|with\\)\\>" ; "when" removed ; "[ \t]*\\(\\sw+\\(\\.\\sw*\\)*\\)?") ; RE "[ \t]*\\([a-zA-Z0-9_\\.\\|, ]+\\)\\W") '(1 font-lock-keyword-face) '(2 font-lock-reference-face nil t)) ;; ;; Goto tags. '("<<\\(\\sw+\\)>>" 1 font-lock-reference-face) )) "Gaudy level highlighting for Ada mode.") (defvar ada-font-lock-keywords ada-font-lock-keywords-1 "Default expressions to highlight in Ada mode.")