Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

Indentation cleanup, added smart_brackets and smart_insertions, and more #284

Merged
merged 22 commits into from
Sep 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
bb8109b
Fixes #281: )-key moves cursor forward instead of inserting ) when ap…
eidheim Sep 4, 2016
2379bca
Minor: fixed tab size that in a few files would be set to 0, and remo…
eidheim Sep 5, 2016
92f93c9
Indentation cleanup and improvements
eidheim Sep 5, 2016
ab2f699
Added move on '>' and '(' in '>(' when filling out template and funct…
eidheim Sep 6, 2016
0d5f6f4
Smart brackets: added exception where a single ' did not count as a c…
eidheim Sep 7, 2016
2150557
Added preference item: smart_brackets
eidheim Sep 7, 2016
da9f001
Added smart_insertions
eidheim Sep 7, 2016
f656b76
Smart indentation/brackets/insertions cleanup and improvements
eidheim Sep 8, 2016
bb0f873
Simplified and improved Source::SpellCheckView::is_code_iter
eidheim Sep 8, 2016
a4619cd
Minor cleanup and made insertion of ' and " more restrictive
eidheim Sep 8, 2016
0ecc3be
Fixed Source::SpellCheckView::is_code_iter for some languages
eidheim Sep 8, 2016
2bf54e0
Now performs smart insertions on selected text
eidheim Sep 9, 2016
25544a1
Spellcheck cleanup and improvements
eidheim Sep 9, 2016
780fe03
Now uses grip when choosing Compile and run on a markdown file
eidheim Sep 10, 2016
de879bc
Added keypad keys home, end, up, down, left, right to key check expre…
eidheim Sep 12, 2016
b547747
Cleanup of menu item activations
eidheim Sep 12, 2016
c9f2aa0
Added info messages when no action happens from menu items
eidheim Sep 12, 2016
ab82cbe
Minor fixes to key_press_events
eidheim Sep 12, 2016
ba93408
Smart paste now also works on selected text
eidheim Sep 12, 2016
e3452d9
Renamed smart_insertions to start_inserts, and fixed a bug when remov…
eidheim Sep 13, 2016
16eb16b
Now updates directory view text color when theme is changed outside o…
eidheim Sep 13, 2016
43eaad0
Now adds semicolon after lambda unless the lambda is a parameter
eidheim Sep 13, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required (VERSION 2.8.8)

project(juci)
set(JUCI_VERSION "1.2.1.2")
set(JUCI_VERSION "1.2.1.5")

set(CPACK_PACKAGE_NAME "jucipp")
set(CPACK_PACKAGE_CONTACT "Ole Christian Eidheim <eidheim@gmail.com>")
Expand Down
14 changes: 10 additions & 4 deletions src/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,15 @@ bool Config::remove_deprecated_nodes(const boost::property_tree::ptree &default_
if(parent_path.size()>0)
parent_path+=".";
bool unchanged=true;
for(auto &node: config_cfg) {
auto path=parent_path+node.first;
for(auto it=config_cfg.begin();it!=config_cfg.end();) {
auto path=parent_path+it->first;
try {
default_cfg.get<std::string>(path);
unchanged&=remove_deprecated_nodes(default_cfg, node.second, path);
unchanged&=remove_deprecated_nodes(default_cfg, it->second, path);
++it;
}
catch(const std::exception &e) {
config_cfg.erase(node.first);
it=config_cfg.erase(it);
unchanged=false;
}
}
Expand Down Expand Up @@ -193,6 +194,11 @@ void Config::get_source() {

source.cleanup_whitespace_characters=source_json.get<bool>("cleanup_whitespace_characters");
source.show_whitespace_characters=source_json.get<std::string>("show_whitespace_characters");

source.smart_brackets=source_json.get<bool>("smart_brackets");
source.smart_inserts=source_json.get<bool>("smart_inserts");
if(source.smart_inserts)
source.smart_brackets=true;

source.show_map = source_json.get<bool>("show_map");
source.map_font_size = source_json.get<std::string>("map_font_size");
Expand Down
3 changes: 3 additions & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class Config {
bool cleanup_whitespace_characters;
std::string show_whitespace_characters;

bool smart_brackets;
bool smart_inserts;

bool show_map;
std::string map_font_size;
bool show_git_diff;
Expand Down
4 changes: 2 additions & 2 deletions src/entrybox.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ EntryBox::Entry::Entry(const std::string& content, std::function<void(const std:
}
});
signal_key_press_event().connect([this](GdkEventKey* key){
if(key->keyval==GDK_KEY_Up) {
if(key->keyval==GDK_KEY_Up || key->keyval==GDK_KEY_KP_Up) {
auto &history=entry_histories[get_placeholder_text()];
if(history.size()>0) {
selected_history++;
Expand All @@ -42,7 +42,7 @@ EntryBox::Entry::Entry(const std::string& content, std::function<void(const std:
set_position(-1);
}
}
if(key->keyval==GDK_KEY_Down) {
if(key->keyval==GDK_KEY_Down || key->keyval==GDK_KEY_KP_Down) {
auto &history=entry_histories[get_placeholder_text()];
if(history.size()>0) {
if(selected_history!=0)
Expand Down
4 changes: 4 additions & 0 deletions src/files.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ R"RAW(
"cleanup_whitespace_characters": false,
"show_whitespace_characters_comment": "Determines what kind of whitespaces should be drawn. Use comma-separated list of: space, tab, newline, nbsp, leading, text, trailing or all",
"show_whitespace_characters": "",
"smart_brackets_comment": "If smart_inserts is enabled, this option is automatically enabled. When inserting an already closed bracket, the cursor might instead be moved, avoiding the need of arrow keys after autocomplete",
"smart_brackets": true,
"smart_inserts_comment": "When for instance inserting (, () gets inserted. Applies to: (), [], \", '. Also enables pressing ; inside an expression before a final ) to insert ; at the end of line, and deletions of empty insertions",
"smart_inserts": false,
"show_map": true,
"map_font_size": "1",
"show_git_diff": true,
Expand Down
53 changes: 23 additions & 30 deletions src/project.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ std::unordered_map<std::string, std::string> Project::debug_run_arguments;
std::atomic<bool> Project::compiling(false);
std::atomic<bool> Project::debugging(false);
std::pair<boost::filesystem::path, std::pair<int, int> > Project::debug_stop;
std::string Project::debug_status;
std::unique_ptr<Project::Base> Project::current;
#ifdef JUCI_ENABLE_DEBUG
std::unordered_map<std::string, Project::Clang::DebugOptions> Project::Clang::debug_options;
Expand Down Expand Up @@ -67,20 +68,27 @@ void Project::on_save(size_t index) {
}
}

void Project::debug_update_status(const std::string &debug_status) {
void Project::debug_update_status(const std::string &new_debug_status) {
debug_status=new_debug_status;
if(debug_status.empty())
debug_status_label().set_text("");
else
debug_status_label().set_text("debug: "+debug_status);
debug_activate_menu_items();
}

void Project::debug_activate_menu_items() {
auto &menu=Menu::get();
auto view=Notebook::get().get_current_view();
menu.actions["debug_stop"]->set_enabled(!debug_status.empty());
menu.actions["debug_kill"]->set_enabled(!debug_status.empty());
menu.actions["debug_step_over"]->set_enabled(!debug_status.empty());
menu.actions["debug_step_into"]->set_enabled(!debug_status.empty());
menu.actions["debug_step_out"]->set_enabled(!debug_status.empty());
menu.actions["debug_backtrace"]->set_enabled(!debug_status.empty());
menu.actions["debug_show_variables"]->set_enabled(!debug_status.empty());
menu.actions["debug_backtrace"]->set_enabled(!debug_status.empty() && view);
menu.actions["debug_show_variables"]->set_enabled(!debug_status.empty() && view);
menu.actions["debug_run_command"]->set_enabled(!debug_status.empty());
menu.actions["debug_toggle_breakpoint"]->set_enabled(view && static_cast<bool>(view->toggle_breakpoint));
menu.actions["debug_goto_stop"]->set_enabled(!debug_status.empty());
}

Expand Down Expand Up @@ -471,8 +479,10 @@ void Project::Clang::debug_backtrace() {
auto iter=view->get_iter_for_dialog();
view->selection_dialog=std::make_unique<SelectionDialog>(*view, view->get_buffer()->create_mark(iter), true, true);
auto rows=std::make_shared<std::unordered_map<std::string, Debug::LLDB::Frame> >();
if(backtrace.size()==0)
if(backtrace.size()==0) {
Info::get().print("No backtrace found");
return;
}

bool cursor_set=false;
for(auto &frame: backtrace) {
Expand Down Expand Up @@ -521,8 +531,10 @@ void Project::Clang::debug_show_variables() {
auto iter=view->get_iter_for_dialog();
view->selection_dialog=std::make_unique<SelectionDialog>(*view, view->get_buffer()->create_mark(iter), true, true);
auto rows=std::make_shared<std::unordered_map<std::string, Debug::LLDB::Variable> >();
if(variables.size()==0)
if(variables.size()==0) {
Info::get().print("No variables found");
return;
}

for(auto &variable: variables) {
std::string row="#"+std::to_string(variable.thread_index_id)+":#"+std::to_string(variable.frame_index)+":"+variable.file_path.filename().string()+":"+std::to_string(variable.line_nr)+" - <b>"+Glib::Markup::escape_text(variable.name)+"</b>";
Expand Down Expand Up @@ -629,33 +641,14 @@ void Project::Markdown::compile_and_run() {
}

std::stringstream stdin_stream, stdout_stream;
auto exit_status=Terminal::get().process(stdin_stream, stdout_stream, "markdown "+filesystem::escape_argument(Notebook::get().get_current_view()->file_path.string()));
auto exit_status=Terminal::get().process(stdin_stream, stdout_stream, "command -v grip");
if(exit_status==0) {
boost::system::error_code ec;
auto temp_path=boost::filesystem::temp_directory_path(ec);
if(!ec) {
temp_path/=boost::filesystem::unique_path();
temp_path+=".html";
if(!boost::filesystem::exists(temp_path)) {
last_temp_path=temp_path;
std::ofstream file_stream(temp_path.string(), std::fstream::binary);
file_stream << stdout_stream.rdbuf();
file_stream.close();

auto uri=temp_path.string();
#ifdef __APPLE__
Terminal::get().process("open "+filesystem::escape_argument(uri));
#else
#ifdef __linux
uri="file://"+uri;
#endif
GError* error=nullptr;
gtk_show_uri(nullptr, uri.c_str(), GDK_CURRENT_TIME, &error);
g_clear_error(&error);
#endif
}
}
auto command="grip -b "+filesystem::escape_argument(Notebook::get().get_current_view()->file_path.string());
Terminal::get().print("Running: "+command+" in a quiet background process\n");
Terminal::get().async_process(command, "", nullptr, true);
}
else
Terminal::get().print("Warning: install grip to preview Markdown files\n");
}

void Project::Python::compile_and_run() {
Expand Down
4 changes: 3 additions & 1 deletion src/project.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ namespace Project {
extern std::atomic<bool> compiling;
extern std::atomic<bool> debugging;
extern std::pair<boost::filesystem::path, std::pair<int, int> > debug_stop;
extern std::string debug_status;
void debug_update_status(const std::string &new_debug_status);
void debug_activate_menu_items();
void debug_update_stop();
void debug_update_status(const std::string &debug_status);

class Base {
protected:
Expand Down
12 changes: 6 additions & 6 deletions src/selectiondialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ SelectionDialog::SelectionDialog(Gtk::TextView& text_view, Glib::RefPtr<Gtk::Tex
}

bool SelectionDialog::on_key_press(GdkEventKey* key) {
if(key->keyval==GDK_KEY_Down && list_view_text.get_model()->children().size()>0) {
if((key->keyval==GDK_KEY_Down || key->keyval==GDK_KEY_KP_Down) && list_view_text.get_model()->children().size()>0) {
auto it=list_view_text.get_selection()->get_selected();
if(it) {
it++;
Expand All @@ -238,7 +238,7 @@ bool SelectionDialog::on_key_press(GdkEventKey* key) {
}
return true;
}
else if(key->keyval==GDK_KEY_Up && list_view_text.get_model()->children().size()>0) {
else if((key->keyval==GDK_KEY_Up || key->keyval==GDK_KEY_KP_Up) && list_view_text.get_model()->children().size()>0) {
auto it=list_view_text.get_selection()->get_selected();
if(it) {
it--;
Expand All @@ -257,7 +257,7 @@ bool SelectionDialog::on_key_press(GdkEventKey* key) {
hide();
return true;
}
else if(key->keyval==GDK_KEY_Left || key->keyval==GDK_KEY_Right) {
else if(key->keyval==GDK_KEY_Left || key->keyval==GDK_KEY_KP_Left || key->keyval==GDK_KEY_Right || key->keyval==GDK_KEY_KP_Right) {
hide();
return false;
}
Expand Down Expand Up @@ -347,7 +347,7 @@ void CompletionDialog::select(bool hide_window) {
}

bool CompletionDialog::on_key_release(GdkEventKey* key) {
if(key->keyval==GDK_KEY_Down || key->keyval==GDK_KEY_Up)
if(key->keyval==GDK_KEY_Down || key->keyval==GDK_KEY_KP_Down || key->keyval==GDK_KEY_Up || key->keyval==GDK_KEY_KP_Up)
return false;

if(show_offset>text_view.get_buffer()->get_insert()->get_iter().get_offset()) {
Expand Down Expand Up @@ -381,7 +381,7 @@ bool CompletionDialog::on_key_press(GdkEventKey* key) {
}
if(key->keyval==GDK_KEY_Shift_L || key->keyval==GDK_KEY_Shift_R || key->keyval==GDK_KEY_Alt_L || key->keyval==GDK_KEY_Alt_R || key->keyval==GDK_KEY_Control_L || key->keyval==GDK_KEY_Control_R || key->keyval==GDK_KEY_Meta_L || key->keyval==GDK_KEY_Meta_R)
return false;
if(key->keyval==GDK_KEY_Down && list_view_text.get_model()->children().size()>0) {
if((key->keyval==GDK_KEY_Down || key->keyval==GDK_KEY_KP_Down) && list_view_text.get_model()->children().size()>0) {
auto it=list_view_text.get_selection()->get_selected();
if(it) {
it++;
Expand All @@ -395,7 +395,7 @@ bool CompletionDialog::on_key_press(GdkEventKey* key) {
select(false);
return true;
}
if(key->keyval==GDK_KEY_Up && list_view_text.get_model()->children().size()>0) {
if((key->keyval==GDK_KEY_Up || key->keyval==GDK_KEY_KP_Up) && list_view_text.get_model()->children().size()>0) {
auto it=list_view_text.get_selection()->get_selected();
if(it) {
it--;
Expand Down