582 |
|
|
583 |
int automatic_hscrolling_p; |
int automatic_hscrolling_p; |
584 |
|
|
585 |
|
/* How close to the margin can point get before the window is scrolled |
586 |
|
horizontally. */ |
587 |
|
int automatic_hscroll_margin; |
588 |
|
|
589 |
|
/* How much to scroll horizontally when point is inside the above margin. */ |
590 |
|
Lisp_Object Vautomatic_hscroll_step; |
591 |
|
|
592 |
/* A list of symbols, one for each supported image type. */ |
/* A list of symbols, one for each supported image type. */ |
593 |
|
|
594 |
Lisp_Object Vimage_types; |
Lisp_Object Vimage_types; |
8024 |
Lisp_Object window; |
Lisp_Object window; |
8025 |
{ |
{ |
8026 |
int hscrolled_p = 0; |
int hscrolled_p = 0; |
8027 |
|
int hscroll_relative_p = FLOATP (Vautomatic_hscroll_step); |
8028 |
|
int hscroll_step_abs = 0; |
8029 |
|
double hscroll_step_rel = 0; |
8030 |
|
|
8031 |
|
if (hscroll_relative_p) |
8032 |
|
{ |
8033 |
|
hscroll_step_rel = XFLOAT_DATA (Vautomatic_hscroll_step); |
8034 |
|
if (hscroll_step_rel < 0) |
8035 |
|
{ |
8036 |
|
hscroll_relative_p = 0; |
8037 |
|
hscroll_step_abs = 0; |
8038 |
|
} |
8039 |
|
} |
8040 |
|
else if (INTEGERP (Vautomatic_hscroll_step)) |
8041 |
|
{ |
8042 |
|
hscroll_step_abs = XINT (Vautomatic_hscroll_step); |
8043 |
|
if (hscroll_step_abs < 0) |
8044 |
|
hscroll_step_abs = 0; |
8045 |
|
} |
8046 |
|
else |
8047 |
|
hscroll_step_abs = 0; |
8048 |
|
|
8049 |
while (WINDOWP (window)) |
while (WINDOWP (window)) |
8050 |
{ |
{ |
8051 |
struct window *w = XWINDOW (window); |
struct window *w = XWINDOW (window); |
8052 |
|
|
8053 |
if (WINDOWP (w->hchild)) |
if (WINDOWP (w->hchild)) |
8054 |
hscrolled_p |= hscroll_window_tree (w->hchild); |
hscrolled_p |= hscroll_window_tree (w->hchild); |
8055 |
else if (WINDOWP (w->vchild)) |
else if (WINDOWP (w->vchild)) |
8071 |
&text_area_width, &text_area_height); |
&text_area_width, &text_area_height); |
8072 |
|
|
8073 |
/* Scroll when cursor is inside this scroll margin. */ |
/* Scroll when cursor is inside this scroll margin. */ |
8074 |
/* Shouldn't we export this `5' for customization ? -stef */ |
hscroll_margin |
8075 |
hscroll_margin = 5 * CANON_X_UNIT (XFRAME (w->frame)); |
= automatic_hscroll_margin * CANON_X_UNIT (XFRAME (w->frame)); |
8076 |
|
|
8077 |
if ((XFASTINT (w->hscroll) |
if ((XFASTINT (w->hscroll) |
8078 |
&& w->cursor.x < hscroll_margin) |
&& w->cursor.x <= hscroll_margin) |
8079 |
|| (cursor_row->enabled_p |
|| (cursor_row->enabled_p |
8080 |
&& cursor_row->truncated_on_right_p |
&& cursor_row->truncated_on_right_p |
8081 |
&& (w->cursor.x > text_area_width - hscroll_margin))) |
&& (w->cursor.x >= text_area_width - hscroll_margin))) |
8082 |
{ |
{ |
8083 |
struct it it; |
struct it it; |
8084 |
int hscroll; |
int hscroll; |
8085 |
struct buffer *saved_current_buffer; |
struct buffer *saved_current_buffer; |
8086 |
int pt; |
int pt; |
8087 |
|
int wanted_x; |
8088 |
|
|
8089 |
/* Find point in a display of infinite width. */ |
/* Find point in a display of infinite width. */ |
8090 |
saved_current_buffer = current_buffer; |
saved_current_buffer = current_buffer; |
8091 |
current_buffer = XBUFFER (w->buffer); |
current_buffer = XBUFFER (w->buffer); |
8092 |
|
|
8093 |
if (w == XWINDOW (selected_window)) |
if (w == XWINDOW (selected_window)) |
8094 |
pt = BUF_PT (current_buffer); |
pt = BUF_PT (current_buffer); |
8095 |
else |
else |
8106 |
move_it_in_display_line_to (&it, pt, -1, MOVE_TO_POS); |
move_it_in_display_line_to (&it, pt, -1, MOVE_TO_POS); |
8107 |
current_buffer = saved_current_buffer; |
current_buffer = saved_current_buffer; |
8108 |
|
|
8109 |
/* Center cursor in window. */ |
/* Position cursor in window. */ |
8110 |
hscroll = (max (0, it.current_x - text_area_width / 2) |
if (!hscroll_relative_p && hscroll_step_abs == 0) |
8111 |
/ CANON_X_UNIT (it.f)); |
hscroll = max (0, it.current_x - text_area_width / 2) |
8112 |
|
/ CANON_X_UNIT (it.f); |
8113 |
|
else if (w->cursor.x >= text_area_width - hscroll_margin) |
8114 |
|
{ |
8115 |
|
if (hscroll_relative_p) |
8116 |
|
wanted_x = text_area_width * (1 - hscroll_step_rel) |
8117 |
|
- hscroll_margin; |
8118 |
|
else |
8119 |
|
wanted_x = text_area_width |
8120 |
|
- hscroll_step_abs * CANON_X_UNIT (it.f) |
8121 |
|
- hscroll_margin; |
8122 |
|
hscroll |
8123 |
|
= max (0, it.current_x - wanted_x) / CANON_X_UNIT (it.f); |
8124 |
|
} |
8125 |
|
else |
8126 |
|
{ |
8127 |
|
if (hscroll_relative_p) |
8128 |
|
wanted_x = text_area_width * hscroll_step_rel |
8129 |
|
+ hscroll_margin; |
8130 |
|
else |
8131 |
|
wanted_x = hscroll_step_abs * CANON_X_UNIT (it.f) |
8132 |
|
+ hscroll_margin; |
8133 |
|
hscroll |
8134 |
|
= max (0, it.current_x - wanted_x) / CANON_X_UNIT (it.f); |
8135 |
|
} |
8136 |
hscroll = max (hscroll, XFASTINT (w->min_hscroll)); |
hscroll = max (hscroll, XFASTINT (w->min_hscroll)); |
8137 |
|
|
8138 |
/* Don't call Fset_window_hscroll if value hasn't |
/* Don't call Fset_window_hscroll if value hasn't |
15063 |
DEFVAR_BOOL ("automatic-hscrolling", &automatic_hscrolling_p, |
DEFVAR_BOOL ("automatic-hscrolling", &automatic_hscrolling_p, |
15064 |
doc: /* *Non-nil means scroll the display automatically to make point visible. */); |
doc: /* *Non-nil means scroll the display automatically to make point visible. */); |
15065 |
automatic_hscrolling_p = 1; |
automatic_hscrolling_p = 1; |
15066 |
|
|
15067 |
|
DEFVAR_INT ("automatic-hscroll-margin", &automatic_hscroll_margin, |
15068 |
|
doc: /* *How many columns away from the window edge point is allowed to get |
15069 |
|
before automatic hscrolling will horizontally scroll the window. */); |
15070 |
|
automatic_hscroll_margin = 5; |
15071 |
|
|
15072 |
|
DEFVAR_LISP ("automatic-hscroll-step", &Vautomatic_hscroll_step, |
15073 |
|
doc: /* *How many columns to scroll the window when point gets too close to the edge. |
15074 |
|
When point is less than `automatic-hscroll-margin' columns from the window |
15075 |
|
edge, automatic hscrolling will scroll the window by the amount of columns |
15076 |
|
determined by this variable. If its value is a positive integer, scroll that |
15077 |
|
many columns. If it's a positive floating-point number, it specifies the |
15078 |
|
fraction of the window's width to scroll. If it's nil or zero, point will be |
15079 |
|
centered horizontally after the scroll. Any other value, including negative |
15080 |
|
numbers, are treated as if the value were zero. |
15081 |
|
|
15082 |
|
Automatic hscrolling always moves point outside the scroll margin, so if |
15083 |
|
point was more than scroll step columns inside the margin, the window will |
15084 |
|
scroll more than the value given by the scroll step. |
15085 |
|
|
15086 |
|
Note that the lower bound for automatic hscrolling specified by `scroll-left' |
15087 |
|
and `scroll-right' overrides this variable's effect. */); |
15088 |
|
Vautomatic_hscroll_step = make_number (0); |
15089 |
|
|
15090 |
DEFVAR_LISP ("image-types", &Vimage_types, |
DEFVAR_LISP ("image-types", &Vimage_types, |
15091 |
doc: /* List of supported image types. |
doc: /* List of supported image types. |