1 #if !defined(lint) && !defined(DOS)
2 static char rcsid
[] = "$Id: margin.c 1032 2008-04-11 00:30:04Z hubert@u.washington.edu $";
6 * ========================================================================
7 * Copyright 2013-2019 Eduardo Chappa
8 * Copyright 2006-2008 University of Washington
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * ========================================================================
19 /*======================================================================
22 Implements message data gathering and formatting
27 #include "../pith/headers.h"
28 #include "../pith/string.h"
29 #include "../pith/state.h"
30 #include "../pith/conf.h"
39 * format_view_margin - return sane value for vertical margins
42 format_view_margin(void)
45 char tmp
[100], e
[200], *err
, lastchar
= 0;
46 int left
= 0, right
= 0, leftm
= 0, rightm
= 0;
49 memset(margin
, 0, sizeof(margin
));
52 * We initially tried to make sure that the user didn't shoot themselves
53 * in the foot by setting this too small. People seem to want to do some
54 * strange stuff, so we're going to relax the wild shot detection and
55 * let people set what they want, until we get to the point of totally
56 * absurd. We've also added the possibility of appending the letter c
57 * onto the width. That means treat the value as an absolute column
58 * instead of a width. That is, a right margin of 76c means wrap at
59 * column 76, whereas right margin of 4 means to wrap at column
62 if(ps_global
->VAR_VIEW_MARGIN_LEFT
){
63 strncpy(tmp
, ps_global
->VAR_VIEW_MARGIN_LEFT
, sizeof(tmp
)-1);
64 tmp
[sizeof(tmp
)-1] = '\0';
65 removing_leading_and_trailing_white_space(tmp
);
74 if((err
= strtoval(tmp
, &left
, 0, 0, 0, e
, sizeof(e
), "Viewer-margin-left")) != NULL
){
76 dprint((2, "%s\n", err
));
84 leftm
= MIN(MAX(0, leftm
), ps_global
->ttyo
->screen_cols
);
89 if(ps_global
->VAR_VIEW_MARGIN_RIGHT
){
90 strncpy(tmp
, ps_global
->VAR_VIEW_MARGIN_RIGHT
, sizeof(tmp
)-1);
91 tmp
[sizeof(tmp
)-1] = '\0';
92 removing_leading_and_trailing_white_space(tmp
);
101 if((err
= strtoval(tmp
, &right
, 0, 0, 0, e
, sizeof(e
), "Viewer-margin-right")) != NULL
){
103 dprint((2, "%s\n", err
));
107 rightm
= ps_global
->ttyo
->screen_cols
- right
;
111 rightm
= MIN(MAX(0, rightm
), ps_global
->ttyo
->screen_cols
);
116 if((rightm
> 0 || leftm
> 0) && rightm
>= 0 && leftm
>= 0
117 && ps_global
->ttyo
->screen_cols
- rightm
- leftm
>= 8){
127 * Give a margin for help and such
130 non_messageview_margin(void)
132 static int margin
[2];