ProjectDjangoTagsMenu/DjangoTagsMenuHandler.py

changeset 35
e98f7b5ed394
parent 34
78bda568c0a1
child 39
c75a95d5cfd4
equal deleted inserted replaced
34:78bda568c0a1 35:e98f7b5ed394
1354 1354
1355 elif tag == "singlelinecommentselect": 1355 elif tag == "singlelinecommentselect":
1356 templateText = '{{# {0} #}}'.format(selectedText) 1356 templateText = '{{# {0} #}}'.format(selectedText)
1357 replace = True 1357 replace = True
1358 elif tag == "multilinecommentselect": 1358 elif tag == "multilinecommentselect":
1359 templateText = '{{% comment %}} {0} {{% endcomment }}'.format( 1359 templateText = '{{% comment %}} {0} {{% endcomment %}}'.format(
1360 selectedText) 1360 selectedText)
1361 replace = True 1361 replace = True
1362 elif tag == "singlelinecommentdialog": 1362 elif tag == "singlelinecommentdialog":
1363 data, ok = DjangoTagInputDialog.getText( 1363 data, ok = DjangoTagInputDialog.getText(
1364 None, 1364 None,
1371 from .MultiLineInputDialog import MultiLineInputDialog 1371 from .MultiLineInputDialog import MultiLineInputDialog
1372 comment, ok = MultiLineInputDialog.getText( 1372 comment, ok = MultiLineInputDialog.getText(
1373 None, self.tr("Multi Line Comment"), 1373 None, self.tr("Multi Line Comment"),
1374 self.tr("Enter comment:"), "") 1374 self.tr("Enter comment:"), "")
1375 if ok: 1375 if ok:
1376 templateText = '{{% comment %}} {0} {{% endcomment }}'.format( 1376 templateText = '{{% comment %}} {0} {{% endcomment %}}'.format(
1377 comment) 1377 comment)
1378 elif tag == "singlelinecommentclipboard": 1378 elif tag == "singlelinecommentclipboard":
1379 templateText = '{{# {0} #}}'.format( 1379 templateText = '{{# {0} #}}'.format(
1380 QApplication.clipboard().text().strip()) 1380 QApplication.clipboard().text().strip())
1381 elif tag == "multilinecommentclipboard": 1381 elif tag == "multilinecommentclipboard":
1382 templateText = '{{% comment %}} {0} {{% endcomment }}'.format( 1382 templateText = '{{% comment %}} {0} {{% endcomment %}}'.format(
1383 QApplication.clipboard().text().strip()) 1383 QApplication.clipboard().text().strip())
1384 elif tag == "multilinecommentfile": 1384 elif tag == "multilinecommentfile":
1385 filename = E5FileDialog.getOpenFileName( 1385 filename = E5FileDialog.getOpenFileName(
1386 None, 1386 None,
1387 self.tr("Comment File"), 1387 self.tr("Comment File"),
1391 try: 1391 try:
1392 f = open(filename, "r", encoding="utf-8") 1392 f = open(filename, "r", encoding="utf-8")
1393 comment = f.read() 1393 comment = f.read()
1394 f.close() 1394 f.close()
1395 templateText = ( 1395 templateText = (
1396 '{{% comment %}} {0} {{% endcomment }}'.format( 1396 '{{% comment %}} {0} {{% endcomment %}}'.format(
1397 comment)) 1397 comment))
1398 except (IOError, OSError) as err: 1398 except (IOError, OSError) as err:
1399 E5MessageBox.critical( 1399 E5MessageBox.critical(
1400 None, 1400 None,
1401 self.tr("Comment File"), 1401 self.tr("Comment File"),

eric ide

mercurial