def saveState(self): self.getParams() self.ctrl.findDlgFindText = misc.fromGUI(self.findEntry.GetValue()) self.ctrl.findDlgReplaceText = misc.fromGUI( self.replaceEntry.GetValue()) self.ctrl.findDlgMatchWholeWord = self.matchWhole self.ctrl.findDlgMatchCase = self.matchCase self.ctrl.findDlgDirUp = self.dirUp self.ctrl.findDlgUseExtra = self.useExtra tmp = [] for i in range(self.elements.GetCount()): tmp.append(bool(self.elements.IsChecked(i))) self.ctrl.findDlgElements = tmp
def OnReplace(self, event): if not self.sc.word: return sp = self.ctrl.sp u = undo.SinglePara(sp, undo.CMD_MISC, self.sc.line) word = util.toInputStr(misc.fromGUI(self.replaceEntry.GetValue())) ls = sp.lines sp.gotoPos(self.sc.line, self.sc.col) ls[self.sc.line].text = util.replace( ls[self.sc.line].text, word, self.sc.col, len(self.sc.word)) sp.rewrapPara(sp.getParaFirstIndexFromLine(self.sc.line)) # rewrapping a paragraph can have moved the cursor, so get the new # location of it, and then advance past the just-changed word self.sc.line = sp.line self.sc.col = sp.column + len(word) sp.clearMark() sp.markChanged() u.setAfter(sp) sp.addUndo(u) self.gotoNext(False)
def OnMisc(self, event = None): if (self.tsIndex == -1) or self.block: return ts = self.titles.pages[self.pageIndex][self.tsIndex] ts.items = [util.toInputStr(s) for s in misc.fromGUI(self.textEntry.GetValue()).split("\n")] self.stringsLb.SetString(self.tsIndex, "--".join(ts.items)) ts.x = util.str2float(self.xEntry.GetValue(), 0.0) ts.y = util.str2float(self.yEntry.GetValue(), 0.0) ts.setAlignment(self.alignCombo.GetClientData(self.alignCombo.GetSelection())) self.xEntry.Enable(not ts.isCentered) ts.size = util.getSpinValue(self.sizeEntry) ts.font = self.fontCombo.GetClientData(self.fontCombo.GetSelection()) ts.isBold = self.boldCb.GetValue() ts.isItalic = self.italicCb.GetValue() ts.isUnderlined = self.underlinedCb.GetValue() self.previewCtrl.Refresh()
def OnMisc(self, event=None): if (self.tsIndex == -1) or self.block: return ts = self.titles.pages[self.pageIndex][self.tsIndex] ts.items = [ util.toInputStr(s) for s in misc.fromGUI(self.textEntry.GetValue()).split("\n") ] self.stringsLb.SetString(self.tsIndex, "--".join(ts.items)) ts.x = util.str2float(self.xEntry.GetValue(), 0.0) ts.y = util.str2float(self.yEntry.GetValue(), 0.0) ts.setAlignment( self.alignCombo.GetClientData(self.alignCombo.GetSelection())) self.xEntry.Enable(not ts.isCentered) ts.size = util.getSpinValue(self.sizeEntry) ts.font = self.fontCombo.GetClientData(self.fontCombo.GetSelection()) ts.isBold = self.boldCb.GetValue() ts.isItalic = self.italicCb.GetValue() ts.isUnderlined = self.underlinedCb.GetValue() self.previewCtrl.Refresh()
def OnSearch(self, event = None): l = [] wx.BeginBusyCursor() s = util.lower(misc.fromGUI(self.searchEntry.GetValue())) sex = self.sexRb.GetSelection() nt = self.nameRb.GetSelection() selTypes = {} item = -1 while 1: item = self.typeList.GetNextItem(item, wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED) if item == -1: break selTypes[self.typeList.GetItemData(item)] = True if len(selTypes) == len(nameArr.typeNamesCnt): doTypes = False else: doTypes = True for i in xrange(nameArr.count): if (sex != 2) and (sex == nameArr.sex[i]): continue if doTypes and nameArr.type[i] not in selTypes: continue if s: name = util.lower(nameArr.name[i]) if nt == 0: if not name.startswith(s): continue elif nt == 1: if name.find(s) == -1: continue elif nt == 2: if not name.endswith(s): continue l.append(i) self.list.items = l self.list.SetItemCount(len(l)) self.list.EnsureVisible(0) wx.EndBusyCursor() self.foundLabel.SetLabel("%d names found." % len(l))
def OnSearch(self, event=None): l = [] wx.BeginBusyCursor() s = util.lower(misc.fromGUI(self.searchEntry.GetValue())) sex = self.sexRb.GetSelection() nt = self.nameRb.GetSelection() selTypes = {} item = -1 while 1: item = self.typeList.GetNextItem(item, wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED) if item == -1: break selTypes[self.typeList.GetItemData(item)] = True if len(selTypes) == len(nameArr.typeNamesCnt): doTypes = False else: doTypes = True for i in xrange(nameArr.count): if (sex != 2) and (sex == nameArr.sex[i]): continue if doTypes and nameArr.type[i] not in selTypes: continue if s: name = util.lower(nameArr.name[i]) if nt == 0: if not name.startswith(s): continue elif nt == 1: if name.find(s) == -1: continue elif nt == 2: if not name.endswith(s): continue l.append(i) self.list.items = l self.list.SetItemCount(len(l)) self.list.EnsureVisible(0) wx.EndBusyCursor() self.foundLabel.SetLabel("%d names found." % len(l))
def OnMisc(self, event=None): self.cfg.scriptDir = self.scriptDirEntry.GetValue().rstrip("/\\") self.cfg.pdfViewerPath = self.progEntry.GetValue() self.cfg.pdfViewerArgs = misc.fromGUI(self.argsEntry.GetValue()) for i, it in enumerate(self.checkListItems): setattr(self.cfg, it[0], bool(self.checkList.IsChecked(i))) self.cfg.paginateInterval = util.getSpinValue(self.paginateEntry) self.cfg.mouseWheelLines = util.getSpinValue(self.wheelScrollEntry) self.cfg.splashTime = util.getSpinValue(self.splashTimeEntry)
def OnMisc(self, event = None): self.cfg.scriptDir = self.scriptDirEntry.GetValue().rstrip("/\\") self.cfg.pdfViewerPath = self.progEntry.GetValue() self.cfg.pdfViewerArgs = misc.fromGUI(self.argsEntry.GetValue()) self.cfg.capitalize = self.autoCapSentences.GetValue() self.cfg.capitalizeI = self.autoCapI.GetValue() self.cfg.honorSavedPos = self.honorSavedPos.GetValue() self.cfg.checkOnExport = self.checkErrorsCb.GetValue() self.cfg.paginateInterval = util.getSpinValue(self.paginateEntry) self.cfg.confirmDeletes = util.getSpinValue(self.confDelEntry) self.cfg.mouseWheelLines = util.getSpinValue(self.wheelScrollEntry) self.cfg.splashTime = util.getSpinValue(self.splashTimeEntry)
def OnReplace(self, event=None, autoFind=False): if self.searchLine == -1: return False value = util.toInputStr(misc.fromGUI(self.replaceEntry.GetValue())) ls = self.ctrl.sp.lines sp = self.ctrl.sp u = undo.SinglePara(sp, undo.CMD_MISC, self.searchLine) ls[self.searchLine].text = util.replace(ls[self.searchLine].text, value, self.searchColumn, self.searchWidth) sp.rewrapPara(sp.getParaFirstIndexFromLine(self.searchLine)) self.searchLine = -1 diff = len(value) - self.searchWidth if not self.dirUp: sp.column += self.searchWidth + diff else: sp.column -= 1 if sp.column < 0: sp.line -= 1 if sp.line < 0: sp.line = 0 sp.column = 0 self.searchLine = 0 self.searchColumn = 0 self.searchWidth = 0 else: sp.column = len(ls[sp.line].text) sp.clearMark() sp.markChanged() u.setAfter(sp) sp.addUndo(u) self.OnFind(autoFind=autoFind) return True
def OnReplace(self, event=None, autoFind=False): if self.searchLine == -1: return False value = util.toInputStr(misc.fromGUI(self.replaceEntry.GetValue())) ls = self.ctrl.sp.lines sp = self.ctrl.sp u = undo.SinglePara(sp, undo.CMD_MISC, self.searchLine) ls[self.searchLine].text = util.replace( ls[self.searchLine].text, value, self.searchColumn, self.searchWidth) sp.rewrapPara(sp.getParaFirstIndexFromLine(self.searchLine)) self.searchLine = -1 diff = len(value) - self.searchWidth if not self.dirUp: sp.column += self.searchWidth + diff else: sp.column -= 1 if sp.column < 0: sp.line -= 1 if sp.line < 0: sp.line = 0 sp.column = 0 self.searchLine = 0 self.searchColumn = 0 self.searchWidth = 0 else: sp.column = len(ls[sp.line].text) sp.clearMark() sp.markChanged() u.setAfter(sp) sp.addUndo(u) self.OnFind(autoFind=autoFind) return True
def OnMisc(self, event = None): t = self.autoCompletion.getType(self.lt) t.enabled = bool(self.enabledCb.IsChecked()) self.itemsEntry.Enable(t.enabled) # this is cut&pasted from autocompletion.AutoCompletion.refresh, # but I don't want to call that since it does all types, this does # just the changed one. tmp = [] for v in misc.fromGUI(self.itemsEntry.GetValue()).split("\n"): v = util.toInputStr(v).strip() if len(v) > 0: tmp.append(v) t.items = tmp
def OnMisc(self, event=None): t = self.autoCompletion.getType(self.lt) t.enabled = bool(self.enabledCb.IsChecked()) self.itemsEntry.Enable(t.enabled) # this is cut&pasted from autocompletion.AutoCompletion.refresh, # but I don't want to call that since it does all types, this does # just the changed one. tmp = [] for v in misc.fromGUI(self.itemsEntry.GetValue()).split("\n"): v = util.toInputStr(v).strip() if len(v) > 0: tmp.append(v) t.items = tmp
def OnMisc(self, event=None): self.headers.emptyLinesAfter = util.getSpinValue(self.elinesEntry) if (self.hdrIndex == -1) or self.block: return h = self.headers.hdrs[self.hdrIndex] h.text = util.toInputStr(misc.fromGUI(self.textEntry.GetValue())) self.stringsLb.SetString(self.hdrIndex, h.text) h.xoff = util.getSpinValue(self.xoffEntry) h.line = util.getSpinValue(self.lineEntry) h.align = self.alignCombo.GetClientData(self.alignCombo.GetSelection()) h.isBold = self.boldCb.GetValue() h.isItalic = self.italicCb.GetValue() h.isUnderlined = self.underlinedCb.GetValue()
def OnMisc(self, event = None): self.headers.emptyLinesAfter = util.getSpinValue(self.elinesEntry) if (self.hdrIndex == -1) or self.block: return h = self.headers.hdrs[self.hdrIndex] h.text = util.toInputStr(misc.fromGUI(self.textEntry.GetValue())) self.stringsLb.SetString(self.hdrIndex, h.text) h.xoff = util.getSpinValue(self.xoffEntry) h.line = util.getSpinValue(self.lineEntry) h.align = self.alignCombo.GetClientData(self.alignCombo.GetSelection()) h.isBold = self.boldCb.GetValue() h.isItalic = self.italicCb.GetValue() h.isUnderlined = self.underlinedCb.GetValue()
def OnReplace(self, event): if not self.sc.word: return word = util.toInputStr(misc.fromGUI(self.replaceEntry.GetValue())) ls = self.ctrl.sp.lines ls[self.sc.line].text = util.replace(ls[self.sc.line].text, word, self.sc.col, len(self.sc.word)) self.ctrl.searchLine = -1 diff = len(word) - len(self.sc.word) self.sc.col += len(self.sc.word) + diff self.didReplaces = True self.ctrl.sp.markChanged() self.gotoNext(False)
def OnReplace(self, event): if not self.sc.word: return word = util.toInputStr(misc.fromGUI(self.replaceEntry.GetValue())) ls = self.ctrl.sp.lines ls[self.sc.line].text = util.replace( ls[self.sc.line].text, word, self.sc.col, len(self.sc.word)) self.ctrl.searchLine = -1 diff = len(word) - len(self.sc.word) self.sc.col += len(self.sc.word) + diff self.didReplaces = True self.ctrl.sp.markChanged() self.gotoNext(False)
def OnReplace(self, event=None, autoFind=False): if self.ctrl.searchLine != -1: value = util.toInputStr(misc.fromGUI(self.replaceEntry.GetValue())) ls = self.ctrl.sp.lines ls[self.ctrl.searchLine].text = util.replace( ls[self.ctrl.searchLine].text, value, self.ctrl.searchColumn, self.ctrl.searchWidth) self.ctrl.searchLine = -1 diff = len(value) - self.ctrl.searchWidth if not self.dirUp: self.ctrl.sp.column += self.ctrl.searchWidth + diff else: self.ctrl.sp.column -= 1 if self.ctrl.sp.column < 0: self.ctrl.sp.line -= 1 if self.ctrl.sp.line < 0: self.ctrl.sp.line = 0 self.ctrl.sp.column = 0 self.ctrl.searchLine = 0 self.ctrl.searchColumn = 0 self.ctrl.searchWidth = 0 else: self.ctrl.sp.column = len(ls[self.ctrl.sp.line].text) if diff != 0: self.didReplaces = True self.ctrl.sp.markChanged() self.OnFind(autoFind=autoFind) return True else: return False
def OnReplace(self, event = None, autoFind = False): if self.ctrl.searchLine != -1: value = util.toInputStr(misc.fromGUI(self.replaceEntry.GetValue())) ls = self.ctrl.sp.lines ls[self.ctrl.searchLine].text = util.replace( ls[self.ctrl.searchLine].text, value, self.ctrl.searchColumn, self.ctrl.searchWidth) self.ctrl.searchLine = -1 diff = len(value) - self.ctrl.searchWidth if not self.dirUp: self.ctrl.sp.column += self.ctrl.searchWidth + diff else: self.ctrl.sp.column -= 1 if self.ctrl.sp.column < 0: self.ctrl.sp.line -= 1 if self.ctrl.sp.line < 0: self.ctrl.sp.line = 0 self.ctrl.sp.column = 0 self.ctrl.searchLine = 0 self.ctrl.searchColumn = 0 self.ctrl.searchWidth = 0 else: self.ctrl.sp.column = len(ls[self.ctrl.sp.line].text) if diff != 0: self.didReplaces = True self.ctrl.sp.markChanged() self.OnFind(autoFind = autoFind) return True else: return False
def OnMisc(self, event): self.scDict.set(misc.fromGUI(self.itemsEntry.GetValue()).split("\n"))
def OnMisc(self, event=None): for it in self.items: setattr(self.cfg, it, misc.fromGUI(getattr(self, it).GetValue()))
def OnMisc(self, event): if self.blockEvents: return self.pf.pdfName = misc.fromGUI(self.nameEntry.GetValue()) self.pf.filename = self.fileEntry.GetValue()
def OnFind(self, event=None, autoFind=False): if not autoFind: self.getParams() value = misc.fromGUI(self.findEntry.GetValue()) if not self.matchCase: value = util.upper(value) if value == "": return self.searchWidth = len(value) if self.dirUp: inc = -1 else: inc = 1 line = self.ctrl.sp.line col = self.ctrl.sp.column ls = self.ctrl.sp.lines if (line == self.searchLine) and (col == self.searchColumn): text = ls[line].text col += inc if col >= len(text): line += 1 col = 0 elif col < 0: line -= 1 if line >= 0: col = max(len(ls[line].text) - 1, 0) fullSearch = False if inc > 0: if (line == 0) and (col == 0): fullSearch = True else: if (line == (len(ls) - 1)) and (col == (len(ls[line].text))): fullSearch = True self.searchLine = -1 while True: found = False while True: if (line >= len(ls)) or (line < 0): break if self.typeIncluded(ls[line].lt): text = ls[line].text if not self.matchCase: text = util.upper(text) if inc > 0: res = text.find(value, col) else: res = text.rfind(value, 0, col + 1) if res != -1: if not self.matchWhole or (util.isWordBoundary( text[res - 1:res]) and util.isWordBoundary( text[res + len(value):res + len(value) + 1])): found = True break line += inc if inc > 0: col = 0 else: if line >= 0: col = max(len(ls[line].text) - 1, 0) if found: self.searchLine = line self.searchColumn = res self.ctrl.sp.gotoPos(line, res) self.ctrl.sp.setMark(line, res + self.searchWidth - 1) if not autoFind: self.ctrl.makeLineVisible(line) self.ctrl.updateScreen() break else: if autoFind: break if fullSearch: wx.MessageBox("Search finished without results.", "No matches", wx.OK, self) break if inc > 0: s1 = "end" s2 = "start" restart = 0 else: s1 = "start" s2 = "end" restart = len(ls) - 1 if wx.MessageBox( "Search finished at the %s of the script. Do\n" "you want to continue at the %s of the script?" % (s1, s2), "Continue?", wx.YES_NO | wx.YES_DEFAULT, self) == wx.YES: line = restart fullSearch = True else: break if not autoFind: self.ctrl.updateScreen()
def OnFind(self, event=None, autoFind=False): if not autoFind: self.getParams() value = misc.fromGUI(self.findEntry.GetValue()) if not self.matchCase: value = util.upper(value) if value == "": return self.searchWidth = len(value) if self.dirUp: inc = -1 else: inc = 1 line = self.ctrl.sp.line col = self.ctrl.sp.column ls = self.ctrl.sp.lines if (line == self.searchLine) and (col == self.searchColumn): text = ls[line].text col += inc if col >= len(text): line += 1 col = 0 elif col < 0: line -= 1 if line >= 0: col = max(len(ls[line].text) - 1, 0) fullSearch = False if inc > 0: if (line == 0) and (col == 0): fullSearch = True else: if (line == (len(ls) - 1)) and (col == (len(ls[line].text))): fullSearch = True self.searchLine = -1 while True: found = False while True: if (line >= len(ls)) or (line < 0): break if self.typeIncluded(ls[line].lt): text = ls[line].text if not self.matchCase: text = util.upper(text) if inc > 0: res = text.find(value, col) else: res = text.rfind(value, 0, col + 1) if res != -1: if not self.matchWhole or ( util.isWordBoundary(text[res - 1: res]) and util.isWordBoundary(text[res + len(value): res + len(value) + 1])): found = True break line += inc if inc > 0: col = 0 else: if line >= 0: col = max(len(ls[line].text) - 1, 0) if found: self.searchLine = line self.searchColumn = res self.ctrl.sp.gotoPos(line, res) self.ctrl.sp.setMark(line, res + self.searchWidth - 1) if not autoFind: self.ctrl.makeLineVisible(line) self.ctrl.updateScreen() break else: if autoFind: break if fullSearch: wx.MessageBox("Nothing was found.", "No Matches", wx.OK, self) break if inc > 0: s1 = "end" s2 = "start" restart = 0 else: s1 = "start" s2 = "end" restart = len(ls) - 1 if wx.MessageBox("Search finished at the %s of the screenplay.\n" "Continue at the %s of the screenplay?" % (s1, s2), "Continue?", wx.YES_NO | wx.YES_DEFAULT, self) == wx.YES: line = restart fullSearch = True else: break if not autoFind: self.ctrl.updateScreen()