100 lines
3.2 KiB
C++
100 lines
3.2 KiB
C++
WindowID StatusWindowID;
|
|
|
|
void InitStatusWindow() {
|
|
Window *window = CreateWind();
|
|
StatusWindowID = window->id;
|
|
Buffer *buffer = CreateBuffer(SysAllocator, GetUniqueBufferName(ProjectFolder, "status_bar"));
|
|
buffer->special = true;
|
|
View *view = CreateView(buffer->id);
|
|
view->special = true;
|
|
window->active_view = view->id;
|
|
window->draw_line_numbers = false;
|
|
window->draw_scrollbar = false;
|
|
window->draw_line_highlight = true;
|
|
window->secondary_window_style = true;
|
|
window->primary = false;
|
|
window->jump_history = false;
|
|
window->lose_focus_on_escape = true;
|
|
}
|
|
|
|
void LayoutStatusWindow(Rect2I *rect, int16_t wx, int16_t wy) {
|
|
Unused(wx); Unused(wy);
|
|
Window *window = GetWindow(StatusWindowID);
|
|
Rect2I copy_rect = *rect;
|
|
if (!window->visible) {
|
|
rect = ©_rect;
|
|
}
|
|
Int barsize = GetExpandingBarSize(window);
|
|
window->document_rect = window->total_rect = CutBottom(rect, barsize);
|
|
}
|
|
|
|
void UpdateStatusWindow() {
|
|
ProfileFunction();
|
|
Scratch scratch;
|
|
BSet main = GetBSet(PrimaryWindowID);
|
|
BSet title = GetBSet(StatusWindowID);
|
|
title.view->scroll.y = 0;
|
|
if (title.window->id == ActiveWindowID) {
|
|
return;
|
|
}
|
|
|
|
#if 0
|
|
Vec2I doc_rect = GetSize(title.window->document_rect);
|
|
Int width_in_chars = doc_rect.x / title.window->font->char_spacing;
|
|
|
|
char buff[1024];
|
|
for (int i = 0; i < 1024; i += 1) buff[i] = ' ';
|
|
|
|
RawReplaceText(title.buffer, GetRange(title.buffer), u"");
|
|
RawAppendf(title.buffer, "%.*s", width_in_chars - 1, buff);
|
|
RawAppendf(title.buffer, "@");
|
|
return;
|
|
#endif
|
|
|
|
String16 buffer_string = GetString(title.buffer);
|
|
Range replace_range = {0, title.buffer->len};
|
|
Seek(buffer_string, u"\n", &replace_range.max);
|
|
|
|
Caret caret = main.view->carets[0];
|
|
XY xy = PosToXY(main.buffer, GetFront(caret));
|
|
|
|
String indicators = "";
|
|
if (main.buffer->dirty) {
|
|
indicators = Format(scratch, "%S!", indicators);
|
|
}
|
|
if (SearchCaseSensitive) {
|
|
indicators = Format(scratch, "%SC", indicators);
|
|
}
|
|
if (SearchWordBoundary) {
|
|
indicators = Format(scratch, "%SW", indicators);
|
|
}
|
|
|
|
String commands = Format(scratch, ":Errors[%d]", ErrorCount);
|
|
if (main.buffer->changed_on_disk) {
|
|
commands = Format(scratch, "%S :Reopen", commands);
|
|
}
|
|
For (ActiveProcesses) {
|
|
if (it.args.output_view == main.view->id) {
|
|
commands = Format(scratch, "%S :KillProcess", commands);
|
|
break;
|
|
}
|
|
}
|
|
|
|
String s = Format(scratch, "%S:%lld:%lld %S | :Prev :Next :Close %S", main.buffer->name, (long long)xy.line + 1ll, (long long)xy.col + 1ll, indicators, commands);
|
|
For (ActiveProcesses) {
|
|
if (it.args.output_view == main.view->id) {
|
|
s = Format(scratch, "%S %lld :KillProcess", s, (long long)it.id);
|
|
}
|
|
}
|
|
|
|
String16 string = ToString16(scratch, s);
|
|
String16 string_to_replace = GetString(title.buffer, replace_range);
|
|
if (string_to_replace != string) {
|
|
SelectRange(title.view, replace_range);
|
|
ReplaceEx(scratch, title.view, string);
|
|
}
|
|
|
|
SelectRange(title.view, MakeRange(0));
|
|
ResetHistory(title.buffer);
|
|
}
|