What's a way to implement backspace working in field in ncurses - c

I am try to create tui via ncurses. And I have same problem.
There are two fields:
Name
_______
Password
_______
How to implement backspace-support in each field ?
And how to use '*' to show each character in password-field ? (Now I use field_opts_off(field[1], O_PUBLIC);and it doesn't show characters in password-field, only move cursor).
Thank you.

There is no tutorial for the forms package that I recall. However, the ncurses test-programs (which are available separately as ncurses-examples) contains a program demo_forms which does implement deletion by maintaining the edited field contents as a hidden field buffer, and decrementing its length in the case for REQ_DEL_CHAR.
Here is a screenshot of the program:
Regarding the "non-ncurses" suggestion: dialog is a curses/ncurses application, and has no particular dependency upon bash.

"Non-ncurses" solution (just for an alternative):
You can use dialog program to perform this task in a very easy way. Just run some linux system commands from C to achieve a nice TUI.
If you want to install it, the package name is dialog too.
For a textfield, you can do: dialog --inputbox <text> <height> <width> [<init>]
For a password field: dialog --passwordbox <text> <height> <width> [<init>]
For more info: http://bash.cyberciti.biz/guide/Bash_display_dialog_boxes

Related

How to save codes on VS Code Mac?

I am using VS Code on a Mac to write ReactJS, however I find that I could not save my code. If I use command and s to save, then the JSX will be a mess, just like shown in the picture:
enter image description here
So how could I solve it? Thank you
I think your code is being saved, but that your code formatting is messing-up your code.
Hit the following combination : Shift+Command+P
This will open a menu on top. Inside that menu type Format Document With..., and select it. It will allow you to format your code with a different auto-format tool. Choose the one that is appropriate for your code i.e. Prettier.

SpelEvaluationException: EL1007E '#' not well managed when trying to develope a dialog answering with 'emails'

I'm writing a Dialog that identifies some required capabilities and provides as output the name and the email of the person having those capabilities.
I wrote a dialog node that provides an output like this: "The person you are looking for is name-surname and the email is xxxxx#yyyy.com" , but if I run it I receive the following error "SpelEvaluationException: EL1007E"
The error disappear when replacing the '#' in the answer with any other character
I also tried to build a context variable containing the email and building the answer using the variable but the error is the same.
Any suggestion?
Thanks
You need to escape the # by adding \\ so it should be x\\#y.com

KDevelop: transform selected text?

I was wondering whether there was a function in KDevelop similar to the one that we used to have in Quanta (miss you, Quanta, btw).
I would like to set a keyboard shortcut, and apply a text transformation upon hitting it. Example:
I select my text to be translated, and I get back: <?=_('my text to be translated'?>
As you can see, this saves me a lot of awkward keystrokes...
I only found this feature in PHPStorm (where it is called "Live Templates"). I defined it like this: <?=t('$SELECTION$')?> and I can call it by hitting CTRL+ALT+J, and select it from the dropdown that appears.
You should be able to do that using a snippet with the following text: <?=_('%{selection}'?>
And you can bind a Shortcut to a snippet.
However my tests showed that this doesn't work correctly - there seems to be a bug somewhere.
As alternative you can write a script that does insert the text. See the documentation.

How to protect files(docs) form being downloaded

I have some documents on a subdirectory for example www.example.com/documents, inside the document folder i have files(e.g. File1.doc, file2.docx, and So on). I want users to view the files But not to download it.
How can i do this?
In order to view the file the user need to download them... Maybe I don't fully get your point but I think this is not an option
(Programmer's Lore-Keepers) forgive my suggestions here...
This is a bit of a 'grey-area-programming'.
Have you considered perhaps using a technology of your choice javascript/jQuery to capture the "known" ways of copying while on your page?
Positive test : suppose the user clicks enter on a textbox and you're using jQuery to trap the enter command to then set off your trigger that is a default action to a control of your choice.
Think about this as a negative test... if the user uses key combinations such as Ctrl+A or Ctrl+P or Ctrl+S then you intercept it and interrupt their action in theory...
Other factors to consider would be how to capture the mouse drags and perhaps even right-click actions.
Hope this helps.

Installshield 2011: Take path from one window, take text from second

Good day, everyone. I have that task assigned which consists in creating simple installscript-only project, that should have 2 windows: first will prompt user to enter a path and create text file in this specified location, while second will promt for text input and save anything user writes into this text file.
Funny point is that I have small installshield experience (completed tutorials... well, yeah, that's all) and very little programming experience on top of that. As far as i understand, I should first create two custom dialog windows (for example by cloning them from standard ones), then create .rul files with functions, determining behavior for each. After which, include them into main setup.rul and call functions at specific point of time.
Question is - what exact dialog windows/functions/points of time will be best for such task? For reference i searched into "Serial Number Validation Sample Project" but, honestly, the way it customized default window is just confused me even more... So, please, can anybody help? Thank you.
For future reference, here's working solution.
Asked that same question at flexera forums, and here's what I got:
Off the top of my head (without InstallShield handy to check this) 1)
Create an InstallScript project, just accept all of the defaults in
the new project wizard unless you want to add localization or
something. 2) Your description implies that you do not need
maintenance (repair, modify, uninstall) support. If correct go to
Project\Settings and on the Maintenance tab select 'no uninstall or
maintenance'. 3) You can put your code at the top of the
OnFirstUIBefore function and then call Exit so that the rest of that
default code is never executed, since you are not installing anything.
As part of your InstallShield IDE, in the Start menu (for IS2012
Spring) is a tool that demonstrates all of the built in dialogs. You
can look through those choices and select the dialog that is best for
your situation. It sounds like you want to:
Call AskPath or SdAskDestPath (there are several other possibilities)
Then call AskText and save that string.
If you need to make layout or text changes to the default dialogs look
at your Dialogs view and select which ever dialog you selected above
and edit it. (If you decide to use skins make sure you select the skin
before you make any dialog layout changes.)
Then do something similar to the functional body of the WriteLine
example http://kb.flexerasoftware.com/doc/Helpnet/installshield14langref/LangrefWriteLine_Example.htm
The actual WriteLine example function prototype is for a MSI custom
action which is not what you want. Ignore the function protoype and
just use the code in your project to create the file at the path you
already collected and write the line of text that you collected.
Then call Exit;
(big thanks to user phill_mn for that answer)
And here's the code for setup.rul:
#include "ifx.h"
function OnFirstUIBefore()
number nvFileHandle;
string svResult;
string szTargetPath, szFeatures;
BOOL bLicenseAccepted;
begin
AskPath ("Please choose a path where text file will be saved","c:\\",szTargetPath);
MessageBox("File yourtext.txt wiil be created or overwritten at " +szTargetPath, INFORMATION);
AskText ("Please enter some text to save into that file", "Text goes here", svResult);
OpenFileMode (FILE_MODE_APPEND);
if (CreateFile (nvFileHandle, szTargetPath, "yourtext.txt") < 0) then
MessageBox ("Creating failed.", SEVERE);
abort;
else
if (WriteLine(nvFileHandle, svResult) < 0) then
MessageBox ("Writing failed.", SEVERE);
else
MessageBox ("Success.", INFORMATION);
endif;
endif;
CloseFile (nvFileHandle);
Do(EXIT);
return 0;
end;

Resources