flutter emulate shell window with xterm - flutter

I am making an ssh function in my project. (with https://pub.dartlang.org/packages/ssh), right now session is connected with xterm, cmd can be expected, and the result from the ssh server is displayed in a Text widget, which will have the string like '[0m ... [0m', if I print the result into the console(print(result)), it will display correctly with the color specified, so how can I emulate a shell window which displays the result correctly in my app?
The output of the app now
Output in console which I want to emulate in my app
another example of cmd 'top' in app
output in console that i want to realize

Well, the weird [0 you see are ANSI escape codes. These codes tell the terminal that a certain part of a string needs to get a color. You can find a list of colors here: https://en.wikipedia.org/wiki/ANSI_escape_code#Colors.
Then when you have that info, you will need some tool that can style parts of a TextField. In Flutter you can use the RichText class: https://docs.flutter.io/flutter/widgets/RichText-class.html. My suggestion is to do a find and replace on the text you are showing.
References:
Display a few words in different colors in Flutter
How to change the output color of echo in Linux

Related

Increase the Terminal width in Visual Studio Code

My R Interactive Terminal in Visual Studio Code is too short, cutting-off or wrapping the returned values too early, leading to confusion during data analysis or feature engineering. Is there any way for me to increase the width of the R Interactive Terminal?
Specifically, I am referring to the Terminal Window that is used to display processed code results from R, Python or any other interpreter:
https://webzest.com/vsc_terminal.png
you can collapse the sidebar to gain some more space. the toggle sidebar command is under View/Appearance/Show Side Bar and the keyboard shortcut is ⌘+B on macos or ⌃+B on windows. see attached screen image.
edit: thanks for sharing a screen-print, that helps to explain what you are seeing. sorry i misunderstood... i am wondering if the issue is related to the R shell you are running.
you can see in the attached screen images that the zsh shell uses all of the space available to the terminal panel.
...also, this is on macos, i have not tried windows but that could be part of it.
can you try some other shells and see if they are affected in the same way?
You can use the new setting in v1.61:
workbench.action.terminal.sizeToContentWidth
to toggle wrapping the lines. Depending on your current terminal width you may or may not get a horizontal scrollbar when you do this but at least you won't get wrapping at some pre-determined too small width. This command is also available on the terminal tab context menu: Toggle Size to Content Width.
This question and answer should help
Basically setting options("width"=200) or any value that works for you

How to create a modal for a VSCode extension?

I'm trying to make an extension for VSCode to Find text in File (Like in Notepad++).
Is there an API for using a modal in a VSCode extension? or at least extend the Command Palette?
VS Code (1.34) has no concept modal UI. Extensions can only show basic dialog messages modally using the showMessage apis.
Messages can show message text and a set of buttons. By default VS Code will render messages in its UI. The MessageOptions.modal option makes VS Code render the message using system UI instead.
Try positing a more specific question about what you are trying to accomplish. VS Code's extension model is different from other editors, so if you are trying to replicate functionality from another editor like Notepad++ you may need to rethink the user experience.
I believe what you are looking for is an input box. It will show a UI where you can input text. From there you can grab the text of a document and parse it for entered text. For completeness, VS Code does this with ctrl + f or cmd + f depending on OS. Add the shift key to search the whole project.
As mentioned above there are the limited built-in inputs and message box (which can also be used to display choice buttons).
You can also have a look at WebView these can be used to display a side-bar view (like the EXPLORER) or a full document. They are made up from HTML and plain old JavaScript. You will have to pass simple string messages between your HTML/JS view and vscode itself.
https://code.visualstudio.com/api/extension-guides/webview
https://github.com/Microsoft/vscode-extension-samples/tree/main/tree-view-sample
A large 'document' view example vscode extension is call 'nearest-icons'
https://github.com/noGreg/nearest-icons

Gnome shell two monitors full screen apps

I'm working on the Ubuntu 16.04 whit Gnome Shell version 3.18.5 and I'm using two monitors. Issue which I have regarding aplications opend in the full screen mode.
For expample if I open on the monitor number 1 my browser and on the monitor number 2 terminal in full screen mode plus some additional application such as a code editor(not full screen). Now when I'm focus on the code editor which is on the top of the terminal it's ok but when I click on my broser window(monitor 1) then the code editor gose behind the terminal automatically.
I've prepared some video to better show this problem:
In this video you can see correct behaviour when I'm using one monitor.
Here is video showing incorrect behaviour. Don't care about the elements which are above the terminal on the left screen. Terminal was set to full screen.
Dose anybody know how to change this behaviour? I was looking for solution in google but without success. Thank you.
That's the expected behavior when things are in focus/out of focus. Try resizing your windows so they don't block one another; thus, nothing will be "behind" anything else when you shift focus by clicking here or there.

Is it possible to move the command prompt to a certain position on the screen?

As the title says, is it possible? I've searched all over the internet in order to find it, but whatever variation of my search query I come up with, I end up getting results which are about the move command which is used to move files/folders, instead of the actual prompt.
When doing
mode /?
The only result I can remotely relate to the appearance of the prompt is the Display mode,
(mode con:cols=x lines=y)
As I've said, I can't find any documentation about this & I'm extremely curious, can it be done? I know it can be done in Visual Studio to set a position where it should show it's dialog, so I'm presuming it can be done...
PS: If it can be done, what value should I use to have it perfectly centered when using these size settings?
mode con:cols=50 lines=15
Thank you in advance.
Yorrick
You cannot do so directly from a batch file. However, you can write a small program to do that. The relevant Windows API function is MoveWindow.

oh-my-zsh themes don't show properly (background stays white) [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I am trying to figure out why my oh-my-zsh themes don't work properly. The colors show up properly, but background stays white (with black text). below is my /.zshrc file and current path variable:
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
export ZSH_THEME="robbyrussell"
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# Set to this to use case-sensitive completion
# CASE_SENSITIVE="true"
# Comment this out to disable weekly auto-update checks
# DISABLE_AUTO_UPDATE="true"
# Uncomment following line if you want to disable colors in ls
#DISABLE_LS_COLORS="true"
# Uncomment following line if you want to disable autosetting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment following line if you want red dots to be displayed while waiting for completion
# COMPLETION_WAITING_DOTS="true"
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
plugins=(git rails ruby brew)
source $ZSH/oh-my-zsh.sh
# Customize to your needs...
autoload -U colors
colors
here is $PATH :
➜ ~ echo $PATH
/Users/natascha/.rbenv/shims:/Users/natascha/.rbenv/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:/usr/texbin
I am on Mac OS X 10.7.5 and installed oh-my-zsh months ago.. I have made a post in the git issue, https://github.com/robbyrussell/oh-my-zsh/issues/929#issuecomment-11652602, it seems to still have not been resolved? My plugins work ( i.e. i can type rails c for "rails console").
Thank you for any help.
Short answer: no, zsh can't help you here. You need to change the terminal emulator color settings, not the zsh settings.
This is what you're currently seeing:
and this is what you're expecting to see:
This is the line that produces this prompt:
PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c
%{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
The Z-Shell does have some foreground, background settings you can use in the PROMPT - that's what the fg_bold means (foreground to bold). You can replace this with bg_ for background, and omit the bold to use a non-bold font.
For example, we can set the background of the PROMPT to green by adding %{bg[green]%}:
PROMPT='%{$bg[green]%}%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c
%{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
This results in:
However, this more than likely is not what you want. Note several things:
The bg[green] does not extend to the edge of the terminal window - the PROMPT settings only work where the line is drawn.
The background color is reset to 'default' at the end of the prompt - that's done by %{$reset_color%} (necessary to change the foreground color to default). Getting a consistant, whole-line background color gets messy quickly.
How the colors work
Roughly (I could be wrong in details, but the overall gist is correct, I believe): the shell you use sends a color code to the terminal emulator. The terminal emulator is responsible for interpreting that color code, and displaying it on the screen. This means there are two settings you can fiddle with:
The shell color settings. That's what you're doing in your zshrc. Primiarily, this allows for consistency - you can say "Display this bit of the prompt in the same $COLOR as that bit of the prompt". This doesn't mean the user will see the prompt in $COLOR; $COLOR is a label, not much more.
The displayed color settings. That's where you set the preferred font, background, text color, etc. It's where you can say "display everything the shell says is $COLOR_1 as red, $COLOR_2 as green", etc.
There are 16 colors you can use in an ANSI terminal, which may-or-may-not be displayed correctly. Check this table for some common terminal colors, and note the differences displayed between them!
Fixing your colors
If you're using Terminal.app (on OS X, I'd recommend iTerm2), open the preferences for Terminal (command+,), and select "Settings". There's a bunch of "profiles" you can choose from - to emulate the robbyrussell screenshot above, you'd want to fiddle with the colors a little. "Homebrew" is pretty close, but has different "text" colors (green instead of white).
[Here is the robbyrussell zsh theme with the Homebrew Terminal.app profile:
If you'd like a good, pre-set, easy-on-the-eyes color scheme, check out Solarized.
Like said in the answer above it is "You need to change the terminal emulator color settings:"
I don't find any reason changing terminal app, the easiest way is only changing the theme to one of the available themes in the link below, you can find one that suits to oh-my-zsh themes.
osx-terminal-themes
For me the fix was found in a preferences panel where I had to deselect which was overriding the theme...
I'm using gnome-terminal on an instance of Red Hat.
Found Under:
Terminal -> Preferences -> Unnamed -> Colors -> Use colors from system theme
(took me much too long to realize that...)
I was surprised this didn't work out of the box as well. However, I was able to get pretty close with just a few minor changes to the Basic theme:
Change the background to a dark color
Change text to a light color
Change selection/opacity to get a good highlight
Also, when selecting a color, use the eye dropper to get the exact color you're looking for:
With the eyedropper and a picture of his theme, you should be able to get pretty close.