-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Custom file picker width max min and factor #1089
Custom file picker width max min and factor #1089
Conversation
This isn't a percentage. |
074310c
to
6cef00b
Compare
I have removed the word 'percentage' and expanded the meaning of the variable. |
book/src/configuration.md
Outdated
@@ -23,6 +23,7 @@ To override global configuration parameters, create a `config.toml` file located | |||
| `idle-timeout` | Time in milliseconds since last keypress before idle timers trigger. Used for autocompletion, set to 0 for instant. | `400` | | |||
| `completion-trigger-len` | The min-length of word under cursor to trigger autocompletion | `2` | | |||
| `auto-info` | Whether to display infoboxes | `true` | | |||
| `file-picker-width` | File picker width, values from 0.0 to 1.0 treated as a factor | `0.5` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's going to be an editor.file-picker
section (#988) so this can be a key in that sub config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, then we have to wait #988 to be merged
@@ -166,7 +166,12 @@ impl<T: 'static> Component for FilePicker<T> { | |||
surface.clear_with(area, background); | |||
|
|||
let picker_width = if render_preview { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be less confusing to have the config as preview-width
instead of picker-width
since I would assume picker-width
to mean the width of the entire window (including the preview and the picker).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But preview
is the right side not always showed. Maybe we have to choose a name for the left side of the picker. Suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I think we can have two different options - file-picker.width
and file-picker.preview-width
. width
can control the whole picker + preview window size and preview-width
can control the size of the preview inside this window.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :-)
I wonder if this could be represented using both percentage and/or min width? How do we factor those in later? |
Percentage and factor represents the same thing 50% = 0.5, and the current implementation allows both proportional part of the picker width or number of characters with only one variable (similar to how emacs do it). Min width is very interesting, any suggestion about how to name it? |
6cef00b
to
19f1940
Compare
bf4290a
to
61be1fd
Compare
61be1fd
to
635bad0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't get to test this out but code wise looks good to me. Just some comments left.
|`height-factor` | File picker height, treated as a factor. | `0.9` | | ||
|`preview-width-factor` | File picker preview width, treated as a factor. | `0.5` | | ||
|`preview-min-width` | File picker preview minimum width in columns. | `60` | | ||
|`file-min-width` | File picker filenames minimum width in columns when preview is showed. | `20` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filenames minimum width seemed confusing to me?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i know my English sucks ;-), any suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File picker preview minimum width in columns?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+----------------+-------------------+
| file-min-width | preview-min-width |
| filenames... | code... |
+----------------+-------------------+
file-min-width
is the other side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how to explain this too, hopefully someone can help.
preview_min_width: 60, | ||
file_min_width: 20, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add a comment that both of this should total up to 80.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Out of curiosity, what is the reason? preview-min-width = 25
, file-min-width = 20
works, and preview-min-width = 80
, file-min-width = 30
works too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that's why you put 80? Like previously I saw a number 80 being removed, and you replaced it with the sum of these two.
At the very least I think we should still make it look nice for 80x24 terminals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried locally and didn't seemed to break current behavior so should be good.
635bad0
to
679e772
Compare
cx.editor.config.file_picker.width_factor, | ||
cx.editor.config.file_picker.height_factor, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass in &cx.editor.config.file_picker
instead
> cx.editor.config.file_picker.preview_min_width | ||
+ cx.editor.config.file_picker.file_min_width; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit repetitive, add let config = &cx.editor.config.file_picker
at the top of render
cmp::max( | ||
area.width | ||
- cmp::max( | ||
preview_width, | ||
cx.editor.config.file_picker.preview_min_width, | ||
), | ||
cx.editor.config.file_picker.file_min_width, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than cmp::max(a, b)
a.max(b)
can be used. In this case a.max(b).max(c)
.
vertical: (area.height as f32 * (1.0 - width_factor)).round() as u16, | ||
horizontal: (area.width as f32 * (1.0 - height_factor)).round() as u16, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using floats feels wrong to me, why not specify a percentage from 0-100
?
Closing as inactive. Feel free to open a new PR if you wish to continue. |
This allow custom file picker width settings