dialog/whiptail radiolist consistence - linux

So basically I am trying to rewrite a bash script which uses dialog --radiolist for choosing locale,keyboard,time. At the moment the tag is a number that corresponds to a local (I created a hashtable for it). But because I have, and want to keep it that way for now, around 100 locales it gets messy at the end.
What I wanna achieve is to make it more compact without having to add or add an artificial, non visible item that might easily translate to its tag. (as a tag I would put the locale name)
What I have tried:
1. Noobish thing but I though that there might be some way to include empty like NULL in ASCII or 0, blank space etc, but dialog would always make it visible.
2. Exclude the item at all and finish on on/off but instead on/off takes place of item (not surprisingly if options are as follow --radiolist text height width list-height [ tag item status ])
3. Instead of letting the dialog on exit write to the output the name of the chosen locale I created an output statement myself.
I had red a lot about dialog and whiptail(http://linux.die.net/man/1/dialog, http://linuxcommand.org/lc3_adv_dialog.php) but always end up with having to add tag and an item. Would appreciate any suggestions and maybe some info if there is easily plug-gable dialog/whiptail compatible libs.
Thank You in advance

Perhaps you overlooked the --no-tags option (see manpage):
--no-tags
Some widgets (checklist, inputmenu, radiolist, menu) display a
list with two columns (a "tag" and "description"). The tag is
useful for scripting, but may not help the user. The --no-tags
option (from Xdialog) may be used to suppress the column of tags
from the display. Unlike the --no-items option, this does not
affect the data which is read from the script.
The question mentions whiptail and consistency, which could refer to consistency across dialog and whiptail. There is none, since
whiptail provides fewer options than dialog (inevitably, there will be differences, since there is no one-one mapping possible)
consistency as such between the two is done in dialog occasionally to help with compatibility (the reverse is not true).

Related

Python Inquirer Module: Remove Choices When Done (Using Curses)

NOTE: Although I give a lot of info on Inquirer, I'm pretty sure that most of it won't apply (just being safe). For my actual question about curses, its at the bottom.
I'm using the Inquirer module in Python 3 to allow the user to select a value from a list. I run this:
import inquirer
choice = inquirer.prompt([inquirer.List("size",message="Which size do you need?",choices=["Large", "Medium", "Small"])
And I'm given this:
[?] What size do you need?: Medium
Large
> Medium
Small
And using the up and down keys, I can change my selection, and hit enter to choose, after which the "choice" variable contains the value I selected. The issue is: Once the selection is done, the choices still show. I want to delete them when done. I'm currently using ANSI Escape Codes to delete the choices from onscreen when done, where x is the number of choices:
import sys
for i in range (x+1):
sys.stdout.write('\x1b[1A')
sys.stdout.write('\x1b[2K')
Which leaves the printed text as:
[?] What size do you need?: Medium
The issue is, ANSI escape codes aren't universal. I want to use a solution that works on all terminals, preferably curses, but curses isn't very friendly to new users, so I was wondering if anyone knew how to use curses to "delete x lines above current position". Thanks!
curses, as such, would erase the whole display (which is probably not what you want). A low-level terminfo/termcap approach might seem promising, but while ECMA-48 does define a sequence (ED, with parameter 1) which erases above the current position, there is no predefined terminfo/termcap capability which corresponds to this. All that you will find there is the capability for erasing to the end of the screen, or erasing the whole screen.
"ANSI sequences" is an obsolete term. Referring to ECMA-48, you could do
sys.stdout.write('\x1b[1J')
after moving the cursor to the last location you would like to erase.

How to list all saved custom filters in Control-M?

Assume you created some, eg 3, custom filters saved with filter names A,B, C, using Control-M's ISPF client in zOS (mainframe). Using such custom filters, you can easily switch between the list of jobs to be shown in the Active Jobs File, using primary ISPF commands like:
s A
s B
s C
If you only have like 3 such filters, and with names like A, B or C, it's a piece of cake to remember them all. However, if you have like a dozen of names, each with up to (say) a length 8 (XYZ10000, PQR123, etc), it's pretty much impossible to remember them all.
So is it somehow possible to bring up a list of all available filters (similar to an ISPF memberlist)? If not, where to go find all such filters that are defined, maybe in some ISPF profile dataset member?
If you want to see a list of filters all you need to do is type SHOW ? in the command line and it will bring up a list of save filters.
Put an S beside the one you want to select it.
Rather accidentally, I discovered the correct (and complete) answer to my own question ...
The previous answer is a good start, i.e. you need to issue command show ? (or just s ?). But in my case just typing show ? still didn't show the filters (like A, B or C as in my question). The additional clue to really get it to work, at least in my case, is that I also have to press the PF8-key to perform a page down in that pop-up window (shown after first typing show ?). And without pressing the PF8-key, I only see a list of (vanilla) filters that come with Control-M.

Sublime text multiple cursors?

Sublime Text is so damn advanced and this seems like such a stupid question, but...
I started writing a for loop in PHP (using SFTP), loved that it gave me a choice to auto-generate the loop. However, it enters this weird multi-cursor mode, which
1)I am not really sure how to use/exit without using the mouse;
2) it seems useless, seeing as all 3 type the same thing, even though I need to change, for example, the $i > x or $i = x.
Although Sublime does indeed support the idea of multiple cursors (which is an incredible time saver and useful as all get out, as we're about to see), what you're actually asking about here is a snippet which in this case happens to also include multiple cursors.
The general idea is that for code that you're likely to type many times (e.g. a for loop), you can create a snippet that will generate the bulk of the text for you in one shot, and then allow you to easily customize it as needed. In this case, the snippet in question is part of the default functionality of Sublime and is provided by the shipped PHP package.
To answer point #2 in your question first, this is far from useless. As seen here, I enter the text for and then press Tab to expand the snippet out. The first thing to notice here is that the status line says Field 1 of 4 to tell me that I'm in a snippet and that it contains four fields.
The first field is the name of the control variable for the loop, and all of them are selected so that as I change the name, all of them change at the same time because when there are multiple cursors, the text you type appears at all of them at the same time.
Once I'm done changing the name of the variable, I press Tab again to go to the next field, which allows me to easily change the point at which the loop starts. Another press of Tab takes me to the third field, where I can specify where the loop ends.
One last press of Tab exits the snippet and selects the text in the loop, so I can start writing my code (caveat: I am not a PHP developer).
At this point you can see Sublime offering another snippet for echo, which would expand out to an echo statement complete with quotes, then allow me to edit the text in the echo and skip to the end.
Circling back around to the first point in your question, you can use Esc at any point to jump out of a snippet and go back to regular editing. You can also use Tab or Shift+Tab to move through the fields in the snippet, and pressing Tab at the last field in the snippet exits it as well.
In this particular case, the first field in the snippet sets up multiple cursors, and so exiting the snippet while this field is active leaves multiple cursors in effect. You can jump back to a single cursor by pressing Esc one more time (this is true regardless of how you ended up with multiple cursors).

Exclude comments from search results in IntelliJ global search?

I found the grammar error "it's" as a possessive on one page of a large project. I'm trying to search for any other usages of this on pages to correct it, but I'm getting results containing hundreds of comments. I just want to filter for the important user-facing portions of the project. Is there a way to exclude comments from the results of a global search?
In more recent versions, at least in PyCharm 2018 (similar to IntelliJ), there is a filter option "Except comments," as shown here:
(Click the small filter icon to show the dropdown.)
Note: The selected filter option persists during a session, and the active filter option is not immediately apparent unless you open the dropdown. To prevent accidentally limiting subsequent searches, it may be a good idea to switch back to "Anywhere" afterward.
Another approach would be to enable the "Regular expression" (or "Regex") checkbox in the search dialog, then use some kind of negative lookaround to exclude comments.
In one case, I needed to exclude lines with single-line comments (e.g. # this is a comment) from a search, but not lines with inline comments (e.g. a=b+1 # this is an inline comment). The following did the trick, searching for something (for Python comments, starting with #):
^((?!#).)*something.*$
Please note I'm not a regex-expert, so this regex pattern can probably be improved upon greatly, but it illustrates the idea. You can play around with this on regex101. Any comments to improve the pattern are most welcome, of course.
Note sure if this approach could be extended to multiline comments though. (as in """ several lines here """).
It's difficult to suggest something without really looking at the code, but since it seems like a one-off thing, I would use global search just in comments to temporary replace "it's" with some #temporary-token#, then use global search everywhere, you should everything what's left. Then rollback temporary token for comments. Should be easy to try with VCS. Just an idea.
As you can see, with "Comments only" option, only one #token is found.

In ncurses what does the attribute A_PROTECT do?

In ncurses:
1.What does the A_PROTECT attribute do? Everywhere on the net, the docs just say: Protected mode. What is that?
2.Also I would like to mark the area where the user inputs characters with an underscore, but I would like when the user deletes or backspaces to have the underscore reappear. Is there an attribute that does that, or I have to manually do that?
Protected mode may refer to a little-used feature of some DEC terminals (notably the VT220 and related), called selective erase.
The general idea is that some text can be internally marked as protected. This doesn't change the way it is rendered on the screen, but character cells so marked are not erased by the DECSEL and DECSED (Selective Erase in Line and Selective Erase Data) commands.
This would typically be used to implement something like a data entry form. Field headings and markup would be protected text, and data entered into the fields would be unprotected. You can erase the contents of the form to reset it by performing Selective Erase; thus erasing the data fields but not the headings.
Protect mode is defined by the terminal I'm not sure if it does anything on modern terminals.
There is an attribute "A_UNDERLINE" that underlines a character if your terminal supports it.
For handling input you may want to look at the form library (distributed with ncurses) or cdk (http://invisible-island.net/cdk/)

Resources