How to enclose selected text in tags - pyqt5

I need to tag the selected text.
text -> <tag>text</tag>
cursor = self.textEdit.textCursor()
If cursor.hasSelection():
len_text = len(cursor.selectedText())
cursor.movePosition(QTextCursor.Left, QTextCursor.MoveAnchor, len_text)
cursor.insertText(tag)
cursor.movePosition(QTextCursor.Right, QTextCursor.MoveAnchor, len_text)
cursor.insertText(f'{tag[:1]}/{tag[1:]}')
cursor.clearSelection()
self.textEdit.setTextCursor(cursor)
Of course this will only work if the cursor is at the end of the selection
How do I move the cursor to the end if it is positioned elsewhere? Let's say the text was selected from right to left or by double clicking
Maybe I didn't choose the right approach to solve the problem?

Related

Close button "X" to show default cursor

sorry but I can't find the answer.
I want to change the minus magnifying to a normal\default arrow cursor when I'm hovering over the "X" to close the image...this image below doesn't show my cursor but do you know what I'm talking about ? Here is the example ? - codepen.io/dimsemenov/pen/vKrqs

Move text cursor to previous string when I am at the left corner of current string

Is it possible in IntelliJ IDEA to move cursor to previous string when it is at the left corner of current string and I am pushing on left arrow keyboard key.
Let me explain:
1) Text cursor at the left corner of line 4
2) I am pushing on left arrow keyboard key
3) All I want to get - move text cursor to end of previous (3) line
But IDEA not moving text cursor from previous line, it just stays there.
Help me please.
This is because by default IntelliJ allows placing the caret after the end of line. When you press your ← key, it does not move as it would have to go to the infinite right side of your file, which is not very convenient (at least that's how I understand it :p).
Go to Settings > Editor and uncheck Allow placement of caret after end of line, this will solve your problem.

Word: remove page from multipage userform

I want, depending of the previous choice from the user just let some tab's being seen.
Once i am new in VBA, i start showing all the tab's and after the choice from the user, i remove the tab's that i don't want. For that i am using this line of code
MultiPage1.Pages.Remove "name of the tab"
The problem is, if i don't have the same CAPTION and the NAME field of the tab the tab is not remove.
If anyone have a diferent solution for this or another away to remove without have to change the caption for the same name of NAME field i would be thankful.
Thanks
You can give a page of a multi-page control a different name from the caption in the Properties Window. You can access it from the View menu.
I've highlighed the name of the control in yellow and the caption in aqua.
If the captions are unique, you could use a Select Case statement to get the name, based on the caption. Are users actually typing in the caption of the tabs they want, or selecting from check boxes? In either case, the captions would have to be unique, so you could do something like:
Select Case True
Case Check1.Value
MultiPage1.Pages.Remove Pages("kp").Index
Case Check2.Value
MultiPage1.Pages.Remove Pages("jp").Index
End Select
That's a bit rough, but is that the general idea?

How do you deselect the text in a rename dialog without moving the cursor, with the keyboard, in IntelliJ IDEA

I'm using IntelliJ IDEA 10.5.2
Example:
Say I want to rename this class to SomeAwesomeClass.
If we do the Rename refactoring we get a dialog like this:
It has the cursor in the right place however the text is selected. So if we started writing "Awesome" the original name would disappear. So what I want to do is keep the cursor position but deselect the text.
I have not been able to find any way to do this. All things I've tried ether moves the cursor or removes the text or does nothing.
Left or Right keys goes to the left or right.
Up or down does nothing.
Esc closes the dialog.
PageUp or PageDown does nothing.
Home or End goes to left or right.
The fact that the cursor is in the right place to start with makes me believe this is a existing feature...
In 11-eap (110.365) when you rename a class (Shift+F6):
at first full class name is selected and you have a dropdown with suggested names, press Esc
full class name is still selected (dropdown gone), press Esc again
you have class name unselected, and can write at cursor
Note a third Esc will exit rename.
In earlier versions (10.5.2) you can do a trick:
Before rename select one character (shift+arrow forward) where you want to end up (in SomeClass select C) then Shift+F6 and arrow back. I know it is a lot of keys to presses but in a long class name this helps.

How to wrap comment.text in vba

I have a situation in which text in one of the cells is massive.When I change the contents of this cell the previous value becomes a comment to that cell.Now the problem is, this text is so big that I cannot see complete text.If I use .Shape.Textframe.Autosize=true then I have to go on browsing till god knows when to see the text.
What I need to do is whatever and however big the text might be in Commnet.text,I want to show it in one and one place only.i.e when I hover on comment.
Place a TextBox where you will on your worksheet adjusted to the size you want, this still reads the comment although this is not on a hover, but perhaps will help
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not ActiveCell.Comment Is Nothing Then
ActiveSheet.Shapes("Text Box 1").TextFrame.Characters.Text = ActiveCell.Comment.Text
Else: ActiveSheet.Shapes("Text Box 1").TextFrame.Characters.Text = ""
End If
End Sub
Actually after considering this further you really are trying to get comment to act as you want. So I recommend Resize all comments in the selected area and on the same link further down the page Show Excel Comments in Centre of Active Window.
These get you closer to what i think you want.
How about a pop-up text box? I.e., the user clicks on the cell and a pop-up form with the text appears. The best part is you can make the pop-up as big as you want.
Personally, I would make the pop-up resizable, but with only the Close button at top. I can't think of a way to trigger this form with just a mouse rollover, but I'm only using 2003. Later versions allow you more tricks.
xlSheet.Range(xlSheet.Cells(rowCount,1), xlSheet.Cells(rowCount,8)).Merge
xlSheet.Range(xlSheet.Cells(rowCount,1), xlSheet.Cells(rowCount,8)).HorizontalAlignment = 1
xlSheet.Range(xlSheet.Cells(rowCount,1), xlSheet.Cells(rowCount,8)).WrapText = True
xlSheet.Range(xlSheet.Cells(rowCount,1), xlSheet.Cells(rowCount,8)).RowHeight=45