1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
#
from pygments.token import Token
from nubia import context, statusbar
class NubiaExampleStatusBar(statusbar.StatusBar):
def __init__(self, context):
self._last_status = None
def get_rprompt_tokens(self):
if self._last_status:
return [(Token.RPrompt, "Error: {}".format(self._last_status))]
return []
def set_last_command_status(self, status):
self._last_status = status
def get_tokens(self):
spacer = (Token.Spacer, " ")
if context.get_context().verbose:
is_verbose = (Token.Warn, "ON")
else:
is_verbose = (Token.Info, "OFF")
return [
(Token.Toolbar, "Hello!"),
spacer,
(Token.Toolbar, "Verbose "),
spacer,
is_verbose,
]
|