How to show long ListItem in Rust TUI List - rust

I am working on a Terminal User Interface where one of the widgets is a List where I show some logs. Right now, I have two functions: listener(log_list) and printer(log_list). In listener I receive the logs and store them in log_list, which is a Arc<Mutex<VecDeque<ListItem<'_>>>>, and then I print that VecDeque in a List in printer function.
The problem is when a line of this log is longer than terminal width, because it just cuts it, missing part of the information when printing. So which would it be the best way to solve this? I mean, I could create a shared value with the terminal width that I get in printer, and share it to listener, so that I cut each log longer than the width and create 2 ListItems, but I find this very messy. Is there any elegant way of doing this?
Thanks

Related

Reprint a table in js terminal without a waterfall print or clearing console

JS has this great feature called console.table. It allows a list of objects to be displayed as a table.
Now I could like to create a simple little program that continously displays the same table just with updated values (individual values change very fast, so a re render only on change isn't an option)
So far I got the best results simply rendering one table after the other, which leaves the most recent table always at the bottom. The problem with this is that it fills the entire terminal extremely fast and as such makes scrolling back up difficult.
Another option would be to clear the terminal and the print the table again. But this leads to excessive "blinking" which makes the table unreadable.
So basically I would need a way to print the console.table, somehow get the terminal cursor back to the start of a table and the overwrite it, similar to how it works in a lot of terminal programms like htop. Is there a way to do this in node js?

UE4 - Removing Text When Exiting TriggerBox

Having some trouble getting text to disappear when I exit the trigger box from reading the note. I can easily display the text I want but I am unsure how I can make it disappear when I leave the triggerbox. Blueprint included, any help is appreciated.
Connect GetPlayerController to Create Widget?
Also store the created widget as a variable. It's likely that the widget reference is being lost once the E input event is finished, so the RemoveFromParent node doesn't know what to remove.
For widgets that you're going to use all the time, pre-create them and store them as variables. Much easier to maintain in the long run.

Is it possible to keep a variable active with Revit Python Shell, using canned commands?

I'm currently using Revit Python Shell 2017 and I'd like let's say to make "communicate" different canned commands.
For instance, let's say I load a house model, and I create some additional walls on it, via a canned command that I would have previously created. While creating these walls, I could store all these new walls IDs in a variable, as a list.
Now, if I want to delete exactly these walls afterwards, I'd like to identify them using their IDs that I stored in the list, then delete them.
If I was in an interactive Python Shell session, well the "IDs list" variable would still be accessible (as long as I don't close the shell), and I could just retrieve the IDs from it, then delete the walls.
But what if I'm using canned commands? The first command would be "create the walls", and the 2nd would be "erase these walls". But that "IDs list" variable doesn't exists in the second canned command environment, so that I can't use it to erase the walls.
So, what would be the approach? Of course in this example I could identify the walls in the second command using a different methodology, such as asking the user to select them etc etc.. But the idea I'm going for would be the store that list from the first command "somewhere in Revit", and retrieve it when calling the second command.
I could write the list to an external text file, and read the file in the second command... but is there a cleaner way?
I'm sorry for the beginner's language used here, and hope that my question is clear enough! And that somebody can help ;)
Best,
Arnaud.
This is a great question Arnaud, in the past Ive done the following:
Create a text project parameter, and populate it with XML (yes you can have line breaks in a text parameter). This is similar to what Ideate BIM Link does (check the project parameters of any project that has used BIM Link). This is a long-winded method for keeping data persistent between commands.
The second part (saving a walls IDs) is more difficult I think, as I understand it every time you open a project the IDs are reassigned. You could test this to see if its the case?
Another method could involve using an External command that lingers after you have finished selecting walls. Could you go into a little more info about what youre wanting to achieve?
So,
Just for leaving a trace, I solved this using pyRevit and its ability to store data in temporary files (here, look for "Using Temporary Files").

s3270 - Write text to session, not inside an input field

I have an interesting problem interfacing to an IBM mainframe based CICS application. I can login and write to input fields successfully using s3270 and x3270if. However, the CICS system I am working with expects certain commands to simply be written to the "screen", not a proper input field. I am using the String() function to write to input fields, but I cannot seem to find a function that will simply write a string to a given screen position.
Has anyone dealt with a similar scenario and can provide me with some pointers?
With 3270, there is no such thing as "write to the screen," as opposed to writing to a field. A formatted 3270 buffer is a set of fields, each with a certain set of attributes. You cannot write to an arbitrary screen position unless there is an unprotected field that includes that position. That's 3270 specs, that's how 3270 hardware worked, that's how 3270 emulators work, and any API you may be using for working with 3270 emulators will just expose that.
(You may have an unformatted buffer with 3270, but I gather that's not the situation you are facing, since then you would be able to write to any screen position - the buffer is essentially one big field.)
So you need to figure out how the screen you are trying to write to is formatted, and where its fields are, and where the application expects its input. If you can just run the emulation and type the input according to whatever instructions you have then it should be straightforward - wherever your input goes, that's where you should put it programmatically.

how can I extract text contents from GUI apps in linux?

I want to extract text contents from GUI apps,here are 2 examples::
example 1:
Suppose I opened firefox, and input url : www.google.com
how can I extract the string "www.google.com" from firefox using my own app ?
example 2:
open calculator(using gcalctool),then input 1+1
How can I extract the string "1+1" of calculator from my own program?
in brief ,what I want is to find out whether there is a way to extract the text contents from any widget of an GUI application
Thanks
I don't think there's a generic way to do this, at least not a very elegant one.
Some inelegant ideas:
You might be able to modify the X window system or even some toolkit framework to extract what is being displayed in specific window elements as text.
You could take a screenshot and use an OCR library to convert the pixels back into text for the interesting areas.
You could recompile the apps of interest to add some kind of mechanism for asking them questions.
You could use something like xtest to inject events highlighting the region of interest and copying it to the clipboard.
I believe firefox and gcalctool are for examples only and you just want to know in general how to pass output of one application to other application.
There are many ways to do that on Linux, like:
piping
application1 | application2
btw here is the Firefox command line manual if you want to start firefox on Ubuntu with a URL. eg:
firefox "$url"
where $url is a variable whose value can be www.mozilla.org
That sounds difficult. Supposing you're running X11, you can very easily grab a window picture ( see "man xwd"); however there is no easy way to get to the text unless it's selected and therefore copied to the clipboard.
Alternatively, if you only want to capture user input, this is quite easy to do, too, by activation the X11 record extension: put this in your /etc/X11/xorg.conf:
Section "Module"
Load "record"
#Load other modules you need ...
EndSection
though it may prove difficult to use too, see example code for Xorg/X11 record extension fails

Resources