1
1
mirror of https://github.com/dbcli/pgcli.git synced 2024-11-09 16:34:32 +03:00

Switch the shorted prompt when prompt length is too long. Connect #587

This commit is contained in:
Jonathan Virga 2017-02-08 10:32:01 +01:00
parent 4ad7c0f11b
commit 0559c5119e

View File

@ -85,6 +85,7 @@ class NullHandler(logging.Handler):
class PGCli(object):
default_prompt = '\\u@\\h:\\d> '
max_len_prompt = 30
def set_default_pager(self, config):
configured_pager = config['main'].get('pager')
@ -494,7 +495,11 @@ class PGCli(object):
set_vi_mode_enabled=set_vi_mode)
def prompt_tokens(_):
return [(Token.Prompt, self.get_prompt(self.prompt_format))]
prompt = self.get_prompt(self.prompt_format)
if (self.prompt_format == self.default_prompt and
len(prompt) > self.max_len_prompt):
prompt = self.get_prompt('\\d> ')
return [(Token.Prompt, prompt)]
def get_continuation_tokens(cli, width):
return [(Token.Continuation, '.' * (width - 1) + ' ')]