src/strutil.h: created align_crt_t type for string alignment on terminal.

Changed type of related function arguments.

src/strutil.c (str_fit_to_term): changed type of 3rd argument
from int to align_crt_t.

src/strutil8bit.c (str_8bit_fit_to_term): likewise.

src/strutilascii.c (str_ascii_fit_to_term): likewise.

src/strutilutf8.c (str_utf8_fit_to_term): likewise.

src/screen.c: changed type of alignment variables and structure fields
This commit is contained in:
Andrew Borodin 2009-04-24 20:01:06 +04:00
parent 16dd0ad073
commit d716433399
6 changed files with 24 additions and 26 deletions

View File

@ -70,7 +70,7 @@ typedef struct format_e {
struct format_e *next;
int requested_field_len;
int field_len;
int just_mode;
align_crt_t just_mode;
int expand;
const char *(*string_fn)(file_entry *, int len);
const char *title;
@ -419,7 +419,7 @@ static struct {
const char *id;
int min_size;
int expands;
int default_just;
align_crt_t default_just;
const char *title;
int use_in_gui;
const char *(*string_fn)(file_entry *, int);
@ -1304,7 +1304,7 @@ parse_display_format (WPanel *panel, const char *format, char **error, int issta
format_e *darr, *old = 0, *home = 0; /* The formats we return */
int total_cols = 0; /* Used columns by the format */
int set_justify; /* flag: set justification mode? */
int justify = 0; /* Which mode. */
align_crt_t justify = J_LEFT; /* Which mode. */
int items = 0; /* Number of items in the format */
size_t i;

View File

@ -407,7 +407,7 @@ str_term_form (const char *text)
}
const char *
str_fit_to_term (const char *text, int width, int just_mode)
str_fit_to_term (const char *text, int width, align_crt_t just_mode)
{
return used_class.fit_to_term (text, width, just_mode);
}

View File

@ -52,28 +52,26 @@ typedef enum {
ESTR_FAILURE = 2
} estr_t;
/* constanst originally from screen.c
* used for alignment strings on terminal
/* alignment strings on terminal
*/
#define J_LEFT 0x01
#define J_RIGHT 0x02
#define J_CENTER 0x03
/*
if there is enough space for string on terminal, string is centered
otherwise is aligned to left
*/
#define J_CENTER_LEFT 0x04
typedef enum {
J_LEFT = 0x01,
J_RIGHT = 0x02,
J_CENTER = 0x03,
/* if there is enough space for string on terminal,
* string is centered otherwise is aligned to left */
J_CENTER_LEFT = 0x04,
/* fit alignment, if string is to long, is truncated with '~' */
J_LEFT_FIT = 0x11,
J_RIGHT_FIT = 0x12,
J_CENTER_FIT = 0x13,
J_CENTER_LEFT_FIT = 0x14
} align_crt_t;
#define IS_FIT(x) ((x) & 0x0010)
#define MAKE_FIT(x) ((x) | 0x0010)
#define HIDE_FIT(x) ((x) & 0x000f)
/* fit alignment, if string is to long, is truncated with '~' */
#define J_LEFT_FIT 0x11
#define J_RIGHT_FIT 0x12
#define J_CENTER_FIT 0x13
#define J_CENTER_LEFT_FIT 0x14
#define INVALID_CONV ((GIConv) (-1))
/* standard convertors */
@ -85,7 +83,7 @@ extern GIConv str_cnv_not_convert;
/* all functions in str_class must be defined for every encoding */
struct str_class {
estr_t (*vfs_convert_to) (GIConv coder, const char *string,
int size, GString *buffer); /*I*/
int size, GString *buffer); /*I*/
void (*insert_replace_char) (GString *buffer);
int (*is_valid_string) (const char *); /*I*/
int (*is_valid_char) (const char *, size_t); /*I*/
@ -108,7 +106,7 @@ struct str_class {
int (*tolower) (const char *, char **, size_t *);
void (*fix_string) (char *); /*I*/
const char *(*term_form) (const char *); /*I*/
const char *(*fit_to_term) (const char *, int, int); /*I*/
const char *(*fit_to_term) (const char *, int, align_crt_t); /*I*/
const char *(*term_trim) (const char *text, int width); /*I*/
void (*msg_term_size) (const char *, int *, int *); /*I*/
const char *(*term_substring) (const char *, int, int); /*I*/
@ -366,7 +364,7 @@ const char *str_term_form (const char *text);
* result is completed with spaces to width
* I
*/
const char *str_fit_to_term (const char *text, int width, int just_mode);
const char *str_fit_to_term (const char *text, int width, align_crt_t just_mode);
/* like str_term_form, but when text is wider than width, three dots are
* inserted at begin and result is completed with suffix of text

View File

@ -208,7 +208,7 @@ str_8bit_term_form (const char *text)
}
static const char *
str_8bit_fit_to_term (const char *text, int width, int just_mode)
str_8bit_fit_to_term (const char *text, int width, align_crt_t just_mode)
{
static char result[BUF_MEDIUM];
char *actual;

View File

@ -201,7 +201,7 @@ str_ascii_term_form (const char *text)
}
static const char *
str_ascii_fit_to_term (const char *text, int width, int just_mode)
str_ascii_fit_to_term (const char *text, int width, align_crt_t just_mode)
{
static char result[BUF_MEDIUM];
char *actual;

View File

@ -575,7 +575,7 @@ utf8_tool_compose (char *buffer, size_t size)
static const char *
str_utf8_fit_to_term (const char *text, int width, int just_mode)
str_utf8_fit_to_term (const char *text, int width, align_crt_t just_mode)
{
static char result[BUF_MEDIUM * 6];
const struct term_form *pre_form;