Skip to content

Commit c485d7d

Browse files
committed
Make statusline separator configurable
1 parent 2e12634 commit c485d7d

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

lldb/include/lldb/Core/Debugger.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ class Debugger : public std::enable_shared_from_this<Debugger>,
313313

314314
std::vector<FormatEntity::Entry> GetStatuslineFormat() const;
315315

316+
llvm::StringRef GetStatuslineSeparator() const;
317+
316318
llvm::StringRef GetShowProgressAnsiPrefix() const;
317319

318320
llvm::StringRef GetShowProgressAnsiSuffix() const;

lldb/source/Core/CoreProperties.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ let Definition = "debugger" in {
180180
Global,
181181
DefaultStringValue<"${target.file.basename} ${line.file.basename}:${line.number}:${line.column} ${thread.stop-reason}">,
182182
Desc<"List of statusline format entities.">;
183+
def StatuslineSeparator: Property<"statusline-separator", "String">,
184+
Global,
185+
DefaultStringValue<" | ">,
186+
Desc<"Separator between statusline format entities.">;
183187
def UseSourceCache: Property<"use-source-cache", "Boolean">,
184188
Global,
185189
DefaultTrue,

lldb/source/Core/Debugger.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,12 @@ std::vector<FormatEntity::Entry> Debugger::GetStatuslineFormat() const {
469469
return GetPropertyAtIndexAs<std::vector<FormatEntity::Entry>>(idx, {});
470470
}
471471

472+
llvm::StringRef Debugger::GetStatuslineSeparator() const {
473+
const uint32_t idx = ePropertyStatuslineSeparator;
474+
return GetPropertyAtIndexAs<llvm::StringRef>(
475+
idx, g_debugger_properties[idx].default_cstr_value);
476+
}
477+
472478
bool Debugger::GetUseAutosuggestion() const {
473479
const uint32_t idx = ePropertyShowAutosuggestion;
474480
return GetPropertyAtIndexAs<bool>(

lldb/source/Core/Statusline.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,19 @@ void Statusline::Update() {
139139
if (auto frame_sp = exe_ctx.GetFrameSP())
140140
symbol_ctx = frame_sp->GetSymbolContext(eSymbolContextEverything);
141141

142+
llvm::StringRef separator = m_debugger.GetStatuslineSeparator();
143+
142144
// Add the user-configured components.
143145
bool add_separator = false;
144146
for (const FormatEntity::Entry &entry : m_debugger.GetStatuslineFormat()) {
147+
StreamString format_entity_stream;
148+
if (add_separator)
149+
format_entity_stream << separator;
150+
add_separator =
151+
FormatEntity::Format(entry, format_entity_stream, &symbol_ctx, &exe_ctx,
152+
nullptr, nullptr, false, false);
145153
if (add_separator)
146-
stream << " | ";
147-
add_separator = FormatEntity::Format(entry, stream, &symbol_ctx, &exe_ctx,
148-
nullptr, nullptr, false, false);
154+
stream << format_entity_stream.GetString();
149155
}
150156

151157
// Add progress reports at the end, if enabled.
@@ -157,7 +163,7 @@ void Statusline::Update() {
157163
}
158164
if (m_progress_report) {
159165
if (add_separator)
160-
stream << " | ";
166+
stream << separator;
161167
stream << m_progress_report->message;
162168
}
163169
}

0 commit comments

Comments
 (0)