diff --git a/form/form.h b/form/form.h index 09856dc..470b81e 100644 --- a/form/form.h +++ b/form/form.h @@ -205,6 +205,7 @@ typedef void (*Form_Hook)(FORM *); #define O_PASSOK (0x0100U) #define O_STATIC (0x0200U) #define O_DYNAMIC_JUSTIFY (0x0400U) /* ncurses extension */ +#define O_NO_LEFT_STRIP (0x0800U) /* ncurses extension */ /* form options */ #define O_NL_OVERLOAD (0x0001U) diff --git a/form/form.priv.h b/form/form.priv.h index 4d1dfe7..b9bdea2 100644 --- a/form/form.priv.h +++ b/form/form.priv.h @@ -162,7 +162,8 @@ TypeArgument; #define ALL_FIELD_OPTS (Field_Options)( \ STD_FIELD_OPTS |\ - O_DYNAMIC_JUSTIFY) + O_DYNAMIC_JUSTIFY |\ + O_NO_LEFT_STRIP) #define C_BLANK ' ' #define is_blank(c) ((c)==C_BLANK) diff --git a/form/frm_driver.c b/form/frm_driver.c index eebde42..c3a8285 100644 --- a/form/frm_driver.c +++ b/form/frm_driver.c @@ -979,7 +979,8 @@ Perform_Justification(FIELD *field, WINDOW *win) int len; int col = 0; - bp = Get_Start_Of_Data(field->buf, Buffer_Length(field)); + bp = Field_Has_Option(field, O_NO_LEFT_STRIP)? field->buf: + Get_Start_Of_Data(field->buf, Buffer_Length(field)); len = (int)(After_End_Of_Data(field->buf, Buffer_Length(field)) - bp); if (len > 0) @@ -1023,7 +1024,8 @@ Undo_Justification(FIELD *field, WINDOW *win) FIELD_CELL *bp; int len; - bp = Get_Start_Of_Data(field->buf, Buffer_Length(field)); + bp = Field_Has_Option(field, O_NO_LEFT_STRIP)? field->buf: + Get_Start_Of_Data(field->buf, Buffer_Length(field)); len = (int)(After_End_Of_Data(field->buf, Buffer_Length(field)) - bp); if (len > 0) diff --git a/man/form_field_opts.3x b/man/form_field_opts.3x index ff27fe1..8e0f351 100644 --- a/man/form_field_opts.3x +++ b/man/form_field_opts.3x @@ -91,10 +91,13 @@ O_WRAP Words that do not fit on a line are wrapped to the next line. Words are blank-separated. .PP -One extension option is defined (extensions are off by default): +Two extension options are defined (extensions are off by default): .TP 5 O_DYNAMIC_JUSTIFY Permit dynamic fields to be justified, like static fields. +.TP 5 +O_NO_LEFT_STRIP +Preserve leading whitespace in the field buffer which are normally discarded. .SH RETURN VALUE Except for \fBfield_opts\fR, each routine returns one of the following: .TP 5