diff options
| author | Keith Packard <keithp@keithp.com> | 2013-03-10 21:05:34 -0700 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2013-05-07 20:07:08 -0700 | 
| commit | 6dea353e732b6e19586c844796bc3bb848cc92f8 (patch) | |
| tree | f31c854ea9d359772dd3997554328b2b139a288e | |
| parent | 1629acba4a63baae2c687ed56a17d02faf45f5e5 (diff) | |
altos: Expose ao_put_string function
This works like puts, except it doesn't add a trailing newline.
Signed-off-by: Keith Packard <keithp@keithp.com>
| -rw-r--r-- | src/core/ao.h | 3 | ||||
| -rw-r--r-- | src/core/ao_cmd.c | 20 | 
2 files changed, 17 insertions, 6 deletions
| diff --git a/src/core/ao.h b/src/core/ao.h index 977e10b8..548e8738 100644 --- a/src/core/ao.h +++ b/src/core/ao.h @@ -145,6 +145,9 @@ extern __pdata char	ao_cmd_lex_c;  extern __pdata enum ao_cmd_status ao_cmd_status;  void +ao_put_string(__code char *s); + +void  ao_cmd_lex(void);  void diff --git a/src/core/ao_cmd.c b/src/core/ao_cmd.c index 3d086a57..6eed08d9 100644 --- a/src/core/ao_cmd.c +++ b/src/core/ao_cmd.c @@ -28,8 +28,8 @@ static __xdata char	cmd_line[CMD_LEN];  static __pdata uint8_t	cmd_len;  static __pdata uint8_t	cmd_i; -static void -put_string(__code char *s) +void +ao_put_string(__code char *s)  {  	char	c;  	while ((c = *s++)) @@ -39,7 +39,7 @@ put_string(__code char *s)  static void  backspace(void)  { -	put_string ("\010 \010"); +	ao_put_string ("\010 \010");  }  static void @@ -47,7 +47,7 @@ readline(void)  {  	char c;  	if (ao_echo()) -		put_string("> "); +		ao_put_string("> ");  	cmd_len = 0;  	for (;;) {  		flush(); @@ -303,13 +303,21 @@ help(void)  	__pdata uint8_t cmds;  	__pdata uint8_t cmd;  	__code struct ao_cmds * __pdata cs; -	const char *h; +	__code const char *h; +	uint8_t e;  	for (cmds = 0; cmds < ao_ncmds; cmds++) {  		cs = ao_cmds[cmds];  		for (cmd = 0; cs[cmd].func; cmd++) {  			h = cs[cmd].help; -			printf("%-45s %s\n", h, h + 1 + strlen(h)); +			ao_put_string(h); +			e = strlen(h); +			h += e + 1; +			e = 45 - e; +			while (e--) +				putchar(' '); +			ao_put_string(h); +			putchar('\n');  		}  	}  } | 
