203 Public method to generate hyperlink text. |
203 Public method to generate hyperlink text. |
204 |
204 |
205 @param editor reference to the editor to work on |
205 @param editor reference to the editor to work on |
206 @type Editor |
206 @type Editor |
207 """ |
207 """ |
|
208 if editor is None: |
|
209 return |
|
210 |
208 from .HyperlinkMarkupDialog import HyperlinkMarkupDialog |
211 from .HyperlinkMarkupDialog import HyperlinkMarkupDialog |
209 dlg = HyperlinkMarkupDialog(False, True) |
212 dlg = HyperlinkMarkupDialog(False, True) |
210 if dlg.exec_() == QDialog.Accepted: |
213 if dlg.exec_() == QDialog.Accepted: |
211 text, target, title = dlg.getData() |
214 text, target, title = dlg.getData() |
212 |
215 |
213 link = "[{0}]".format(text) |
216 link = "[{0}]".format(text) |
214 if target and title: |
217 if target and title: |
215 link = '{0}({1} "{2}")'.format(link, target, title) |
218 link = '{0}({1} "{2}")'.format(link, target, title) |
216 elif target: |
219 elif target: |
248 markup = "{0}-----{0}{0}".format(lineSeparator) |
251 markup = "{0}-----{0}{0}".format(lineSeparator) |
249 editor.insert(markup) |
252 editor.insert(markup) |
250 cline, cindex = editor.getCursorPosition() |
253 cline, cindex = editor.getCursorPosition() |
251 editor.setCursorPosition(cline + 3, 0) |
254 editor.setCursorPosition(cline + 3, 0) |
252 editor.endUndoAction() |
255 editor.endUndoAction() |
|
256 |
|
257 def hasQuote(self): |
|
258 """ |
|
259 Public method to indicate the availability of block quote markup. |
|
260 |
|
261 @return flag indicating the availability of block quote markup |
|
262 @rtype bool |
|
263 """ |
|
264 return True |
|
265 |
|
266 def quote(self, editor): |
|
267 """ |
|
268 Public method to generate block quote text. |
|
269 |
|
270 @param editor reference to the editor to work on |
|
271 @type Editor |
|
272 """ |
|
273 if editor is None: |
|
274 return |
|
275 |
|
276 editor.beginUndoAction() |
|
277 markup = "> " |
|
278 sline, sindex, eline, eindex = editor.getSelection() |
|
279 for line in range(sline, eline + 1 if eindex > 0 else eline): |
|
280 editor.insertAt(markup, line, 0) |
|
281 editor.endUndoAction() |
|
282 |
|
283 def hasImage(self): |
|
284 """ |
|
285 Public method to indicate the availability of image markup. |
|
286 |
|
287 @return flag indicating the availability of image markup |
|
288 @rtype bool |
|
289 """ |
|
290 return True |
|
291 |
|
292 def image(self, editor): |
|
293 """ |
|
294 Public method to generate image text. |
|
295 |
|
296 @param editor reference to the editor to work on |
|
297 @type Editor |
|
298 """ |
|
299 if editor is None: |
|
300 return |
|
301 |
|
302 from .ImageMarkupDialog import ImageMarkupDialog |
|
303 dlg = ImageMarkupDialog(ImageMarkupDialog.MarkDownMode) |
|
304 if dlg.exec_() == QDialog.Accepted: |
|
305 address, altText, title, originalSize, width, height = \ |
|
306 dlg.getData() |
|
307 |
|
308 if title: |
|
309 markup = ''.format(altText, address, title) |
|
310 else: |
|
311 markup = ''.format(altText, address) |
|
312 |
|
313 editor.beginUndoAction() |
|
314 editor.insert(markup) |
|
315 cline, cindex = editor.getCursorPosition() |
|
316 editor.setCursorPosition(cline, cindex + len(markup)) |
|
317 editor.endUndoAction() |