Browse Source

Merge pull request #1 from cppit/master

Update eidheim/jucipp
merge-requests/365/head
Ole Christian Eidheim 11 years ago
parent
commit
f6d9984d79
  1. 1
      juci/config.json
  2. 1
      juci/menu.xml
  3. 30
      juci/notebook.cc
  4. 2
      juci/notebook.h
  5. 55
      juci/source.cc
  6. 2
      juci/source.h

1
juci/config.json

@ -47,6 +47,7 @@
"edit_cut": "<control>x",
"edit_paste": "<control>v",
"edit_undo": "<control>z",
"edit_redo": "<control>y",
"edit_find": "<control>f",
"compile_and_run": "<control><alt>r",
"compile": "<control>r"

1
juci/menu.xml

@ -20,6 +20,7 @@
<separator/>
<menuitem action='EditFind'/>
<menuitem action='EditUndo'/>
<menuitem action='EditRedo'/>
</menu>
<menu action='ProjectMenu'>
<menuitem action='ProjectCompileAndRun'/>

30
juci/notebook.cc

@ -120,8 +120,31 @@ void Notebook::Controller::CreateKeybindings(Keybindings::Controller
Gtk::AccelKey(keybindings.config_
.key_map()["edit_undo"]),
[this]() {
//OnUndo();
});
INFO("On undo");
Glib::RefPtr<Gsv::UndoManager> undo_manager =
CurrentTextView().get_source_buffer()->get_undo_manager();
if (Pages() != 0 && undo_manager->can_undo()) {
undo_manager->undo();
}
INFO("Done undo");
}
);
keybindings.action_group_menu()->
add(Gtk::Action::create("EditRedo",
"Redo"),
Gtk::AccelKey(keybindings.config_
.key_map()["edit_redo"]),
[this]() {
INFO("On Redo");
Glib::RefPtr<Gsv::UndoManager> undo_manager =
CurrentTextView().get_source_buffer()->get_undo_manager();
if (Pages() != 0 && undo_manager->can_redo()) {
undo_manager->redo();
}
INFO("Done Redo");
});
entry_.view_.entry().signal_activate().
connect(
[this]() {
@ -515,7 +538,8 @@ void Notebook::Controller
}
}
Gtk::TextView& Notebook::Controller::CurrentTextView() {
Source::View& Notebook::Controller::CurrentTextView() {
INFO("Getting sourceview");
return text_vec_.at(CurrentPage())->view();
}

2
juci/notebook.h

@ -36,7 +36,7 @@ namespace Notebook {
Directories::Config& dir_cfg);
~Controller();
Glib::RefPtr<Gtk::TextBuffer> Buffer(Source::Controller *source);
Gtk::TextView& CurrentTextView();
Source::View& CurrentTextView();
int CurrentPage();
Gtk::Box& entry_view();
Gtk::Notebook& Notebook();

55
juci/source.cc

@ -28,6 +28,7 @@ Range(const Source::Range &org) :
//// View ////
//////////////
Source::View::View() {
Gsv::init();
override_font(Pango::FontDescription("Monospace"));
set_show_line_numbers(true);
set_highlight_current_line(true);
@ -360,36 +361,36 @@ void Source::Controller::OnOpenFile(const string &filepath) {
//OnUpdateSyntax must happen in main thread, so the parse-thread
//sends a signal to the main thread that it is to call the following function:
parsing_done.connect([this](){
INFO("Updating syntax");
view().
OnUpdateSyntax(model().ExtractTokens(0, buffer()->get_text().size()),
model().config());
INFO("Syntax updated");
});
INFO("Updating syntax");
view().
OnUpdateSyntax(model().ExtractTokens(0, buffer()->get_text().size()),
model().config());
INFO("Syntax updated");
});
buffer()->signal_end_user_action().connect([this]() {
std::thread parse([this]() {
if (parsing.try_lock()) {
INFO("Starting parsing");
while (true) {
const std::string raw = buffer()->get_text().raw();
std::map<std::string, std::string> buffers;
notebook_->MapBuffers(&buffers);
buffers[model().file_path()] = raw;
if (model().ReParse(buffers) == 0 &&
raw == buffer()->get_text().raw()) {
break;
}
}
parsing.unlock();
parsing_done();
INFO("Parsing completed");
}
std::thread parse([this]() {
if (parsing.try_lock()) {
INFO("Starting parsing");
while (true) {
const std::string raw = buffer()->get_text().raw();
std::map<std::string, std::string> buffers;
notebook_->MapBuffers(&buffers);
buffers[model().file_path()] = raw;
if (model().ReParse(buffers) == 0 &&
raw == buffer()->get_text().raw()) {
break;
}
}
parsing.unlock();
parsing_done();
INFO("Parsing completed");
}
});
parse.detach();
});
parse.detach();
});
}
}
Glib::RefPtr<Gtk::TextBuffer> Source::Controller::buffer() {
return view().get_buffer();
Glib::RefPtr<Gsv::Buffer> Source::Controller::buffer() {
return view().get_source_buffer();
}

2
juci/source.h

@ -152,7 +152,7 @@ namespace Source {
int column,
std::vector<AutoCompleteData>
*suggestions);
Glib::RefPtr<Gtk::TextBuffer> buffer();
Glib::RefPtr<Gsv::Buffer> buffer();
bool is_saved() { return is_saved_; }
bool is_changed() { return is_changed_; }
std::string path() { return model().file_path(); }

Loading…
Cancel
Save