PyQt QTextEdit text selection without moving the cursor (like ubuntu terminal) - pyqt

I've developed a shell (imitating the ubuntu terminal --> can only edit text after current prompt) by a PyQt QTextEdit.
The thing is when I select some text, the cursor moves as I'm selecting this text (so it disappers from the current command line) and I would like the cursor to stay where it is (only when I select text because I want it to move when I move it programmatically by textEdit.moveCursor(...)) at the same time I'm selecting the text.
Does anybody have any idea of how could I do that?
My solution for now, is to save the position at any change of it (except when it changes by a click), and when I copy some text en paste it, it'll be automatically pasted in the last position the cursor was before the click. That works perfectly but it's "ugly" for the user because, as I said, when he selects the text the cursor disappears of the current line and is where the user is selecting the text. Not like in ubuntu terminal.
Thanks in advance! And sorry for my english.
Adri

I don't see an easy solution to implement this with a text editor API. A terminal is a hack, basically. It mixes a read-only element (anything above the current prompt) with a text editor.
My approach would be to create two text editors, make one read only and display the results of all operations there. If you hide the borders of the two editors, then it will look like a single one. You may have to forward a bunch of events (like scrolling with the keyboard) to the read-only display.

Related

Sublime Text: How can I disable auto scrolling while I'm typing in the Find box?

I am currently trying to write a complex regex for a huge file. Every time I type in the find input box to make a small change, Sublime scrolls me either to the top of the document or to a semi-random location (from what I can remember, it doesn't always scroll to the first match), even when there are matches where I'm already scrolled to in the file. It makes for a pretty painful workflow: I write down the line number on a piece of paper, edit my regex, and then have to "go-to" back to the line I was already at. How can I prevent this, or at the very least, does anybody know why exactly this is happening in the first place?
This is controlled by the Highlight Matches button in the Find and Find and Replace panels, and causes Sublime to show you all of the matches, highlighting one of them and outlining the remainder in a region to show you where they are.
The visual appearance of the button is controlled by the theme you use, but it's always in this position in the panel (and it should have the same icon in all other find panels as well); it also has a tooltip that tells you the name.
When the search term is modified and this option is turned on, Sublime jumps to a match, though this doesn't occur if the panel opens with an existing search term already in it; in that case matches are highlighted but the view doesn't change.
The option also exists in Incremental Find panel as well, but turning it off there only stops other matches from being highlighted as by definition Incremental Find is for jumping to a search term incrementally as you modify it.

Get the Text widget that is focused [tkinter]

Simple question, not sure if there is an answer.
Imagine you have 2 text boxes in a tkinter window, is it possible to know which of the 2 the user is focused on, then return the text widget object itself, or a variable that tells you something.
**Context: **Trying to insert a set of characters at the users cursor, but I want it to add it at their cursor regardless of the text box. Instead of:
self.text1.insert(tk.INSERT, "
Some text..."), I want self.focusedText.insert(tk.INSERT, "
Some text at your cursor in the focused text widget..."). Is there some way to figure out which of many Text widgets a user is focused on? Thanks!

How can I see only changed lines in file with SmartGit?

I'm seeing full file with highlighted lines. But I want to see only changed lines as in SourceTree. SourceTree displays only changed lines and it very comfortable. I must not scroll all file to find changes.
Can I tune SmartGit for it?
Thanks.
SmartGit 17.1 supports this - it's called "Compact Change Display".
AFAIK this is not possible in SmartGit.
But there are several ways to get to the changes quickly.
You can use the arrow buttons on the right or its shortcuts F6 and SHIFT+F6.
Or you can move the mouse between the two view and then using the mouse wheel. When the mouse is located at this area, scrolling will take you directly to the next change instead of just some lines up/down (see red markings in attached screenshot)

How can I set the default orientation of labview windows?

Whenever I open a new labview project, it opens two small windows, one for the block diagram and the front panel. Since using labview effectively requires simultaneous use of both, is it possible to set things up such that, upon starting a new VI, it opens these two windows in pre-determined positions and sizes?
I do not know setting to do so (and think there is no such setting), but your problem is easily solvable if you press ctrl+t when new vi is opened.
ctrl+t will set front panel on the left half part of the screen and block diagram on the right part. Pressing ctrl+t a second time will set the panel to top half and diagram to the bottom half.
Shortcuts In LabVIEW
Another workaround:
Create a new empty VI
Resize and reposition the front panel window as you wish
Do the same for the block diagram window
Save the VI as a template (.vit)
Double click the template to use it (position and size of windows will be as they were when saving)
Alternatively if you want to be doing manually everytime. You can press WIN+LEFT on one of the windows and WIN+RIGHT on the other. This will evenly distribute the two windows over the screen.
You can set window position for individual VIs by pressing Ctrl+I to open the VI properties, and setting the desired appearance under "Window Size"

How to center text if there isn't enough newlines to get text to the center in sublime?

While coding in Sublime Text 3 if I get to the bottom of the page and try to use the show_at_center command I won't get able to get the current line all the way up to the center of the page because there isn't enough new lines. So I have to manually hit enter a bunch of times to get the text to come back up. Is there a way around this? Like some sort of command that: moves the text to the center of the screen even if there is only blank space below and no newlines.
Open your user preferences (Preferences -> Settings-User) and add the following setting:
"scroll_past_end": true
This allows you to keep scrolling the view all the way down until the last line is at the very top of the window.

Resources