2012-01-10 48 views
9

Tôi nhận thấy có một tệp LexCoffeeScript.cxx trong mã nguồn SciTE; tuy nhiên, SciTE dường như không có tùy chọn menu CoffeeScript trong menu Ngôn ngữ của nó.Bật lexer CoffeeScript trong SciTE?

Thêm tùy chọn theo cách thủ công không có tác dụng - vẫn không có bất kỳ màu cú pháp nào.

Có cách nào để bật được xây dựng trong lexer (thay vì sử dụng sang một bên ngoài) không?

Trả lời

0

Bạn cần đặt dòng này vào tệp SciTEGlobal.properties của mình. Có thể mở trong menu Tùy chọn trong SciTE bằng cách nhấp vào Open Global Options File.

import lexers/[dir] 

đâu [dir] là vị trí của LexCoffeeScript.cxx tập tin trong thư mục lexers trong /usr/share/scite/.

CẬP NHẬT Cố gắng này bản thân mình, cài đặt của tôi về SciTE không có bất kỳ tập tin CoffeeScript cxx vì vậy tôi tải về các gói scintillua từ here được đóng gói với một lexer lua coffeescript. Làm theo hướng dẫn trên để cài đặt nó và nó hoạt động tốt.

+0

Xin lỗi, bạn đang nhập khẩu một * C++ * tập tin từ SciTE? Bạn có chắc chắn đó là cách để làm điều đó? – Mehrdad

+0

@Mehrdad Cập nhật câu trả lời của tôi với những gì tôi đã làm. Tôi không thể tìm thấy tệp '.cxx' trong nguồn của mình. – Jivings

+0

Có, và nó không hoạt động (hoặc có ý nghĩa nhiều). Bạn đã thử nó chưa? – Mehrdad

3

Rõ ràng, từ vựng CoffeeScript được biên dịch trong Scintilla nhưng không được sử dụng bởi SciTE. Tôi có nghĩa là không có tệp coffeescript.properties hoặc bất kỳ tệp nào khác có liên quan đến từ khoá. Bạn mèo cố gắng tạo của riêng bạn và thiết lập các lexer gia hạn tập tin bạn sử dụng để coffeescript:

# Define SciTE settings for Coffeescript files. 
file.patterns.coffeescript=*.coffee 
filter.coffeescript=Coffeescript (coffee)|$(file.patterns.coffeescript)| 
lexer.$(file.patterns.coffeescript)=coffeescript 
... 

Sau đó, bạn sẽ xác định từ khóa, phong cách màu và các công cụ khác được hỗ trợ bởi lexer - kiểm tra nguồn của nó. Bạn có thể lấy cảm hứng trong cpp.properties, ví dụ: (Các lexer cho C/C++ và ngôn ngữ tương tự được gọi là cpp.) Dưới đây là hỗ trợ các quốc gia từ vựng:

val SCE_COFFEESCRIPT_DEFAULT=0 
val SCE_COFFEESCRIPT_COMMENT=1 
val SCE_COFFEESCRIPT_COMMENTLINE=2 
val SCE_COFFEESCRIPT_COMMENTDOC=3 
val SCE_COFFEESCRIPT_NUMBER=4 
val SCE_COFFEESCRIPT_WORD=5 
val SCE_COFFEESCRIPT_STRING=6 
val SCE_COFFEESCRIPT_CHARACTER=7 
val SCE_COFFEESCRIPT_UUID=8 
val SCE_COFFEESCRIPT_PREPROCESSOR=9 
val SCE_COFFEESCRIPT_OPERATOR=10 
val SCE_COFFEESCRIPT_IDENTIFIER=11 
val SCE_COFFEESCRIPT_STRINGEOL=12 
val SCE_COFFEESCRIPT_VERBATIM=13 
val SCE_COFFEESCRIPT_REGEX=14 
val SCE_COFFEESCRIPT_COMMENTLINEDOC=15 
val SCE_COFFEESCRIPT_WORD2=16 
val SCE_COFFEESCRIPT_COMMENTDOCKEYWORD=17 
val SCE_COFFEESCRIPT_COMMENTDOCKEYWORDERROR=18 
val SCE_COFFEESCRIPT_GLOBALCLASS=19 
val SCE_COFFEESCRIPT_STRINGRAW=20 
val SCE_COFFEESCRIPT_TRIPLEVERBATIM=21 
val SCE_COFFEESCRIPT_HASHQUOTEDSTRING=22 
val SCE_COFFEESCRIPT_COMMENTBLOCK=22 
val SCE_COFFEESCRIPT_VERBOSE_REGEX=23 
val SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT=24 

Tất cả .properties file được nạp tự động bằng dòng import * từ SciTEGlobal.properties. Bạn cũng có thể thêm Coffeescript|coffee||\ vào menu.language để nhận một mục menu mới trong Languages và/hoặc *.coffee đến source.files để xem tiện ích mở rộng trong hộp thoại Mở tệp.

Thật lạ khi tác giả không cung cấp tệp .properties với từ khoá. Nó có thể là lexer JavaScript có thể được sử dụng thay thế. Bạn có thể hỏi về nó trong SciTE mailing list.

--- Ferda

1

Câu trả lời của Ferda là đúng.

Đây là một tập tin coffeescript.properties mẫu để bắt đầu và giúp bạn tiết kiệm một chút thời gian ...

# Define SciTE settings for Coffeescript files. 
file.patterns.coffeescript=*.coffee 
filter.coffeescript=Coffeescript (coffee)|$(file.patterns.coffeescript)| 
lexer.$(file.patterns.coffeescript)=coffeescript 

keywordclass.coffeescript=abstract boolean break byte case catch char class \ 
const continue debugger default delete do double else enum export extends \ 
final finally float for function goto if implements import in instanceof \ 
int interface long native new package private protected public \ 
return short static super switch synchronized this throw throws \ 
transient try typeof var void volatile while with 
keywords.$(file.patterns.coffeescript)=$(keywordclass.coffeescript) 

keywordclass2.coffeescript=$ 
keywords2.$(file.patterns.coffeescript)=$(keywordclass2.coffeescript) 

# White space 
style.coffeescript.0=fore:#808080 
# Comment: ### ### 
style.coffeescript.1=$(colour.code.comment.box),$(font.code.comment.box) 
# Line Comment: # 
style.coffeescript.2=$(colour.code.comment.line),$(font.code.comment.line) 
# Doc comment: block comments beginning with /** or /*! 
style.coffeescript.3=$(colour.code.comment.doc),$(font.code.comment.doc) 
# Number 
style.coffeescript.4=$(colour.number) 
# Keyword 
style.coffeescript.5=$(colour.keyword),bold 
# Double quoted string 
style.coffeescript.6=$(colour.string) 
# Single quoted string 
style.coffeescript.7=$(colour.char) 
# UUIDs (only in IDL) 
style.coffeescript.8=fore:#804080 
# Preprocessor 
style.coffeescript.9=$(colour.preproc) 
# Operators 
style.coffeescript.10=fore:#FF6600,bold 
# Identifiers 
style.coffeescript.11=fore:#FF1493 
# End of line where string is not closed 
style.coffeescript.12=fore:#000000,$(font.monospace),back:#E0C0E0,eolfilled 
# Verbatim strings 
style.coffeescript.13=fore:#007F00,$(font.monospace),back:#E0FFE0,eolfilled 
# Regular expressions for JavaScript 
style.coffeescript.14=fore:#3F7F3F,$(font.monospace),back:#E0F0FF,eolfilled 
# Doc Comment Line: line comments beginning with /// or //!. 
style.coffeescript.15=$(colour.code.comment.doc),$(font.code.comment.doc) 
# Keywords2 
style.coffeescript.16=fore:#B00040 
# Comment keyword 
style.coffeescript.17=fore:#3060A0,$(font.code.comment.doc) 
# Comment keyword error 
style.coffeescript.18=fore:#804020,$(font.code.comment.doc) 
# Raw strings 
style.coffeescript.20=$(colour.string),back:#FFF3FF,eolfilled 
# Triple-quoted strings 
style.coffeescript.21=$(font.monospace),fore:#007F00,back:#E0FFE0,eolfilled 
# Hash-quoted strings for Pike 
style.coffeescript.22=$(font.monospace),fore:#007F00,back:#E7FFD7,eolfilled 
# Verbose Regex 
style.coffeescript.23=fore:#659900 
# Verbose Regex Comment 
style.coffeescript.24=$(colour.code.comment.doc)