Search is back
This commit is contained in:
parent
0d79b55112
commit
2e974251fa
@ -1090,46 +1090,41 @@ void BufferText::Search(etk::UString &data, bool back, bool caseSensitive, bool
|
||||
APPL_WARNING("no search data");
|
||||
return;
|
||||
}
|
||||
etk::VectorType<uniChar_t> mVectSearch;
|
||||
mVectSearch = data.GetVector();
|
||||
APPL_TODO("Remove for now ...");
|
||||
/*
|
||||
if (false == back) {
|
||||
//APPL_INFO("search data Forward : startSearchPos=" << startSearchPos );
|
||||
int32_t foundPos;
|
||||
bool findSomething = m_EdnBuf.SearchForward(startSearchPos, mVectSearch, &foundPos, caseSensitive);
|
||||
int32_t foundPosEnd;
|
||||
bool findSomething = m_EdnBuf.SearchForward(startSearchPos, data, &foundPos, &foundPosEnd, caseSensitive);
|
||||
if( false == findSomething
|
||||
&& true == wrap)
|
||||
{
|
||||
//APPL_INFO("WrapMode !!! 0 ==> end");
|
||||
findSomething = m_EdnBuf.SearchForward(0, mVectSearch, &foundPos, caseSensitive);
|
||||
findSomething = m_EdnBuf.SearchForward(0, data, &foundPos, &foundPosEnd, caseSensitive);
|
||||
}
|
||||
// if find data :
|
||||
if (true == findSomething) {
|
||||
// select new position
|
||||
int32_t endSelectionPos = foundPos+mVectSearch.Size();
|
||||
SetInsertPosition(endSelectionPos);
|
||||
m_EdnBuf.Select(SELECTION_PRIMARY, foundPos, endSelectionPos);
|
||||
SetInsertPosition(foundPosEnd);
|
||||
m_EdnBuf.Select(SELECTION_PRIMARY, foundPos, foundPosEnd);
|
||||
}
|
||||
} else {
|
||||
//APPL_INFO("search data Backward : " << data.GetDirectPointer() );
|
||||
int32_t foundPos;
|
||||
bool findSomething = m_EdnBuf.SearchBackward(startSearchPos, mVectSearch, &foundPos, caseSensitive);
|
||||
int32_t foundPosEnd;
|
||||
bool findSomething = m_EdnBuf.SearchBackward(startSearchPos, data, &foundPos, &foundPosEnd, caseSensitive);
|
||||
if( false == findSomething
|
||||
&& true == wrap)
|
||||
{
|
||||
//APPL_INFO("WrapMode !!! end ==> 0");
|
||||
findSomething = m_EdnBuf.SearchBackward(m_EdnBuf.Size(), mVectSearch, &foundPos, caseSensitive);
|
||||
findSomething = m_EdnBuf.SearchBackward(m_EdnBuf.Size(), data, &foundPos, &foundPosEnd, caseSensitive);
|
||||
}
|
||||
// if find data :
|
||||
if (true == findSomething) {
|
||||
// select new position
|
||||
int32_t endSelectionPos = foundPos+mVectSearch.Size();
|
||||
SetInsertPosition(foundPos);
|
||||
m_EdnBuf.Select(SELECTION_PRIMARY, foundPos, endSelectionPos);
|
||||
m_EdnBuf.Select(SELECTION_PRIMARY, foundPos, foundPosEnd);
|
||||
}
|
||||
}
|
||||
*/
|
||||
m_centerRequested = true;
|
||||
RequestUpdateOfThePosition();
|
||||
}
|
||||
|
@ -986,13 +986,25 @@ bool EdnBuf::charMatch(char first, char second, bool caseSensitive)
|
||||
* @return false ==> not found data
|
||||
*
|
||||
*/
|
||||
bool EdnBuf::SearchForward(int32_t startPos, etk::VectorType<int8_t> &searchVect, int32_t *foundPos, bool caseSensitive)
|
||||
bool EdnBuf::SearchForward(int32_t startPos, etk::UString &search, int32_t *foundPos, int32_t *foundPosEnd, bool caseSensitive)
|
||||
{
|
||||
etk::VectorType<int8_t> searchVect;
|
||||
if (true == m_isUtf8) {
|
||||
char * tmpPointer = search.Utf8Data();
|
||||
while (*tmpPointer != '\0') {
|
||||
searchVect.PushBack(*tmpPointer++);
|
||||
}
|
||||
} else {
|
||||
etk::VectorType<unsigned int> tmppp = search.GetVector();
|
||||
convertUnicodeToIso(m_charsetType, tmppp, searchVect);
|
||||
}
|
||||
// remove the '\0' at the end of the string ...
|
||||
searchVect.PopBack();
|
||||
int32_t position;
|
||||
int32_t searchLen = searchVect.Size();
|
||||
int32_t dataLen = m_data.Size();
|
||||
char currentChar = '\0';
|
||||
//APPL_INFO(" startPos=" << startPos << " searchLen=" << searchLen);
|
||||
APPL_INFO(" startPos=" << startPos << " searchLen=" << searchLen);
|
||||
for (position=startPos; position<dataLen - (searchLen-1); position++) {
|
||||
currentChar = m_data[position];
|
||||
if (true == charMatch(currentChar, searchVect[0], caseSensitive)) {
|
||||
@ -1007,11 +1019,13 @@ bool EdnBuf::SearchForward(int32_t startPos, etk::VectorType<int8_t> &searchVect
|
||||
}
|
||||
if (true == found) {
|
||||
*foundPos = position;
|
||||
*foundPosEnd = position + searchVect.Size();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
*foundPos = m_data.Size();
|
||||
*foundPosEnd = m_data.Size();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1027,8 +1041,21 @@ bool EdnBuf::SearchForward(int32_t startPos, etk::VectorType<int8_t> &searchVect
|
||||
* @return false ==> not found data
|
||||
*
|
||||
*/
|
||||
bool EdnBuf::SearchBackward(int32_t startPos, etk::VectorType<int8_t> &searchVect, int32_t *foundPos, bool caseSensitive)
|
||||
bool EdnBuf::SearchBackward(int32_t startPos, etk::UString &search, int32_t *foundPos, int32_t *foundPosEnd, bool caseSensitive)
|
||||
{
|
||||
etk::VectorType<int8_t> searchVect;
|
||||
if (true == m_isUtf8) {
|
||||
char * tmpPointer = search.Utf8Data();
|
||||
while (*tmpPointer != '\0') {
|
||||
searchVect.PushBack(*tmpPointer++);
|
||||
}
|
||||
} else {
|
||||
etk::VectorType<unsigned int> tmppp = search.GetVector();
|
||||
convertUnicodeToIso(m_charsetType, tmppp, searchVect);
|
||||
}
|
||||
// remove the '\0' at the end of the string ...
|
||||
searchVect.PopBack();
|
||||
|
||||
int32_t position;
|
||||
int32_t searchLen = searchVect.Size();
|
||||
char currentChar = '\0';
|
||||
@ -1047,11 +1074,13 @@ bool EdnBuf::SearchBackward(int32_t startPos, etk::VectorType<int8_t> &searchVec
|
||||
}
|
||||
if (true == found) {
|
||||
*foundPos = position - (searchLen-1);
|
||||
*foundPosEnd = position + searchVect.Size();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
*foundPos = m_data.Size();
|
||||
*foundPosEnd = m_data.Size();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -115,8 +115,8 @@ class EdnBuf {
|
||||
int32_t CountForwardNLines( int32_t startPos, int32_t nLines);
|
||||
int32_t CountBackwardNLines( int32_t startPos, int32_t nLines);
|
||||
|
||||
bool SearchForward( int32_t startPos, etk::VectorType<int8_t> &searchVect, int32_t *foundPos, bool caseSensitive = true);
|
||||
bool SearchBackward( int32_t startPos, etk::VectorType<int8_t> &searchVect, int32_t *foundPos, bool caseSensitive = true);
|
||||
bool SearchForward( int32_t startPos, etk::UString &search, int32_t *foundPos, int32_t *foundPosEnd, bool caseSensitive = true);
|
||||
bool SearchBackward( int32_t startPos, etk::UString &search, int32_t *foundPos, int32_t *foundPosEnd, bool caseSensitive = true);
|
||||
bool SearchForward( int32_t startPos, char searchChar, int32_t *foundPos);
|
||||
bool SearchBackward( int32_t startPos, char searchChar, int32_t *foundPos);
|
||||
bool SelectAround( int32_t startPos, int32_t &beginPos, int32_t &endPos);
|
||||
|
@ -72,6 +72,8 @@ CodeView::CodeView(void)
|
||||
RegisterMultiCast(ednMsgGuiRm);
|
||||
RegisterMultiCast(ednMsgGuiSelect);
|
||||
RegisterMultiCast(ednMsgGuiChangeCharset);
|
||||
RegisterMultiCast(ednMsgGuiFind);
|
||||
RegisterMultiCast(ednMsgGuiReplace);
|
||||
}
|
||||
|
||||
CodeView::~CodeView(void)
|
||||
@ -376,33 +378,26 @@ void CodeView::OnReceiveMessage(ewol::EObject * CallerObject, const char * event
|
||||
} else {
|
||||
APPL_ERROR(" on event " << eventId << " unknow data=\"" << data << "\"" );
|
||||
}
|
||||
} else if (eventId == ednMsgGuiFind) {
|
||||
etk::UString myDataString;
|
||||
SearchData::GetSearch(myDataString);
|
||||
if (data == "Next") {
|
||||
BufferManager::Get(m_bufferID)->Search(myDataString, false, SearchData::GetCase(), SearchData::GetWrap(), SearchData::GetRegExp() );
|
||||
} else if (data == "Previous") {
|
||||
BufferManager::Get(m_bufferID)->Search(myDataString, true, SearchData::GetCase(), SearchData::GetWrap(), SearchData::GetRegExp() );
|
||||
}
|
||||
} else if (eventId == ednMsgGuiReplace) {
|
||||
etk::UString myDataString;
|
||||
SearchData::GetReplace(myDataString);
|
||||
if (data == "Normal") {
|
||||
BufferManager::Get(m_bufferID)->Replace(myDataString);
|
||||
} else if (data == "All") {
|
||||
|
||||
}
|
||||
}
|
||||
/*
|
||||
switch (id)
|
||||
{
|
||||
case APPL_MSG__CURRENT_FIND_PREVIOUS:
|
||||
{
|
||||
etk::UString myDataString;
|
||||
SearchData::GetSearch(myDataString);
|
||||
BufferManager::Get(m_bufferID)->Search(myDataString, true, SearchData::GetCase(), SearchData::GetWrap(), SearchData::GetRegExp() );
|
||||
}
|
||||
break;
|
||||
case APPL_MSG__CURRENT_FIND_NEXT:
|
||||
{
|
||||
etk::UString myDataString;
|
||||
SearchData::GetSearch(myDataString);
|
||||
BufferManager::Get(m_bufferID)->Search(myDataString, false, SearchData::GetCase(), SearchData::GetWrap(), SearchData::GetRegExp() );
|
||||
}
|
||||
break;
|
||||
case APPL_MSG__CURRENT_REPLACE:
|
||||
{
|
||||
etk::UString myDataString;
|
||||
SearchData::GetReplace(myDataString);
|
||||
BufferManager::Get(m_bufferID)->Replace(myDataString);
|
||||
}
|
||||
break;
|
||||
case APPL_MSG__CURRENT_REPLACE_ALL:
|
||||
break;
|
||||
case APPL_MSG__CURRENT_GOTO_LINE:
|
||||
if (dataID<0) {
|
||||
dataID = 0;
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <MainWindows.h>
|
||||
#include <CodeView.h>
|
||||
#include <BufferView.h>
|
||||
#include <Search.h>
|
||||
|
||||
#include <ewol/widget/Button.h>
|
||||
#include <ewol/widget/CheckBox.h>
|
||||
@ -47,12 +48,13 @@
|
||||
#undef __class__
|
||||
#define __class__ "MainWindows"
|
||||
|
||||
extern const char * const TYPE_EOBJECT_EDN_MAIN_WINDOWS = "MainWindows";
|
||||
extern const char * const TYPE_EOBJECT_EDN_MAIN_WINDOWS = __class__;
|
||||
|
||||
MainWindows::MainWindows(void)
|
||||
{
|
||||
APPL_DEBUG("CREATE WINDOWS ... ");
|
||||
ewol::SizerVert * mySizerVert = NULL;
|
||||
ewol::SizerVert * mySizerVert2 = NULL;
|
||||
ewol::SizerHori * mySizerHori = NULL;
|
||||
//ewol::Button * myButton = NULL;
|
||||
CodeView * myCodeView = NULL;
|
||||
@ -124,25 +126,25 @@ MainWindows::MainWindows(void)
|
||||
myBufferView->SetFillX(true);
|
||||
myBufferView->SetFillY(true);
|
||||
mySizerHori->SubWidgetAdd(myBufferView);
|
||||
myCodeView = new CodeView();
|
||||
myCodeView->SetExpendX(true);
|
||||
myCodeView->SetExpendY(true);
|
||||
myCodeView->SetFillX(true);
|
||||
myCodeView->SetFillY(true);
|
||||
|
||||
myCodeView->SetFontSize(11);
|
||||
myCodeView->SetFontNameNormal( "freefont/FreeMono.ttf");
|
||||
myCodeView->SetFontNameBold( "freefont/FreeMonoBold.ttf");
|
||||
myCodeView->SetFontNameItalic( "freefont/FreeMonoOblique.ttf");
|
||||
myCodeView->SetFontNameBoldItalic("freefont/FreeMonoBoldOblique.ttf");
|
||||
/*
|
||||
myCodeView->SetFontSize(11);
|
||||
myCodeView->SetFontNameNormal( "ubuntu/UbuntuMono-R.ttf");
|
||||
myCodeView->SetFontNameBold( "ubuntu/UbuntuMono-B.ttf");
|
||||
myCodeView->SetFontNameItalic( "ubuntu/UbuntuMono-RI.ttf");
|
||||
myCodeView->SetFontNameBoldItalic("ubuntu/UbuntuMono-BI.ttf");
|
||||
*/
|
||||
mySizerHori->SubWidgetAdd(myCodeView);
|
||||
mySizerVert2 = new ewol::SizerVert();
|
||||
mySizerHori->SubWidgetAdd(mySizerVert2);
|
||||
// search area :
|
||||
Search * mySearch = new Search();
|
||||
mySizerVert2->SubWidgetAdd(mySearch);
|
||||
|
||||
// main buffer Area :
|
||||
myCodeView = new CodeView();
|
||||
myCodeView->SetExpendX(true);
|
||||
myCodeView->SetExpendY(true);
|
||||
myCodeView->SetFillX(true);
|
||||
myCodeView->SetFillY(true);
|
||||
myCodeView->SetFontSize(11);
|
||||
myCodeView->SetFontNameNormal( "freefont/FreeMono.ttf");
|
||||
myCodeView->SetFontNameBold( "freefont/FreeMonoBold.ttf");
|
||||
myCodeView->SetFontNameItalic( "freefont/FreeMonoOblique.ttf");
|
||||
myCodeView->SetFontNameBoldItalic("freefont/FreeMonoBoldOblique.ttf");
|
||||
mySizerVert2->SubWidgetAdd(myCodeView);
|
||||
|
||||
// Generic event ...
|
||||
RegisterMultiCast(ednMsgGuiSaveAs);
|
||||
|
@ -31,221 +31,175 @@
|
||||
#include "MainWindows.h"
|
||||
#include "appl/globalMsg.h"
|
||||
|
||||
#include <ewol/widget/Button.h>
|
||||
#include <ewol/widget/CheckBox.h>
|
||||
#include <ewol/widget/SizerHori.h>
|
||||
#include <ewol/widget/SizerVert.h>
|
||||
#include <ewol/widget/Label.h>
|
||||
#include <ewol/widget/Entry.h>
|
||||
#include <ewol/widget/List.h>
|
||||
#include <ewol/widget/ContextMenu.h>
|
||||
#include <ewol/widget/PopUp.h>
|
||||
#include <ewol/widget/Spacer.h>
|
||||
#include <ewol/widget/Menu.h>
|
||||
#include <ewol/widgetMeta/FileChooser.h>
|
||||
#include <ewol/WidgetManager.h>
|
||||
#include <ewol/EObject.h>
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Search"
|
||||
|
||||
extern const char * const TYPE_EOBJECT_APPL_SEARCH = __class__;
|
||||
|
||||
|
||||
const char* const l_eventSearchEntry = "appl-search-entry";
|
||||
const char* const l_eventReplaceEntry = "appl-replace-entry";
|
||||
const char* const l_eventSearchBt = "appl-search-button";
|
||||
const char* const l_eventReplaceBt = "appl-replace-button";
|
||||
const char* const l_eventCaseCb = "appl-case-sensitive-CheckBox";
|
||||
const char* const l_eventWrapCb = "appl-wrap-CheckBox";
|
||||
const char* const l_eventForwardCb = "appl-forward-CheckBox";
|
||||
const char* const l_eventHideBt = "appl-hide-button";
|
||||
|
||||
Search::Search(void)
|
||||
/*: m_localDialog(NULL),
|
||||
m_searchLabel(NULL),
|
||||
m_searchEntry(NULL),
|
||||
m_replaceLabel(NULL),
|
||||
m_replaceEntry(NULL),
|
||||
m_CkMatchCase(NULL),
|
||||
m_CkWrapAround(NULL) */
|
||||
{
|
||||
// nothing to do ...
|
||||
m_forward = false;
|
||||
|
||||
ewol::Entry * myEntry = NULL;
|
||||
ewol::Button * myButton = NULL;
|
||||
ewol::CheckBox * mycheckbox = NULL;
|
||||
|
||||
myEntry = new ewol::Entry();
|
||||
myEntry->RegisterOnEvent(this, ewolEventEntryModify, l_eventSearchEntry);
|
||||
myEntry->SetExpendX(true);
|
||||
myEntry->SetFillX(true);
|
||||
SubWidgetAdd(myEntry);
|
||||
|
||||
myEntry = new ewol::Entry();
|
||||
myEntry->RegisterOnEvent(this, ewolEventEntryModify, l_eventReplaceEntry);
|
||||
myEntry->SetExpendX(true);
|
||||
myEntry->SetFillX(true);
|
||||
SubWidgetAdd(myEntry);
|
||||
|
||||
myButton = new ewol::Button("Search");
|
||||
myButton->RegisterOnEvent(this, ewolEventButtonPressed, l_eventSearchBt);
|
||||
SubWidgetAdd(myButton);
|
||||
|
||||
myButton = new ewol::Button("Replace");
|
||||
myButton->RegisterOnEvent(this, ewolEventButtonPressed, l_eventReplaceBt);
|
||||
SubWidgetAdd(myButton);
|
||||
|
||||
mycheckbox = new ewol::CheckBox("Aa");
|
||||
mycheckbox->RegisterOnEvent(this, ewolEventCheckBoxClicked, l_eventCaseCb);
|
||||
SubWidgetAdd(mycheckbox);
|
||||
|
||||
mycheckbox = new ewol::CheckBox("Wrap");
|
||||
mycheckbox->RegisterOnEvent(this, ewolEventCheckBoxClicked, l_eventWrapCb);
|
||||
SubWidgetAdd(mycheckbox);
|
||||
|
||||
mycheckbox = new ewol::CheckBox("Forward");
|
||||
mycheckbox->RegisterOnEvent(this, ewolEventCheckBoxClicked, l_eventForwardCb);
|
||||
SubWidgetAdd(mycheckbox);
|
||||
|
||||
myButton = new ewol::Button("Hide");
|
||||
myButton->RegisterOnEvent(this, ewolEventButtonPressed, l_eventHideBt);
|
||||
SubWidgetAdd(myButton);
|
||||
|
||||
RegisterMultiCast(ednMsgGuiSearch);
|
||||
RegisterMultiCast(ednMsgGuiReplace);
|
||||
|
||||
|
||||
}
|
||||
|
||||
Search::~Search(void)
|
||||
{
|
||||
/*
|
||||
if (NULL!=m_localDialog) {
|
||||
gtk_widget_hide(m_localDialog);
|
||||
gtk_widget_destroy(m_localDialog);
|
||||
m_localDialog = NULL;
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
/*
|
||||
void Search::Display(GtkWindow *parent)
|
||||
|
||||
/**
|
||||
* @brief Check if the object has the specific type.
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type of the object we want to check
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
bool Search::CheckObjectType(const char * const objectType)
|
||||
{
|
||||
if(NULL == m_localDialog) {
|
||||
m_localDialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
// set dialog not resisable
|
||||
gtk_window_set_resizable(GTK_WINDOW(m_localDialog), FALSE);
|
||||
// set the windows alwais on top of every all system windows
|
||||
//gtk_window_set_keep_above(GTK_WINDOW(m_localDialog), TRUE);
|
||||
// Set the dialog on top of the selected windows
|
||||
gtk_window_set_transient_for(GTK_WINDOW(m_localDialog), parent);
|
||||
// set the dialog on the top right
|
||||
gtk_window_set_gravity(GTK_WINDOW(m_localDialog), GDK_GRAVITY_NORTH_EAST);
|
||||
// Remove the dialogue from the task bar
|
||||
gtk_window_set_skip_taskbar_hint(GTK_WINDOW(m_localDialog), TRUE);
|
||||
// this element did not apear in the miniature of the windows
|
||||
gtk_window_set_skip_pager_hint(GTK_WINDOW(m_localDialog), TRUE);
|
||||
// select the program icone
|
||||
//gtk_window_set_default_icon_name("Replace");
|
||||
|
||||
// set default title :
|
||||
gtk_window_set_title(GTK_WINDOW(m_localDialog), "Search / Replace");
|
||||
|
||||
// Default size open windows
|
||||
//gtk_window_set_default_size(GTK_WINDOW(m_localDialog), 300, 400);
|
||||
|
||||
// enable the close signal of the windows
|
||||
g_signal_connect(G_OBJECT(m_localDialog), "destroy", G_CALLBACK(OnButtonQuit), this);
|
||||
|
||||
// Create a vertical box for stacking the menu and editor widgets in.
|
||||
GtkWidget *vbox = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_add(GTK_CONTAINER(m_localDialog), vbox);
|
||||
|
||||
// Set key Accelerator :
|
||||
//AccelKey::getInstance()->LinkCommonAccel(GTK_WINDOW(m_localDialog));
|
||||
|
||||
// **********************************************************
|
||||
// * Search Entry
|
||||
// **********************************************************
|
||||
{
|
||||
GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
|
||||
gtk_container_add(GTK_CONTAINER (vbox), hbox);
|
||||
// search label
|
||||
m_searchLabel = gtk_label_new("Search ");
|
||||
gtk_box_pack_start(GTK_BOX(hbox), m_searchLabel, FALSE, TRUE, 0);
|
||||
// Search entry
|
||||
m_searchEntry = gtk_entry_new();
|
||||
gtk_box_pack_start(GTK_BOX(hbox), m_searchEntry, TRUE, TRUE, 0);
|
||||
// Connect signals :
|
||||
g_signal_connect(G_OBJECT(m_searchEntry), "activate", G_CALLBACK(OnButtonNext), this);
|
||||
g_signal_connect(G_OBJECT(m_searchEntry), "changed", G_CALLBACK(OnEntrySearchChange), this);
|
||||
}
|
||||
// **********************************************************
|
||||
// * Replace Entry
|
||||
// **********************************************************
|
||||
{
|
||||
GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
|
||||
gtk_container_add(GTK_CONTAINER (vbox), hbox);
|
||||
// search label
|
||||
m_replaceLabel = gtk_label_new("Replace");
|
||||
gtk_box_pack_start(GTK_BOX(hbox), m_replaceLabel, FALSE, TRUE, 0);
|
||||
// Search entry
|
||||
m_replaceEntry = gtk_entry_new();
|
||||
gtk_box_pack_start(GTK_BOX(hbox), m_replaceEntry, TRUE, TRUE, 0);
|
||||
// Connect signals :
|
||||
g_signal_connect(G_OBJECT(m_replaceEntry), "changed", G_CALLBACK(OnEntryReplaceChange), this);
|
||||
}
|
||||
|
||||
// **********************************************************
|
||||
// * mode Selection
|
||||
// **********************************************************
|
||||
m_CkMatchCase = gtk_check_button_new_with_label("Case Sensitive");
|
||||
gtk_container_add(GTK_CONTAINER (vbox), m_CkMatchCase);
|
||||
m_CkWrapAround = gtk_check_button_new_with_label("Wrap arround");
|
||||
gtk_container_add(GTK_CONTAINER (vbox), m_CkWrapAround);
|
||||
m_CkRegularExpression = gtk_check_button_new_with_label("Regular Expression");
|
||||
gtk_container_add(GTK_CONTAINER (vbox), m_CkRegularExpression);
|
||||
|
||||
// connect signals :
|
||||
g_signal_connect(G_OBJECT(m_CkMatchCase), "activate", G_CALLBACK(OnCheckBoxEventCase), this);
|
||||
g_signal_connect(G_OBJECT(m_CkMatchCase), "clicked", G_CALLBACK(OnCheckBoxEventCase), this);
|
||||
g_signal_connect(G_OBJECT(m_CkWrapAround), "activate", G_CALLBACK(OnCheckBoxEventWrap), this);
|
||||
g_signal_connect(G_OBJECT(m_CkWrapAround), "clicked", G_CALLBACK(OnCheckBoxEventWrap), this);
|
||||
g_signal_connect(G_OBJECT(m_CkRegularExpression), "activate", G_CALLBACK(OnCheckBoxEventRegExp), this);
|
||||
g_signal_connect(G_OBJECT(m_CkRegularExpression), "clicked", G_CALLBACK(OnCheckBoxEventRegExp), this);
|
||||
|
||||
|
||||
// **********************************************************
|
||||
// * Search / Replace button
|
||||
// **********************************************************
|
||||
{
|
||||
GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
|
||||
gtk_container_add(GTK_CONTAINER (vbox), hbox);
|
||||
// Find previous
|
||||
m_BtPrevious = gtk_button_new_with_label("Previous");
|
||||
gtk_container_add(GTK_CONTAINER (hbox), m_BtPrevious);
|
||||
// Find Next
|
||||
m_BtNext = gtk_button_new_with_label("Next");
|
||||
gtk_container_add(GTK_CONTAINER (hbox), m_BtNext);
|
||||
// Replace
|
||||
m_BtReplace = gtk_button_new_with_label("Replace");
|
||||
gtk_container_add(GTK_CONTAINER (hbox), m_BtReplace);
|
||||
// Replace & next
|
||||
m_BtReplaceAndNext = gtk_button_new_with_label("Replace & Find");
|
||||
gtk_container_add(GTK_CONTAINER (hbox), m_BtReplaceAndNext);
|
||||
// Exit
|
||||
m_BtQuit = gtk_button_new_with_label("Close");
|
||||
gtk_container_add(GTK_CONTAINER (hbox), m_BtQuit);
|
||||
|
||||
// Connect signals :
|
||||
g_signal_connect(G_OBJECT(m_BtPrevious), "activate", G_CALLBACK(OnButtonPrevious), this);
|
||||
g_signal_connect(G_OBJECT(m_BtPrevious), "released", G_CALLBACK(OnButtonPrevious), this);
|
||||
g_signal_connect(G_OBJECT(m_BtNext), "activate", G_CALLBACK(OnButtonNext), this);
|
||||
g_signal_connect(G_OBJECT(m_BtNext), "released", G_CALLBACK(OnButtonNext), this);
|
||||
g_signal_connect(G_OBJECT(m_BtReplace), "activate", G_CALLBACK(OnButtonReplace), this);
|
||||
g_signal_connect(G_OBJECT(m_BtReplace), "released", G_CALLBACK(OnButtonReplace), this);
|
||||
g_signal_connect(G_OBJECT(m_BtReplaceAndNext), "activate", G_CALLBACK(OnButtonReplaceAndNext), this);
|
||||
g_signal_connect(G_OBJECT(m_BtReplaceAndNext), "released", G_CALLBACK(OnButtonReplaceAndNext), this);
|
||||
g_signal_connect(G_OBJECT(m_BtQuit), "activate", G_CALLBACK(OnButtonQuit), this);
|
||||
g_signal_connect(G_OBJECT(m_BtQuit), "released", G_CALLBACK(OnButtonQuit), this);
|
||||
}
|
||||
|
||||
// recursive version of gtk_widget_show
|
||||
gtk_widget_show_all(m_localDialog);
|
||||
if (NULL == objectType) {
|
||||
APPL_ERROR("check error : \"" << TYPE_EOBJECT_APPL_SEARCH << "\" != NULL(pointer) ");
|
||||
return false;
|
||||
}
|
||||
if(NULL == m_localDialog) {
|
||||
APPL_ERROR("No search-dialog instance");
|
||||
if (objectType == TYPE_EOBJECT_APPL_SEARCH) {
|
||||
return true;
|
||||
} else {
|
||||
// update datas :
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_CkWrapAround), SearchData::GetWrap());
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_CkMatchCase), SearchData::GetCase());
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_CkRegularExpression), SearchData::GetRegExp());
|
||||
if (true == SearchData::GetRegExp()) {
|
||||
gtk_widget_set_sensitive(m_CkMatchCase, false);
|
||||
} else {
|
||||
gtk_widget_set_sensitive(m_CkMatchCase, true);
|
||||
if(true == ewol::SizerHori::CheckObjectType(objectType)) {
|
||||
return true;
|
||||
}
|
||||
// Remove data form the search
|
||||
etk::UString myDataString = "";
|
||||
SearchData::SetSearch(myDataString);
|
||||
gtk_entry_set_text(GTK_ENTRY(m_searchEntry), myDataString.c_str());
|
||||
if (0 == strlen(myDataString.c_str())) {
|
||||
m_haveSearchData = false;
|
||||
} else {
|
||||
m_haveSearchData = true;
|
||||
}
|
||||
|
||||
SearchData::GetReplace(myDataString);
|
||||
gtk_entry_set_text(GTK_ENTRY(m_replaceEntry), myDataString.c_str());
|
||||
if (0 == strlen(myDataString.c_str())) {
|
||||
m_haveReplaceData = false;
|
||||
} else {
|
||||
m_haveReplaceData = true;
|
||||
}
|
||||
|
||||
gtk_widget_set_sensitive(m_BtPrevious, m_haveSearchData);
|
||||
gtk_widget_set_sensitive(m_BtNext, m_haveSearchData);
|
||||
// basic no search data
|
||||
gtk_widget_set_sensitive(m_BtReplace, false);
|
||||
gtk_widget_set_sensitive(m_BtReplaceAndNext, false);
|
||||
|
||||
|
||||
// set focus on a specific widget :
|
||||
//gtk_window_set_focus(parent, m_searchEntry);
|
||||
gtk_widget_grab_focus(m_searchEntry);
|
||||
|
||||
// display the dialogue box
|
||||
gtk_widget_show_all(m_localDialog);
|
||||
|
||||
// hide regular expression
|
||||
gtk_widget_hide(m_CkRegularExpression);
|
||||
APPL_ERROR("check error : \"" << TYPE_EOBJECT_APPL_SEARCH << "\" != \"" << objectType << "\"");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void Search::Destroy(void)
|
||||
/**
|
||||
* @brief Get the current Object type of the EObject
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type description
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
const char * const Search::GetObjectType(void)
|
||||
{
|
||||
/*
|
||||
if (NULL!=m_localDialog) {
|
||||
gtk_widget_destroy(m_localDialog);
|
||||
m_localDialog = NULL;
|
||||
}
|
||||
*/
|
||||
return TYPE_EOBJECT_APPL_SEARCH;
|
||||
}
|
||||
|
||||
|
||||
void Search::Hide(void)
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
void Search::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
|
||||
{
|
||||
//gtk_widget_hide(m_localDialog);
|
||||
ewol::SizerHori::OnReceiveMessage(CallerObject, eventId, data);
|
||||
//APPL_INFO("Search receive message : \"" << eventId << "\" data=\"" << data << "\"");
|
||||
if ( eventId == l_eventSearchEntry) {
|
||||
SearchData::SetSearch(data);
|
||||
} else if ( eventId == l_eventReplaceEntry) {
|
||||
SearchData::SetReplace(data);
|
||||
} else if ( eventId == l_eventSearchBt) {
|
||||
if (true==m_forward) {
|
||||
SendMultiCast(ednMsgGuiFind, "Previous");
|
||||
} else {
|
||||
SendMultiCast(ednMsgGuiFind, "Next");
|
||||
}
|
||||
} else if ( eventId == l_eventReplaceBt) {
|
||||
SendMultiCast(ednMsgGuiReplace, "Normal");
|
||||
if (true==m_forward) {
|
||||
SendMultiCast(ednMsgGuiFind, "Previous");
|
||||
} else {
|
||||
SendMultiCast(ednMsgGuiFind, "Next");
|
||||
}
|
||||
} else if ( eventId == l_eventCaseCb) {
|
||||
if (data == "true") {
|
||||
SearchData::SetCase(true);
|
||||
} else {
|
||||
SearchData::SetCase(false);
|
||||
}
|
||||
} else if ( eventId == l_eventWrapCb) {
|
||||
if (data == "true") {
|
||||
SearchData::SetWrap(true);
|
||||
} else {
|
||||
SearchData::SetWrap(false);
|
||||
}
|
||||
} else if ( eventId == l_eventForwardCb) {
|
||||
if (data == "true") {
|
||||
m_forward = true;
|
||||
} else {
|
||||
m_forward = false;
|
||||
}
|
||||
} else if ( eventId == l_eventHideBt) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -27,54 +27,43 @@
|
||||
#define __SEARCH_H__
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <ewol/widget/SizerHori.h>
|
||||
|
||||
extern const char * const TYPE_EOBJECT_APPL_SEARCH;
|
||||
|
||||
class Search
|
||||
class Search : public ewol::SizerHori
|
||||
{
|
||||
public:
|
||||
// Constructeur
|
||||
Search(void);
|
||||
~Search(void);
|
||||
|
||||
public:
|
||||
void Destroy(void);
|
||||
//void Display(GtkWindow *parent);
|
||||
void Hide(void);
|
||||
/*
|
||||
/**
|
||||
* @brief Check if the object has the specific type.
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type of the object we want to check
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
bool CheckObjectType(const char * const objectType);
|
||||
/**
|
||||
* @brief Get the current Object type of the EObject
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type description
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
const char * const GetObjectType(void);
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
|
||||
private:
|
||||
GtkWidget * m_localDialog; //!< local dialog element
|
||||
// entry
|
||||
GtkWidget * m_searchLabel; //!< gtk label of the search section
|
||||
GtkWidget * m_searchEntry; //!< gtk entry of the search section
|
||||
GtkWidget * m_replaceLabel; //!< gtk label of the replace section
|
||||
GtkWidget * m_replaceEntry; //!< gtk entry of the replace section
|
||||
// checkbox
|
||||
GtkWidget * m_CkMatchCase; //!< tick of the case matching
|
||||
GtkWidget * m_CkWrapAround; //!< tick of the wrap the file
|
||||
GtkWidget * m_CkRegularExpression; //!< the test is a regular expression
|
||||
// button
|
||||
GtkWidget * m_BtPrevious; //!< Button Previous
|
||||
GtkWidget * m_BtNext; //!< Button Next
|
||||
GtkWidget * m_BtReplace; //!< Button Replace
|
||||
GtkWidget * m_BtReplaceAndNext; //!< Button Replace and find next
|
||||
GtkWidget * m_BtQuit; //!< Button Quit
|
||||
bool m_haveSearchData;
|
||||
bool m_haveReplaceData;
|
||||
// CallBack for GTK+ gui
|
||||
private :
|
||||
static void OnButtonPrevious(GtkWidget *widget, gpointer user_data);
|
||||
static void OnButtonNext(GtkWidget *widget, gpointer user_data);
|
||||
static void OnButtonReplace(GtkWidget *widget, gpointer user_data);
|
||||
static void OnButtonReplaceAndNext(GtkWidget *widget, gpointer user_data);
|
||||
static void OnButtonQuit(GtkWidget *widget, gpointer user_data);
|
||||
static void OnCheckBoxEventCase(GtkWidget *widget, gpointer user_data);
|
||||
static void OnCheckBoxEventWrap(GtkWidget *widget, gpointer user_data);
|
||||
static void OnCheckBoxEventRegExp(GtkWidget *widget, gpointer user_data);
|
||||
static void OnEntrySearchChange(GtkWidget *widget, gpointer user_data);
|
||||
static void OnEntryReplaceChange(GtkWidget *widget, gpointer user_data);
|
||||
*/
|
||||
bool m_forward;
|
||||
};
|
||||
|
||||
#define EDN_CAST_APPL_SEARCH(curentPointer) EWOL_CAST(TYPE_EOBJECT_APPL_SEARCH,Search,curentPointer)
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -45,7 +45,7 @@
|
||||
extern const char* const ednMsgGuiGotoLine; // data : "???" / "1" ... "999999999999"
|
||||
|
||||
extern const char* const ednMsgGuiSearch; // data : ""
|
||||
extern const char* const ednMsgGuiReplace; // data : ""
|
||||
extern const char* const ednMsgGuiReplace; // data : "Normal" "All"
|
||||
extern const char* const ednMsgGuiFind; // data : "Next" "Previous" "All" "None"
|
||||
|
||||
extern const char* const ednMsgGuiChangeColor; // data : "Black" "White"
|
||||
|
Loading…
x
Reference in New Issue
Block a user