Skip to content

Commit

Permalink
New option disable_center to disable center alignment
Browse files Browse the repository at this point in the history
Bug-Debian: tats#175
Bug-Debian: tats#185
  • Loading branch information
tats authored and bptato committed Jun 26, 2023
1 parent 7a93594 commit 3c30130
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
10 changes: 8 additions & 2 deletions file.c
Original file line number Diff line number Diff line change
Expand Up @@ -4319,7 +4319,10 @@ set_alignment(struct readbuffer *obuf, struct parsed_tag *tag)
if (parsedtag_get_value(tag, ATTR_ALIGN, &align)) {
switch (align) {
case ALIGN_CENTER:
flag = RB_CENTER;
if (DisableCenter)
flag = RB_LEFT;
else
flag = RB_CENTER;
break;
case ALIGN_RIGHT:
flag = RB_RIGHT;
Expand Down Expand Up @@ -5183,7 +5186,10 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env)
if (!(obuf->flag & (RB_PREMODE | RB_IGNORE_P)))
flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit);
RB_SAVE_FLAG(obuf);
RB_SET_ALIGN(obuf, RB_CENTER);
if (DisableCenter)
RB_SET_ALIGN(obuf, RB_LEFT);
else
RB_SET_ALIGN(obuf, RB_CENTER);
return 1;
case HTML_N_CENTER:
CLOSE_A;
Expand Down
3 changes: 2 additions & 1 deletion fm.h
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ struct readbuffer {
#define RB_HTML5 0x400000

#define RB_GET_ALIGN(obuf) ((obuf)->flag&RB_ALIGN)
#define RB_SET_ALIGN(obuf,align) {(obuf)->flag &= ~RB_ALIGN; (obuf)->flag |= (align); }
#define RB_SET_ALIGN(obuf,align) do{(obuf)->flag &= ~RB_ALIGN; (obuf)->flag |= (align); }while(0)
#define RB_SAVE_FLAG(obuf) {\
if ((obuf)->flag_sp < RB_STACK_SIZE) \
(obuf)->flag_stack[(obuf)->flag_sp++] = RB_GET_ALIGN(obuf); \
Expand Down Expand Up @@ -1125,6 +1125,7 @@ global char UseAltEntity init(FALSE);
#define GRAPHIC_CHAR_CHARSET 0
global char UseGraphicChar init(GRAPHIC_CHAR_CHARSET);
global char DisplayBorders init(FALSE);
global char DisableCenter init(FALSE);
extern char *graph_symbol[];
extern char *graph2_symbol[];
extern int symbol_width;
Expand Down
3 changes: 3 additions & 0 deletions rc.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ static int OptionEncode = FALSE;
#define CMT_ALT_ENTITY N_("Use ASCII equivalents to display entities")
#define CMT_GRAPHIC_CHAR N_("Character type for border of table and menu")
#define CMT_DISP_BORDERS N_("Display table borders, ignore value of BORDER")
#define CMT_DISABLE_CENTER N_("Disable center alignment")
#define CMT_FOLD_TEXTAREA N_("Fold lines in TEXTAREA")
#define CMT_DISP_INS_DEL N_("Display INS, DEL, S and STRIKE element")
#define CMT_COLOR N_("Display with color")
Expand Down Expand Up @@ -422,6 +423,8 @@ struct param_ptr params1[] = {
CMT_GRAPHIC_CHAR, (void *)graphic_char_str},
{"display_borders", P_CHARINT, PI_ONOFF, (void *)&DisplayBorders,
CMT_DISP_BORDERS, NULL},
{"disable_center", P_CHARINT, PI_ONOFF, (void *)&DisableCenter,
CMT_DISABLE_CENTER, NULL},
{"fold_textarea", P_CHARINT, PI_ONOFF, (void *)&FoldTextarea,
CMT_FOLD_TEXTAREA, NULL},
{"display_ins_del", P_INT, PI_SEL_C, (void *)&displayInsDel,
Expand Down
7 changes: 6 additions & 1 deletion table.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,12 +616,17 @@ print_item(struct table *t, int row, int col, int width, Str buf)
alignment = ALIGN_RIGHT;
else if ((t->tabattr[row][col] & HTT_ALIGN) == HTT_CENTER)
alignment = ALIGN_CENTER;
if (DisableCenter && alignment == ALIGN_CENTER)
alignment = ALIGN_LEFT;
align(lbuf, width, alignment);
Strcat(buf, lbuf->line);
}
else {
lbuf = newTextLine(NULL, 0);
align(lbuf, width, ALIGN_CENTER);
if (DisableCenter)
align(lbuf, width, ALIGN_LEFT);
else
align(lbuf, width, ALIGN_CENTER);
Strcat(buf, lbuf->line);
}
}
Expand Down

0 comments on commit 3c30130

Please sign in to comment.