Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Alan Hemmings
    @goblinfactory
    ... including a modal pop up etc ...
    i.e. my focus is to get edit features out as quickly as possible because that's what I need for my own projects.
    edit and list views with scrolling and keyboard handling
    Alan Hemmings
    @goblinfactory
    @jgoyvaerts send me a DM with your email address and we can exchange emails, then I can work with you to get your input on what edit features to build first and if you can offer me some early testing and feedback I would be able to get it out much faster.
    Alan Hemmings
    @goblinfactory
    @/all just a quick ping to say I'm going to be working on Konsole over the next few weeks; ping me if you have urgent requirements or bugfixes you would like to see included in any alpha releases.
    Jameson
    @jmerkow
    @goblinfactory I just stumbled on this project an its absolutely incredible. I am amazed.
    What is an easy way to re-direct outputs to a window? I am using ILogger from microsoft.extensions.logging.
    Basically I'd like to have a window with a progress bar and another with the output of the logs
    I supposed I could send the logs to a file and then set a window to tail the file? I thought there might be an easier way
    Jameson
    @jmerkow
    That may also have issues with the stream depending on when its flushed
    I could also create a new logger provider. I was hoping there was an easy baked in method
    Alan Hemmings
    @goblinfactory
    Hi @jmerkow Ah, yes... I've needed to do that a few times myself, .. in my scenarios I think I created a serilogSink that takes a IConsole as a dependency and simply manually wire that up. Let see if I can code up an example, that's actually a common requirement ...and was one of the use cases I was thinking of when i wrote the lib to start with, I'll go make some coffee then see if I can create a sink, then publish a simple package with a demo ... gimme a little while (sorry for the slow reply I was out for a few days ...deliberately off the grid)
    @jmerkow I should create a sink for here : https://github.com/serilog/serilog/wiki/Provided-Sinks
    oooh, I can steal some ideas from coloured Console sink...
    Alan Hemmings
    @goblinfactory
    more idea? mmm.. -> I'd like to create a general errror handler window as well, a method that allows you to run some code and choose how to handle errors,
    something like window.Monitor(()=> { some code }, detailedErrorWin, messageErrorWin ) where
    I do something like
    while(true) { 
    try 
    {
      someCode();
    }catch(Exception ex) {
       messageErrorWin?.LogErrorSummary(ex);
       detailedErrorWin?.LogErrorDetail(ex);
    }
    }
    ah, then ...also if you call Window.Monitor(()=> SomeCode); Konsole can use the static theme to find the default layout for code monitoring, possibly Left + right and right has top and bottom split with detail and full error logs, all nicely colourised.
    What's really missing and what I've been working towards adding is scrolling support to windows, otherwise small windows with logs are pretty useless.
    @jmerkow what I wrote above applies to using Konsole with logs, ... not that useful at the moment without scrolling support. nice for demos and really quick test projects but will start to really come alive with scrolling support. (it's part of the data input taht I'm working on)
    sorry, i got side tracked...
    Going to make some coffee, then will take a stab at writing a serilog sink package as promised...
    3 replies
    Alan Hemmings
    @goblinfactory
    Screen Shot 2021-07-12 at 12.37.05.png
    @jmerkow ok so this works
    here's the code
    using Serilog;
    using Serilog.Configuration;
    using Serilog.Core;
    using Serilog.Events;
    using System;
    
    
    namespace Konsole.Sink
    {
      public class KonsoleSink : ILogEventSink
      {
        IFormatProvider _formatProvider;
        private readonly IConsole _window;
        private readonly IConsole _errorWindow;
    
        public KonsoleSink(IFormatProvider formatProvider, IConsole window, IConsole errorWindow)
        {
          _formatProvider = formatProvider;
          _window = window;
          _errorWindow = errorWindow;
        }
    
        public void Emit(LogEvent logEvent)
        {
          // todo; format with colour and log errors to error window.
          _window.WriteLine(logEvent.RenderMessage(_formatProvider));
        }
      }
    
      public static class KonsoleSinkExtensions
      {
        public static LoggerConfiguration KonsoleWindow(
                  this LoggerSinkConfiguration loggerConfiguration,
                  IConsole window,
                  IConsole errorWindow = null,
                  IFormatProvider fmtProvider = null
                  )
        {
          return loggerConfiguration.Sink(new KonsoleSink(fmtProvider, window, errorWindow));
        }
      }
    }
    heres' the test program
    using System;
    using System.Threading;
    using Konsole;
    using Konsole.Sink;
    using Serilog;
    
    namespace Sample
    {
      public class Program
      {
        public static void Main()
        {
          var window = new Window();
          var (main, logs) = window.SplitLeftRight("main", "logs");
    
          Log.Logger = new LoggerConfiguration()
              .MinimumLevel.Verbose()
              .WriteTo.KonsoleWindow(logs)
              .CreateLogger();
    
          try
          {
            main.WriteLine("Warming up");
    
            Log.Debug("Getting started");
    
            Log.Information("Hello {Name} from thread {ThreadId}", Environment.GetEnvironmentVariable("USERNAME"), Thread.CurrentThread.ManagedThreadId);
    
            Log.Warning("No coins remain at position {@Position}", new { Lat = 25, Long = 134 });
    
            Fail();
          }
          catch (Exception e)
          {
            Log.Error(e, "Something went wrong");
          }
          finally
          {
            main.WriteLine("shutting down.");
          }
    
          Log.CloseAndFlush();
        }
    
        static void Fail()
        {
          throw new DivideByZeroException();
        }
      }
    }
    just going for a walk, I'll drop an update that colourises this using the current window theme and supports error window et al
    Alan Hemmings
    @goblinfactory
    Screen Shot 2021-07-12 at 14.44.40.png
    sample updated with colours (hard coded theme) and configurable window for error and warning output, looks like this when it runs
    1 reply
    screenshots are from me running a C# console app on Linux from Visual studio code...
    Alan Hemmings
    @goblinfactory
    (Just a reminder; that's a hack, because it's not cross platfom yet. Konsole will crash as soon as any writeLine causes any of the windows to scroll on Mac if you don't set the window to clip, i.e. not scroll) which will mean you won't be able to use it to "tail" watch a log or file, the new lines will simply dissapear off the bottom
    8 replies
    Alan Hemmings
    @goblinfactory
    Screen Shot 2021-07-12 at 16.25.58.png
    above is what it looks like running in a mac osx terminal;
    Alan Hemmings
    @goblinfactory
    @jmerkow I haven't created a package yet. I need to sort out supporting some default themes for light and dark backgrounds, that will take a while. However, a serilog sink is only a page of code, I've written a sample you can copy from here : https://github.com/goblinfactory/konsole-test-serilog-sink
    Jameson
    @jmerkow
    This is really really useful. Thanm you. I ended up home brewing a quick custom logger where you pass IConsoles for various LogLevel. Im out right now but Im going to go through your implementation to compare and or steal from. Im new to c# so im still familiarizing myself with all the different libraries. Yours looks much nicer than mine.
    Jameson
    @jmerkow
    @goblinfactory Can a progress bar's total be changed after its created? i.e. If I am processing something asynchronously, the size of the queue make increase
    1 reply
    Jameson
    @jmerkow
    Ok last question. Is there an IConsole that corresponds to System.Console? I want to write some functions that operate on IConsole, I want to have the option to not have any IConsoles create (i.e. a default of System.Console)
    9 replies
    Probably not my actual last question
    Auburg
    @Auburg
    @goblinfactory Hi i've started using your library and it's very powerful but are you planning a v7 / 8 ? I would like to see the planned improvements for inputs
    Alan Hemmings
    @goblinfactory
    78C1756B-3A4F-443A-AD4E-6EBF0FBDA1D4-1-384x234-0-oriented.png
    Alan Hemmings
    @goblinfactory

    Hi @Auburg Unfortunately not. While I know that there are a lot of people using Konsole in lots of projects, there's been little to zero community involvement, little to no issues reported, no interest in collaborating ...zero. It makes NO sense to contribute further to any .NET development work. In my opinion the .net opensource community is dying. There's a TON of wonderful things that adding some simple input handling to konsole will enable. I've already done the legwork to make all the windows themable using a single "themestring" so you can totally skin every single window and subwindow and control inside any window with a 1 line command, look at the most recent commit / branch. (see sample image here)
    I've also started working on default set of Input behaviour that you can invoke with some kind of .Run() command, that will take all keyboard and optionally mouse IO and have "tab" to cause the "active" window to cycle between windows re-rendering the window on activate with .Active theme, which will have been set with the single themestring. So window navigation keyboard events go to the Run handler that re-renders windows, and "control" navigation would raise KeyPress events to the active control inside a window. Basically it means you can "WriteLine a control, that can accept events." or Render() a control and pass in optional keyhandlers. The design is meant to allow you to built control libraries, like file browsers in the screenshot, to lists, (the file browser uses an embedded "list" control" ) Currently I have a list control that highlights the "active" list item, with the themeset colour, but don't have scrolling lists yet.

    That's where I left the project because of lack of community spirit or "gumption".
    My library is not simple, and so it's not easy for users to dive into the code and contribute. That's something that would require a complete redesign to address.

    Lastly; there are some excellent .NET io libraries that do cross platform input ...but not in windows.
    The obvious thing to do would be to merge the two... either create a Konsole community add on for those projects, and use konsole to manage the windows, and those other libraries to manage Input.

    there are also some excellent libraries that do true color, but also ...not in proper windows.

    Either way, I've started programming in Go, and the console support in Go is just so incredibly brilliant there's zero reasons for me to spend any effort on Konsole when the .net community doesn't give back ... at all...like ...basically zero.

    I've had a sponsor me up as an experiment, ...not because I want to make money out of konsole, but because i thought it would be a good way to measure how many F** .net community people give about open source.

    I sponsor 1 person... and DESPITE the fact that github will literally match the sponsoring amount, I don't have a single sponsor.

    So...Nah....

    I gave this a really good run! I use konsole heavily when I write .net devops utilities to spike up monitoring something.

    My recommendation to you as a work around is just use Konsole ... as a Konsole ... a set of windows, and dont use it as an application capture user input.
    write a simple GPRC or zeroMq or akka.net (my favourite) and setup Konsole as a message processor and have konsole subscribe / handle IXYZHasChanged events/messages.

    then you can simply configure the Konsole as a remote actor, using akka.net remoting.
    here's a worked example of how I've used akka.net with konsole;

    https://github.com/goblinfactory/10-alternatives-to-akka

    Alan Hemmings
    @goblinfactory

    @Auburg Aaah, I forgot...
    Possibly the simplest solution is to create a community extension for Spectre (look to see how spectre does rendering) and simply REnder() ...to a Konsole window. Then you have the best of both worlds...

    So some quick ways forward for you to get input handling...
    Simplest and easiest ... is to make konsole app a "remote" konsole dashboard. it can live on a big screen somewhere using the pattern in 10 alterantives to akka shown above. (remote actor configuration in Hokon files <-- akka configuration perlance)
    then write a very simple non windowy ... input controller, that uses spectre Input handling.
    boom ...you're done

    https://github.com/spectreconsole/spectre.console

    Screenshot 2022-02-04 at 11.32.29.png

    this is what you want: and is imho the best IO library for .net at present;

    I believe it shouldnt be a lot of work to either ... render Spectre to Konsole, or ... create a lite version of the konsole DSL style of rendering windows, inside spectre.

    2 console apps ; 1 the dashboard ...using konsole and windows...
    and 2) the command app, a simple console app using spectre; using akka.net "tell" ...
    Also if you don't like akka.net ...if that FEELS wrong...
    Then simply use MediatR ...and create a handler that fowards messages to the dashboard using akka.net remote actors.
    That handler would be a "router" that "routes" the message to the dashboard, then you can write a GRPCRouter or a AkkaRouter ... or even a httpRouter (and have the dashboard konsole app run a background webapi on a port.
    Alan Hemmings
    @goblinfactory

    best of luck!

    oh oh! or you could convert to Golang, and use one of these many libraries;
    https://golangrepo.com/catalog/go-console-ui_newest_1

    I'm serious about the above; learn a new language and make your console UI's simply be message handlers and continue to write your back end code in C#
    no different to writing your front end in REACT ... or Blazor. Just ...in Go your brain will think differently and you'll improve you C# programming. Mine did ...within a few days I was writing my C# waay more simply than I used to.
    @Auburg ...did I mention Spectre?
    @Auburg ...did I mention Spectre? 😎😂 It is really that good.
    Auburg
    @Auburg
    hi - thanks for getting back to me! I'll take in everything you've said and have a look at your recommendations. Regards
    Alan Hemmings
    @goblinfactory
    apologies for language above... I see I am too late to edit my text and replace the F***** with Frankenbeans ... in case this offended anyone. (blush!)