def receivedStdout(self, proc, buf, length): """ Writes the received text from Rumor into the Kate buffer """ text = unicode(QString.fromUtf8(buf, length)) text = text.replace('\r', '') # remove carriage returns if text == '\n': return # discard single newline, typically output on exit. if self.noBarlines: text = text.replace('|', '') text = text.replace('\n\n', '\n') # avoid empty lines text = text.replace('\n', '\n' + self.indent) editor.insertText(text)
def keyPressEvent(self, e): """ Called when the user presses a key. """ if not self.r.isRunning(): return if e.key() == Qt.Key_Escape: self.r.animateClick() elif self.r.keyboardEmu: if e.key() in (Qt.Key_Enter, Qt.Key_Return): editor.insertText('\n' + self.r.indent) elif not e.isAutoRepeat() and not e.text().isEmpty(): # pass key to Rumor self.r.sendkey(str(e.text()))
def writeSign(self, sign): if self.shorthands.isChecked() and sign in shorthands: art = '^-_'[self.direction.currentItem()] + shorthands[sign] else: art = ('^', '', '_')[self.direction.currentItem()] + '\\' + sign text = editor.selectedText() if text: def repl(m): if m.group('chord'): return m.group('full') + art else: return m.group() editor.replaceSelectionWith(Res.chord.sub(repl, text)) else: editor.insertText(art)
def printout(self): """ Creates the score output using LilyDOM and writes it to the current document. """ d = Document() d.typographicalQuotes = self.settings.typq.isChecked() # version: Version(d.body, unicode(self.settings.lyversion.currentText())) Newline(d.body) # language: lang = self.settings.getLanguage() if lang: d.language = lang Text(d.body, '\\include "%s.ly"\n' % lang) # header: h, head = Header(d), self.titles.read() for n in headerNames: if head[n]: h[n] = head[n] # Remove default LilyPond tagline? if self.settings.tagl.isChecked() and not h['tagline']: Comment(h, " %s" % _("Remove default LilyPond tagline")) h['tagline'] = Scheme(d, '#f') if len(h): d.body.append(h) Newline(d.body) # paper size: if self.settings.paper.currentItem(): Scheme(Paper(d.body), '(set-paper-size "%s"%s)' % ( str(self.settings.paper.currentText()), self.settings.paperLandscape.isChecked() and " 'landscape" or "" )) Newline(d.body) parts = self.parts.parts() if parts: self.printoutParts(d, parts) # and finally print out: editor.insertText(unicode(d))