I can't print to VSCode's console with stdout.write - flutter

I'm running a flutter application in VSCode and want to print to console using this code:
stdout.write('Text');
But the console doesn't show anything after executing this line. Why is that?
(print statements work as expected).
EDIT:
the print function works fine. I just wanted to print something inside a for loop without a newline, that's why I was trying to use stdout.writeln. I ended up building the string I wanted to print in the for loop and printing it only once with the print function.

I had the same problem, "solved" it using StringBuffer and one final print:
final StringBuffer buffer = StringBuffer();
for (var i = 0; i < 100; i++) {
buffer.write('$i, ');
}
print(buffer.toString());

Just use print("Hello console"); =D

I had the same problem myself.
Unfortunately I can't tell you the reason why stdout doesn't work on terminal logs but I can tell you that you can see them using Dart DevTools on the part of Logging

Same here. In my case this code
import 'dart:io';
void main() {
for (int i = 0; i <= 10; i = i + 2) {
stdout.write('$i ');
}
}
Do not show this output in VS Code console.
0 2 4 8 10
It does in other IDEs so I guess it's VS Code problem.

Related

How can I add space between code and comment?

I'm using nerdcommenter alongside neovim, and every time I comment out a block of code with <leader>cc, the code isn't really spaced out:
fn main() {
//println!("Hello, world!");
}
I want to get an output of something like this:
fn main() {
// println!("Hello, world!");
}
Is there a command or configuration that I'm missing out on? (I haven't configured nerdcommenter at all in my vimrc)
See the plugin docs : use g:NERDSpaceDelims configuration option
" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1
Or for Neovim with Lua configuration :
vim.g.NERDSpaceDelims = 1

Does dartpad not support I/O?

Recently I was trying out some code snippets from "Dart For Absolute Beginners" on DartPad.
Specifically:
import 'dart:math';
import 'dart:io';
void main()
{
int guess;
Random rand = new Random(); //create a random number generator
int answer = rand.nextInt(100); //gets a random integer from 0 to 99
do
{
print("Enter your guess:");
String temp = stdin.readLineSync(); //read in from the keyboard
guess = int.parse(temp); //convert String to integer
if (guess < answer)
{
print("Too low!");
}
else if (guess > answer)
{
print("Too high!");
}
}
while (guess != answer);
print("You got it!");
}
However upon running, it shows the error "Error compiling to JavaScript:
unsupported import: dart:io"
So my question is
Is it that we can't run I/O operations on DartPad and we need a full fledge editor for that ?
or is there something else wrong ??
The dart:io library is not supported in DartPad. However you can use this Dart compiler, it supports dart:io.
As noted in the dart:io documentation:
Important: Browser-based apps can't use this library. Only the following can import and use the dart:io library:
Servers
Command-line scripts
Flutter mobile apps
Flutter desktop apps

How to remove the console from the Roblox Exploit Api Dll Inject

I got the api sauce and I'm editing it.
When you inject the api, the console comes out and tells you to enter the command there.
I just want to erase the console that comes out by injecting api, inject and execute what I wrote as a command into the C# text box, but it didn't go well.
So I fixed the code in the console window, aenter image description herend Roblox crashed.
Tell me how to solve this problem.
And I will show you the status code with the console coming out and the code with the error after fixing it without the console coming out. Make sure the console doesn't come out, and if the command you wrote down in the text box presses the Execute button, let Roblox run it.
Code before modification (state with console)
void main()
{
ShowWindow(GetConsoleWindow(), 0);
CONSOLEBYPASS();
freopen("CONOUT$", "w", stdout);
freopen("CONIN$", "r", stdin);
HWND ConsoleHandle = GetConsoleWindow();
SetWindowPos(ConsoleHandle, HWND_TOPMOST, 50, 20, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
ShowWindow(ConsoleHandle, 1);
SetConsoleTitle("Sxploit // Credits to Aero // Updated by L");
XHosted::Run(XHosted::GetVersion());
//XHosted::XDumper();
RobloxState = XHosted::GetRState();
VanillaState = luaL_newstate();
BreakPointsInit();
luaL_openlibs(VanillaState);
luaL_newmetatable(VanillaState, "garbagecollector");
lua_pushcfunction(VanillaState, UserDataGC);
lua_setfield(VanillaState, -2, "gc");
lua_pushvalue(VanillaState, -1);
lua_setfield(VanillaState, -2, "index");
WrapGlobals(RobloxState, VanillaState);
SetLevel(RobloxState, 7);
RegisterShittyFunc(VanillaState);
lua_newtable(VanillaState);
lua_setglobal(VanillaState, "_G");
CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)input, NULL, NULL, NULL);
std::string i;
Execute("warn('Connect to Roblox')");
while (true) {
getline(std::cin, i);
Execute(i.c_str());
i = "";
}
}
BOOL WINAPI CONSOLEBYPASS()
{
DWORD nOldProtect;
if (!VirtualProtect(FreeConsole, 1, PAGE_EXECUTE_READWRITE, &nOldProtect))
return FALSE;
(BYTE)(FreeConsole) = 0xC3; //opcode time
if (!VirtualProtect(FreeConsole, 1, nOldProtect, &nOldProtect))
return FALSE;
AllocConsole();
}
Code after modification (the console does not come out, but the Inject causes the Roblox to crash)
void main()
{
BreakPointsInit();
luaL_openlibs(VanillaState);
luaL_newmetatable(VanillaState, "garbagecollector");
lua_pushcfunction(VanillaState, UserDataGC);
lua_setfield(VanillaState, -2, "gc");
lua_pushvalue(VanillaState, -1);
lua_setfield(VanillaState, -2, "index");
WrapGlobals(RobloxState, VanillaState);
SetLevel(RobloxState, 6);
RegisterShittyFunc(VanillaState);
lua_newtable(VanillaState);
lua_setglobal(VanillaState, "_G");
CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)input, NULL, NULL, NULL);
std::string i;
Execute("warn('Connect to Roblox')");
}
The picture over there is the console window I want to erase.
You cant remove that console app from here, this console is used to push lua script that given by pipes from your exploit to roblox, the only way how to teke out that console is to hide it.
As i understand this is a c++ code right?
void HideConsole()
{
::ShowWindow(::GetConsoleWindow(), SW_HIDE);
}
You're using Axon Source i can see, you can give the code pls?
//Necesary for hide console
#include <Windows.h>
//Hide Console
void HideConsole()
{
::ShowWindow(::GetConsoleWindow(), SW_HIDE);
}
//Check Is Console Visible
bool IsConsoleVisible()
{
return ::IsWindowVisible(::GetConsoleWindow()) != FALSE;
}
Axon is currently entirely patched, I would suggest checking out Imperious Transpiler with more stability and actually working!
Check it here: https://v3rmillion.net/showthread.php?pid=7615717
(Also if you don't know the basic fix for that, I don't think you will be able to update addys every Wednesday.)

How to fold all open editors in visual studio code using a script

I would like to be able to create/write a command to fold all code in all open editors within visual studio code.
I believe I am very close.
I am using the "script commands" extension written by Marcel J. Kloubert
When I use the following script with 7 or so open editors in a single group. I achieve the following:
The open editor (at the time of execution) has its code folded
VSC will loop over the open editors
No other editor has its code folded
The script I am using:
// Fold all code in all open editors.
function execute(args) {
// Obtain access to vscode
var vscode = args.require('vscode');
// Set number of open editors... (future: query vscode for number of open editors)
var numOpenEditor = 20;
// Loop for numOpenEditor times
for (var i = 0; i <= numOpenEditor; i++){
// Fold the current open editor
vscode.commands.executeCommand('editor.foldAll');
// Move to the next editor to the right
vscode.commands.executeCommand('workbench.action.nextEditor');
// Loop message
var statusString = 'Loop ->' + i
// print message
vscode.window.showErrorMessage(statusString);
}
}
// Script Commands must have a public execute() function to work.
exports.execute = execute;
I have made an interesting observation, when I use the above script with 7 or so open editors with two groups or more. Something about switching to a new group will allow the command editor.foldAll to work. Note, that if a group has multiple editors, the only editor to fold its code is the open editor in the group. Thus, all other editors will not fold.
I also thought that maybe... the script needed to slow down, so I added a function to pause on every iteration. This did not turn out to work either.
Any help would be great!
You just need to make this function async and wait for the executeCommand calls to complete before moving on:
// Fold all code in all open editors.
async function execute(args) {
// Obtain access to vscode
var vscode = args.require('vscode');
// Set number of open editors... (future: query vscode for number of open editors)
var numOpenEditor = 5;
// Loop for numOpenEditor times
for (var i = 0; i <= numOpenEditor; i++) {
// Fold the current open editor
await vscode.commands.executeCommand('editor.foldAll');
// Move to the next editor to the right
await vscode.commands.executeCommand('workbench.action.nextEditor');
// Loop message
var statusString = 'Loop ->' + i
// print message
vscode.window.showErrorMessage(statusString);
}
}
// Script Commands must have a public execute() function to work.
exports.execute = execute;

Convert GdkX11Window to VTE Terminal class in an focus event

I need to receive a GTK+ focus in event on a Terminal (VTE), but the event returns EventFocus which holds Gtk.Window reference:
http://www.valadoc.org/gdk-3.0/Gdk.EventFocus.html
How can I get the Terminal from the Window reference? I cannot retype it, it looks like it is a container. But I am unable to find which method to call to get the Terminal.
Terminal terminal = new Terminal();
// ...
terminal.focus_in_event.connect((event) =>
{
the_terminal = event.window; // DOES NOT WORK > invalid cast from `GdkX11Window' to `Terminal'
return false;
});
Thanks for pointing out I dont need it. Yeah, my real code is:
for (int i = 0; i < terminal.length; i++) {
this.terminal[i].focus_in_event.connect((event) =>
{
GLib.stdout.printf("Focus event terminal %p\n", this.terminal[i]);
return false;
});
}
Unfortunately it always prints null :-(
Thanks!
I'm not sure there is an easy way to convert a Gdk.Window to a Gtk.Widget as not all widgets have an associated GDK window, necessarily. As I see it, there's no compelling reason to try to extract the terminal from the event. In the context of the callback, you can simply reference the outer variable terminal and Vala will lift it into the callback.
Terminal terminal = new Terminal();
// ...
terminal.focus_in_event.connect((event) =>
{
terminal.queue_draw();
return false;
});