[Lisppaste-cvs] CVS update: lisppaste2/coloring-types.lisp

Brian Mastenbrook bmastenbrook at common-lisp.net
Tue Nov 16 21:55:53 UTC 2004


Update of /project/lisppaste/cvsroot/lisppaste2
In directory common-lisp.net:/tmp/cvs-serv942

Modified Files:
	coloring-types.lisp 
Log Message:
add Objective C coloring type

Date: Tue Nov 16 22:55:52 2004
Author: bmastenbrook

Index: lisppaste2/coloring-types.lisp
diff -u lisppaste2/coloring-types.lisp:1.10 lisppaste2/coloring-types.lisp:1.11
--- lisppaste2/coloring-types.lisp:1.10	Sat Sep 25 22:20:27 2004
+++ lisppaste2/coloring-types.lisp	Tue Nov 16 22:55:51 2004
@@ -268,6 +268,8 @@
     "switch" "typedef" "union"  "unsigned" "void"
     "volatile" "while"  "__restrict" "_Bool"))
 
+(defvar *c-terminators* '(#\space #\return #\tab #\newline #\. #\/ #\- #\* #\+ #\{ #\} #\( #\) #\' #\" #\[ #\] #\< #\> #\#))
+
 (define-coloring-type :basic-c "Basic C"
   :modes (:normal :comment :word-ish :paren-ish :string :char :single-escape :preprocessor)
   :default-mode :normal
@@ -276,7 +278,7 @@
   ((:normal
     ((scan-any "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789")
      (set-mode :word-ish
-               :until (scan-any '(#\space #\return #\tab #\newline #\. #\/ #\- #\* #\+ #\{ #\} #\( #\) #\' #\" #\[ #\] #\< #\> #\#))
+               :until (scan-any *c-terminators*)
                :advancing nil))
     ((scan "/*")
      (set-mode :comment
@@ -423,3 +425,20 @@
           (format nil "<span class=\"symbol\">~A</span>"
                   s)
           s)))))
+
+(define-coloring-type :objective-c "Objective C"
+  :autodetect (lambda (text) (search "mac" text :test #'char=))
+  :parent :c++
+  :formatters
+  ((:word-ish
+    (lambda (type s)
+      (declare (ignore type))
+      (let ((result (if (find-package :cocoa-lookup)
+			(funcall (symbol-function (intern "SYMBOL-LOOKUP" :cocoa-lookup))
+                                  s))))
+        (if result
+            (format nil "<a href=\"~A\" class=\"symbol\">~A</a>"
+                    result (call-parent-formatter))
+	    (if (member s *c-reserved-words* :test #'string=)
+		(format nil "<span class=\"symbol\">~A</span>" s)
+		s)))))))





More information about the Lisppaste-cvs mailing list