Cursor between the wrong characters when clicking an inactive NSTextField with the "Truncate Head" Line Break - xcode

I used Interface Builder to create an NSTextField and set its Line Break to Truncate Head (because if its text is too long to display all at once, I'd rather see the last few words than the first few).
My problem is that the modified Line Break compromises my ability to place my cursor in a specific position when making the NSTextField active (a.k.a. First Responder) by clicking the mouse. In this example, the NSTextField is not active, and I attempt to place my cursor between the "L" and "A" in "lazy".
After clicking, the cursor appears before the word "over".
Clearly, the NSTextField is ignoring the modified Line Break, and positioning the cursor as if it were the default. Can I achieve the effect of Truncate Head but keep the ability to place the cursor in a specific location by clicking?
I had the idea to record the mouseDown location, compare that to attributedStringValue's size, and calculate where the cursor should go, but I quickly got in over my head.
Original question: NSTextField keep scrolling at the end
I have the following silly problem:
I placed a single-line NSTextField on my View. The idea would be that it contains a long URL, but in my case mostly the ending is interesting.
So I would like the content to appear like scrolled to the end (so the beginning is not visible if it is longer than the textfield). The problem is that I do not know how to set this properly. I tried the "Text Direction" option to Right To Left which then displays properly, but as soon the user clicks on the field it jumps back to the beginning, thus confusing the user.
Please let me know what I am missing.
Thanks!

Related

how to prevent emacs from changing cursor position when scrolling the page

there is this annoying behavior in emacs which I don't know how to get rid of it.
lets say the current cursor position is on line 10 column 15.
now I need to quickly look up something far down the same buffer, I scroll down to that location and as I scroll down (or up) the cursor keeps moving and it loses its original location.
many people suggest to set a marker before scrolling but that is not a good solution, because you have to be always mindful of this fact before scrolling (which is impossible)
I know there should be a simple solution but I have not found it yet.
I'll appreciate your suggestions
As far as I know, Emacs doesn't allow you to scroll in such a way that your point disappears. I just took a quick look at xdisp.c and it looks like this is a fundamental assumption in the C code. This is different from some more recent editors (Sublime Text, VSCode etc).
However, the "many people" you mention actually have a reasonable point. If you're moving through the file by searching (C-s the-thing-im-looking-for) then Emacs will set a marker for you automatically.
I guess you could try adding a hook that set a marker at point whenever you scrolled? It wouldn't be trivial because you'd have to cope with things like not setting a load of markers through the file as your scroll dragged the cursor down. But my recommendation is probably to alter your workflow to match how Emacs wants to do things. In this case, it's probably a better approach than the modern editors it sounds like you're used to.
An option that might or might not be useful is scroll-preserve-screen-position. The description is somewhat hard to understand, but a net result is that if you mainly scroll using C-v/M-v, the point will visually stay at the same place on the screen (so if you do e.g. C-v C-v M-v M-v, the point will come back to its original position.
However, note that many commands do push a mark before they jump: isearch, end-of-buffer, imenu, xref-find-definition ... In all those cases, you can then press C-u C-SPC (the same command that you use to set the mark but called with a prefix argument) to pop the mark (concretely, jump to the last mark). If you need to jump back more than once, you can set the variable set-mark-command-repeat-pop to t, so that you only need to do C-u once and then repeatedly press C-SPC to pop more and more marks from the mark ring.
In general, there are better ways to navigate a buffer than scrolling in the wild; the cases where you do need to scroll, starting from "your current" point are (or should/could be ...) sufficiently rare that you know beforehand that you will be spending a possibly long time "looking around" in the buffer. It is then quite fast to set a mark, do your stuff somewhere else, and C-u <mash C-SPC as often as needed> until you get back to your initial point.

Cannot move cursor up and down in text area (Firefox 77.0.1 (64-bit), Windows)

In my web app I cannot move the cursor up or down when editing a multi-row text in a simple text area.
The cursor seems to be "locked" to either the first row or the last row. It can be moved left or right normally but not across line breaks.
It is impossible to place the cursor into one of the middle rows. Not by keyboard, and not by mouse either.
The same text area works like a charm in Chrome. I can place the cursor wherever I want and how I want - as expected.
Any idea why this is so and what I can do to fix this?
The text area's css property "user-select" was set to "none". Setting it to "auto" fixed the issue.

Xcode Editor text selection issue

If I want to delete few lines of text in most of text editors, not touching some words on the bottom line and the whole upper line, I put cursor on the bottom row leaving all unnecessary words to the left of the cursor. Then I select few lines vertically by holding Shift + ↑. I stop on upper row and get some selection: part below + right part of the upper row:
In this example I want to get rid of if word and an empty space between the function header and the code, not touching the function header (even hough let will stick to the opening bracket {).
Normally (not in Xcode) I would still hold Shift and will press cmd + ➝ to deselect the right (selected) part or the top row.
Result will be like this:
I can simply press Delete and job is done.
However, in Xcode such shortcut usage makes bottom row fully selected (till the right) and not changes upper row selection:
Same thing happens if you select from top to bottom and you need to remove extra selection from the bottom line.
I tried to rebind shortcuts in Preferences but didn't find a solution.
This example is very particular and maybe not the best, however I face such selection problems only in Xcode and have to use mouse which is not handy.
This is a rather old question, but what you want is fairly simple to achieve. If your cursor is between the if and the let, you would only need to press option-shift-left arrow twice. The first time, it would select the if and the leading tabs, and the second would select the empty line.

How do I shift a set of lines one space to the right within a text editor?

How do I shift a set of lines one space to the right within a text editor?
If I wanted to shift a set of lines several spaces to the right, I would perform:
selected text + Tab
However, I just want to shift the text one space to the right without tabbing.
Any suggestions?
Hold down the alt key, left-click and hold the mouse button down on the first line where you wish to insert your space. Then, while still holding down the left mouse button, drag the mouse vertically to extend this edit point to all the lines you want to move. Dragging it horizontally will create a box selection, which you want to avoid, as the selected text will end up being replaced, rather than a space be added.
Also, you cannot select individual, disjoint lines to move. You can only use alt-drag over a contiguous block of lines.
Once you have your multiline edit point created, hit the spacebar once.
Tada.
Here's a blog post by Scott Guthrie with more details and a vidya demo
If you don't want to use the mouse, you can use shift+alt+(up, down, left, or right) to create a box selection, or a multiline edit point.

how to move the dotted line from the middle of a "alt" sequence diagram

I'm using the UML sequence diagram in gliffy for Jira and I can't seem to move the dotted line to the middle of the alt box - it stays stuck to the top and I don't see a handle for it. How do I move it to the middle?
It's really fiddly but it possible.
1) Double click the top guard condition [If] to go into text edit mode.
2) Add some carriage returns (new lines) at the end - the idea is to move the cursor down to where you want the line to go
If the line doesn't move when you insert the new lines (it's a bit flaky) then click outside the box (to save) and wait a few seconds for it to catch up.
If it still doesn't move the line, then move the shape a little to get it to redraw.
Finally, delete the shape and start again if it still won't move it.
As I said, it's a bit flaky.

Resources