Need to know cursor character position in a CRichEdit control - position

I have an old MFC app with multiple CRichEdit controls. Currently, the app has no "Find" capability, and I want to add it. Like Notepad, I would like the search to begin from the current cursor position. Unfortunately, as insane is it seems, I can't find any way to determine where the cursor is. I have spent hours searching forums. Even going back to the Win32 Edit control, I can find no message to query the cursor position. This seems ridiculous. Am I missing something here?

OK, I found the answer to this. The CRichEdit::GetSel() function will return the character range if there is a current selection. If there is no current selection, the start and end character offsets will be equal to the cursor position. This is not made clear in any documentation I have seen, nor have I found it in any forum.

Related

Searching in VSCode since the actual position

After a search, if founded, I would like the VSCode move to the next ocurrence, after my position, not to the first occurrence since the top of the code.
Is it possible? How?
Version 1.55.2

How to search only until end of document / be warned at end of document? (LibreOffice)

Using LibreOffice Writer (version 6.0.7.3), I'm often searching for strings from within largish Writer document, and am using the ctrl+F search. While searching, I'm rather concentrated on looking at where the searched term is found from within the document text, and just press the arrow at the toolbar using mouse to get me to the next instance of the search string. I do this without actually looking at the toolbar.
When I've found the last search string from within the document, LibreOffice Writer only prints darker grey text "Reached end of document" on lighter grey background (sort of "grayed out" thing) on the toolbar. But -- me having eyes fixed on the document text and not looking at the toolbar -- I just keep on pressing the arrow button, and after second or third round get a sort of Déjà-vu feeling. Looking then at the toolbar, while not actually at the last specimen of the searched string within the document there seems to be no indication that I'm half way on my third helping...
What is the advantage of not actually allowing me (while using ctrl+F or ctrl+H at tools->options... or whatnot) to select that to me next should not go past the end of the document (by "next" momentarily becoming "first") without me being properly warned with a "yes-no-whatnot" dialog box that really would stop me from going past end, and be asked if I really want to go for a second helping?
Or have I really (again) missed something?
On my PC (Xbuntu 18.04.4 LTS , Xfce desktop environment 4.12, 32-bit) the same nastiness is found at all possible text editors:
Leafpad, version 0.8.18.1
Mousepad, version 0.4.0
Notepadqq, version v1.4.2
Gedit, version 3.28.1
Thunderbird, version 68.7.0
Firefox 75.0
LibreOffice Writer, Version: 6.0.7.3
The only one that seems to have it the way I wish is:
Notepad++, version 7.5.1 (under Wine), it has a checkbox: "wrap around"
Am I just having too narrow line of vision, or is this what everybody (except me) really only wants...
pekka
PS: I have asked the same question at https://ask.libreoffice.org/en/question/234758/ with no success...
Once again, AltSearch saves the day.
My preferred text editor also has an option: vim incremental search stop at end of file

2 spaces indentation in google Docs

To prepare an exam, I have to learn coding using google docs rather than using an IDE. It may seem idiot or impratical but the teacher really insists on that. It seems that is the same thing as Google interviews for example...
So far, I really got used with using two spaces indentation (I hate using tab indendation). And I want to learn how can I do that quickly in Google docs. Is there a shortcut or a "tips" (add-on?) for that?
For example, if you have an "if-condition" starting at the position number 4 and you want to move to the following line, it can be really convenient to have the cursor position at 4. Then, you'll add two spaces to start your block at position number 6. (ALL the if block will have at least position 6). But in Docs, when you move to the following line, the cursor always start at the beginning of the line except if you use the tab indentation. And it's really shitting if you want to indent your code properly...
Do you have a solution for that please ?
I was facing the same problem.
To write Python code in google docs, my solution is:
Switch off auto-capitalization, auto-correction and smart quotes. And other auto-substitutions so that you may write code without docs like formatting.
To do this: Tools> Preferences and uncheck the above items. Screen shots attached below.
Set tab to two spaces.
Right-click on ruler on top of page. Add left-tab stop, an arrow will appear, move this tab stop to 2 spaces from left of ruler. Try adding tab in the current line and if the tab size is OK, save this formatting.
To save:
Format > Paragraph Styles > Normal Text > Update 'Normal Text' to match.
Last, to add color(synatx highlight), you may use 'code blocks extension'.
Click install.
Now, write code in docs, select the code in google doc, click on:
Add-ons > Code Block. A pop up opens up.
Choose language : 'python' for me.
Choose theme: 'atom-one-dark'
click Format.
The code looks much like IDE, and writing more code is easier too.
While I understand that sometimes a point can be made by making students do things in a way that might not seem logical, this one doesn't make any sense to me.
Students don't learn anything useful by pressing space twice instead of letting an editor or IDE do it for them.
I wonder, is it because he/she wants it delivered in Google Docs or because they want you coding that way? If it's the latter, you won't have to hide your workaround.
I can only suggest using a good text editor, I always use the excellent and free Notepad++, and copy and paste it to and from Google Docs. Your instructor will never know. In fact, I'd be hunting around to see of there was a way to access your code files directly in Google Docs from Notepad++, or to auto-sync a folder with Google docs.
Notepad++ has syntax colouring - which will save your life - and can be set to indent with tabs or spaces to whatever indent width you specify. If not using an IDE, I only use Notepad++.
Your instructor sounds like some I had, people who cross a line from being quirky but with a point to make to just being a dick. There is absolutely no point in telling a student to code only in Google docs. Google docs is a great thing, I love it, but it is by no stretch of the imagination a coding tool.
(I see that this is an aged thread, but I'll respond in case someone else with a similar issue - like this year's class for that course - comes looking for an answer.)
You could try (ab)using bulleted lists:
Insert a bulleted list
Right click on the bullet, select "More bullets..."
In the "Symbol" selection list, choose "Format & whitespace" and select one of the whitespace options as bullet char
Repeat for as many levels (of bullet sub-lists) as you think you may need in your program
Fix indentation to match whatever feels best for you
Every time you need to write a nested block, you will have to press "tab" only once, then bullet list level is kept and the indentation with it. To go back to the outer block, just press shift-tab.
However, IMHO it doesn't worth the trouble. Generally, interview question solutions are not that large and hitting spacebar a couple of times is not much of an overhead.
It's somewhat cumbersome but you can set as many tab stops as you want, and docs will move nested tabs to the next tab stop as well. For example:
You can add tab stops by right clicking on that tab bar where you want the tab stop to be and clicking Add left tab stop. You'll want to have all text in the document selected if you want the tab stop to apply everywhere.

Vim- Change background color of certain portion of code

I usually spend a lot of time tinkering with existing code. I need to focus on only a small portion of the file, for which I would like to grey out the background for the rest of the file, so that the portion that I'm interested in stands out distinctively. This should increase my productivity immensely. Does anyone know how can I change background for only certain part of the file?
Try my NrrwRgn plugin. That opens a selected part of the code in a new window. Whenever you write your changes, the will be taken back to the original buffer.
You could of course use syntax highlighting or even the sign column (my BackgroundColor plugin does this) to distinct highlight a certain region, but this will be awkward and will get out of sync soon if you add lines or remove lines.
Try the limelight plugin for Vim. This Plugin Highlights the current code block and dimme the other code before and afterwards.
You can find it here:
https://github.com/junegunn/limelight.vim

ConEmu: Searching through entire buffer

I've recently moved to the ConEmu console and I'm loving it. Its very configurable and it has a lot of the features that I was looking for (A Mac Terminal App replacement of sorts.)
I've not been able to figure out how to search through the entire history buffer though. Theres a key called App+F which seems to search the visible buffer for a string, but theres nothing that lets me search through the entire 9999 lines of buffer. Does anybody know the Keyboard shortcut for this?
Thanks.
For Windows set different hotkey since win+f is binded to Windows actions.
Here is how to set ctrl+f
Apps+F may search entire buffer. But update to the latest build first and note that you need to "Freeze console" to enable buffer search.
BTW, Apps+F is default hotkey, you may choose any suitable.

Resources