赞 | 12 |
VIP | 107 |
好人卡 | 6 |
积分 | 4 |
经验 | 31122 |
最后登录 | 2024-6-29 |
在线时间 | 1606 小时 |
Lv2.观梦者 傻♂逼
- 梦石
- 0
- 星屑
- 374
- 在线时间
- 1606 小时
- 注册时间
- 2007-3-13
- 帖子
- 6562
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 yangff 于 2012-1-24 20:05 编辑
1.
如图,"#{aaa}"中aaa是变量却被当成字符串
$aaa.aaa后面那个"aaa"是方法名却被当成$aaa的一部分当作全局变量处理了
2.
如何实现Notepad++的那种会变色的折叠效果(边上那条表示折叠结构的线)
3.
如何实现多标签页?(一定要建多个StyledTextCtrl?我记得S是支持多页的吧,看默认的编辑器……)
下面是代码,使用时在Frame里面CodeBlock.new(self)就可以了
4. wxRuby里面哪些是可以跨平台的,或者说哪些是不行的- class CodeBlock
- def sci
- return @sci
- end
- def initialize(window)
- font = Font.new(12, TELETYPE, NORMAL, NORMAL,false,"Lucida Console")
- @sci = StyledTextCtrl.new(window)
- @sci.set_edge_mode(STC_EDGE_LINE)
- @sci.set_margin_width 0, @sci.text_width(STC_STYLE_LINENUMBER, '_9999')
- @sci.set_tab_width(2)
- @sci.set_use_tabs(false)
- @sci.set_tab_indents(true)
- @sci.set_back_space_un_indents(true)
- @sci.set_indent(2)
- @sci.set_edge_column(80)
- @sci.style_set_font(STC_STYLE_DEFAULT, font);
- @sci.style_set_foreground(STC_STYLE_DEFAULT, BLACK);
- @sci.style_set_background(STC_STYLE_DEFAULT, Colour.new(250,255,250));
- @sci.style_clear_all()
- @sci.ensure_caret_visible();
- @sci.set_caret_line_visible(true)
- @sci.set_caret_line_background(Colour.new(200,200,248))
- @sci.set_caret_line_back_alpha(40)
- @sci.style_set_foreground(STC_STYLE_LINENUMBER, LIGHT_GREY);
- @sci.style_set_background(STC_STYLE_LINENUMBER, WHITE);
- @sci.style_set_foreground(STC_STYLE_INDENTGUIDE, LIGHT_GREY);
- @sci.set_lexer(STC_LEX_RUBY)
- @sci.style_set_foreground(0, Colour.new(0,0,0)) #SCE_RB_DEFAULT
- @sci.style_set_foreground(2,Colour.new(0,128,0)) #SCE_RB_COMMENTLINE
- @sci.style_set_foreground(3, Colour.new(0,128,0)) #SCE_RB_POD
- @sci.style_set_foreground(4, Colour.new(128,0,0)) #SCE_RB_NUMBER
- @sci.style_set_foreground(5, BLUE) #SCE_RB_WORD
- @sci.style_set_foreground(6, Colour.new(128,0,128)) #SCE_RB_STRING
- @sci.style_set_foreground(7, Colour.new(128,0,128)) #SCE_RB_CHARACTER
- @sci.style_set_foreground(8, Colour.new(0,0,128)) #SCE_RB_CLASSNAME
- @sci.style_set_foreground(9, Colour.new(0,0,128)) #SCE_RB_DEFNAME
- @sci.style_set_foreground(10, Colour.new(0,128,192)) #SCE_RB_OPERATOR
- #@sci.style_set_bold(11,true) #SCE_RB_IDENTIFIER 局部变量 函数。。
- #@sci.style_set_italic(11,true)
- @sci.style_set_foreground(12,Colour.new(128,0,128)) #SCE_RB_REGEX
- @sci.style_set_italic(13,true) #SCE_RB_GLOBAL
- @sci.style_set_bold(13,true)
- @sci.style_set_foreground(14,Colour.new(192,96,0)) #SCE_RB_SYMBOL
- @sci.style_set_foreground(15, Colour.new(0,0,128)) #SCE_RB_MODULE_NAME
- @sci.style_set_italic(16,true) #SCE_RB_INSTANCE_VAR
- #@sci.style_set_bold(16,true) #SCE_RB_INSTANCE_VAR
- @sci.style_set_italic(17,true) #SCE_RB_CLASS_VAR
- @sci.style_set_bold(17,true) #SCE_RB_CLASS_VAR
- @sci.style_set_foreground(18, Colour.new(128,0,128)) #SCE_RB_BACKTICKS
- #SCE_RB_DATASECTION
- @sci.style_set_foreground(19, Colour.new(0,0,0)) #SCE_RB_DATASECTION
- @sci.style_set_foreground(20, Colour.new(128,0,128)) #SCE_RB_HERE_DELIM
- @sci.style_set_foreground(21, Colour.new(128,0,128)) #SCE_RB_HERE_DELIM Q
- @sci.style_set_foreground(22, Colour.new(128,0,128)) #SCE_RB_HERE_DELIM QQ
- @sci.style_set_foreground(23, Colour.new(128,0,128)) #SCE_RB_HERE_DELIM QX
- @sci.style_set_foreground(24, Colour.new(128,0,128)) #SCE_RB_STRING Q
- @sci.style_set_foreground(25, Colour.new(128,0,128)) #SCE_RB_STRING QQ
- @sci.style_set_foreground(26, Colour.new(128,0,128)) #SCE_RB_STRING QX
- @sci.style_set_foreground(27, Colour.new(128,0,128)) #SCE_RB_STRING QR
- @sci.style_set_foreground(28, Colour.new(128,0,128)) #SCE_RB_STRING QW
- @sci.style_set_foreground(29, BLUE) #SCE_RB_WORD_DEMOTED
- @sci.style_set_foreground(30, BLUE) #SCE_RB_STDIN
- @sci.style_set_foreground(31, BLUE) #SCE_RB_STDOUT
- @sci.style_set_foreground(40, BLUE) #SCE_RB_STDERR
-
- #SCE_RB_UPPER_BOUND
- @sci.set_key_words(0, "attr_accessor attr_reader attr_writer module_function begin break elsif module retry unless end case next return until class ensure nil self when def false not super while alias defined? for or then yield and do if redo true else in rescue undef")
-
-
- @sci.set_property("fold","1")
- @sci.set_property("fold.compact", "0")
- @sci.set_property("fold.comment", "1")
- @sci.set_property("fold.preprocessor", "1")
-
- @sci.set_margin_width(1, 0)
- @sci.set_margin_type(1, STC_MARGIN_SYMBOL)
- @sci.set_margin_mask(1, STC_MASK_FOLDERS)
- @sci.set_margin_width(1, 20)
- @sci.marker_define(STC_MARKNUM_FOLDER, STC_MARK_PLUS)
- @sci.marker_define(STC_MARKNUM_FOLDEROPEN, STC_MARK_MINUS)
- @sci.marker_define(STC_MARKNUM_FOLDEREND, STC_MARK_EMPTY)
- @sci.marker_define(STC_MARKNUM_FOLDERMIDTAIL, STC_MARK_EMPTY)
- @sci.marker_define(STC_MARKNUM_FOLDEROPENMID, STC_MARK_EMPTY)
- @sci.marker_define(STC_MARKNUM_FOLDERSUB, STC_MARK_EMPTY)
- @sci.marker_define(STC_MARKNUM_FOLDERTAIL, STC_MARK_EMPTY)
- #SendEditor(SCI_SETFOLDFLAGS, 16, 0);
- @sci.set_fold_flags(16)
- @sci.set_margin_sensitive(1,1)
-
-
- @sci.set_margin_type(0,STC_MARGIN_SYMBOL)
- @sci.set_margin_width(0, 10)
- @sci.set_margin_mask(0,1)
- @sci.marker_define(0,STC_MARK_ARROW)
- @sci.set_margin_sensitive(0,1)
- @sci.marker_set_foreground(0,Colour.new(255,0,0))
- #@sci.marker_add(0,0)
- window.evt_stc_charadded(@sci.get_id) {|evt| onCharadded(evt)}
- window.evt_stc_marginclick(@sci.get_id) {|evt| onMarginClick(evt)}
- #window.evt_stc_markerclick(@sci.get_id) {|evt| onMarkerClick(evt)}
- end
- def onCharadded(evt)
- chr = evt.get_key
- curr_line = @sci.get_current_line
-
- if(chr == 13)
- if curr_line > 0
- line_ind = @sci.get_line_indentation(curr_line - 1)
- if line_ind > 0
- @sci.set_line_indentation(curr_line, line_ind)
- @sci.goto_pos(@sci.position_from_line(curr_line)+line_ind)
- end
- end
- end
- end
- def onMarginClick(evt)
- line_num = @sci.line_from_position(evt.get_position)
- margin = evt.get_margin
- if(margin == 0)
- if @sci.marker_get(line_num)==1
- @sci.marker_delete(line_num,0)
- else
- @sci.marker_add(line_num,0)
- end
-
- end
- if(margin == 1)
- @sci.toggle_fold(line_num)
-
- end
- end
- end
复制代码 |
|