You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adding a parameter, :max-length, to the input element that:
sets the maximum input length, beyond which no :onchange events will occur (except for backspace, naturally)
sets the input elements initial size to fit at most that amount of characters, to avoid creating dead space
Potentially also adding a parameter, :pattern, to the input element as well, that would match the characters being input to some regex, discarding those that don't match.
Hello,
I've been using eww for about a week now, to write a status bar and some extra widgets, and I've really come to enjoy it.
However, once I've gotten to writing a calendar widget, I noticed that it's impossible to set the size of the input widget to something below it's default initial size. I've tried setting:
:space-evenly to false on the parent box element
:width to 0
min-width to 0
The only way, I'm currently aware of, at least, is to set the margin to a negative value, tricking eww into treating it as a smaller thing than it really is.
This is fine and, in my opinion, a perfectly acceptable, albeit a bit hacky, solution. But, when it actually comes to using the input, entering any text beyond the expected limit makes the text then overflow into nearby elements, due to the negative margin. The only way around this, that I can think of, is to put that input element into a literal and have some sort of script or program then restrict the input to a specified amount of characters, n, and, in the case that an attempt is made to enter more than n characters, regenerate the input literal, with it's :value set to the string truncated to n characters.
This, while fairly manageable and easy to do, is a bit tedious, once more than one element should require such treatment, needing to create a new variable for every input element in the widget, beyond adding some overhead from calling an external script or binary, as well as being almost wholly unusable in my use case, since the input element is already within a literal.
Since I assume the default initial size could be also the maximum allowed length of entered characters, adding a :max-length parameter would solve both - specifying a size below the default and limiting input width.
This could be expanded further, adding a :pattern option, that matches the input against a regex expression (just as in HTML).
To that end, thank you for your work on eww; It's a really pleasant to use widget system.
The text was updated successfully, but these errors were encountered:
spflaumer
changed the title
[FEATURE] limit input widget and text length
[FEATURE] input widget: limit width of the widget and the length of the entered text
Feb 5, 2025
This change adds the :max-length and :pattern parameters to the input widget. The :max-length parameter sets the maximum input length and adjusts the initial size of the input element. The :pattern parameter allows for regex-based input filtering.
Disclaimer: The concept of solution was created by AI and you should never copy paste this code before you check the correctness of generated code. Solution might not be complete, you should use this code as an inspiration only.
Latta AI seeks to solve problems in open source projects as part of its mission to support developers around the world. Learn more about our mission at https://latta.ai/ourmission . If you no longer want Latta AI to attempt solving issues on your repository, you can block this account.
Description of the requested feature
Adding a parameter,
:max-length
, to theinput
element that::onchange
events will occur (except for backspace, naturally)input
elements initial size to fit at most that amount of characters, to avoid creating dead spacePotentially also adding a parameter,
:pattern
, to theinput
element as well, that would match the characters being input to some regex, discarding those that don't match.Proposed configuration syntax
Additional context
Hello,
I've been using eww for about a week now, to write a status bar and some extra widgets, and I've really come to enjoy it.
However, once I've gotten to writing a calendar widget, I noticed that it's impossible to set the size of the input widget to something below it's default initial size. I've tried setting:
:space-evenly
to false on the parentbox
element:width
to 0min-width
to 0The only way, I'm currently aware of, at least, is to set the margin to a negative value, tricking eww into treating it as a smaller thing than it really is.
This is fine and, in my opinion, a perfectly acceptable, albeit a bit hacky, solution. But, when it actually comes to using the
input
, entering any text beyond the expected limit makes the text then overflow into nearby elements, due to the negative margin. The only way around this, that I can think of, is to put that input element into a literal and have some sort of script or program then restrict the input to a specified amount of characters,n
, and, in the case that an attempt is made to enter more thann
characters, regenerate the input literal, with it's:value
set to the string truncated ton
characters.This, while fairly manageable and easy to do, is a bit tedious, once more than one element should require such treatment, needing to create a new variable for every input element in the widget, beyond adding some overhead from calling an external script or binary, as well as being almost wholly unusable in my use case, since the
input
element is already within a literal.Since I assume the default initial size could be also the maximum allowed length of entered characters, adding a
:max-length
parameter would solve both - specifying a size below the default and limiting input width.This could be expanded further, adding a
:pattern
option, that matches the input against a regex expression (just as in HTML).To that end, thank you for your work on eww; It's a really pleasant to use widget system.
The text was updated successfully, but these errors were encountered: