-
Notifications
You must be signed in to change notification settings - Fork 309
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
Port set-window-scroll-bars #1535
Open
clample
wants to merge
4
commits into
remacs:master
Choose a base branch
from
clample:1459
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,8 +26,8 @@ use crate::{ | |
run_window_configuration_change_hook as run_window_conf_change_hook, | ||
save_excursion_restore, save_excursion_save, select_window, | ||
selected_window as current_window, set_buffer_internal, set_window_fringes, | ||
update_mode_lines, window_list_1, window_menu_bar_p, window_scroll, window_tool_bar_p, | ||
windows_or_buffers_changed, wset_redisplay, | ||
set_window_scroll_bars, update_mode_lines, window_list_1, window_menu_bar_p, window_scroll, | ||
window_tool_bar_p, windows_or_buffers_changed, wset_redisplay, | ||
}, | ||
remacs_sys::{face_id, glyph_matrix, glyph_row, pvec_type, vertical_scroll_bar_type}, | ||
remacs_sys::{EmacsDouble, EmacsInt, Lisp_Type, Lisp_Window}, | ||
|
@@ -2034,6 +2034,55 @@ pub fn window_pixel_height_before_size_change(window: LispWindowValidOrSelected) | |
window.pixel_height_before_size_change | ||
} | ||
|
||
/// Set width and type of scroll bars of window WINDOW. | ||
/// WINDOW must be a live window and defaults to the selected one. | ||
/// | ||
/// Second parameter WIDTH specifies the pixel width for the vertical scroll | ||
/// bar. If WIDTH is nil, use the scroll bar width of WINDOW's frame. | ||
/// Third parameter VERTICAL-TYPE specifies the type of the vertical scroll | ||
/// bar: left, right, nil or t where nil means to not display a vertical | ||
/// scroll bar on WINDOW and t means to use WINDOW frame's vertical scroll | ||
/// bar type. | ||
/// | ||
/// Fourth parameter HEIGHT specifies the pixel height for the horizontal | ||
/// scroll bar. If HEIGHT is nil, use the scroll bar height of WINDOW's | ||
/// frame. Fifth parameter HORIZONTAL-TYPE specifies the type of the | ||
/// horizontal scroll bar: bottom, nil, or t where nil means to not display | ||
/// a horizontal scroll bar on WINDOW and t means to use WINDOW frame's | ||
/// horizontal scroll bar type. | ||
/// | ||
/// Return t if scroll bars were actually changed and nil otherwise. | ||
#[lisp_fn( | ||
name = "set-window-scroll-bars", | ||
c_name = "set_window_scroll_bars", | ||
min = "1" | ||
)] | ||
pub fn set_window_scroll_bars_lisp( | ||
window: LispWindowLiveOrSelected, | ||
width: LispObject, | ||
vertical_type: LispObject, | ||
height: LispObject, | ||
horizontal_type: LispObject, | ||
) -> bool { | ||
let mut window: LispWindowRef = window.into(); | ||
let updated_window = unsafe { | ||
set_window_scroll_bars( | ||
window.as_mut(), | ||
width, | ||
vertical_type, | ||
height, | ||
horizontal_type, | ||
) | ||
}; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps flip the following logic? I am not sure which I prefer.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, this is more readable to me than I updated the PR |
||
if updated_window.is_null() { | ||
false | ||
} else { | ||
unsafe { apply_window_adjustment(updated_window) }; | ||
true | ||
} | ||
} | ||
|
||
include!(concat!(env!("OUT_DIR"), "/windows_exports.rs")); | ||
|
||
/// Run `window-configuration-change-hook' for FRAME. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@clample In the original implementation, the window is accessed via
decode_live_window
which checks for the selected window being nil first, if yes -> use it instead of the passed window, otherwise check the passed window for being live (otherwise throwing a "wrong type argument exception") and then use it.Do you think this may be the case here? Seems like semantics is not preserved.
reference: window.c line:264
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.
@denis631
LispWindowLiveOrSelected
is meant to encapsulate the logic ofdecode_live_window
.Line 2067 gets the correct 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.
Ohhh so the
#lisp_fn
macro does all the necessary transformations? It this case mappingLispObject
toLispWindowLiveOrSelected
? I see. Nice. Sorry for false negativeThere 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.
@denis631 correct. The
lisp_fn
macro is a proc macro which creates code that looks like:Which is super simple. All of the error handling, checking, and the like occurs in the
From
implementations. Thelisp_fn
macro gets more complicated when the lisp function is of variable arguments. These collect the args into a Vector.Our convention is that where a Lisp function takes optional parameters we use the
Option
type. In the C code this is represented with a Nil value. Essentially C's LispObject is really anOption<LispValue>
.