144 return |
144 return |
145 |
145 |
146 lineSeparator = editor.getLineSeparator() |
146 lineSeparator = editor.getLineSeparator() |
147 editor.beginUndoAction() |
147 editor.beginUndoAction() |
148 if editor.hasSelectedText(): |
148 if editor.hasSelectedText(): |
149 sline, sindex, eline, eindex = editor.getSelection() |
149 sline, _sindex, eline, eindex = editor.getSelection() |
150 if not editor.text(sline).startswith((" ", "\t")): |
150 if not editor.text(sline).startswith((" ", "\t")): |
151 # assume that all selected lines need indentation, |
151 # assume that all selected lines need indentation, |
152 # if first line needs it |
152 # if first line needs it |
153 endLine = eline if eindex > 0 else eline - 1 |
153 endLine = eline if eindex > 0 else eline - 1 |
154 for line in range(sline, endLine + 1): |
154 for line in range(sline, endLine + 1): |
294 return |
294 return |
295 |
295 |
296 lineSeparator = editor.getLineSeparator() |
296 lineSeparator = editor.getLineSeparator() |
297 editor.beginUndoAction() |
297 editor.beginUndoAction() |
298 markup = "> " |
298 markup = "> " |
299 sline, sindex, eline, eindex = editor.getSelection() |
299 sline, _sindex, eline, eindex = editor.getSelection() |
300 for line in range(sline, eline + 1 if eindex > 0 else eline): |
300 for line in range(sline, eline + 1 if eindex > 0 else eline): |
301 editor.insertAt(markup, line, 0) |
301 editor.insertAt(markup, line, 0) |
302 editor.insertAt("::{0}{0}".format(lineSeparator), sline, 0) |
302 editor.insertAt("::{0}{0}".format(lineSeparator), sline, 0) |
303 editor.setCursorPosition(eline + 2, eindex) |
303 editor.setCursorPosition(eline + 2, eindex) |
304 editor.endUndoAction() |
304 editor.endUndoAction() |
324 if editor is None: |
324 if editor is None: |
325 return |
325 return |
326 |
326 |
327 dlg = ImageMarkupDialog(ImageMarkupMode.Rest) |
327 dlg = ImageMarkupDialog(ImageMarkupMode.Rest) |
328 if dlg.exec() == QDialog.DialogCode.Accepted: |
328 if dlg.exec() == QDialog.DialogCode.Accepted: |
329 address, altText, title, originalSize, width, height = dlg.getData() |
329 address, altText, _title, originalSize, width, height = dlg.getData() |
330 |
330 |
331 lineSeparator = editor.getLineSeparator() |
331 lineSeparator = editor.getLineSeparator() |
332 markup = ".. image:: {0}{1}".format(address, lineSeparator) |
332 markup = ".. image:: {0}{1}".format(address, lineSeparator) |
333 lines = 1 |
333 lines = 1 |
334 if altText: |
334 if altText: |
395 |
395 |
396 markup = " #. " if numberedList else " * " |
396 markup = " #. " if numberedList else " * " |
397 lineSeparator = editor.getLineSeparator() |
397 lineSeparator = editor.getLineSeparator() |
398 editor.beginUndoAction() |
398 editor.beginUndoAction() |
399 if editor.hasSelectedText(): |
399 if editor.hasSelectedText(): |
400 startLine, startIndex, endLine, endIndex = editor.getSelection() |
400 startLine, _startIndex, endLine, endIndex = editor.getSelection() |
401 if endIndex == 0: |
401 if endIndex == 0: |
402 endLine -= 1 |
402 endLine -= 1 |
403 for line in range(startLine, endLine + 1): |
403 for line in range(startLine, endLine + 1): |
404 editor.insertAt(markup, line, 0) |
404 editor.insertAt(markup, line, 0) |
405 editor.setCursorPosition(endLine + 1, 0) |
405 editor.setCursorPosition(endLine + 1, 0) |