def update_from_config(self, config_view): lg = ui.View() lg.present("sheet", hide_title_bar=True) logger.debug("Updating configuration") tv = self["editor_view"]["WebEditor"]["web_view"] config = config_view.config font_size = config.get_value("editor.font.size") gutter = config.get_value("editor.show.gutter") style = config.get_value("editor.style") margin = config.get_value("editor.print.margin") wrap = config.get_value("editor.line.wrap") soft_tab = config.get_value("editor.soft.tabs") tab_size = config.get_value("editor.tab.size") lb = ui.Label() lb.text = "Loading Style %r" % style lb.flex = "WH" lg.add_subview(lb) lb.size_to_fit() fs = '''for (var elm in document.getElementsByClass('.CodeMirror')) { elm.style.font_size = '%ipt';" }''' % font_size logger.debug("Applying theme: %r", style) if len(themes.view_list) < 1: themes.get_view_list(self.superview) themes.get_view_list(self.superview.superview) themes.get_view_list(self.superview.fileViewer) themes.get_view_list(self.superview.fileViewer.listview) themes.get_view_list(self.superview.fileViewer.navview) def load(): s = time.clock() self.superview.fileViewer.style = style self.superview.fileViewer.listview.reload() self.superview.fileViewer.set_style() themes.recursive_style_set(style) tv.eval_js("editor.setOption('theme', '%s')" % style) tv.eval_js("editor.setOption('tabSize', '%s')" % tab_size) tv.eval_js("editor.setOption('indentWithTabs', '%s')" % soft_tab) tv.eval_js("editor.setOption('lineWrapping', '%s')" % wrap) tv.eval_js("editor.setOption('lineNumbers', '%s')" % gutter) bc = themes.themes_data[style][0] tv.eval_js("document.body.style.backgroundColor = '%s'" % bc) e = time.clock() logger.debug("Took %.3f seconds to set the style", e - s) lg.close() ui.animate(load, duration=0.001, delay=0.001)
def configure(sender): sss_view = sender.superview.superview.superview ss_view = sender.superview.superview if sss_view: sss_view.config_view.present("sheet") sss_view.config_view.wait_modal() tv = sender.superview.superview["contentContainer"][ "editor_view"]["WebEditor"]["web_view"] config = sss_view.config_view.config font_size = config.get_value("editor.font.size") gutter = config.get_value("editor.show.gutter") style = config.get_value("editor.style") margin = config.get_value("editor.print.margin") wrap = config.get_value("editor.line.wrap") soft_tab = config.get_value("editor.soft.tabs") tab_size = config.get_value("editor.tab.size") fs = '''for (var elm in document.getElementsByClass('.CodeMirror')) { elm.style.font_size = '%ipt';" }''' % font_size if len(themes.view_list) < 1: themes.get_view_list(ss_view) themes.get_view_list(ss_view.superview) themes.get_view_list(ss_view.fileViewer) themes.get_view_list(ss_view.fileViewer.listview) themes.get_view_list(ss_view.fileViewer.navview) def load(): s = time.clock() ss_view.fileViewer.style = style ss_view.fileViewer.listview.reload() ss_view.fileViewer.set_style() themes.recursive_style_set(style) tv.eval_js("editor.setOption('theme', '%s')" % style) tv.eval_js("editor.setOption('tabSize', '%s')" % tab_size) tv.eval_js("editor.setOption('indentWithTabs', '%s')" % soft_tab) tv.eval_js("editor.setOption('lineWrapping', '%s')" % wrap) tv.eval_js("editor.setOption('lineNumbers', '%s')" % gutter) bc = themes.themes_data[style][0] tv.eval_js("document.body.style.backgroundColor = '%s'" % bc) e = time.clock() logger.debug("Took %.3f seconds to set the style", e - s) # lg.close() ui.animate(load, duration=0.001, delay=0.001) else: console.alert("Configuration is only available through the Main View")