2016-05-24 18 views
7

Tôi muốn áp dụng cú pháp tô sáng cho chương trình gọi là "Phosim" và tôi thường lưu các tệp chương trình Phosim (instanceCatalogs) với đuôi tệp .cat.Làm nổi bật cú pháp cho kiểu tập tin tùy chỉnh trong geany với các từ khóa có chứa chữ hoa, chữ thường và gạch dưới

Bây giờ tôi thích áp dụng cú pháp tô sáng cho tất cả các tệp có phần mở rộng .cat.

Cho đến nay tôi đã làm điều này:
Trước tiên tôi tạo filetype tập tin cấu hình mở rộng: ~/.config/geany/filetype_extensions.conf
Nội dung này trông như thế này:

[Extensions] 
Gnuplot=*.gp;*.gnu;*.plt; 
Galfit=*.gal; 
Phosim=*.cat; 
[Groups] 
Script=Gnuplot;Galfit;Phosim; 

Ở đây, tôi đang cố gắng để áp dụng tùy chỉnh nổi bật với các chương trình Gnuplot, Galfit và Phosim. Đối với Gnuplot và Galfit nó hoạt động tốt. Nhưng đối với Phosim tôi có một số vấn đề.

Sau đó, tôi tạo ra tập tin tập tin cấu hình định nghĩa: ~/.config/geany/filedefs/filetypes.Phosim.conf
Các nội dung trong đó trông như thế này:

# Author : Bhishan Poudel 
# Date : May 24, 2016 
# Version : 1.0 


[styling] 
# Edit these in the colorscheme .conf file instead 
default=default 
comment=comment_line 
function=keyword_1 
variable=string_1,bold 
label=label 
userdefined=string_2 
number=number_2 


[keywords] 
# all items must be in one line separated by space 
variables=object Unrefracted_RA_deg SIM_SEED none 
functions= 
lables=10 
userdefined=angle 30 Angle_RA 20.0 none 
numbers=0 1 2 3 4 5 6 7 8 9 


[lexer_properties] 
nsis.uservars=1 
nsis.ignorecase=1 


[settings] 
# default extension used when saving files 
extension=cat 

# single comments, like # in this file 
comment_single=# 
# multiline comments 
#comment_open= 
#comment_close= 


# This setting works only for single line comments 
comment_use_indent=true 

# context action command (please see Geany's main documentation for details) 
context_action_cmd= 

# lexer filetype should be an existing lexer that does not use lexer_filetype itself 
lexer_filetype=NSIS 


[build-menu] 
EX_00_LB=Execute 
EX_00_CM= 
EX_00_WD= 
FT_00_LB= 
FT_00_CM= 
FT_00_WD= 
FT_02_LB= 
FT_02_CM= 
FT_02_WD= 

Bây giờ example.cat của tôi trông như thế này:

# example.cat 
angle 30 
Angle_RA 20.0 
object none 

# Till now, 
# Words highlighted : angle 30 object none 
# Words not highlighted: Angle_RA 20.0 
# I like them also to be highlighted! 

tôi đã làm nổi bật cú pháp chỉ có hai từ, tức là, đối tượng và không có. Tôi đã thử kiểu dáng bằng Fortran vì nó có chữ hoa nhưng nó cũng không hoạt động.

Làm cách nào để chúng tôi có được cú pháp nổi bật cho các tên biến chứa chữ hoa, chữ thường và dấu gạch dưới?

Ví dụ:
tôi đã nổi bật cú pháp cho chữ: objectnone.
Nhưng, đã không nhận được nổi bật cú pháp cho chữ: Angle_RA20.0

Ngoài ra, tôi số của tôi 0, 1, .., 9 được đánh dấu thập phân nhưng không được nhấn mạnh. Làm thế nào chúng ta có thể làm nổi bật số thập phân quá?

Ví dụ:
tôi đã nổi bật cú pháp cho chữ: 11000 nhưng đã không nhận được nổi bật cú pháp cho chữ: 49552.3180.0

Một số liên kết hữu ích đang theo dõi:
Make Geany recognize additional file extensions
Custom syntax highlighting in Geany
http://www.geany.org/manual/current/index.html#custom-filetypes http://www.geany.org/manual/#lexer-filetype

Trả lời

2

Thay vì creatin g tập tin định nghĩa tập tin mới Tôi đã thêm phần mở rộng tập tin cho Python và nó làm việc cho tôi.

Ví dụ: tôi muốn tùy chỉnh làm nổi bật các tệp có phần mở rộng .icat (Nếu bạn quan tâm, đây là tệp danh mục ví dụ cho Phần mềm Phosim trong Thiên văn học.)

Nhược điểm: Những lời bổ sung cũng được nhấn mạnh trong các kịch bản python (py, pyc, .ipy)

Lưu ý: Nếu bài viết ai giải pháp mà làm việc với phần mở rộng tập tin mới, tôi sẽ ~/.config/geany/filedefs/filetypes.Phosim.conf nhiệt liệt chào đón điều đó. tập tin example.pcat của tôi trông như thế này:

# example.pcat 
Unrefracted_RA_deg 0 
Unrefracted_Dec_deg 0 
Unrefracted_Azimuth 0 
Unrefracted_Altitude 89 
Slalib_date 1994/7/19/0.298822999997 
Opsim_rotskypos 0 
Opsim_rottelpos 0 
Opsim_moondec -90 
Opsim_moonra 180 
Opsim_expmjd 49552.3 
Opsim_moonalt -90 
Opsim_sunalt -90 
Opsim_filter 2 
Opsim_dist2moon 180.0 
Opsim_moonphase 10.0 
Opsim_obshistid 99999999 
Opsim_rawseeing 0.65 
SIM_SEED 1000 
SIM_MINSOURCE 1 
SIM_TELCONFIG 0 
SIM_CAMCONFIG 1 
SIM_VISTIME 15000.0 
SIM_NSNAP 1 
object 0 0.0 0.0 20 ../sky/sed_flat.txt 0 0 0 0 0 0 bhishan.fits 0.09 0.0 none 

Tôi muốn Geany để làm nổi bật tất cả các từ đầu tiên với màu vàng, số với mangenta, và từ 'không' với màu xanh.

Trước tiên tôi tạo ra (hoặc, thay đổi nội dung nếu đã tồn tại) file:

~/.config/geany/filetype_extensions.conf 

Và thêm vào sau những thứ bên trong nó.

[Extensions] 
Gnuplot=*.gp;*.gnu;*.plt; 
Galfit=*.gal; 
Phosim=*.pcat; 
Python=*.py;*.pyc;*.ipy;*.icat;*.pcat 
[Groups] 
Script=Gnuplot;Galfit;Phosim;Python; 

Sau đó, tôi đã thêm KEYWORDS bổ sung vào các từ khóa đã tồn tại trong loại tệp python.
Đối với điều này tôi tạo ra (hoặc, thay đổi nội dung nếu đã tồn tại) file:

~/.config/geany/filedefs/filetypes.python 

Bây giờ, tập tin ~/.config/geany/filedefs/filetypes.python trông như thế này:

# Author : Bhishan Poudel 
# Date : June 9, 2016 
# Version : 1.0 
# File : Filetype for both python and phosim_instance_catalogs 

[styling] 
default=default 
commentline=comment_line 
number=number_1 
string=string_1 
character=character 
word=keyword_1 
triple=string_2 
tripledouble=string_2 
classname=type 
defname=function 
operator=operator 
identifier=identifier_1 
commentblock=comment 
stringeol=string_eol 
word2=keyword_2 
decorator=decorator 


[keywords] 
# all items must be in one line 
primary=and as assert break class continue def del elif else except exec finally for from global if import in is lambda not or pass print raise return try while with yield False None True Words_after_this_are_for_Phosim_pcat_files Unrefracted_RA_deg Unrefracted_Dec_deg Unrefracted_Azimuth Unrefracted_Altitude Slalib_date Opsim_moondec Opsim_rotskypos Opsim_rottelpos Opsim_moondec Opsim_moonra Opsim_expmjd Opsim_moonalt Opsim_sunalt Opsim_filter Opsim_dist2moon Opsim_moonphase Opsim_obshistid Opsim_rawseeing SIM_SEED SIM_MINSOURCE SIM_TELCONFIG SIM_CAMCONFIG SIM_VISTIME SIM_NSNAP object 


identifiers=ArithmeticError AssertionError AttributeError BaseException BufferError BytesWarning DeprecationWarning EOFError Ellipsis EnvironmentError Exception FileNotFoundError FloatingPointError FutureWarning GeneratorExit IOError ImportError ImportWarning IndentationError IndexError KeyError KeyboardInterrupt LookupError MemoryError NameError NotImplemented NotImplementedError OSError OverflowError PendingDeprecationWarning ReferenceError RuntimeError RuntimeWarning StandardError StopIteration SyntaxError SyntaxWarning SystemError SystemExit TabError TypeError UnboundLocalError UnicodeDecodeError UnicodeEncodeError UnicodeError UnicodeTranslateError UnicodeWarning UserWarning ValueError Warning ZeroDivisionError __debug__ __doc__ __import__ __name__ __package__ abs all any apply basestring bin bool buffer bytearray bytes callable chr classmethod cmp coerce compile complex copyright credits delattr dict dir divmod enumerate eval execfile exit file filter float format frozenset getattr globals hasattr hash help hex id input int intern isinstance issubclass iter len license list locals long map max memoryview min next object oct open ord pow print property quit range raw_input reduce reload repr reversed round set setattr slice sorted staticmethod str sum super tuple type unichr unicode vars xrange zip array arange Catagorical cStringIO DataFramedate_range genfromtxt linspace loadtxt matplotlib none numpy np pandas pd plot plt pyplot savefig scipy Series sp StringIO 


[lexer_properties] 
fold.comment.python=1 
fold.quotes.python=1 


[settings] 
# default extension used when saving files 
extension=py 

# the following characters are these which a "word" can contains, see documentation 
wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ

# MIME type 
mime_type=text/x-python 
comment_single=# 
comment_open=""" 
comment_close=""" 
comment_use_indent=true 

# context action command (please see Geany's main documentation for details) 
context_action_cmd= 


[indentation] 
width=4 
# 0 is spaces, 1 is tabs, 2 is tab & spaces 
type=0 


[build_settings] 
# %f will be replaced by the complete filename 
# %e will be replaced by the filename without extension 
# (use only one of it at one time) 
compiler=python -m py_compile "%f" 
run_cmd=python "%f" 


[build-menu] 
FT_00_LB=Execute 
FT_00_CM=python %f 
FT_00_WD= 
FT_01_LB= 
FT_01_CM= 
FT_01_WD= 
FT_02_LB= 
FT_02_CM= 
FT_02_WD= 
EX_00_LB=Execute 
EX_00_CM=clear; python %f 
EX_00_WD= 
error_regex=([^:]+):([0-9]+):([0-9:]+)? .* 
EX_01_LB= 
EX_01_CM= 
EX_01_WD= 

Bây giờ, tôi khởi động lại Geany và tôi có thể nhìn thấy tất cả các từ đầu tiên có màu vàng, các màu khác và từ 'không' có màu xanh dương.

Các vấn đề liên quan