|
|
|
@ -4,179 +4,178 @@ Notebook::Model::Model() { |
|
|
|
cc_extension_ = ".cc"; |
|
|
|
cc_extension_ = ".cc"; |
|
|
|
h_extension_ = ".h"; |
|
|
|
h_extension_ = ".h"; |
|
|
|
scrollvalue_ = 50; |
|
|
|
scrollvalue_ = 50; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Notebook::View::View(){ |
|
|
|
Notebook::View::View() { |
|
|
|
view_.pack2(notebook_); |
|
|
|
view_.pack2(notebook_); |
|
|
|
view_.set_position(120); |
|
|
|
view_.set_position(120); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Notebook::Controller::Controller(Keybindings::Controller& keybindings, |
|
|
|
Notebook::Controller::Controller(Keybindings::Controller& keybindings, |
|
|
|
Source::Config& source_cfg, |
|
|
|
Source::Config& source_cfg, |
|
|
|
Directories::Config& dir_cfg) : |
|
|
|
Directories::Config& dir_cfg) : |
|
|
|
source_config_(source_cfg), |
|
|
|
source_config_(source_cfg), |
|
|
|
directories_(dir_cfg) {
|
|
|
|
directories_(dir_cfg) { |
|
|
|
OnNewPage("juCi++"); |
|
|
|
OnNewPage("juCi++"); |
|
|
|
refClipboard_ = Gtk::Clipboard::get(); |
|
|
|
refClipboard_ = Gtk::Clipboard::get(); |
|
|
|
view().pack1(directories_.widget(),true,true); |
|
|
|
view().pack1(directories_.widget(), true, true); |
|
|
|
CreateKeybindings(keybindings); |
|
|
|
CreateKeybindings(keybindings); |
|
|
|
|
|
|
|
} // Constructor
|
|
|
|
}// Constructor
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Notebook::Controller::CreateKeybindings(Keybindings::Controller |
|
|
|
void Notebook::Controller::CreateKeybindings(Keybindings::Controller |
|
|
|
&keybindings){ |
|
|
|
&keybindings) { |
|
|
|
directories().m_TreeView.signal_row_activated() |
|
|
|
directories().m_TreeView.signal_row_activated() |
|
|
|
.connect(sigc::mem_fun(*this, |
|
|
|
.connect(sigc::mem_fun(*this, |
|
|
|
&Notebook::Controller::OnDirectoryNavigation)); |
|
|
|
&Notebook::Controller::OnDirectoryNavigation)); |
|
|
|
|
|
|
|
|
|
|
|
keybindings.action_group_menu()-> |
|
|
|
keybindings.action_group_menu()-> |
|
|
|
add(Gtk::Action::create("FileMenu", |
|
|
|
add(Gtk::Action::create("FileMenu", |
|
|
|
Gtk::Stock::FILE)); |
|
|
|
Gtk::Stock::FILE)); |
|
|
|
|
|
|
|
|
|
|
|
keybindings.action_group_menu()-> |
|
|
|
keybindings.action_group_menu()-> |
|
|
|
add(Gtk::Action::create("FileNewStandard", |
|
|
|
add(Gtk::Action::create("FileNewStandard", |
|
|
|
Gtk::Stock::NEW, |
|
|
|
Gtk::Stock::NEW, |
|
|
|
"New empty file", |
|
|
|
"New empty file", |
|
|
|
"Create a new file"), |
|
|
|
"Create a new file"), |
|
|
|
[this]() { |
|
|
|
[this]() { |
|
|
|
is_new_file_ = true; |
|
|
|
is_new_file_ = true; |
|
|
|
OnFileNewEmptyfile(); |
|
|
|
OnFileNewEmptyfile(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
keybindings.action_group_menu()-> |
|
|
|
keybindings.action_group_menu()-> |
|
|
|
add(Gtk::Action::create("FileNewCC", |
|
|
|
add(Gtk::Action::create("FileNewCC", |
|
|
|
"New cc file"), |
|
|
|
"New cc file"), |
|
|
|
Gtk::AccelKey(keybindings.config_ |
|
|
|
Gtk::AccelKey(keybindings.config_ |
|
|
|
.key_map()["new_cc_file"]), |
|
|
|
.key_map()["new_cc_file"]), |
|
|
|
[this]() { |
|
|
|
[this]() { |
|
|
|
is_new_file_ = true; |
|
|
|
is_new_file_ = true; |
|
|
|
OnFileNewCCFile(); |
|
|
|
OnFileNewCCFile(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
keybindings.action_group_menu()-> |
|
|
|
keybindings.action_group_menu()-> |
|
|
|
add(Gtk::Action::create("FileNewH", |
|
|
|
add(Gtk::Action::create("FileNewH", |
|
|
|
"New h file"), |
|
|
|
"New h file"), |
|
|
|
Gtk::AccelKey(keybindings.config_ |
|
|
|
Gtk::AccelKey(keybindings.config_ |
|
|
|
.key_map()["new_h_file"]), |
|
|
|
.key_map()["new_h_file"]), |
|
|
|
[this]() { |
|
|
|
[this]() { |
|
|
|
is_new_file_ = true; |
|
|
|
is_new_file_ = true; |
|
|
|
OnFileNewHeaderFile(); |
|
|
|
OnFileNewHeaderFile(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
keybindings.action_group_menu()-> |
|
|
|
keybindings.action_group_menu()-> |
|
|
|
add(Gtk::Action::create("WindowCloseTab", |
|
|
|
add(Gtk::Action::create("WindowCloseTab", |
|
|
|
"Close tab"), |
|
|
|
"Close tab"), |
|
|
|
Gtk::AccelKey(keybindings.config_ |
|
|
|
Gtk::AccelKey(keybindings.config_ |
|
|
|
.key_map()["close_tab"]), |
|
|
|
.key_map()["close_tab"]), |
|
|
|
[this]() { |
|
|
|
[this]() { |
|
|
|
OnCloseCurrentPage(); |
|
|
|
OnCloseCurrentPage(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
keybindings.action_group_menu()-> |
|
|
|
keybindings.action_group_menu()-> |
|
|
|
add(Gtk::Action::create("EditFind", |
|
|
|
add(Gtk::Action::create("EditFind", |
|
|
|
Gtk::Stock::FIND), |
|
|
|
Gtk::Stock::FIND), |
|
|
|
[this]() { |
|
|
|
[this]() { |
|
|
|
is_new_file_ = false; |
|
|
|
is_new_file_ = false; |
|
|
|
OnEditSearch(); |
|
|
|
OnEditSearch(); |
|
|
|
//TODO(Oyvang, Zalox, Forgi)Create function OnEditFind();
|
|
|
|
// TODO(Oyvang) Zalox, Forgi)Create function OnEditFind();
|
|
|
|
}); |
|
|
|
}); |
|
|
|
keybindings.action_group_menu()-> |
|
|
|
keybindings.action_group_menu()-> |
|
|
|
add(Gtk::Action::create("EditCopy", |
|
|
|
add(Gtk::Action::create("EditCopy", |
|
|
|
Gtk::Stock::COPY),
|
|
|
|
Gtk::Stock::COPY), |
|
|
|
[this]() { |
|
|
|
[this]() { |
|
|
|
OnEditCopy(); |
|
|
|
OnEditCopy(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
keybindings.action_group_menu()-> |
|
|
|
keybindings.action_group_menu()-> |
|
|
|
add(Gtk::Action::create("EditCut", |
|
|
|
add(Gtk::Action::create("EditCut", |
|
|
|
Gtk::Stock::CUT), |
|
|
|
Gtk::Stock::CUT), |
|
|
|
[this]() { |
|
|
|
[this]() { |
|
|
|
OnEditCut(); |
|
|
|
OnEditCut(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
keybindings.action_group_menu()-> |
|
|
|
keybindings.action_group_menu()-> |
|
|
|
add(Gtk::Action::create("EditPaste", |
|
|
|
add(Gtk::Action::create("EditPaste", |
|
|
|
Gtk::Stock::PASTE), |
|
|
|
Gtk::Stock::PASTE), |
|
|
|
[this]() { |
|
|
|
[this]() { |
|
|
|
OnEditPaste(); |
|
|
|
OnEditPaste(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
keybindings.action_group_hidden()-> |
|
|
|
keybindings.action_group_hidden()-> |
|
|
|
add(Gtk::Action::create("EditPaste", |
|
|
|
add(Gtk::Action::create("EditPaste", |
|
|
|
Gtk::Stock::PASTE), |
|
|
|
Gtk::Stock::PASTE), |
|
|
|
[this]() { |
|
|
|
[this]() { |
|
|
|
OnEditPaste(); |
|
|
|
OnEditPaste(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
entry_.view_.entry().signal_activate(). |
|
|
|
entry_.view_.entry().signal_activate(). |
|
|
|
connect( |
|
|
|
connect( |
|
|
|
[this]() { |
|
|
|
[this]() { |
|
|
|
if(is_new_file_){ |
|
|
|
if (is_new_file_) { |
|
|
|
OnNewPage(entry_.text()); |
|
|
|
OnNewPage(entry_.text()); |
|
|
|
entry_.OnHideEntries(is_new_file_); |
|
|
|
entry_.OnHideEntries(is_new_file_); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
Search(true); |
|
|
|
Search(true); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
entry_.button_apply().signal_clicked(). |
|
|
|
entry_.button_apply().signal_clicked(). |
|
|
|
connect( |
|
|
|
connect( |
|
|
|
[this]() {
|
|
|
|
[this]() { |
|
|
|
OnNewPage(entry_.text()); |
|
|
|
OnNewPage(entry_.text()); |
|
|
|
entry_.OnHideEntries(is_new_file_);
|
|
|
|
entry_.OnHideEntries(is_new_file_); |
|
|
|
}); |
|
|
|
}); |
|
|
|
entry_.button_close().signal_clicked(). |
|
|
|
entry_.button_close().signal_clicked(). |
|
|
|
connect( |
|
|
|
connect( |
|
|
|
[this]() {
|
|
|
|
[this]() { |
|
|
|
entry_.OnHideEntries(is_new_file_);
|
|
|
|
entry_.OnHideEntries(is_new_file_); |
|
|
|
}); |
|
|
|
}); |
|
|
|
entry_.button_next().signal_clicked(). |
|
|
|
entry_.button_next().signal_clicked(). |
|
|
|
connect( |
|
|
|
connect( |
|
|
|
[this]() {
|
|
|
|
[this]() { |
|
|
|
Search(true);
|
|
|
|
Search(true); |
|
|
|
}); |
|
|
|
}); |
|
|
|
entry_.button_prev().signal_clicked(). |
|
|
|
entry_.button_prev().signal_clicked(). |
|
|
|
connect( |
|
|
|
connect( |
|
|
|
[this]() {
|
|
|
|
[this]() { |
|
|
|
Search(false);
|
|
|
|
Search(false); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Notebook::Controller::GeneratePopup(std::vector<string> items){ |
|
|
|
void Notebook::Controller::GeneratePopup(std::vector<string> items) { |
|
|
|
Gtk::ScrolledWindow popup_scroll_; |
|
|
|
Gtk::ScrolledWindow popup_scroll_; |
|
|
|
Gtk::ListViewText listview_(1,false,Gtk::SelectionMode::SELECTION_SINGLE); |
|
|
|
Gtk::ListViewText listview_(1, false, Gtk::SelectionMode::SELECTION_SINGLE); |
|
|
|
Gtk::Dialog popup_("",true); |
|
|
|
Gtk::Dialog popup_("", true); |
|
|
|
listview_.set_enable_search(false); |
|
|
|
listview_.set_enable_search(false); |
|
|
|
listview_.set_hscroll_policy(Gtk::ScrollablePolicy::SCROLL_NATURAL); |
|
|
|
listview_.set_hscroll_policy(Gtk::ScrollablePolicy::SCROLL_NATURAL); |
|
|
|
listview_.set_activate_on_single_click(true); |
|
|
|
listview_.set_activate_on_single_click(true); |
|
|
|
listview_.signal_row_activated(). |
|
|
|
listview_.signal_row_activated(). |
|
|
|
connect([this, &listview_, &popup_](const Gtk::TreeModel::Path& path, |
|
|
|
connect([this, &listview_, &popup_](const Gtk::TreeModel::Path& path, |
|
|
|
Gtk::TreeViewColumn*) { |
|
|
|
Gtk::TreeViewColumn*) { |
|
|
|
std::string t = listview_.get_text(listview_.get_selected()[0]); |
|
|
|
std::string t = listview_.get_text(listview_.get_selected()[0]); |
|
|
|
CurrentTextView().get_buffer()->insert_at_cursor(t); |
|
|
|
CurrentTextView().get_buffer()->insert_at_cursor(t); |
|
|
|
popup_.response(Gtk::RESPONSE_DELETE_EVENT);
|
|
|
|
popup_.response(Gtk::RESPONSE_DELETE_EVENT); |
|
|
|
}); |
|
|
|
}); |
|
|
|
for (auto &i : items) listview_.append(i); |
|
|
|
for (auto &i : items) listview_.append(i); |
|
|
|
listview_.set_headers_visible(false); |
|
|
|
listview_.set_headers_visible(false); |
|
|
|
popup_scroll_.add(listview_);
|
|
|
|
popup_scroll_.add(listview_); |
|
|
|
popup_.get_vbox()->pack_start(popup_scroll_); |
|
|
|
popup_.get_vbox()->pack_start(popup_scroll_); |
|
|
|
popup_.set_size_request(80,80); |
|
|
|
popup_.set_size_request(80, 80); |
|
|
|
popup_.show_all(); |
|
|
|
popup_.show_all(); |
|
|
|
Gdk::Rectangle temp1, temp2; |
|
|
|
Gdk::Rectangle temp1, temp2; |
|
|
|
CurrentTextView(). |
|
|
|
CurrentTextView(). |
|
|
|
get_cursor_locations( |
|
|
|
get_cursor_locations( |
|
|
|
CurrentTextView(). |
|
|
|
CurrentTextView(). |
|
|
|
get_buffer()->get_insert()-> |
|
|
|
get_buffer()->get_insert()-> |
|
|
|
get_iter(), temp1, temp2); |
|
|
|
get_iter(), temp1, temp2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int x = temp1.get_x(); |
|
|
|
int x = temp1.get_x(); |
|
|
|
int y = temp1.get_y(); |
|
|
|
int y = temp1.get_y(); |
|
|
|
text_vec_.at(CurrentPage())-> |
|
|
|
text_vec_.at(CurrentPage())-> |
|
|
|
view().buffer_to_window_coords( |
|
|
|
view().buffer_to_window_coords( |
|
|
|
Gtk::TextWindowType::TEXT_WINDOW_WIDGET, |
|
|
|
Gtk::TextWindowType::TEXT_WINDOW_WIDGET, |
|
|
|
temp2.get_x(), |
|
|
|
temp2.get_x(), |
|
|
|
temp2.get_y(), |
|
|
|
temp2.get_y(), |
|
|
|
x, y); |
|
|
|
x, y); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int widht = Notebook().get_width()-88; |
|
|
|
int widht = Notebook().get_width()-88; |
|
|
|
int height = Notebook().get_height()-180; |
|
|
|
int height = Notebook().get_height()-180; |
|
|
|
if(x>widht){ |
|
|
|
if (x > widht) { |
|
|
|
x = widht; } |
|
|
|
x = widht; } |
|
|
|
if(y>height){ |
|
|
|
if (y > height) { |
|
|
|
y =height; |
|
|
|
y = height; |
|
|
|
} |
|
|
|
} |
|
|
|
popup_.move(x, y+88); |
|
|
|
popup_.move(x, y+88); |
|
|
|
popup_.run(); |
|
|
|
popup_.run(); |
|
|
|
@ -191,7 +190,7 @@ bool Notebook::Controller::ScrollEventCallback(GdkEventScroll* scroll_event) { |
|
|
|
scrolledtext_vec_.at(page)-> |
|
|
|
scrolledtext_vec_.at(page)-> |
|
|
|
get_vscrollbar()->get_adjustment(); |
|
|
|
get_vscrollbar()->get_adjustment(); |
|
|
|
if ( direction_y != 0 ) { |
|
|
|
if ( direction_y != 0 ) { |
|
|
|
int dir_val = direction_y==-1?-model_.scrollvalue_:+model_.scrollvalue_;
|
|
|
|
int dir_val = direction_y == -1 ? -model_.scrollvalue_:+model_.scrollvalue_; |
|
|
|
adj->set_value(adj->get_value()+dir_val); |
|
|
|
adj->set_value(adj->get_value()+dir_val); |
|
|
|
text_vec_.at(page)->view().set_vadjustment(adj); |
|
|
|
text_vec_.at(page)->view().set_vadjustment(adj); |
|
|
|
linenumbers_vec_.at(page)->view().set_vadjustment(adj); |
|
|
|
linenumbers_vec_.at(page)->view().set_vadjustment(adj); |
|
|
|
@ -219,7 +218,7 @@ void Notebook::Controller::OnNewPage(std::string name) { |
|
|
|
Notebook().append_page(*editor_vec_.back(), name); |
|
|
|
Notebook().append_page(*editor_vec_.back(), name); |
|
|
|
Notebook().show_all_children(); |
|
|
|
Notebook().show_all_children(); |
|
|
|
Notebook().set_current_page(Pages()-1); |
|
|
|
Notebook().set_current_page(Pages()-1); |
|
|
|
Notebook().set_focus_child(text_vec_.at(Pages()-1)->view());
|
|
|
|
Notebook().set_focus_child(text_vec_.at(Pages()-1)->view()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Notebook::Controller::OnOpenFile(std::string path) { |
|
|
|
void Notebook::Controller::OnOpenFile(std::string path) { |
|
|
|
@ -235,7 +234,7 @@ void Notebook::Controller::OnOpenFile(std::string path) { |
|
|
|
OnBufferChange(); |
|
|
|
OnBufferChange(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Notebook::Controller::OnCreatePage(){ |
|
|
|
void Notebook::Controller::OnCreatePage() { |
|
|
|
text_vec_.push_back(new Source::Controller(source_config())); |
|
|
|
text_vec_.push_back(new Source::Controller(source_config())); |
|
|
|
linenumbers_vec_.push_back(new Source::Controller(source_config())); |
|
|
|
linenumbers_vec_.push_back(new Source::Controller(source_config())); |
|
|
|
scrolledline_vec_.push_back(new Gtk::ScrolledWindow()); |
|
|
|
scrolledline_vec_.push_back(new Gtk::ScrolledWindow()); |
|
|
|
@ -250,14 +249,15 @@ void Notebook::Controller::OnCreatePage(){ |
|
|
|
scrolledline_vec_.back()->get_vscrollbar()->hide(); |
|
|
|
scrolledline_vec_.back()->get_vscrollbar()->hide(); |
|
|
|
linenumbers_vec_.back()->view().set_editable(false); |
|
|
|
linenumbers_vec_.back()->view().set_editable(false); |
|
|
|
linenumbers_vec_.back()->view().set_sensitive(false); |
|
|
|
linenumbers_vec_.back()->view().set_sensitive(false); |
|
|
|
editor_vec_.back()->pack_start(*scrolledline_vec_.back(),false,false); |
|
|
|
editor_vec_.back()->pack_start(*scrolledline_vec_.back(), false, false); |
|
|
|
editor_vec_.back()->pack_start(*scrolledtext_vec_.back(), true, true); |
|
|
|
editor_vec_.back()->pack_start(*scrolledtext_vec_.back(), true, true); |
|
|
|
BufferChangeHandler(text_vec_.back()->view().get_buffer()); |
|
|
|
BufferChangeHandler(text_vec_.back()->view().get_buffer()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Notebook::Controller::OnCloseCurrentPage() { |
|
|
|
void Notebook::Controller::OnCloseCurrentPage() { |
|
|
|
//TODO (oyvang, zalox, forgi) Save a temp file, in case you close one you dont want to close?
|
|
|
|
// TODO(oyvang) zalox, forgi)
|
|
|
|
if(Pages()!=0){ |
|
|
|
// Save a temp file, in case you close one you dont want to close?
|
|
|
|
|
|
|
|
if (Pages() != 0) { |
|
|
|
int page = CurrentPage(); |
|
|
|
int page = CurrentPage(); |
|
|
|
Notebook().remove_page(page); |
|
|
|
Notebook().remove_page(page); |
|
|
|
delete text_vec_.at(page); |
|
|
|
delete text_vec_.at(page); |
|
|
|
@ -297,24 +297,24 @@ void Notebook::Controller::OnEditCut() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::string Notebook::Controller::GetCursorWord(){ |
|
|
|
std::string Notebook::Controller::GetCursorWord() { |
|
|
|
int page = CurrentPage(); |
|
|
|
int page = CurrentPage(); |
|
|
|
std::string word; |
|
|
|
std::string word; |
|
|
|
Gtk::TextIter start,end; |
|
|
|
Gtk::TextIter start, end; |
|
|
|
start = Buffer(text_vec_.at(page))->get_insert()->get_iter(); |
|
|
|
start = Buffer(text_vec_.at(page))->get_insert()->get_iter(); |
|
|
|
end = Buffer(text_vec_.at(page))->get_insert()->get_iter(); |
|
|
|
end = Buffer(text_vec_.at(page))->get_insert()->get_iter(); |
|
|
|
if(!end.ends_line()) { |
|
|
|
if (!end.ends_line()) { |
|
|
|
while(!end.ends_word()){ |
|
|
|
while (!end.ends_word()) { |
|
|
|
end.forward_char(); |
|
|
|
end.forward_char(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(!start.starts_line()) { |
|
|
|
if (!start.starts_line()) { |
|
|
|
while(!start.starts_word()){ |
|
|
|
while (!start.starts_word()) { |
|
|
|
start.backward_char(); |
|
|
|
start.backward_char(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
word = Buffer(text_vec_.at(page))->get_text(start,end); |
|
|
|
word = Buffer(text_vec_.at(page))->get_text(start, end); |
|
|
|
//TODO(Oyvang)fix selected text
|
|
|
|
// TODO(Oyvang) fix selected text
|
|
|
|
return word; |
|
|
|
return word; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -324,7 +324,7 @@ void Notebook::Controller::OnEditSearch() { |
|
|
|
entry_.OnShowSearch(GetCursorWord()); |
|
|
|
entry_.OnShowSearch(GetCursorWord()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Notebook::Controller::Search(bool forward){ |
|
|
|
void Notebook::Controller::Search(bool forward) { |
|
|
|
int page = CurrentPage(); |
|
|
|
int page = CurrentPage(); |
|
|
|
std::string search_word; |
|
|
|
std::string search_word; |
|
|
|
search_word = entry_.text(); |
|
|
|
search_word = entry_.text(); |
|
|
|
@ -332,25 +332,25 @@ void Notebook::Controller::Search(bool forward){ |
|
|
|
|
|
|
|
|
|
|
|
if ( !forward ) { |
|
|
|
if ( !forward ) { |
|
|
|
if ( search_match_start_ == 0 || |
|
|
|
if ( search_match_start_ == 0 || |
|
|
|
search_match_start_.get_line_offset() == 0) { |
|
|
|
search_match_start_.get_line_offset() == 0) { |
|
|
|
search_match_start_= Buffer(text_vec_.at(CurrentPage()))->end(); |
|
|
|
search_match_start_ = Buffer(text_vec_.at(CurrentPage()))->end(); |
|
|
|
} |
|
|
|
} |
|
|
|
search_match_start_. |
|
|
|
search_match_start_. |
|
|
|
backward_search(search_word, |
|
|
|
backward_search(search_word, |
|
|
|
Gtk::TextSearchFlags::TEXT_SEARCH_TEXT_ONLY | |
|
|
|
Gtk::TextSearchFlags::TEXT_SEARCH_TEXT_ONLY | |
|
|
|
Gtk::TextSearchFlags::TEXT_SEARCH_VISIBLE_ONLY, |
|
|
|
Gtk::TextSearchFlags::TEXT_SEARCH_VISIBLE_ONLY, |
|
|
|
search_match_start_, |
|
|
|
search_match_start_, |
|
|
|
search_match_end_);
|
|
|
|
search_match_end_); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if ( search_match_end_ == 0 ) { |
|
|
|
if ( search_match_end_ == 0 ) { |
|
|
|
search_match_end_= Buffer(text_vec_.at(CurrentPage()))->begin(); |
|
|
|
search_match_end_ = Buffer(text_vec_.at(CurrentPage()))->begin(); |
|
|
|
} |
|
|
|
} |
|
|
|
search_match_end_. |
|
|
|
search_match_end_. |
|
|
|
forward_search(search_word, |
|
|
|
forward_search(search_word, |
|
|
|
Gtk::TextSearchFlags::TEXT_SEARCH_TEXT_ONLY | |
|
|
|
Gtk::TextSearchFlags::TEXT_SEARCH_TEXT_ONLY | |
|
|
|
Gtk::TextSearchFlags::TEXT_SEARCH_VISIBLE_ONLY, |
|
|
|
Gtk::TextSearchFlags::TEXT_SEARCH_VISIBLE_ONLY, |
|
|
|
search_match_start_, |
|
|
|
search_match_start_, |
|
|
|
search_match_end_); |
|
|
|
search_match_end_); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -358,38 +358,38 @@ void Notebook::Controller::OnBufferChange() { |
|
|
|
int page = CurrentPage(); |
|
|
|
int page = CurrentPage(); |
|
|
|
int text_nr = Buffer(text_vec_.at(page))->get_line_count(); |
|
|
|
int text_nr = Buffer(text_vec_.at(page))->get_line_count(); |
|
|
|
int line_nr = Buffer(linenumbers_vec_.at(page))->get_line_count(); |
|
|
|
int line_nr = Buffer(linenumbers_vec_.at(page))->get_line_count(); |
|
|
|
while (line_nr < text_nr ){ |
|
|
|
while (line_nr < text_nr) { |
|
|
|
line_nr++; |
|
|
|
line_nr++; |
|
|
|
Buffer(linenumbers_vec_.at(page))-> |
|
|
|
Buffer(linenumbers_vec_.at(page))-> |
|
|
|
insert(Buffer(linenumbers_vec_.at(page))->end(), |
|
|
|
insert(Buffer(linenumbers_vec_.at(page))->end(), |
|
|
|
"\n"+std::to_string(line_nr)+" "); |
|
|
|
"\n"+std::to_string(line_nr)+" "); |
|
|
|
} |
|
|
|
} |
|
|
|
while (line_nr > text_nr ){ |
|
|
|
while (line_nr > text_nr) { |
|
|
|
Gtk::TextIter iter = Buffer(linenumbers_vec_.at(page))->get_iter_at_line(line_nr); |
|
|
|
Gtk::TextIter iter = |
|
|
|
|
|
|
|
Buffer(linenumbers_vec_.at(page))->get_iter_at_line(line_nr); |
|
|
|
iter.backward_char(); |
|
|
|
iter.backward_char(); |
|
|
|
line_nr--; |
|
|
|
line_nr--; |
|
|
|
Buffer(linenumbers_vec_.at(page))-> |
|
|
|
Buffer(linenumbers_vec_.at(page))-> |
|
|
|
erase(iter, |
|
|
|
erase(iter, |
|
|
|
Buffer(linenumbers_vec_.at(page))->end()); |
|
|
|
Buffer(linenumbers_vec_.at(page))->end()); |
|
|
|
} |
|
|
|
} |
|
|
|
if(Buffer(text_vec_.at(page))->get_insert()->get_iter().starts_line() && |
|
|
|
if (Buffer(text_vec_.at(page))->get_insert()->get_iter().starts_line() && |
|
|
|
Buffer(text_vec_.at(page))->get_insert()->get_iter().get_line() == |
|
|
|
Buffer(text_vec_.at(page))->get_insert()->get_iter().get_line() == |
|
|
|
Buffer(text_vec_.at(page))->end().get_line()) { |
|
|
|
Buffer(text_vec_.at(page))->end().get_line()) { |
|
|
|
|
|
|
|
|
|
|
|
GdkEventScroll* scroll = new GdkEventScroll; |
|
|
|
GdkEventScroll* scroll = new GdkEventScroll; |
|
|
|
scroll->delta_y = 1.0; |
|
|
|
scroll->delta_y = 1.0; |
|
|
|
scroll->delta_x = 0.0; |
|
|
|
scroll->delta_x = 0.0; |
|
|
|
ScrollEventCallback(scroll); |
|
|
|
ScrollEventCallback(scroll); |
|
|
|
delete scroll; |
|
|
|
delete scroll; |
|
|
|
} |
|
|
|
} |
|
|
|
Gtk::TextIter start,end; |
|
|
|
Gtk::TextIter start, end; |
|
|
|
std::string word; |
|
|
|
std::string word; |
|
|
|
start = Buffer(text_vec_.at(page))->get_insert()->get_iter(); |
|
|
|
start = Buffer(text_vec_.at(page))->get_insert()->get_iter(); |
|
|
|
end = Buffer(text_vec_.at(page))->get_insert()->get_iter(); |
|
|
|
end = Buffer(text_vec_.at(page))->get_insert()->get_iter(); |
|
|
|
start.backward_char(); |
|
|
|
start.backward_char(); |
|
|
|
word = Buffer(text_vec_.at(page))->get_text(start,end); |
|
|
|
word = Buffer(text_vec_.at(page))->get_text(start, end); |
|
|
|
if( word == "."){ |
|
|
|
if (word == ".") { |
|
|
|
//TODO(Oyvang,Zalox,Forgie) Remove TEST
|
|
|
|
// TODO(Forgie) Zalox,Forgie) Remove TEST
|
|
|
|
std::vector<std::string> TEST; |
|
|
|
std::vector<std::string> TEST; |
|
|
|
TEST.push_back("toString()"); |
|
|
|
TEST.push_back("toString()"); |
|
|
|
TEST.push_back("toLower()"); |
|
|
|
TEST.push_back("toLower()"); |
|
|
|
@ -401,11 +401,12 @@ void Notebook::Controller::OnBufferChange() { |
|
|
|
} |
|
|
|
} |
|
|
|
void Notebook::Controller |
|
|
|
void Notebook::Controller |
|
|
|
::OnDirectoryNavigation(const Gtk::TreeModel::Path& path, |
|
|
|
::OnDirectoryNavigation(const Gtk::TreeModel::Path& path, |
|
|
|
Gtk::TreeViewColumn* column) { |
|
|
|
Gtk::TreeViewColumn* column) { |
|
|
|
Gtk::TreeModel::iterator iter = directories().m_refTreeModel->get_iter(path); |
|
|
|
Gtk::TreeModel::iterator iter = directories().m_refTreeModel->get_iter(path); |
|
|
|
if(iter) { |
|
|
|
if (iter) { |
|
|
|
Gtk::TreeModel::Row row = *iter; |
|
|
|
Gtk::TreeModel::Row row = *iter; |
|
|
|
boost::filesystem::path fs_path(Glib::ustring(row[directories().view().m_col_path])); |
|
|
|
std::string upath = Glib::ustring(row[directories().view().m_col_path]); |
|
|
|
|
|
|
|
boost::filesystem::path fs_path(upath); |
|
|
|
if (boost::filesystem::is_directory(fs_path)) { |
|
|
|
if (boost::filesystem::is_directory(fs_path)) { |
|
|
|
directories().m_TreeView.row_expanded(path) ? |
|
|
|
directories().m_TreeView.row_expanded(path) ? |
|
|
|
directories().m_TreeView.collapse_row(path) : |
|
|
|
directories().m_TreeView.collapse_row(path) : |
|
|
|
@ -428,7 +429,7 @@ int Notebook::Controller::CurrentPage() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Glib::RefPtr<Gtk::TextBuffer> |
|
|
|
Glib::RefPtr<Gtk::TextBuffer> |
|
|
|
Notebook::Controller::Buffer( Source::Controller *source ) { |
|
|
|
Notebook::Controller::Buffer(Source::Controller *source) { |
|
|
|
return source->view().get_buffer(); |
|
|
|
return source->view().get_buffer(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -440,10 +441,10 @@ Gtk::Notebook& Notebook::Controller::Notebook() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Notebook::Controller::BufferChangeHandler(Glib::RefPtr<Gtk::TextBuffer> |
|
|
|
void Notebook::Controller::BufferChangeHandler(Glib::RefPtr<Gtk::TextBuffer> |
|
|
|
buffer) { |
|
|
|
buffer) { |
|
|
|
buffer->signal_changed().connect( |
|
|
|
buffer->signal_changed().connect( |
|
|
|
[this]() { |
|
|
|
[this]() { |
|
|
|
OnBufferChange(); |
|
|
|
OnBufferChange(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|