NO

Author Topic: Handle CLI progress '\r' in an edit control  (Read 2690 times)

Offline tony74

  • Member
  • *
  • Posts: 53
Re: Handle CLI progress '\r' in an edit control
« Reply #15 on: December 05, 2024, 05:25:20 PM »
@John Z: OK, attached concount.zip. I'm running Win10 pro: build 19045, haven't had any issues. It does sound like something needs to be cleared. I don't have Win7  anymore, so can't help with tracking it down. I'm pretty sure I closed all the handles, the external process closes normally and I can re-run it without restarting the GUI. Without Win7, I'm limited to just guesswork. If it requires a reboot to clear on 7 and runs ok on 10 and 11, there's a system anomaly of some kind. Something 7 isn't letting go of between runs. I'll search for similar behavior online.

Offline John Z

  • Member
  • *
  • Posts: 920
Re: Handle CLI progress '\r' in an edit control
« Reply #16 on: December 05, 2024, 06:14:30 PM »
Hi Tony74,

Yes it is simple, thought it might be more.  Didn't see anything wrong of course.

Thanks,
John

P.S. suggest reducing some of the console sleeps for testing operation at higher speeds too, once happy with the basics.


Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2151
Re: Handle CLI progress '\r' in an edit control
« Reply #17 on: December 05, 2024, 06:36:11 PM »
concount linked with msvcrt.dll leads other problems, as it use larger buffering.
Z console3 crash with it.

with unbuffered version works better.

EDIT:
concount3c_tl.zip is msvcrt.dll version with normal buffer.
idea is to test printf from different CRTs.


function setbuf(stdout, NULL); set minimal buffering.

test_msvcrt.zip have 32-bit msvcrt.lib and minimal runtime code for it.
« Last Edit: December 05, 2024, 11:35:12 PM by TimoVJL »
May the source be with you

Offline tony74

  • Member
  • *
  • Posts: 53
Re: Handle CLI progress '\r' in an edit control
« Reply #18 on: December 05, 2024, 08:49:08 PM »
@John Z: That looks great, have to try it out online with live data and see if it holds up. On my end, this means a rewrite of the front-end, so may take a minute.
I'm attaching the redone concount files. You can change the Sleep duration in main.h of console3c from 0 to whatever (50 seem pretty good, defaults to 200).

@Timo: So concount is having trouble with msvcrt? Too big a buffer?  What crt did you replace it with?
 concount is about as 'bare-bones' as it comes, a super simple test exe. Surprised the crt buffer size induces a crash.

Still trying to figure out why console3 isn't running right on 7, I can't see anything in the code that seems amiss, at least not yet.

Will post back when I have something.

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2151
Re: Handle CLI progress '\r' in an edit control
« Reply #19 on: December 06, 2024, 07:19:41 AM »
as yt-dlp needs Window 8+ and use msvcrt.dll and setbuf, Windows 7 can't run it.
perhaps testing using OutputDebugString() and DbgView helps to understand, how it works.

i haven't tested _popen() family for pipes yet.
May the source be with you

Offline John Z

  • Member
  • *
  • Posts: 920
Re: Handle CLI progress '\r' in an edit control
« Reply #20 on: December 06, 2024, 10:16:06 AM »
Getting closer check this log file -
Almost there, hopefully.

John Z

Then I'll try WIN 7 again....

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2151
Re: Handle CLI progress '\r' in an edit control
« Reply #21 on: December 06, 2024, 11:08:42 AM »
next thing to try with real yt-dlp ...
May the source be with you

Offline John Z

  • Member
  • *
  • Posts: 920
Re: Handle CLI progress '\r' in an edit control
« Reply #22 on: December 06, 2024, 06:32:45 PM »
So I had to, and did, solve the line splitting issue.  Weirdly fixing that broke the move back overwrite code so now I have to revise the move back to overwrite the last progress line.  It is almost there but I have to replace a fixed 510 char count with a measured char, so it is close.  Fixing the splitting took some doing so we will also need to assess speed.  I'm sure it can be optimized once it works with my gross code...

John Z

Offline HellOfMice

  • Member
  • *
  • Posts: 203
  • Never be pleased, always improve
Re: Handle CLI progress '\r' in an edit control
« Reply #23 on: December 06, 2024, 06:35:47 PM »
If you want I can test under w11, just tell me what I have to do. I did not followed this post. 8)
--------------------------------
Kenavo

Offline John Z

  • Member
  • *
  • Posts: 920
Re: Handle CLI progress '\r' in an edit control
« Reply #24 on: December 06, 2024, 09:52:25 PM »
Hi Tony74,

Here is the completed display project.
Fixed split lines, a major issue not just a byte two.
Fixed status line after split lines fixed.

Attached project zip, screen shot, and last log file.

I won't say optimized, and there is the ReadLine routine for split lines replicated in used in two places, it could go in a proc and be called, but is not a speed issue and can stay as is.

Have not yet tested at speed.  Have not tested in Windows 7 (although I think it may fly)
I suspect several memset 500's will need to be changed to the full buffer size when data is streaming. But ok to test for now.

Cheers,
John

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2151
Re: Handle CLI progress '\r' in an edit control
« Reply #25 on: December 06, 2024, 10:01:32 PM »
Works in Windows 7 x64  with concount3c stream :)
May the source be with you

Offline tony74

  • Member
  • *
  • Posts: 53
Re: Handle CLI progress '\r' in an edit control
« Reply #26 on: December 06, 2024, 11:27:58 PM »
@John Z:
Dude! You've been busting your a$$ on this thing! You can just pm me with the name you want on the copyright...

Anyway, I haven't done a re-write yet, this is still the original so you can see why I needed the live edit-control stuff.
So, two downloads: the Release Package and the Project files.

The Release folder exceeds the site's limits, so have to get it here: https://file.io/Y2b7eTjHLJVF

kiss.exe has to run in it's Release folder to access yt-dlp and the files yt-dlp uses.
I just overwrite the Release kiss.exe with the latest compile from the Project folder.

I run it from a desktop shortcut, thereafter.

It's not pretty, it's not 'slick', but it works good enough for the kids (who don't want to use command-lines or complicated full-featured front-ends).
It needs a complete refactoring at this point, we'll see.

Oh yeah, 'Kiss' stands for 'Keep It Simple Stupid'.
When you look at the code you'll see the irony in that.

« Last Edit: December 06, 2024, 11:52:45 PM by tony74 »

Offline tony74

  • Member
  • *
  • Posts: 53
Re: Handle CLI progress '\r' in an edit control
« Reply #27 on: December 07, 2024, 04:43:25 AM »
Here's a proj version with the inclusion of runapp, setup with an edit control, everything ready to go.
I Figured since I already knew my way around the code, it'd be faster if I did it... BUT... I haven't run it yet.

I think John should get first crack after all the work he's put in to get it this far.

It's the same thing we've been doing all along, except now it's going for a live stream, not a local test app.
In case anyone blows it up, there's a 'Save' folder included that has the complete original proj. You can refer to that if things 'go south'.

@John Z: Check to make sure I've got the most recent version of runapp in there, there's been a lot of revs.
( and make sure I'm not calling getnsub anywhere, I don't use it in the current build ).
« Last Edit: December 07, 2024, 04:52:13 AM by tony74 »

Offline John Z

  • Member
  • *
  • Posts: 920
Re: Handle CLI progress '\r' in an edit control
« Reply #28 on: December 07, 2024, 11:14:27 AM »
Hi Tony74,

I've got the project you posted, It does look like the latest version of readapp.c.  My clean-up was incomplete and there is still some fluff in there.

I have tested the readapp down to 1 millisecond i.e. Sleep(1) and it worked fine on my somewhat under powered laptop.

It fails at sleep 0 most likely because the receive buffer may have more than one line or one line plus a segment , etc.  This can be fixed if needed.  If this version fails you can 1st try turning off the logging as that consumes time.

As far as testing the entire project I had no clue what yt-dlp was.  I've learned at least what it is supposed to do.  I don't use youtube and have no idea how to get a video..... maybe once in a while someone sent me a link - maybe.

Anyway, better for others more experienced in this area to test under real conditions to see if it all works as hoped.

Post back if more improvement is needed.

Enjoy,
John Z

 

Offline tony74

  • Member
  • *
  • Posts: 53
Re: Handle CLI progress '\r' in an edit control
« Reply #29 on: December 07, 2024, 11:48:54 PM »
@John Z: Thanks for all the effort you've put in, I'll run it and see how it goes.
I don't use youtube either, but I do use Freetube. However, you don't need to bother with it.
 
Note: youtube defaults to MP4, you can select MP3 if you just want audio track.
Paste any of these links into the Kiss app and click [Download]:


https://www.youtube.com/watch?v=pPStdjuYzSI                              (CUDA intro - 3:20 min)

https://youtu.be/F2HH7J-Sx80          (Warren Zevon: Lawyers, Guns and Money - 3:30 min) MP3 POP

https://youtu.be/VU0nDHtV-ww                                 (Cal Tjader: Tjader album - 41:29 min) MP3 JAZZ

https://youtu.be/Zup7rmDj6fE  (Mambisimo big band: Sofrito Mongo Santamaria - 6:21 min) MP3 LATIN

https://youtu.be/_ovdm2yX4MA                                                         Avici, Levels - 3:19 min) MP3 EDM

https://youtu.be/R0gWefJXBuU                                             (Smooth Jazz Guitar - 11:37:04) MP3 CHILL

https://youtu.be/Sq7Qd9PSmR0        (Mussorgsky, Pictures at an Exhibition, Leipzig - 37:47) MP3 CLASS

https://youtu.be/H4YRPdRXKFs                  (Dennis Ritchy: Memorial, 'Write in C' tune - 3:37) 

https://youtu.be/EY6q5dv_B-o    (Ken Thompson, Brian Kernigan, Interview 2019 - 1:03:51)

https://youtu.be/rXuswL_3Qto                                    (Mike Abrash, Interview 2022 - 48:40)
               
https://youtu.be/I845O57ZSy4                               (John Carmac, Interview 2022 - 5:15:50)                         


The music will be in the  ..\Kiss\Audio folder.
The videos will be in the ..\Kiss\video folder.