注册会员 登录
Project1 返回首页

zh99998的个人空间 https://rpg.blue/?42757 [收藏] [复制] [分享] [RSS]

日志

Sci-style

已有 533 次阅读2010-11-18 15:21 |个人分类:Ruby

仅自己备用+纪念。。需要的拿,看不懂不要问

style = "
# White space
style.ruby.0=fore:#128,128,128
# Error
style.ruby.1=back:#255,0,0
# Comment line
style.ruby.2=fore:#00,127,00,$(font.comment)
# POD
style.ruby.3=fore:#00,64,00,back:#192,255,192,$(font.monospace),eolfilled
# Number
style.ruby.4=fore:#00,127,127
# Word
style.ruby.5=fore:#00,00,127,bold
# String
style.ruby.6=fore:#127,00,127,$(font.monospace)
# Def name
style.ruby.9=fore:#00,127,127,bold
# Operator
style.ruby.10=bold
# Identifier
style.ruby.11=
# Regex
style.ruby.12=fore:#000000,back:#A0FFA0
# Global
style.ruby.13=fore:#128,00,128
# Symbol
style.ruby.14=fore:#192,160,48
# MODULE_NAME
style.ruby.15=fore:#160,00,160,bold
# INSTANCE_VAR
style.ruby.16=fore:#B00080
# DATASECTION
style.ruby.19=fore:#600000,back:#FFF0D8,eolfilled
# HERE_DELIM
style.ruby.20=fore:#000000,back:#DDD0DD
# HERE_Q
style.ruby.21=fore:#7F007F,back:#DDD0DD,eolfilled,notbold
# HERE_QQ
style.ruby.22=fore:#7F007F,back:#DDD0DD,eolfilled,bold
# HERE_QX
style.ruby.23=fore:#7F007F,back:#DDD0DD,eolfilled,italics
# STRING_Q
style.ruby.24=fore:#7F007F,$(font.monospace),notbold
# STRING_QQ
style.ruby.25=$(colour.string),$(font.monospace)
# STRING_QX
style.ruby.26=fore:#FFFF00,back:#A08080
# STRING_QR
style.ruby.27=fore:#000000,back:#A0FFA0
# STRING_QW
style.ruby.28=fore:#000000,back:#FFFFE0
# Demoted Keyword
style.ruby.29=$(style.ruby.5)
# STDIN
style.ruby.30=back:#FF8080
# STDOUT
style.ruby.31=back:#FF8080
# STDERR
style.ruby.40=back:#FF8080

# Matched Operators
style.ruby.34=fore:#0000FF,bold
style.ruby.35=fore:#FF0000,bold
# Braces are only matched in operator style
braces.ruby.style=10
"

result = []
style.each_line do |line|
line.chomp!
next if line.empty?
if line[/^\#\ (.*)/]
$style_now = "STC_RB_" + ($1.upcase.delete " ")
elsif line[/^style\.ruby\.\d+=(.*)/]
style = $1
    
    if style[/fore\:\#(\d+)\,(\d+)\,(\d+)/]
      result << "style_set_foreground(#{$style_now},Colour.new( #{$1}, #{$2}, #{$3}) )"
    end
    
    if style[/fore\:\#(\w{2})(\w{2})(\w{2})/]
      result << "style_set_foreground(#{$style_now},Colour.new( #{$1.hex}, #{$2.hex}, #{$3.hex}) )"
    end
    
    if style[/back\:\#(\d+)\,(\d+)\,(\d+)/]
      result << "style_set_background(#{$style_now},Colour.new( #{$1}, #{$2}, #{$3}) )"
    end
    
    if (style[/back\:\#(\w{2})(\w{2})(\w{2})/])
      result << "style_set_background(#{$style_now},Colour.new( #{$1.hex}, #{$2.hex}, #{$3.hex}) )"
    end
    
    if style["notbold"]
      result << "style_set_bold(#{$style_now}, false)"
    elsif style["bold"]
      result << "style_set_bold(#{$style_now}, true)"
    end

    if style["italic"]
      result << "style_set_italic(#{$style_now}, true)" #
    end
    
    if style["eolfilled"]
      result << "style_set_eol_filled(#{$style_now}, true)" #
    end
      
  end
  
end
  

print result.join "\n"
exit

鸡蛋

鲜花

评论 (0 个评论)

facelist doodle 涂鸦笔

您需要登录后才可以评论 登录 | 注册会员

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-26 23:54

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

返回顶部