def __set_buffer_code(self,buffer,file,linenum,before=3,after=3): """ Gets the code surrounding a selected line """ # Check if file exists and is a .py file # Generate tags for code window tools.newTextTag({'name': 'normal','family': 'courier'},buffer) tools.newTextTag({'name': 'current','family': 'courier','background': 'yellow','weight': 700},buffer) # Open file fd=open(file,'r') # Read lines count=0 for line in fd: count+=1 # Add code to buffer if count==linenum: iter=buffer.get_end_iter() # Set mark for later scrolling mark=buffer.create_mark(None,iter,True) buffer.insert_with_tags_by_name(iter,line,'current') else: iter=buffer.get_end_iter() buffer.insert_with_tags_by_name(iter,line,'normal') # Set cursor at line number and return mark to current line buffer.place_cursor(buffer.get_iter_at_line(linenum-1)) return mark
def setup_text_styles(self): """ Setup text styles used in application console log """ buf=self.widgets.txtConsoleLog.get_buffer() #newTextTag({'name': 'normal','foreground': self.preferences.log.normalcolor},buf) newTextTag({'name': 'internal','foreground': self.preferences.log.internalcolor, 'weight': 700},buf) #newTextTag({'name': 'info','foreground': self.preferences.log.notifcolor, 'weight': 700},buf) newTextTag({'name': 'error','foreground': self.preferences.log.errorcolor, 'weight': 700},buf)
def setupTextStyles(self): """ Setup text styles used by application """ buffer=self.widgets.txtLog.get_buffer() tools.newTextTag({'name': 'normal','foreground': self.preferences.log.normalcolor},buffer) tools.newTextTag({'name': 'internal','foreground': self.preferences.log.internalcolor, 'weight': 700},buffer) tools.newTextTag({'name': 'logopen','foreground': self.preferences.log.logopencolor, 'weight': 700},buffer) tools.newTextTag({'name': 'plugin','foreground': self.preferences.log.plugincolor, 'weight': 700},buffer)