comp.lang.ada
 help / color / mirror / Atom feed
* TextColors in Ada
@ 1997-05-26  0:00 Markus Voelter P
  1997-05-26  0:00 ` Rolf Ebert
  0 siblings, 1 reply; 2+ messages in thread
From: Markus Voelter P @ 1997-05-26  0:00 UTC (permalink / raw)



Hi Ada,

i'm currently trying to write a Ada Editor with syntax highlighting,
( especially as an exercise for me, to learn Ada ). Therefore i need to
know the following things:
-  How can I get keys like ALT-A or Ctrl-F
-  how can I display different Textcolors 
All this i try under Linux, Gnat, no X11

regards Markus
voelter@rz-nov2.rz.fh-weingarten.de




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: TextColors in Ada
  1997-05-26  0:00 TextColors in Ada Markus Voelter P
@ 1997-05-26  0:00 ` Rolf Ebert
  0 siblings, 0 replies; 2+ messages in thread
From: Rolf Ebert @ 1997-05-26  0:00 UTC (permalink / raw)



>>>>> "Markus" == Markus Voelter P <voelter@rz-nov2.rz.fh-weingarten.de> 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

\f
;;;---------------------------------------------------
;;; 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.")





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1997-05-26  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-05-26  0:00 TextColors in Ada Markus Voelter P
1997-05-26  0:00 ` Rolf Ebert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox