Templates/TemplateViewer.py

branch
5_0_x
changeset 505
2219cb4f46c5
parent 108
03d3adf59bde
child 792
a13346916170
equal deleted inserted replaced
504:da6d0d7037e5 505:2219cb4f46c5
672 indent = line.replace(line.lstrip(), "") 672 indent = line.replace(line.lstrip(), "")
673 txt, lines, count = itm.getExpandedText(varValues, indent) 673 txt, lines, count = itm.getExpandedText(varValues, indent)
674 # It should be done in this way to allow undo 674 # It should be done in this way to allow undo
675 editor.beginUndoAction() 675 editor.beginUndoAction()
676 if editor.hasSelectedText(): 676 if editor.hasSelectedText():
677 line = editor.getSelection()[0] 677 line, index = editor.getSelection()[0:2]
678 editor.removeSelectedText() 678 editor.removeSelectedText()
679 else: 679 else:
680 line = editor.getCursorPosition()[0] 680 line, index = editor.getCursorPosition()
681 681
682 if len(indent) > 0: 682 if lines == 1:
683 count += len(indent) 683 count += index
684 else:
685 if len(indent) > 0:
686 count += len(indent)
684 687
685 if "i_n_s_e_r_t_i_o_n" in txt and "s_e_l_e_c_t" in txt: 688 if "i_n_s_e_r_t_i_o_n" in txt and "s_e_l_e_c_t" in txt:
686 txt = "'Insertion and selection can not be in template together'" 689 txt = "'Insertion and selection can not be in template together'"
687 690
688 if "i_n_s_e_r_t_i_o_n" in txt: 691 if "i_n_s_e_r_t_i_o_n" in txt:
689 lines = 1 692 lines = 1
690 for aline in txt.splitlines(): 693 for aline in txt.splitlines():
691 count = aline.find("i_n_s_e_r_t_i_o_n") 694 count = aline.find("i_n_s_e_r_t_i_o_n")
692 if count >= 0: 695 if count >= 0:
693 txt = txt.replace("i_n_s_e_r_t_i_o_n", "") 696 txt = txt.replace("i_n_s_e_r_t_i_o_n", "")
694 if len(indent) > 0: 697 if lines == 1:
695 count += len(indent) 698 count += index
699 else:
700 if len(indent) > 0:
701 count += len(indent)
696 break 702 break
697 else: 703 else:
698 lines += 1 704 lines += 1
699 705
700 setselect = False 706 setselect = False

eric ide

mercurial