Code Monkey home page Code Monkey logo

Comments (22)

goblinfactory avatar goblinfactory commented on May 24, 2024 1

@HamedFathi @NicoCG I've created a draft netstandard version of ProgressBar and ProgressBarSlim that you can test here : https://www.nuget.org/packages/Goblinfactory.ProgressBar/0.1.0

install-package Goblinfactory.ProgressBar

This works in windows, but in Mac setting the cursorTop is not working at the moment. I will see if I can find a workaround for this, this is the first draft, and I'm pleased it was a simple port to netstandard.

Please note, this now lives in a completely different repository, see link above. (I've put the port to netstandard back in the original progressbar repo)

from konsole.

goblinfactory avatar goblinfactory commented on May 24, 2024

ProgressBar already works with .net core!

I've Tested version 1.0 manually by git clone and opening the solution on my mac using Xamarin Studio, and running the multiple progress bars sample from Mac terminal. Not manually tested version 2, although there are only cosmetic changes to ProgressBar between 1 and 2 so should still work? (if anyone can confirm, that would be great?)

The current challenge with supporting .net core is because Window and MockConsole classes use the windows Console.MoveBufferArea to scroll blocks of the console window screen.

I would absolutely love to support .NET Core, and finding a way to efficiently scrolls parts of the screen is core (excuse the pun) to being able to port this to .NET core.

My thoughts on this are, ... things I need to spike

  • being able to get direct access to the buffer underlying the actual console window. This has obvious security implications (being able to read stuff you're not allowed to etc).
    • this would need to be on a platform basis, and some clever work done (bait and switch) perhaps to switch out some *native 'scroll' functionality depending on the platform.

However, before sorting out the .NET core support I need to fix some new serious issues I've not noticed before, (will create a separate issue for this later when I can define the problem more clearly) specifically that multiple ProgressBar s have problems keeping track of their current .CursorTop position if the window they are in starts to scroll. They still work, but you end up with ghost trails.

Once that's sorted, then next challenge is to make a cross platform MockConsole (spikes) that can scroll on any platform.

The last challenge is to setup CI/CD, perhaps use some container technology with Cake C# build to run regression tests across each platform.

without tests... on all the platforms, won't be possible.

So yeah... that would be my #1 personal goal for this project.

Thanks for suggesting.

from konsole.

goblinfactory avatar goblinfactory commented on May 24, 2024

leaving this open so folk can jump in with offers to volunteer, write spikes, drop down comments, e.g. if anyone knows... has a link to a project somewhere showing scrolling on Mac or Linux from Mono, or .net core, that would be super useful.

from konsole.

goblinfactory avatar goblinfactory commented on May 24, 2024

Ah, forgot to leave a link to the "bait and switch" pattern for switching out platform specific code in a portable class library.

http://ericsink.com/entries/pcl_bait_and_switch.html

from konsole.

midianok avatar midianok commented on May 24, 2024

@HamedFathi I successfully run on Windows 10 Konsole.Sample and TestPackage.V2.0.1 with several changes in FieldReader. Also dotnet core console encoding is UTF-8 by deafult, so you need manualy set console encoding to UTF-16. If you want a try, you can clone my fork https://github.com/midianok/konsole.
Planning to run test on Linux debian, as have a free time.

from konsole.

HamedFathi avatar HamedFathi commented on May 24, 2024

@midianok

wow thanks I will check it ASAP

from konsole.

goblinfactory avatar goblinfactory commented on May 24, 2024

I'm going to do this!
Going to take all the mini features, progressBar, forms, windows etc, and move them into separate .NET Standard (I think that's the latest cross xform funki-ness) projects.
Watch this space next few days.

from konsole.

HEskandari avatar HEskandari commented on May 24, 2024

Just FYI that on .NET Core 2 (even the ported fork) it blows up. Looks like Console.CursorVisible throws an exception on get for some reason. See here.

from konsole.

goblinfactory avatar goblinfactory commented on May 24, 2024

It's actually going to be a lot easier that I had originally thought. Most of the enquiries I've had are for the progressBar only, so the approach is going to be to to simply create a .net 2 standard project to host new controls, and then use the existing Konsole Mock console for testing. If it passes all the tests running against MockConsole then that's good enough for me and I'll create the packages. (roughly). That will mean porting the Interfaces first to .net 2 standard, and then working backwards from there, but that should be difficult.

Re: throw an exception : I'm aware of that, and will simply stubb that out, not include non portable methods and properties in the .net 2 standard interfaces. I'll be moving all the individual Konsole 'components' to their own package, and if a particular component cannot function without access to a native non .net standard function, then only that component will have that restriction. This might mean that a particular item might cause some cursor flicker under high update frequencies; will need to consider the impact and do a bit of user testing.

from konsole.

goblinfactory avatar goblinfactory commented on May 24, 2024

@HamedFathi Unfortunately the port of Console to .netCore is not complete and Console.MoveBufferArea needed for window scrolling is still outstanding since Aug 17 with no one saying they will work on it.
https://github.com/dotnet/corefx/issues/22992
I will be splitting the progress bar out from the main project so that it can be fully cross platform and .netcore. working on that now.

from konsole.

NicoCG avatar NicoCG commented on May 24, 2024

@goblinfactory.

Is there any ETA on .netcore / netstandard version?

from konsole.

goblinfactory avatar goblinfactory commented on May 24, 2024

@NicoCG Thanks for the friendly nudge, let me take a look again today and see what I can do.
What features or controls do you need most urgently? The reason I ask, is that the windowing library is most likely not practical to port as long as MoveBufferArea or anything similar is not available in dotnet core. If all you really want is a progressBar then I'm pretty certain I can do that.

from konsole.

goblinfactory avatar goblinfactory commented on May 24, 2024

@HamedFathi @NicoCG @HEskandari @midianok
The netstandard version of ProgressBar and ProgressBarSlim is ready for testing. I've fixed the cursor problem and tested on Mac and Windows, and package version 0.1.0 is ready for some manual testing.

I'd really appreciated some quick testing of that package; if it works correctly then I'll tag and release version `1.0.

Thanks for your support,
Cheers,
Alan

p.s. In case anyone else get's here and TLDR, the netstandard version is in a new repo here
https://github.com/goblinfactory/progress-bar

from konsole.

goblinfactory avatar goblinfactory commented on May 24, 2024

If this is good enough for what you guys need, then I'll close this issue, cheers, A

from konsole.

HEskandari avatar HEskandari commented on May 24, 2024

@goblinfactory I'm testing it and will report back shortly.

from konsole.

HEskandari avatar HEskandari commented on May 24, 2024

Yeah...seem to work fine on .NET Standard 2.0 on Mac OSX 10.14.2.

from konsole.

wocar avatar wocar commented on May 24, 2024

what about everything else? I recieve an error in osx that it is not implemented

from konsole.

goblinfactory avatar goblinfactory commented on May 24, 2024

@wocar I've left this thread open on purpose because it's a complicated topic and the discussion needs to be read in full. If you had, you would have seen that the ProgressBar has been ported to .net standard here : https://github.com/goblinfactory/progress-bar : If you have any issues with that package, please report the issue in that repo, thanks!

from konsole.

goblinfactory avatar goblinfactory commented on May 24, 2024

I've opened a new issue #30 and will see if I can find some volunteers to help patch .NET core 2.1, because that's where the real issue lies. Nothing we can do until .net core actually supports scrolling on Unix.

from konsole.

goblinfactory avatar goblinfactory commented on May 24, 2024

@HamedFathi @mateuszlewko @midianok @HEskandari @NicoCG
I hope I'm not getting everyone's hopes up, but I've just pushed a proof of concept to konsole-spike here : https://github.com/goblinfactory/konsole-spike

This is looking promising as an option for me to give you a purely .NET standard version of Konsole, that is 100% .net Standard, that runs a bit slowly if you draw and use it.

If you want high speed, then you include an additional .NET Framework DLL, and you can get native rendering and a huge performance increase, many hundreds of times faster.

Here are the limitations;
Your application can be .NET standard, or .net framework or .NET core, but will not run on Mac, or Unix if you use the high speed renderer.

Also, scrolling windows are only supported in Windows. Windows that don't scroll can be created in non windows / mac, unix. (needs testing)

I'm busy working on this, and could use some volunteers testers to test features as I bring them out over the next few days.

The spike repo is a throw away repo, I'll be updating the Konsole packages.

cheers all

Alan

p.s. if you've not been here for a while, please take a look at the latest updatest with version 4.x.
Ability to do SplitRows() and SplitColumns() to easily build any shape window layout.

e.g. this is the code I'm using to test the spike project

            var window = new Window();
            var consoles = window.SplitRows(
                    new Split(4, "heading", LineThickNess.Single),
                    new Split(10),
                    new Split(0),
                    new Split(4, "status", LineThickNess.Single)
            ); ; ;

            var headline = consoles[0];
            var contentTop = consoles[1];
            var contentBottom = consoles[2];
            var status = consoles[3];

            var longText = "Let's see if these do? heres more text to see if this eventually wraps? text to see if this eventually wraps?text to see if this eventually wraps?";

            var menu = contentTop.SplitLeft("menu");
            var content = contentTop.SplitRight("content");

            var splits = contentBottom.SplitColumns(
                    new Split(20, "menu2"),
                    new Split(0),
                    new Split(20, "content3")
                );
            var menu2 = splits[0];
            menu2.WriteLine(longText);
            var content2a = splits[1];
            var content2parts = content2a.SplitRows(
                new Split(0, "content 2"),
                new Split(5, "demo REPL input")
                );
            var content2 = content2parts[0];
            var input = content2parts[1];
            var content3 = splits[2];
            content2.WriteLine(longText);
            content3.WriteLine(longText);
            headline.WriteLine("my headline");
            headline.WriteLine("line2");
            headline.WriteLine("line3");
            content.WriteLine("content goes here");
            content.WriteLine("Do these lines ╢╖╣║╗╟  print?");
            content.WriteLine(longText);
            menu.WriteLine("Options A");
            menu.WriteLine("Options B");
            menu.WriteLine(longText);
            menu.WriteLine("Options D");
            status.Write("System offline!");
            flush();
            input.WriteLine(ConsoleColor.Green, "  press 'esc' to quit");
            
            //input.CursorVisible = true;
            //input.CursorLeft = 0;
            //input.CursorTop = 0;
            
            char key = 'x';
            int color = 0;
            var statusProgress = new ProgressBar(status, 100);
            
            while (key != 'q')
            {
                color++;
                content2.WriteLine((ConsoleColor)(color % 15), longText);
                var fruit = $"apples {color}";
                menu2.WriteLine(fruit);
                menu.WriteLine(fruit);
                statusProgress.Refresh(color % 100, fruit);
                flush();
                var readKey = Console.ReadKey(true);
                if (readKey.Key == ConsoleKey.Escape)
                {
                    input.Colors = new Colors(ConsoleColor.White, ConsoleColor.Red);
                    input.WriteLine("   --- GOOD BYE!! ---   ");
                    flush();
                    Thread.Sleep(1000);
                    return;
                }
                if (readKey.Key == ConsoleKey.Enter)
                {
                    input.WriteLine("");
                    continue;
                }
                key = readKey.KeyChar;

                input.Write(new string(new[] { key }));
            }

produces this output

spike

from konsole.

goblinfactory avatar goblinfactory commented on May 24, 2024

just to be clear, this is 100% .NET Standard Konsole library, referencing a small .NET Framework Shim that does the "high speed screen update", and the demo project is .NET core only. The shim also prevents the user from resizing the console which used to destroy the layouts if you accidentally resized a window while attempting to move it.

from konsole.

goblinfactory avatar goblinfactory commented on May 24, 2024

closing as done.

from konsole.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.