-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(#89): added input file as window title #107
base: main
Are you sure you want to change the base?
feat(#89): added input file as window title #107
Conversation
Posible changes
|
I'm unsure about the implementation, mainly because you are introducing Now I see a parameter like this, I would love being able to use this argument to be able to set the title to anything I want like "my super app" I'm unsure maybe window.autotitle or window.title=auto It's just a feedback suggestion. Also, it's a bit strange that (either):
|
@ccoVeille I was thinking the same, that a As for implying For the moment, I will implement |
I'm fine with what you plan to do. There is one thing that is unclear. You said auto would be the default value. Initially your changes weren't setting a title if none was provided. What is current behavior and the current title? So before merging your changes. I'm on phone, and without a computer to check |
Or maybe you were saying that passing --window.title would behave as if --window. title=auto was provided |
@ccoVeille I am doing the following: if config.Window {
// same as before
titleText := config.Input
if config.Title != "auto" {
titleText = config.Title
}
} else {
if config.Title != "auto" {
printErrorFatal(...) // show that title can only be shown if `config.Window` is true
}
} If passing |
Thanks, it's clearer Anyway, I'm a bit doubtful about your pseudo code here I will wait for the changes to be pushed |
@ccoVeille wouldn't that be what is doing in the pseudo code. if config.Window { // window mode
} else { // not in window mode
if config.Title != auto {
printErrorFatal(...)
}
} Or you mean another way to do it? |
No my point is that if someone user or is it because the auto will be default value, so when not passed it would be equal to auto? if so, then in window mode, the default value would be auto too ? so it would by default use the binary name and not the current behavior to be the input I hope it's clearer |
@ccoVeille This is the behaviour with the pseudo code implemented: freeze-windowtitle-nowindow.mp4 |
One thing though is that maybe this is because I am new to using Is there a way to do |
I'm unsure, look at the documentation, but it's simply |
@ccoVeille I am gonna search through the documentation, but I have In the meantime I am doing this: args := os.Args[1:]
for i, arg := range args {
switch arg {
case "--window.title":
if i+1 < len(args) {
if strings.HasPrefix(args[i+1], "--") || strings.HasPrefix(args[i+1], "-") { // check if next arg is a flag
args[i] = "--window.title=auto"
}
} else { // if no more args `--window.title` set to default "auto"
args[i] = "--window.title=auto"
}
break
case "--window.title=": // if window title equals to ""
printErrorFatal("Invalid argument", errors.New("Use --window.title or --window.title=auto instead"))
}
}
ctx, err := k.Parse(args) |
This is ugly and should be avoided I cannot urge yourself to do it in another way |
I know, as of right now what I got is: type Config struct {
// ...
Title string `json:"title,omitempty" help:"Display input file as title. {{--window.title=auto}} as default" prefix:"window." default:"auto" group:"Window"`
// ...
} But this results in the error: > ./freeze cut.go --window --window.title
ERROR Invalid Usage
--window.title: expected string value but got "EOL" (<EOL>) or > ./freeze cut.go --window.title --window
ERROR Invalid Usage
--window.title: expected string value but got "--window" (long flag); perhaps try --window.title="--window"? |
@ccoVeille if using it like |
Here is the current state of the behaviour: freeze-window-title-demo.mp4Note The amount of changes is because |
I saw you opened alecthomas/kong#432 Let's wait |
@ccoVeille yes, let's see if it can be use as a I stashed the changes for the time being 😁 |
@ccoVeille from the discussion on alecthomas/kong#432 it seems that is not possible to do One option to solve this if showing the input file as the title is not an option, could be to do the following: type Config struct {
// ...
Title bool `json:"title ... prefix:"window."`
TitleName string `json:"titleName .... prefix:"window." default="auto"`
// ...
} If if config.Window {
// ...
if config.Title {
title := config.Input
if config.TitleName != "auto" {
title = config.TitleName
}
// add title to image
}
} else {
if config.Title || config.TitleName != "auto" {
// error for invalid usage since depends on `config.Window = true`
}
} |
This seems too complicated. This feature would require 2-3 parameters. Also, it's uneasy for me to review pseudo code that I cannot fetch/test/help you to improve. I think it's important to list the things you want to achieve:
Am I missing something? |
Based on this and the fact you are struggling to implement it in an easy way with Kong. If we add the fact that user needs to provide an additional parameter to set his title to something that will be the filename they already provided, and the fact we can assume most people may also change the title directly by reading the documentation (if they do) I would recommend to simplify the implementation
I think it would allow to cover anyone need |
@ccoVeille yes, this is what I meant with my pseudo code, it is too convoluted and over-complex to implement a way to set title or not that way. I will commit the changes I made using Implementation:
With this implementation it will lead to the following usage:
And the user can set in This will leave the following:
|
Modified window controls to return the space that the elements occupy.
@ccoVeille I added the changes to work with I tried to simplify a bit more the arguments of |
- [x] Created struct for the positions of the title. - [x] Extracted into validator function for the title and position. - [x] Extracted position computing into `getPositions`. - [x] Simplify `NewWindowTitle` arguments
@ccoVeille I made the changes, tell me if I left something out from the feedback you gave me. |
@ccoVeille I made the changes according to your last feedback. For some reason I thought you meant unexported fields in my head and the brain wasn't braining correctly in that moment 😅 |
fix: fixed height problem when using `librsvg`
@ccoVeille can you test something? When I am in my branch and I compile and run
I don't know if it just working like it should and this is some weird behaviour from github or Note Slightly off-topic but I thought that when using |
I cannot test now and for the next 3 days, as I'm not at home and with a phone only. Could it be a font thing? Are the font available on the GHA docker images? |
@ccoVeille I am using the default font (JetBrains Mono) where can I check for the GHA docker images, to see if it is using the same font? I made some testing with and without Note Image on the top is Command used:
Seems like |
Oh I'm seeing your few months old message only now. Did you try to see why it differs? |
@ccoVeille tbh, I couldn't find why it is, at least to my knowledge. Because if I am using the same font locally, the resulting image should have the same font both with and without |
Ok, it happens. Font world is the CSS part of image: Bermuda Triangle |
@ccoVeille yeah, being a wannabe web-dev myself I know what you mean. I will be testing this branch tomorrow in case some things need some tweaks or minor fixes, to have it in a state that works, maybe reducing the font size of the title at least makes it not stand out as much. |
With these changes when
--window=true
if--window.title=true
it will display the input filename as the title of the screenshot../freeze cut.go --window --window.title
make test
on MacOS 14.5 (23F79)Closes #89.