How to show invisible characters in webstorm - webstorm

As many of you have probably come across the problem of cutting and pasting some code, which comes along with it some hidden characters often resulting in the dreaded UNEXPECTED_TOKEN_ILLEGAL
Is there a way within Webstorm to show/hide invisible characters?

Install and use Zero Width Characters locator plugin-- it can detect quite few invisible characters (e.g. UTF-8 BOOM sequence, non-breakable space etc).
It is implemented as separate inspection with highest (Error) severity so will be easy to spot or check whole folder/project just for these issues.
There is a ticket (Feature Request) to have an option to show invisible characters in editor.
https://youtrack.jetbrains.com/issue/IDEA-115572 -- watch this ticket (star/vote/comment) to get notified on any progress.

Related

W10/Wins32 C++ How to determine what characters are available to write to an HDC

My goto font for code text editing, in my own editor, has, for years, been Consolas.
I thought its coverage was good but then I discovered that W10 was adding an automatic fallback so even my Ancient Egyptian hieroglyphics font (U+13000 et al) would appear.
Now my editor (internally UTF-8 multi-byte but switching to WCHAR for display including packing two part 21 bit Unicode which the SDK handles nicely) has offered a pop-up box that provided a quick and easy access to characters not on my keyboard and that used GetFontUnicodeRanges() to determine the coverage.
This is obviously now woefully inadequate. I've searched but not found a way to determine what character codes will result in a character on the display and yet Windows is doing it effortlessly at runtime. I can ask about any individual font I want to load but not what will happen.
I must be missing something. I really don't want to resort to writing whole blocks of text to an HDC to a bitmap and then pattern matching on that for the old rectangle or the ? in a box we all know so well.
Has somebody already done this?
Is there a magic trick I am missing?
I am retired now so I have time to delve but I've run out of ideas.

Ways to make one line in console window disappear after a couple seconds?

I need to basically flash a set of numbers for roughly 2 seconds. The user will then have to remember the numbers and type them. How can I do this? I have tried to use a timer or changing the color of the text to the same color of the background, but I can't think of a better way of doing so. Any suggestions?
You have basically three ways of handling this, because typical terminals don't have have the concept of a "screen", just lines.
Use carriage return or backspace characters to overwrite previous characters with blank spaces (but note the user can hit Enter to "preserve" the data in this case).
Print out a bunch of empty lines afterwards, but the user can scroll back.
Use a curses library of some kind (probably ncurses).
You'll need to look at the choices and see which is the best fit for exactly what you are trying to achieve.

Problems with setting insertion point in a wxTextCtrl

I'm trying to implement a custom widget in wxWidgets (version 2.8.12), essentially a modified single line wxTextCtrl. It takes a text input that consists of two sets of 8-digit hexadecimal numbers separated by a space, and I want the control to automatically handle that space. For example, if the user types 1-8 in twice (no press of the space bar required), the resulting contents of the text control should be:
12345678 12345678
If the user were to then place their cursor after the first '3' and backspace three times, that space should automatically adjust as they edit, resulting in:
45678123 45678
Essentially, the space should be completely transparent to the user.
I have this, for the most part, done. The code is a bit long to paste here, so here is a Gist:
https://gist.github.com/036c1a90f77521a8653c
There is one bug, however, that I can't seem to fix- upon typing the ninth digit, it automatically inserts the space, but the cursor ends up right after the space, right behind the ninth digit.
All attempts to use wxTextCtrl::SetInsertionPoint() and wxTextCtrl::SetInsertionPointEnd() have shown no success, so I've come here as a last resort in hopes that somebody can point out what I'm doing wrong.
To assist in testing this widget out, I've prepared a very quick and dirty application containing the widget:
https://gist.github.com/cf3219eb47e2bfe85b38
Or click here to download the code as a tarball:
https://gist.github.com/gists/cf3219eb47e2bfe85b38/download
Just run make to clean, compile, and run the code all at once. You'll need wxWidgets 2.8.12 installed to compile, of course.
Mostly every other facet of this widget works exactly as I want it to- it is just this one very large problem that is keeping this from working. There is, however, one tiny bug that I'm curious about, and though it isn't a major concern I'd like to fix it some time.
The space will be automatically handled even upon deleting characters, even if you delete a selection- however, if the selection that you delete ends on the ninth digit, it won't reformat the contents of the control after the deletion.
If anybody can pinpoint the cause of that it would be appreciated, but the insertion point problem is obviously my main concern.
Thanks to anybody willing to help, I tried to provide as much information and explanation as possible- if I missed anything, please let me know.
Generally speaking, it's difficult to modify the input handling of a native control as it behaves differently under different platforms. I don't know if you tested your code under all (or at least more than one) of them already but I fully expect you to find more problems.
Instead of trying to do it on your own, I'd recommend that you look at wxMaskedEdit proposed for the addition to wxWidgets itself. It's not final yet but there is a preliminary version already and I think it could work with 2.8 too (although it's developed with 2.9, of course).

help with type of window dialog resource needed

I am writing a windows program (no mfc) and need to output a status line to the operator every few seconds or so. I tried using rich text boxes but after so many hours it seems to hang up. Does anybody have an suggestions on what I can use instead?
People mentioned that my buffers might have been exhausted. I thought I had planned for that. After I had about 1000 lines displayed I would take the first 500 and remove them using the select and cut options in rich text boxes. I still ran into the same problem.
This question appears relevant, and this one too. But they don't give any concrete recommendations for an alternative to rich text boxes.
You might try the Scintilla control (scintilla.org) which does not appear to have any hard limitations on text size. It has a permissive license. It is used by many text editors such as Notepad++, Notepad2, Code::Blocks, FlashDevelop. I haven't tried it personally but there from the documentation it looks easy to use it in a Windows API application. Of course, it might be overkill for your purposes.
If you keep appending to the text in the control every few seconds for hours then you are probably running into some memory constraint on the control or the process. I think you would have this problem with any control you choose given update frequence and how long you're running the program.
Have you considered implementing a simple circular buffer for the content of the text box? Say only keep the last hour's messages. You could maintain a separate log file for history if the operator needed to go back in time for hours.
I ended up writing my own control to do this, essentially duplicating the Output window in Visual Studio. It was a success, but it ended up being much more code than I thought it would be when I started - I insisted on features such as auto-scrolling when the cursor was on the last line, select/copy, bold text, etc. It was backed by a std::deque so I could limit the number of lines stored for the window.
Unfortunately the code belongs to a former employer so I can't share it here.

How do I append a large amount of rich content (images, formatting) quickly to a control without using tons of CPU?

I am using wxWidgets and Visual C++ to create functionality similar to using Unix "tail -f" with rich formatting (colors, fonts, images) in a GUI. I am targeting both wxMSW and wxMAC.
The obvious answer is to use wxTextCtrl with wxTE_RICH, using calls to wxTextCtrl::SetDefaultStyle() and wxTextCtrl::WriteText().
However, on my 3ghz workstation, compiled in release mode, I am unable to keep tailing a log that grows on average of 1 ms per line, eventually falling behind. For each line, I am incurring:
Two calls to SetDefaultStyle()
Two calls two WriteText()
A call to Freeze() and Thaw() the widget
When running this, my CPU goes to 100% on one core using wxMSW after filling up roughly 20,000 lines. The program is visibly slower once it reaches a certain threshold, falling further behind.
I am open to using other controls (wxListCtrl, wxRichTextCtrl, etc).
Have you considered limiting the amount of lines in the view? When we had a similar issue, we just made sure never more than 10,000 lines are in the view. If more lines come in at the bottom we remove lines at the top. This was not using WxWidgets, it was using a native Cocoa UI on Mac, but the issue is the same. If a styled text view (with colors, formatting and pretty printing) grows to large, appending more data at the bottom becomes pretty slow.
Sounds like the control you are using is simply not built for the amount of data you are throwing at it. I would consider building a custom control. Here's some things you could take into account:
When a new line comes in, you don't need to re-render the previous lines... they don't change and the layout won't change due to the new data.
Try to only keep the visible portion plus a few screens of look-back in memory at a time. This would make it a little lighter... but you will have to do your own scroll management if you want the user to be able to scroll back further than your look-back and make it all appear to be seamless.
Don't necessarily update one line at a time. When there is new data, grab it all and update. If you get 10 lines really quickly, and you update the screen all at once, you might save on some of the overhead of doing it line by line.
Hope this helps.
Derive from wxVListBox. From the docs:
wxVListBox is a listbox-like control with the following two main differences from a regular listbox: it can have an arbitrarily huge number of items because it doesn't store them itself but uses OnDrawItem() callback to draw them (so it is a Virtual listbox) and its items can have variable height as determined by OnMeasureItem() (so it is also a listbox with the lines of Variable height).