Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
BasedOnStyle: LLVM
IndentWidth: 4
UseTab: Never
ColumnLimit: 100
ColumnLimit: 120
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: false
Expand Down
7 changes: 3 additions & 4 deletions src/interface/progress_spinner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
ProgressSpinner::ProgressSpinner() : ui(nullptr), active(false) {
}

ProgressSpinner::ProgressSpinner(UserInterface* user_interface, bool activate)
: ui(user_interface), active(false) {
ProgressSpinner::ProgressSpinner(UserInterface* user_interface, bool activate) : ui(user_interface), active(false) {
if (activate && ui != nullptr) {
start();
}
Expand Down Expand Up @@ -104,8 +103,8 @@ int ProgressSpinner::progress_callback_impl(curl_off_t dltotal, curl_off_t dlnow
*
* @return 0 to continue the operation, 1 if clientp is nullptr.
*/
int ProgressSpinner::progress_callback(void* clientp, curl_off_t dltotal, curl_off_t dlnow,
curl_off_t ultotal, curl_off_t ulnow) {
int ProgressSpinner::progress_callback(void* clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal,
curl_off_t ulnow) {
ProgressSpinner* self = static_cast<ProgressSpinner*>(clientp);
if (self == nullptr) {
return 1;
Expand Down
4 changes: 2 additions & 2 deletions src/interface/progress_spinner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,6 @@ class ProgressSpinner {
* @note CURL calls this frequently; ensure your clientp points to a valid
* ProgressSpinner instance.
*/
static int progress_callback(void* clientp, curl_off_t dltotal, curl_off_t dlnow,
curl_off_t ultotal, curl_off_t ulnow);
static int progress_callback(void* clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal,
curl_off_t ulnow);
};
26 changes: 10 additions & 16 deletions src/interface/user-interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ void UserInterface::init_ncurses(void) {
}

if (has_colors()) {
printf("DEBUG: Checking theme - use_dark_theme = %s\n",
this->use_dark_theme ? "true" : "false");
printf("DEBUG: Checking theme - use_dark_theme = %s\n", this->use_dark_theme ? "true" : "false");
if (this->use_dark_theme == true) {
this->init_dark_theme();
} else {
Expand Down Expand Up @@ -175,8 +174,7 @@ void UserInterface::draw_input_area() {
mvprintw(layout.input_y, layout.input_x + 37, "%s", input_buffer.c_str());
}

UserInterface::UserInterface()
: resize_flag(0), running(0), input_cursor_x(0), layout({}), use_dark_theme(true) {
UserInterface::UserInterface() : resize_flag(0), running(0), input_cursor_x(0), layout({}), use_dark_theme(true) {
printf("DEBUG: use_dark_theme = %s\n", this->use_dark_theme ? "true" : "false");
UserInterface::instance = this;
}
Expand Down Expand Up @@ -234,8 +232,8 @@ void UserInterface::end_session(int exit_code) {
exit(exit_code);
}

void UserInterface::print_args(const std::string& model, const std::string& prompt, bool stream,
bool interactive, bool dark_theme) {
void UserInterface::print_args(const std::string& model, const std::string& prompt, bool stream, bool interactive,
bool dark_theme) {
std::string buffer;
buffer += "🛈 model = " + model + "\n";
buffer += "🛈 prompt = " + prompt + "\n";
Expand All @@ -246,8 +244,8 @@ void UserInterface::print_args(const std::string& model, const std::string& prom
this->print(buffer, UserInterface::MESSAGE_TYPE_NORMAL);
}

void UserInterface::print_args_noninteractive(const std::string& model, const std::string& prompt,
bool stream, bool interactive, bool dark_theme) {
void UserInterface::print_args_noninteractive(const std::string& model, const std::string& prompt, bool stream,
bool interactive, bool dark_theme) {
printf("\n");
printf("🛈 model = %s\n", model.c_str());
printf("🛈 prompt = %s\n", prompt.c_str());
Expand Down Expand Up @@ -318,8 +316,7 @@ void UserInterface::select_model(const std::vector<std::string>& models, std::st
}
}

void UserInterface::select_model_noninteractive(const std::vector<std::string>& models,
std::string* model) {
void UserInterface::select_model_noninteractive(const std::vector<std::string>& models, std::string* model) {
int index{};
int read_result{};

Expand Down Expand Up @@ -500,8 +497,7 @@ void UserInterface::render_loop(void) {
std::unique_lock<std::mutex> lock(this->ui_mutex);

// Wait for redraw request or timeout (100ms)
this->cv_redraw.wait_for(lock, std::chrono::milliseconds(1500),
[this] { return this->should_redraw.load(); });
this->cv_redraw.wait_for(lock, std::chrono::milliseconds(1500), [this] { return this->should_redraw.load(); });

// Handle resize (under lock)
if (this->resize_flag) {
Expand Down Expand Up @@ -572,11 +568,9 @@ void UserInterface::draw_spinner() {
attron(COLOR_PAIR(DEFAULT_PAIR));

if (progress > 0) {
mvprintw(this->layout.spinner_y, this->layout.spinner_x, "%c Progress: %d%%",
spinner_chars[frame], progress);
mvprintw(this->layout.spinner_y, this->layout.spinner_x, "%c Progress: %d%%", spinner_chars[frame], progress);
} else {
mvprintw(this->layout.spinner_y, this->layout.spinner_x, "%c Loading...",
spinner_chars[frame]);
mvprintw(this->layout.spinner_y, this->layout.spinner_x, "%c Loading...", spinner_chars[frame]);
}

attroff(COLOR_PAIR(DEFAULT_PAIR));
Expand Down
11 changes: 5 additions & 6 deletions src/interface/user-interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ class UserInterface {
* @param interactive Whether interactive mode is enabled.
* @param dark_theme Whether to active the dark theme.
*/
void print_args(const std::string& model, const std::string& prompt, bool stream,
bool interactive, bool dark_theme);
void print_args(const std::string& model, const std::string& prompt, bool stream, bool interactive,
bool dark_theme);

/**
* Static version of print_args() for non-interactive mode.
Expand All @@ -231,8 +231,8 @@ class UserInterface {
* @param interactive Whether interactive mode is enabled.
* @param dark_theme Whether to active the dark theme.
*/
static void print_args_noninteractive(const std::string& model, const std::string& prompt,
bool stream, bool interactive, bool dark_theme);
static void print_args_noninteractive(const std::string& model, const std::string& prompt, bool stream,
bool interactive, bool dark_theme);

/**
* Prints available models and their corresponding indexes for selection.
Expand All @@ -258,8 +258,7 @@ class UserInterface {
* @param models The list of available local models.
* @param model Pointer to a std::string to receive the user input.
*/
static void select_model_noninteractive(const std::vector<std::string>& models,
std::string* model);
static void select_model_noninteractive(const std::vector<std::string>& models, std::string* model);

/**
* Waits for and retrieves the next user input prompt (interactive mode).
Expand Down
3 changes: 1 addition & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ int main(int argc, const char* argv[]) {
} else {
UserInterface::print_model_list_noninteractive(models);
UserInterface::select_model_noninteractive(models, &model);
UserInterface::print_args_noninteractive(model, prompt, stream, interactive,
dark_theme);
UserInterface::print_args_noninteractive(model, prompt, stream, interactive, dark_theme);
}
}

Expand Down
Loading
Loading