Templates/TemplateViewer.py

changeset 506
6c2ca1e8223a
parent 500
c3abc7895a01
child 536
6d8d39753c82
equal deleted inserted replaced
502:7500b9d5b21d 506:6c2ca1e8223a
668 indent = line.replace(line.lstrip(), "") 668 indent = line.replace(line.lstrip(), "")
669 txt, lines, count = itm.getExpandedText(varValues, indent) 669 txt, lines, count = itm.getExpandedText(varValues, indent)
670 # It should be done in this way to allow undo 670 # It should be done in this way to allow undo
671 editor.beginUndoAction() 671 editor.beginUndoAction()
672 if editor.hasSelectedText(): 672 if editor.hasSelectedText():
673 line = editor.getSelection()[0] 673 line, index = editor.getSelection()[0:2]
674 editor.removeSelectedText() 674 editor.removeSelectedText()
675 else: 675 else:
676 line = editor.getCursorPosition()[0] 676 line, index = editor.getCursorPosition()
677 677
678 if len(indent) > 0: 678 if lines == 1:
679 count += len(indent) 679 count += index
680 else:
681 if len(indent) > 0:
682 count += len(indent)
680 683
681 if "i_n_s_e_r_t_i_o_n" in txt and "s_e_l_e_c_t" in txt: 684 if "i_n_s_e_r_t_i_o_n" in txt and "s_e_l_e_c_t" in txt:
682 txt = "'Insertion and selection can not be in template together'" 685 txt = "'Insertion and selection can not be in template together'"
683 686
684 if "i_n_s_e_r_t_i_o_n" in txt: 687 if "i_n_s_e_r_t_i_o_n" in txt:
685 lines = 1 688 lines = 1
686 for aline in txt.splitlines(): 689 for aline in txt.splitlines():
687 count = aline.find("i_n_s_e_r_t_i_o_n") 690 count = aline.find("i_n_s_e_r_t_i_o_n")
688 if count >= 0: 691 if count >= 0:
689 txt = txt.replace("i_n_s_e_r_t_i_o_n", "") 692 txt = txt.replace("i_n_s_e_r_t_i_o_n", "")
690 if len(indent) > 0: 693 if lines == 1:
691 count += len(indent) 694 count += index
695 else:
696 if len(indent) > 0:
697 count += len(indent)
692 break 698 break
693 else: 699 else:
694 lines += 1 700 lines += 1
695 701
696 setselect = False 702 setselect = False

eric ide

mercurial