- "scale" - should be a pair of values in format WIDTHxHEIGHT. If
given, content will be scaled so that this many "points" will fit
within the window. A "point" is one tenth of the size of an "M"
- which is stored (in the same WxH format) in the "scale:M" attrbiute
+ which is stored (in the same WxH format) in the "scale:M" attribute
which is set by the display pane.
So if "scale" is "800x250" then text is scales so that least 80 M's
fit across and 25 M's fit down.
+ Alternately "scale" can be a single integer in which can the standard
+ scaling is multiplied by 1/1000th of that number.
+
### lib-renderline
following punctuation (=) and try there.
- [X] resolve shift-left vs shift_left distinction - add a "fixed"
suffix? Also consider render-wrap
-- [ ] should zoom affect whole window, not just pane?
+- [X] should zoom affect whole window, not just pane?
- [X] ditch cached-size for images - store in pane data instead.
- [X] use foreach_attr for parsing image details
- [ ] mergeview command to show diff between "found" and "replacement".
return 1;
}
-static int get_scale(struct pane *p)
-{
- char *sc = pane_attr_get(p, "scale");
- int scale;
-
- if (!sc)
- return 1000;
-
- scale = atoi(sc);
- if (scale > 3)
- return scale;
- return 1000;
-}
-
-DEF_CMD(popup_scale_relative)
-{
- struct pane *p = ci->home;
- int scale = get_scale(p);
- int rpt = RPT_NUM(ci);
-
- if (rpt > 10) rpt = 10;
- if (rpt < -10) rpt = -10;
- while (rpt > 0) {
- scale = scale * 11/10;
- rpt -= 1;
- }
- while (rpt < 0) {
- scale = scale * 9 / 10;
- rpt += 1;
- }
-
- attr_set_int(&p->attrs, "scale", scale);
- call("view:changed", ci->focus);
- return 1;
-}
-
DEF_CMD(popup_do_close)
{
const char *str;
key_add(popup_map, "Window:y+", &popup_ignore);
key_add(popup_map, "Window:y-", &popup_ignore);
key_add(popup_map, "Window:close-others", &popup_close_others);
- key_add(popup_map, "Window:scale-relative", &popup_scale_relative);
key_add(popup_map, "pane:defocus", &popup_defocus);
}
return 1;
}
-static int get_scale(struct pane *p)
-{
- char *sc = pane_attr_get(p, "scale");
- int scale;
-
- if (!sc)
- return 1000;
-
- scale = atoi(sc);
- if (scale > 3)
- return scale;
- return 1000;
-}
-
DEF_CMD(tile_attach)
{
struct pane *display = ci->focus;
list_for_each_entry_safe(child, t, &p->children, siblings)
if (child != p2)
pane_reparent(child, p2);
- /* Move attrs "scale" attr to the new pane */
- attr_set_str(&p2->attrs, "scale", attr_find(p->attrs, "scale"));
- attr_set_str(&p->attrs, "scale", NULL);
p = p2;
}
alloc(ti2, pane);
if (!ret)
return NULL;
- attr_set_str(&ret->attrs, "scale", attr_find(p->attrs, "scale"));
ti2->p = ret;
if (after)
pane_move_after(ret, p);
ti->direction = tmp;
ti2->p = remain;
- attr_set_str(&p->attrs, "scale",
- attr_find(remain->attrs, "scale"));
- attr_set_str(&remain->attrs, "scale", NULL);
pane_subsume(remain, p);
}
return 1;
return ti->direction != Neither ? 1 : Efalse;
}
-DEF_CMD(tile_window_scale_relative)
-{
- struct pane *p = ci->home;
- int scale = get_scale(p);
- int rpt = RPT_NUM(ci);
-
- if (wrong_pane(ci))
- return Efallthrough;
-
- if (rpt > 10) rpt = 10;
- if (rpt < -10) rpt = -10;
- while (rpt > 0) {
- scale = scale * 12/10;
- rpt -= 1;
- }
- while (rpt < 0) {
- scale = scale * 10/ 12;
- rpt += 1;
- }
-
- attr_set_int(&p->attrs, "scale", scale);
- call("view:changed", ci->focus);
- return 1;
-}
-
DEF_CMD(tile_other)
{
/* Choose some other tile. If there aren't any, make one.
key_add(tile_map, "Window:split-y", &tile_window_splity);
key_add(tile_map, "Window:close", &tile_window_close);
key_add(tile_map, "Window:close-others", &tile_window_close_others);
- key_add(tile_map, "Window:scale-relative", &tile_window_scale_relative);
key_add(tile_map, "Window:bury", &tile_window_bury);
key_add(tile_map, "OtherPane", &tile_other);
}
REDEF_CMD(emacs_simple);
-REDEF_CMD(emacs_simple_neg);
REDEF_CMD(emacs_simple_num);
REDEF_CMD(emacs_simple_str);
static struct simple_command {
{CMD(emacs_simple), "Window:split-y", "K:CX-2"},
{CMD(emacs_simple), "Window:split-x", "K:CX-3"},
{CMD(emacs_simple), "Window:close", "K:CX-0"},
- {CMD(emacs_simple), "Window:scale-relative", "K:CX:C-="},
- {CMD(emacs_simple_neg), "Window:scale-relative", "K:CX:C--"},
{CMD(emacs_simple), "Window:bury", "K:A-B"},
{CMD(emacs_simple), "Display:new", "K:CX5-2"},
{CMD(emacs_simple), "Display:close", "K:CX5-0"},
return call(sc->type, ci->focus, ci->num, ci->mark);
}
-REDEF_CMD(emacs_simple_neg)
-{
- struct simple_command *sc = container_of(ci->comm, struct simple_command, cmd);
-
- if (!ci->mark)
- return Enoarg;
-
- return call(sc->type, ci->focus, -RPT_NUM(ci), ci->mark);
-}
-
REDEF_CMD(emacs_simple_num)
{
struct simple_command *sc = container_of(ci->comm, struct simple_command, cmd);
return emacs_growx_func(ci);
}
+DEF_CMD(emacs_scale_relative)
+{
+ struct pane *p = ci->focus;
+ char *sc = pane_attr_get(p, "scale:M");
+ int scale = 0;
+ char num[20];
+
+ if (!sc) {
+ call("Message:modal", p, 0, NULL,
+ "Cannot zoom display with fixed-sized font");
+ return 1;
+ }
+ sc = pane_attr_get(p, "scale");
+ if (sc && strchr(sc, 'x')) {
+ call("Message:modal", p, 0, NULL,
+ "Cannot zoom display with fixed layout");
+ return 1;
+ }
+
+ if (sc)
+ scale = atoi(sc);
+ if (scale <= 0)
+ scale = 1000;
+ if (ci->key[strlen(ci->key)-1] == '-')
+ scale = 10 * scale / 12;
+ else
+ scale = 12 * scale / 10;
+ snprintf(num, sizeof(num)-1, "%d", scale);
+ call("Display:set:scale", p, 0, NULL, num);
+ return 1;
+}
+
DEF_CMD(emacs_curs_pos)
{
struct mark *c;
key_add(m, "K-{", &emacs_growx_again);
key_add(m, "K-}", &emacs_growx_again);
+ key_add(m, "K:CX:C-=", &emacs_scale_relative);
+ key_add(m, "K:CX:C--", &emacs_scale_relative);
+
key_add(m, "K:C-S", &emacs_start_search);
key_add(m, "K:C-R", &emacs_start_search);
key_add(m, "K:A-%", &emacs_start_search);