76 Commits
0.1.1 ... 0.2.1

Author SHA1 Message Date
9bad01fc37 sys : rework seem fonctionnal (slow) and a correction start selection error 2011-09-18 20:46:05 +02:00
89394d5770 sys : back to normal compilation and working ok (slow but ok) 2011-09-18 16:43:57 +02:00
03484cc85d sys: rework internal compilation ok 2011-09-18 13:35:24 +02:00
7fbfe1f86a gui : change the display of internal Titile 2011-09-15 18:16:44 +02:00
745ca76a74 SYS : next step of the new display methode ... 2011-09-12 16:43:13 +02:00
2712d4f67d SYS: Buffer anchor mechanism first step 2011-09-11 22:46:36 +02:00
bdc4793955 SYS : remove blobal clean in the main displayer 2011-09-10 10:40:00 +02:00
650206f04e SYS : key error in gtk 3.0 2011-09-08 21:52:02 +02:00
d21d661f15 SYS : color display is back ==> but so slow ... 2011-09-08 14:57:25 +02:00
f5f97c53de SYS : Selection is Back 2011-09-08 14:22:05 +02:00
d78a67f99f SYS : display with left and right movement is back 2011-09-08 14:09:20 +02:00
0b2599fb81 SYS : First step for the display line by line 2011-09-07 18:17:05 +02:00
83dd23b8a9 try to find the error of italic, it seam that cairo does not support monospace italic 2011-09-06 17:05:06 +02:00
2714560c38 SYS : Indent with TAB only when multiple line selected 2011-09-06 09:11:51 +02:00
e48c75df72 gui : Add the current folder in the title area 2011-09-05 10:02:17 +02:00
1de1f787e7 sys : corection of the keypad enter and add the shift+enter replacement with \r 2011-09-05 09:50:15 +02:00
1b3dd3ce98 SYS : catch the shift+tab event 2011-09-04 12:08:48 +02:00
0e6c34d2a0 change the avancement list ==> set it to mabage future version developement 2011-09-04 11:23:01 +02:00
325034bbc0 HL : add bash elif 2011-09-02 17:22:07 +02:00
fc9b98f09e TEST : color changing of menu 2011-09-01 17:58:04 +02:00
a497b028ca GUI : update the display of the about windows to use gtk:about 2011-09-01 16:04:12 +02:00
88b76c074d SYS : Add a Edn:VectorType eraseLen and an erase ==> normalisation with std::vector 2011-09-01 14:34:06 +02:00
28b709bfb8 SYS : Confirm Save when exit 2011-09-01 13:38:12 +02:00
1c01dbd7cd SYS : Change position of the close request message ==> the good position 2011-09-01 09:45:37 +02:00
948240f05f LOG : Remove the change state of the Main windows 2011-08-31 10:11:22 +02:00
990828c69c Error in installation of software 2011-08-31 10:10:03 +02:00
72f63a8990 DISPLAY : add a menu to change the color on the fly 2011-08-31 09:42:30 +02:00
4d2eced7a0 Change name of readme 2011-08-30 09:43:45 +02:00
6598a22981 change format of github readme 2011-08-30 09:42:14 +02:00
01276b581f SEARCH : Change the hide policy 2011-08-26 17:59:38 +02:00
fd13467832 REPLACE : addition done 2011-08-24 12:13:57 +02:00
643f2e38b3 CTAGS : Back is done but the display result is not the best I can do... 2011-08-24 09:44:10 +02:00
c30f57b3f7 GUI : change some displayable element : think at a new methode of gui will be organized 2011-08-19 18:10:46 +02:00
514a5cf003 GUI : Reload on the fly the Color file 2011-08-19 16:09:58 +02:00
0c1f6004eb GUI : Maximisation remove the 'decoration of the windows' ==> need to be an option 2011-08-18 22:50:29 +02:00
c02747d8fb GUI : Add the basic icon for Edn ... must change the color, maybe 2011-08-17 12:24:51 +02:00
80dae2dab9 MAKEFILE : Remove the Abstraction Layer (deprecated) 2011-08-17 12:23:27 +02:00
bd8c11a9da LANG : Add matlab basic parser (not compleate)
HL : Corection of a parser bug
2011-08-16 10:01:28 +02:00
1f08a99ac1 CTAGS : multiple jump OK ... ==> need to go back now... 2011-08-14 11:32:31 +02:00
0eeb214369 HL : Add bash colorisation (basic) 2011-08-12 16:56:32 +02:00
f5911d5463 CTAGS : Set the display of the file for the multiple jump list .
TODO : Set the selection keep when press jump button
TODO : Double click on a specific raw
2011-08-10 15:56:48 +02:00
1f8d3cf045 Remove tag file in the repository 2011-08-10 09:20:54 +02:00
54cc9da39f HL : End of the parsing Error corection 2011-08-09 17:07:03 +02:00
7562c45aa7 CONFIG : update the xml parsing config : XML and boo files 2011-08-09 15:11:58 +02:00
d96a133c6a HL : Correction of a bug of reparsing the buffer betwwen 2 element Erase was not implemented as std::vector ==> I might change this ... 2011-08-09 14:28:58 +02:00
5a47446a09 Remove warning and Custom menuContext 2011-08-08 14:15:44 +02:00
a196c615bf Remove std::vector and std::string from the sources for reson of portability 2011-08-08 14:06:11 +02:00
2c6f280c58 new parsing mode of HL Done with success ==> can have some residual errors
TODO : Recursive Hightlight
2011-08-08 10:24:24 +02:00
722dafaaef base aof te new hilight system 2011-08-07 22:34:27 +02:00
45b4dca615 error whith the Highlight detection 2011-08-07 10:47:06 +02:00
322120a3f3 create the debian package and change the tag name methode 2011-08-06 12:20:08 +02:00
f5993b3f8b remove display of the dialogue from the miniature element 2011-08-05 15:12:40 +02:00
82af3768b0 remove the search windows from the task bar and the miniature bar 2011-08-05 15:10:29 +02:00
4c5f3a0424 String stream and file stream is now OK 2011-08-05 15:03:05 +02:00
7b303d2aad Edn::File is now implemented an integrated in the system ==> test is OK 2011-08-05 14:31:47 +02:00
ff055b88d4 create a class Edn::File that manage the modification of the falineme to get the real filename in the system ==> dit not work corectly... 2011-08-04 18:18:54 +02:00
55681d1dac try to create a real file viewer 2011-08-03 18:01:04 +02:00
ab74a7c516 Correction of a bug in the context menu 2011-08-03 14:47:14 +02:00
1fa86b3b03 Add the context menu for the bufferViewer element 2011-08-03 14:39:39 +02:00
dbade0e4e6 try to set a list when ctags requested and basic realpath for file class 2011-08-02 18:01:30 +02:00
356d7621ae remove from todo list and update license 2011-08-01 18:17:43 +02:00
896beaa4fd Add the goto line number dialogue 2011-08-01 10:01:26 +02:00
7b476ebc49 real installation of edn software in /usr/bin and /usr/shared/edn/... 2011-08-01 09:17:01 +02:00
83f1e2e5b5 add php basic language interpretation 2011-07-31 15:30:11 +02:00
396b03bd42 remove vector (not ready), and correct display error in gtk 3.0 2011-07-31 11:58:44 +02:00
e3e868f351 debut de déplacement du vecteur 2011-07-29 17:07:46 +02:00
0fe575e432 move EdnVectorBin in Edn::VectorType 2011-07-29 13:37:09 +02:00
45aad6b2e2 Mise en place des RegExp en Template ==> OK 2011-07-29 10:44:12 +02:00
f9418d665e mise en place d'un system de RegExp en Template (Non Fonctionnel...) 2011-07-28 18:07:46 +02:00
a751e602ad context menu base 2011-07-27 18:20:13 +02:00
d92945717d some work ... 2011-07-26 17:25:45 +02:00
4da853c367 Correct some display error 2011-07-25 18:01:54 +02:00
dad2057818 test the transparency 2011-07-24 20:25:34 +02:00
088f89d421 try a menu context display 2011-07-22 18:31:43 +02:00
5ff5525c6b Add the version name and compilation date in the About dialog 2011-07-22 10:50:47 +02:00
b3d776b723 add the about dialog 2011-07-22 07:47:25 +02:00
91 changed files with 6044 additions and 7276 deletions

2
.gitignore vendored
View File

@@ -26,7 +26,9 @@ doxygen/ALL/
*.o *.o
*.so *.so
*.pyc *.pyc
tags
edn edn
out
edn_debug edn_debug
edn_release edn_release

View File

@@ -31,6 +31,14 @@ export F_GRIS=
export CADRE_HAUT_BAS=' $(F_INVERSER) $(F_NORMALE)' export CADRE_HAUT_BAS=' $(F_INVERSER) $(F_NORMALE)'
export CADRE_COTERS=' export CADRE_COTERS='
$(F_INVERSER) $(F_NORMALE) $(F_INVERSER) $(F_NORMALE)' $(F_INVERSER) $(F_NORMALE) $(F_INVERSER) $(F_NORMALE)'
VERSION_TAG=$(shell git describe --tags)
#$(info $(VERSION_TAG))
VERSION_TAG_SHORT=$(shell git describe --tags --abbrev=0)
#$(info $(VERSION_TAG_SHORT))
VERSION_BUILD_TIME=$(shell date)
#$(info $(VERSION_BUILD_TIME)) #$(info $(VERSION_BUILD_TIME))
############################################################################### ###############################################################################
@@ -45,10 +53,11 @@ DEBUG:=1
############################################################################### ###############################################################################
### Compilation Define ### ### Compilation Define ###
############################################################################### ###############################################################################
ifeq ("$(DEBUG)", "0") ifeq ("$(DEBUG)", "0")
DEFINE= -DEDN_DEBUG_LEVEL=1 -DNDEBUG -DVERSION_TAG_NAME="\"$(VERSION_TAG)-release\"" DEFINE= -DEDN_DEBUG_LEVEL=1 -DNDEBUG -DVERSION_TAG_NAME="\"$(VERSION_TAG)-release\""
else else
DEFINE= -DEDN_DEBUG_LEVEL=3 -DVERSION_TAG_NAME="\"$(VERSION_TAG)-debug\"" DEFINE= -DEDN_DEBUG_LEVEL=3 -DVERSION_TAG_NAME="\"$(VERSION_TAG)-debug\""
endif
DEFINE+= -DVERSION_BUILD_TIME="\"$(VERSION_BUILD_TIME)\"" DEFINE+= -DVERSION_BUILD_TIME="\"$(VERSION_BUILD_TIME)\""
GTKFLAGS= GTKFLAGS=
@@ -146,16 +155,15 @@ CXXFILES+= tools/EdnTemplate/EdnVectorBuf.cpp \
tools/EdnBuf/EdnBufHistory.cpp tools/EdnBuf/EdnBufHistory.cpp
# Tools internal: # Tools internal:
CXXFILES+= tools/AL/AL_Mutex.cpp \
CXXFILES+= tools/Display/Display.cpp \ CXXFILES+= tools/Display/Display.cpp \
tools/ClipBoard/ClipBoard.cpp \ tools/ClipBoard/ClipBoard.cpp \
tools/MsgBroadcast/MsgBroadcast.cpp \ tools/MsgBroadcast/MsgBroadcast.cpp \
tools/MsgBroadcast/AccelKey.cpp \ tools/MsgBroadcast/AccelKey.cpp \
tools/charset/charsetTable.cpp \ tools/charset/charsetTable.cpp \
tools/charset/charset.cpp \
tools/charset/charset.cpp \ tools/charset/charset.cpp \
tools/NameSpaceEdn/File.cpp \ tools/NameSpaceEdn/File.cpp \
tools/NameSpaceEdn/String.cpp \
tools/NameSpaceEdn/RegExp.cpp tools/NameSpaceEdn/RegExp.cpp
# Gui: # Gui:
@@ -203,7 +211,7 @@ all: build
all: build all: build
-include $(OBJ:.o=.d) -include $(OBJ:.o=.d)
build: .encadrer .versionFile $(OUTPUT_NAME) build: .encadrer .versionFile $(OUTPUT_NAME)
@@ -212,15 +220,19 @@ build: .encadrer $(OUTPUT_NAME)
@echo $(CADRE_COTERS) @echo $(CADRE_COTERS)
@echo ' @echo '
DEBUT DE COMPILATION DU PROGRAMME :'$(CADRE_COTERS) DEBUT DE COMPILATION DU PROGRAMME :'$(CADRE_COTERS)
@echo ' @echo '
Repertoire Sources : $(FILE_DIRECTORY)/'$(CADRE_COTERS) Repertoire Sources : $(FILE_DIRECTORY)/'$(CADRE_COTERS)
@echo ' @echo '
Repertoire object : $(OBJECT_DIRECTORY)/'$(CADRE_COTERS) Repertoire object : $(OBJECT_DIRECTORY)/'$(CADRE_COTERS)
@echo '
@echo ' @echo '
Binaire de sortie : $(F_VIOLET)$(OUTPUT_NAME) $(F_NORMALE)'$(CADRE_COTERS) Binaire de sortie : $(F_VIOLET)$(OUTPUT_NAME) $(F_NORMALE)'$(CADRE_COTERS)
@echo $(CADRE_COTERS) @echo $(CADRE_COTERS)
@echo $(CADRE_HAUT_BAS) @echo $(CADRE_HAUT_BAS)
@mkdir -p $(addprefix $(OBJECT_DIRECTORY)/, $(LISTE_MODULES))
FILE_IMAGES= data/imagesSources/*.png
.versionFile : .versionFile :
@rm -f $(OBJECT_DIRECTORY)/GuiTools/WindowsManager/WindowsManager.o @rm -f $(OBJECT_DIRECTORY)/GuiTools/WindowsManager/WindowsManager.o
@@ -230,14 +242,12 @@ pngToCpp: tools/pngToCpp/pngToCpp.c
pngToCpp: tools/pngToCpp/pngToCpp.c pngToCpp: tools/pngToCpp/pngToCpp.c
@echo $(F_ROUGE)" @echo $(F_ROUGE)"
(bin) $@"$(F_NORMALE) (bin) $@"$(F_NORMALE)
@$(CXX) $< -o $@
@$(CXX) $< -o $@ @$(CXX) $< -o $@
@strip -s $@ @strip -s $@
# Generate basic # Generate basic
$(FILE_DIRECTORY)/GuiTools/myImage.cpp: $(FILE_IMAGES) $(MAKE_DEPENDENCE) pngToCpp $(FILE_DIRECTORY)/GuiTools/myImage.cpp: $(FILE_IMAGES) $(MAKE_DEPENDENCE) pngToCpp
@echo $(F_BLUE)" @echo $(F_BLUE)"
@#echo ./pngToCpp $@ $(FILE_IMAGES)
(.cpp) *.png ==> $@"$(F_NORMALE) (.cpp) *.png ==> $@"$(F_NORMALE)
@./pngToCpp $@ $(FILE_IMAGES) @./pngToCpp $@ $(FILE_IMAGES)
@@ -273,18 +283,54 @@ clean:
@echo Remove File : pngToCpp @echo Remove File : pngToCpp
@rm -f pngToCpp @rm -f pngToCpp
@echo Remove File : $(FILE_DIRECTORY)/GuiTools/myImage.* @echo Remove File : $(FILE_DIRECTORY)/GuiTools/myImage.*
@rm -f $(FILE_DIRECTORY)/GuiTools/myImage.* @rm -f $(FILE_DIRECTORY)/GuiTools/myImage.*
@echo Remove doxygen files : doxygen/* @echo Remove doxygen files : doxygen/*
@rm -rf doxygen @rm -rf doxygen
@rm -f doxygen.log @rm -f doxygen.log
@echo Remove temporary files *.bck @echo Remove temporary files *.bck
@rm -f `find . -name "*.bck"` @rm -f `find . -name "*.bck"`
count: count:
wc -l Makefile `find $(FILE_DIRECTORY)/ -name "*.cpp"` `find $(FILE_DIRECTORY)/ -name "*.h"` wc -l Makefile `find $(FILE_DIRECTORY)/ -name "*.cpp"` `find $(FILE_DIRECTORY)/ -name "*.h"`
install: .encadrer $(OUTPUT_NAME_RELEASE) install: .encadrer .versionFile $(OUTPUT_NAME_RELEASE)
@echo $(CADRE_HAUT_BAS) @echo $(CADRE_HAUT_BAS)
@echo ' INSTALL : $(F_VIOLET)$(OUTPUT_NAME_RELEASE)=>$(PROG_NAME)$(F_NORMALE)'$(CADRE_COTERS)
@echo $(CADRE_HAUT_BAS)
@echo $(F_ROUGE)"
(stripped) $(OUTPUT_NAME_RELEASE) => $(PROG_NAME) "$(F_NORMALE)
@cp $(OUTPUT_NAME_RELEASE) $(PROG_NAME) @cp $(OUTPUT_NAME_RELEASE) $(PROG_NAME)
@strip -s $(PROG_NAME) @strip -s $(PROG_NAME)
@echo $(F_VERT)"
(copy) $(PROG_NAME) /usr/bin/ "$(F_NORMALE)
@cp -vf $(PROG_NAME) /usr/bin/
@echo $(F_VERT)"
(data) data/* ==> /usr/share/edn/ "$(F_NORMALE)
@mkdir -p /usr/share/edn/
@rm -rf /usr/share/edn/*
@cp -vf data/*.xml /usr/share/edn/
@mkdir -p /usr/share/edn/images/
@cp -vf data/imagesSources/icone.png /usr/share/edn/images/
@cp -vf data/imagesSources/delete-24px.png /usr/share/edn/images/
# http://alp.developpez.com/tutoriels/debian/creer-paquet/
package: .encadrer
@echo 'Create Folders ...'
@mkdir -p package/$(PROG_NAME)/DEBIAN/
@mkdir -p package/$(PROG_NAME)/usr/bin/
@mkdir -p package/$(PROG_NAME)/usr/share/doc/
@mkdir -p package/$(PROG_NAME)/usr/share/edn/
# Create the control file
@echo "Package: "$(PROG_NAME) > package/$(PROG_NAME)/DEBIAN/control
@echo "Version: "$(VERSION_TAG_SHORT) >> package/$(PROG_NAME)/DEBIAN/control
@echo "Section: Development,Editors" >> package/$(PROG_NAME)/DEBIAN/control
@echo "Priority: optional" >>package/$(PROG_NAME)/DEBIAN/control
@echo "Architecture: all" >> package/$(PROG_NAME)/DEBIAN/control
@echo "Depends: bash" >> package/$(PROG_NAME)/DEBIAN/control
@echo "Maintainer: Mr DUPIN Edouard <yui.heero@gmail.com>" >> package/$(PROG_NAME)/DEBIAN/control
@echo "Description: Text editor for sources code with ctags management" >> package/$(PROG_NAME)/DEBIAN/control
@echo "" >> package/$(PROG_NAME)/DEBIAN/control
# Create the PostRm
@echo "#!/bin/bash" > package/$(PROG_NAME)/DEBIAN/postrm
@echo "rm ~/."$(PROG_NAME) >> package/$(PROG_NAME)/DEBIAN/postrm @echo "rm ~/."$(PROG_NAME) >> package/$(PROG_NAME)/DEBIAN/postrm

22
README
View File

@@ -1,22 +0,0 @@
Edn (Editeur De N'ours) is a FREE software.
This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.
Terms of license:
You can:
- Redistribute the sources code and binaries.
- Modify the Sources code.
- Use a part of the sources (less than 50%) in an other software, just write somewhere "Edn is great" visible by the user (on your product or on your website with a link to my page).
- Redistribute the modification only if you want.
- Send me the bug-fix (it could be great).
- Pay me a beer or some other things.
- Print the source code on WC paper ...
You can NOT:
- Earn money with this Software (But I can).
- Add malware in the Sources.
- Do something bad with the sources.
- Use it to travel in the space with a toaster.
- Write Java sources code with this software.
I reserve the right to change this licence. If it change the version of the copy you have keep its own license

41
README.md Normal file
View File

@@ -0,0 +1,41 @@
Edn
====
`Edn` (Editeur De N'ours) is a FREE software.
This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.
Instructions
============
download the software :
git clone git://github.com/HeeroYui/edn.git
cd edn
Compile software and install :
sudo make DEBUG=0 install
Run Software :
edn exemple.txt
License
=======
You can:
- Redistribute the sources code and binaries.
- Modify the Sources code.
- Use a part of the sources (less than 50%) in an other software, just write somewhere "Edn is great" visible by the user (on your product or on your website with a link to my page).
- Redistribute the modification only if you want.
- Send me the bug-fix (it could be great).
- Pay me a beer or some other things.
- Print the source code on WC paper ...
You can NOT:
- Earn money with this Software (But I can).
- Add malware in the Sources.
- Do something bad with the sources.
- Use it to travel in the space with a toaster.
I reserve the right to change this licence. If it change the version of the copy you have keep its own license

View File

@@ -41,10 +41,28 @@
*/ */
Buffer::Buffer() Buffer::Buffer()
{ {
static int32_t bufID = 0;
m_uniqueID = bufID++;
static int32_t fileBasicID = 0;
m_fileModify = true; m_fileModify = true;
m_haveName = false; m_haveName = false;
Edn::String mString = "No-Name"; Edn::String mString = "Untitle - ";
m_fileName.SetCompleateName(mString); mString += fileBasicID++;
SetFileName(mString);
m_haveName = false;
// Set basic anchor
bufferAnchorReference_ts tmpAnchor;
tmpAnchor.m_displaySize.x = 0;
tmpAnchor.m_displaySize.y = 0;
tmpAnchor.m_displayStart.x = 0;
tmpAnchor.m_curent = true;
tmpAnchor.m_idAnchor = -1;
tmpAnchor.m_lineId = 0;
tmpAnchor.m_bufferPos = 0;
m_AnchorList.PushBack(tmpAnchor);
m_lineWidth = 10;
m_lineHeight = 10;
} }
/** /**
@@ -55,11 +73,20 @@ Buffer::Buffer()
* @return --- * @return ---
* *
*/ */
Buffer::Buffer(Edn::String &newFileName) Buffer::Buffer(Edn::File &newName)
{ {
m_fileModify = false; m_fileModify = false;
m_haveName = true; SetFileName(newName);
m_fileName.SetCompleateName(newFileName); // Set basic anchor
bufferAnchorReference_ts tmpAnchor;
tmpAnchor.m_displaySize.x = 0;
tmpAnchor.m_displaySize.y = 0;
tmpAnchor.m_displayStart.x = 0;
tmpAnchor.m_curent = true;
tmpAnchor.m_idAnchor = -1;
tmpAnchor.m_lineId = 0;
tmpAnchor.m_bufferPos = 0;
m_AnchorList .PushBack(tmpAnchor);
} }
/** /**
@@ -95,85 +122,6 @@ void Buffer::SetModify(bool status)
} }
} }
Edn::File Buffer::GetFileName(void)
{
return m_fileName;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
Edn::String Buffer::GetName(void)
{
// nothing to do
return m_fileName.GetCompleateName();
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
Edn::String Buffer::GetShortName(void)
{
// nothing to do
return m_fileName.GetShortFilename();
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
Edn::String Buffer::GetFolder(void)
{
// nothing to do
return m_fileName.GetFolder();
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
bool Buffer::HaveName(void)
{
// nothing to do
return true;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void Buffer::SetName(Edn::String &newName)
{
// nothing to do
}
/** /**
* @brief * @brief
* *
@@ -215,7 +163,6 @@ void Buffer::SetLineDisplay(uint32_t lineNumber)
// nothing to do // nothing to do
} }
/** /**
* @brief * @brief
* *
@@ -224,11 +171,12 @@ void Buffer::SetLineDisplay(uint32_t lineNumber)
* @return --- * @return ---
* *
*/ */
int32_t Buffer::Display(DrawerManager &drawer) void Buffer::DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor)
{ {
return ERR_NONE; return;
} }
/** /**
* @brief * @brief
* *
@@ -313,7 +261,6 @@ void Buffer::ScrollUp(void)
// nothing to do // nothing to do
} }
/** /**
* @brief * @brief
* *
@@ -322,13 +269,6 @@ void Buffer::ScrollUp(void)
* @return --- * @return ---
* *
*/ */
void Buffer::ForceReDraw(bool allElement)
{
// nothing to do
}
void Buffer::cursorMove(int32_t gtkKey) void Buffer::cursorMove(int32_t gtkKey)
{ {
// nothing to do // nothing to do
@@ -360,6 +300,7 @@ void Buffer::Replace(Edn::String &data)
int32_t Buffer::FindLine(Edn::String &data) int32_t Buffer::FindLine(Edn::String &data)
{ {
// nothing to do // nothing to do
return 0;
} }
void Buffer::JumpAtLine(int32_t newLine) void Buffer::JumpAtLine(int32_t newLine)
@@ -367,6 +308,21 @@ void Buffer::JumpAtLine(int32_t newLine)
// nothing to do // nothing to do
} }
/**
* @brief Get the current line (to know where to jump)
*
* @param ---
*
* @return Return the current line number
*
*/
int32_t Buffer::GetCurrentLine(void)
{
return 0;
}
/** /**
* @brief request a copy of the selection in the named clipBoard ID * @brief request a copy of the selection in the named clipBoard ID
* *
@@ -410,7 +366,7 @@ void Buffer::Paste(int8_t clipboardID)
void Buffer::RemoveLine(void) void Buffer::RemoveLine(void)
{ {
// nothing to do // nothing to do;
} }
void Buffer::SelectAll(void) void Buffer::SelectAll(void)
@@ -433,3 +389,99 @@ void Buffer::Redo(void)
// nothing to do // nothing to do
} }
void Buffer::AnchorAdd(int32_t anchorID)
{
int32_t localID = AnchorRealId(anchorID);
if (localID >=0) {
EDN_ERROR("[" << m_uniqueID << "] AnchorID="<< anchorID << " already exist !!!");
} else {
bufferAnchorReference_ts tmpAnchor = m_AnchorList[0];
m_AnchorList[0].m_curent = false;
tmpAnchor.m_idAnchor = anchorID;
m_AnchorList.PushBack(tmpAnchor);
EDN_DEBUG("[" << m_uniqueID << "] AnchorID="<< anchorID << " ==> Added");
}
}
void Buffer::AnchorRm(int32_t anchorID)
{
if (anchorID == -1) {
EDN_ERROR("[" << m_uniqueID << "] AnchorID="<< anchorID << " Can not remove this one !!!");
return;
}
int32_t localID = AnchorRealId(anchorID);
if (localID >=0) {
if (m_AnchorList.Size() == 2) {
m_AnchorList[0] = m_AnchorList[1];
}
m_AnchorList.Erase(localID);
EDN_DEBUG("[" << m_uniqueID << "] AnchorID="<< anchorID << " ==> Remove");
} else {
EDN_ERROR("[" << m_uniqueID << "] AnchorID="<< anchorID << " does not exist !!!");
}
}
bool Buffer::AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor)
{
EDN_ERROR("[" << m_uniqueID << "] AnchorID="<< anchorID << " Main buffer ==> can not manage Anchor (type buffer specific)");
return false;
}
bool Buffer::AnchorNext(bufferAnchor_ts & anchor)
{
EDN_ERROR("[" << m_uniqueID << "] AnchorID=?? Main buffer ==> can not manage Anchor (type buffer specific)");
return false;
}
void Buffer::AnchorSetSize(int32_t anchorID, int32_t sizePixelX, int32_t sizePixelY)
{
int32_t localID = AnchorRealId(anchorID);
if (localID >=0) {
m_AnchorList[localID].m_displaySize.x = sizePixelX / m_lineWidth;
m_AnchorList[localID].m_displaySize.y = sizePixelY / m_lineHeight;
}
}
void Buffer::AnchorSetStartOffset(int32_t anchorID, int32_t offsetX, int32_t offsetY)
{
int32_t localID = AnchorRealId(anchorID);
if (localID >=0) {
m_AnchorList[localID].m_displayStart.x += offsetX;
if (0<m_AnchorList[localID].m_displayStart.x) {
m_AnchorList[localID].m_displayStart.x = 0;
}
m_AnchorList[localID].m_displayStart.y += offsetY;
if (0<m_AnchorList[localID].m_displayStart.y) {
m_AnchorList[localID].m_displayStart.y = 0;
}
}
}
int32_t Buffer::AnchorRealId(int32_t anchorID)
{
//EDN_DEBUG("Get real ID : " << anchorID << " in the anchor list size()=" << m_AnchorList.Size());
for(int32_t iii=0; iii < m_AnchorList.Size(); iii++) {
//EDN_DEBUG("check if equal : " << m_AnchorList[iii].m_idAnchor << " id=" << iii);
if (m_AnchorList[iii].m_idAnchor == anchorID) {
return iii;
}
}
return -1;
}
int32_t Buffer::AnchorCurrentId(void)
{
for(int32_t iii=0; iii < m_AnchorList.Size(); iii++) {
if (m_AnchorList[iii].m_curent == true) {
return iii;
}
}
return 0;
}

View File

@@ -31,53 +31,97 @@
#include "charset.h" #include "charset.h"
#include "Edn.h" #include "Edn.h"
extern "C"
typedef struct{ {
typedef struct{
uint32_t nbTotalLine; //!< Number of line in the buffer uint32_t nbTotalLine; //!< Number of line in the buffer
uint32_t nbTotalColomn; //!< Number of line in the buffer uint32_t nbTotalColomn; //!< Number of line in the buffer
uint32_t startLineDisplay; //!< First line display. uint32_t startLineDisplay; //!< First line display.
uint32_t startColomnDisplay; //!< First Colomn displayed uint32_t startColomnDisplay; //!< First Colomn displayed
uint32_t diplayableColomn; //!< NB colomn that can be displayed uint32_t diplayableColomn; //!< NB colomn that can be displayed
uint32_t diplayableLine; //!< NB Line that can be displayed uint32_t diplayableLine; //!< NB Line that can be displayed
}infoStatBuffer_ts; }infoStatBuffer_ts;
typedef struct {
int32_t m_idAnchor; //!< reference id of the anchor (real id of the upper displayer of CodeView)
bool m_curent; //!< set at true if the anchor is a reference with the curent display
int32_t m_lineId; //!< first line ID to display
int32_t m_bufferPos; //!< position of the first lineId
position_ts m_displayStart; //!< start display position
position_ts m_displaySize; //!< size of the curent display
} bufferAnchorReference_ts;
typedef struct {
position_ts m_displayStart; //!< start display position
position_ts m_displaySize; //!< size of the curent display
int32_t m_lineNumber; //!< current line-number id
int32_t m_nbIterationMax; //!< number of cycle needed to end the dispalay
int32_t m_posStart; //!< position of the start of the line
int32_t m_posStop; //!< position of the end of the line
int32_t m_selectionPosStart; //!< position of the selection start
int32_t m_selectionPosStop; //!< position of the selection stop
} bufferAnchor_ts;
}
class Buffer { class Buffer {
public: public:
Buffer(void); Buffer(void);
Buffer(Edn::String &filename); Buffer(Edn::File &newName);
virtual ~Buffer(void); virtual ~Buffer(void);
Edn::File GetFileName(void);
virtual Edn::String GetName(void); Edn::File GetFileName(void)
virtual Edn::String GetShortName(void); {
virtual Edn::String GetFolder(void); return m_fileName;
virtual void SetName(Edn::String &newName); };
void SetFileName(Edn::File &newName)
{
m_fileName = newName;
m_haveName = true;
NameChange();
};
void SetFileName(Edn::String &newName)
{
m_fileName.SetCompleateName(newName);
m_haveName = true;
NameChange();
};
bool HaveName(void)
{
return m_haveName;
}
virtual void Save(void); virtual void Save(void);
virtual bool HaveName(void);
bool IsModify(void); bool IsModify(void);
protected: protected:
void SetModify(bool status); void SetModify(bool status);
virtual void NameChange(void) { /*EDN_DEBUG("check name change ==> no HL change possible");*/};
public: public:
virtual void GetInfo(infoStatBuffer_ts &infoToUpdate); virtual void GetInfo(infoStatBuffer_ts &infoToUpdate);
virtual void SetLineDisplay(uint32_t lineNumber); virtual void SetLineDisplay(uint32_t lineNumber);
virtual int32_t Display(DrawerManager &drawer); virtual void DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor);
virtual void ForceReDraw(bool allElement); // return the new cursor position ...
virtual void AddChar(char * UTF8data); virtual void AddChar(char * UTF8data);
virtual void cursorMove(int32_t gtkKey); virtual void cursorMove(int32_t gtkKey);
virtual void MouseSelectFromCursorTo(int32_t width, int32_t height); virtual void MouseSelectFromCursorTo(int32_t width, int32_t height);
virtual void MouseEvent(int32_t width, int32_t height); virtual void MouseEvent(int32_t width, int32_t height);
virtual void MouseEventDouble(void); virtual void MouseEventDouble(void);
virtual void MouseEventTriple(void); virtual void MouseEventTriple(void);
virtual void ScrollDown(void);
virtual void ScrollUp(void);
virtual void RemoveLine(void); virtual void RemoveLine(void);
virtual void SelectAll(void); virtual void SelectAll(void);
virtual void SelectNone(void); virtual void SelectNone(void);
virtual void Undo(void); virtual void Undo(void);
virtual void Redo(void); virtual void Redo(void);
virtual void SetCharset(charset_te newCharset) {}; virtual void SetCharset(charset_te newCharset) {};
virtual void ScrollDown(void); // must be deprecated
virtual void ScrollUp(void); // must be deprecated
//virtual void SelectAll(void); //virtual void SelectAll(void);
virtual void Copy(int8_t clipboardID); virtual void Copy(int8_t clipboardID);
virtual void Cut(int8_t clipboardID); virtual void Cut(int8_t clipboardID);
@@ -86,11 +130,31 @@ class Buffer {
virtual void Replace(Edn::String &data); virtual void Replace(Edn::String &data);
virtual int32_t FindLine(Edn::String &data); virtual int32_t FindLine(Edn::String &data);
virtual void JumpAtLine(int32_t newLine); virtual void JumpAtLine(int32_t newLine);
virtual int32_t GetCurrentLine(void);
protected: protected:
bool m_fileModify; bool m_fileModify; //!<
Edn::File m_fileName; // naming
Edn::File m_fileName; //!< filename of the curent buffer
bool m_haveName; //!< to know if the file have a name or NOT bool m_haveName; //!< to know if the file have a name or NOT
// anchor section
public:
void AnchorAdd(int32_t anchorID);
void AnchorRm(int32_t anchorID);
virtual bool AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor);
virtual bool AnchorNext(bufferAnchor_ts & anchor);
void AnchorSetSize(int32_t anchorID, int32_t sizePixelX, int32_t sizePixelY);
void AnchorSetStartOffset(int32_t anchorID, int32_t offsetX, int32_t offsetY);
protected:
int32_t m_lineWidth;
int32_t m_lineHeight;
int32_t AnchorRealId(int32_t anchorID);
int32_t AnchorCurrentId(void);
Edn::VectorType<bufferAnchorReference_ts> m_AnchorList; //!< list of all line anchor in the current buffer
int32_t m_uniqueID;
}; };

View File

@@ -1,9 +1,9 @@
/** /**
******************************************************************************* *******************************************************************************
* @file AL_Mutex.h * @file BufferAnchor.cpp
* @brief Editeur De N'ours : Abstraction Layer Mutex * @brief Editeur De N'ours : anchor on a secific buffer (Sources)
* @author Edouard DUPIN * @author Edouard DUPIN
* @date 04/12/2010 * @date 11/09/2011
* @par Project * @par Project
* Edn * Edn
* *
@@ -23,23 +23,16 @@
******************************************************************************* *******************************************************************************
*/ */
#ifndef __AL_MUTEX_H__
#define __AL_MUTEX_H__
//basic mutex with pthread system #include "BufferAnchor.h"
#include <pthread.h>
#include <errno.h>
BufferAnchor::BufferAnchor(void)
{
typedef pthread_mutex_t AL_MUTEX; }
erreurCode_te AL_mutex_init(AL_MUTEX * pointerMutex,bool recursive); BufferAnchor::~BufferAnchor(void)
erreurCode_te AL_mutex_destroy(AL_MUTEX * pointerMutex); {
void AL_mutex_lock(AL_MUTEX * pointerMutex);
void AL_mutex_unlock(AL_MUTEX * pointerMutex);
erreurCode_te AL_mutex_trylock(AL_MUTEX * pointerMutex);
//erreurCode_te AL_mutex_timedlock(AL_MUTEX * pointerMutex, int32_t delay);
#endif
}

View File

@@ -0,0 +1,56 @@
/**
*******************************************************************************
* @file BufferAnchor.h
* @brief Editeur De N'ours : anchor on a secific buffer (header)
* @author Edouard DUPIN
* @date 11/09/2011
* @par Project
* Edn
*
* @par Copyright
* Copyright 2010 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
* You can not earn money with this Software (if the source extract from Edn
* represent less than 50% of original Sources)
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __BUFFER_ANCHOR_H__
#define __BUFFER_ANCHOR_H__
#include "Display.h"
#include "charset.h"
#include "Edn.h"
class BufferAnchor
{
public :
BufferAnchor(void);
~BufferAnchor(void);
MoveAnchor(int32_t offsetLine);
//BufModification(...);
bool DisplayUpdateFirstLine(void);
bool DisplayUpdateNextLine(void);
private :
int32_t m_lineId;
int32_t m_bufferPos;
public:
int32_t m_lineNumber;
int32_t m_posStart;
int32_t m_posStop;
int32_t m_selectionPosStart;
int32_t m_selectionPosStop;
};
#endif

View File

@@ -42,7 +42,8 @@
*/ */
BufferEmpty::BufferEmpty() BufferEmpty::BufferEmpty()
{ {
m_lineWidth = Display::GetFontWidth();
m_lineHeight = Display::GetFontHeight();
} }
/** /**
@@ -67,32 +68,58 @@ BufferEmpty::~BufferEmpty(void)
* @return --- * @return ---
* *
*/ */
int32_t BufferEmpty::Display(DrawerManager &drawer) void BufferEmpty::DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor)
{ {
EDN_DEBUG("Request draw : " << anchor.m_lineNumber);
ColorizeManager * myColorManager = ColorizeManager::getInstance(); ColorizeManager * myColorManager = ColorizeManager::getInstance();
// Get color : // Get color :
Colorize *myColor = NULL; Colorize *myColor = NULL;
if (anchor.m_lineNumber == 0) {
// Clean Buffer // Clean Buffer
drawer.Clean(myColorManager->Get(COLOR_CODE_BASIC_BG) ); drawer.Clean(myColorManager->Get(COLOR_CODE_BASIC_BG) );
myColor = myColorManager->Get("normal"); myColor = myColorManager->Get("normal");
// Draw the 2 comments Lines :
drawer.Text(myColor, 20,20, "edn - Editeur De N'ours, l'Editeur Desoxyribo-Nucleique"); drawer.Text(myColor, 20,20, "edn - Editeur De N'ours, l'Editeur Desoxyribo-Nucleique");
//drawer.Flush(); }
if (anchor.m_lineNumber == 1) {
myColor = myColorManager->Get("commentDoxygen"); myColor = myColorManager->Get("commentDoxygen");
drawer.Text(myColor, 20,25 + Display::GetFontHeight(), "No Buffer Availlable to display"); drawer.Text(myColor, 20,25 + Display::GetFontHeight(), "No Buffer Availlable to display");
drawer.Flush(); }
/* return;
myColor = myColorManager->Get(("SelectedText"));
drawer.Cursor(20, 50);
drawer.EndOfLine(20, 70);
drawer.Tabulation(myColor, 20, 90, 5);
drawer.UTF8UnknownElement(myColor, 20, 120, 3, false);
drawer.Flush();
*/
return ERR_NONE;
} }
bool BufferEmpty::AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor)
{
int32_t localID = AnchorRealId(anchorID);
if (localID >=0) {
EDN_DEBUG("Request anchor");
anchor.m_displaySize.x = m_AnchorList[localID].m_displaySize.x;
anchor.m_displaySize.y = m_AnchorList[localID].m_displaySize.y;
anchor.m_displayStart.x = m_AnchorList[localID].m_displayStart.x;
anchor.m_displayStart.y = m_AnchorList[localID].m_displayStart.y;
anchor.m_nbIterationMax = 2;
anchor.m_lineNumber = m_AnchorList[localID].m_lineId;
anchor.m_posStart = -1;
anchor.m_posStop = -1;
anchor.m_selectionPosStart = -1;
anchor.m_selectionPosStop = -1;
return true;
} else {
return false;
}
}
bool BufferEmpty::AnchorNext(bufferAnchor_ts & anchor)
{
anchor.m_lineNumber++;
EDN_DEBUG("Anchor Next : " << anchor.m_lineNumber);
anchor.m_nbIterationMax--;
if (anchor.m_nbIterationMax<=0) {
return false;
}
return true;
}

View File

@@ -32,7 +32,9 @@ class BufferEmpty : public Buffer {
public: public:
BufferEmpty(void); BufferEmpty(void);
virtual ~BufferEmpty(void); virtual ~BufferEmpty(void);
virtual int32_t Display(DrawerManager &drawer); void DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor);
bool AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor);
bool AnchorNext(bufferAnchor_ts & anchor);
}; };

View File

@@ -62,8 +62,8 @@ BufferManager::~BufferManager(void)
EDN_INFO("~BufferManager::RemoveAll();"); EDN_INFO("~BufferManager::RemoveAll();");
RemoveAll(); RemoveAll();
// clear The list of Buffer // clear The list of Buffer
EDN_INFO("~BufferManager::listBuffer.clear();"); EDN_INFO("~BufferManager::listBuffer.Clear();");
listBuffer.clear(); listBuffer.Clear();
EDN_INFO("~BufferManager::delete(BufferNotExiste);"); EDN_INFO("~BufferManager::delete(BufferNotExiste);");
delete(BufferNotExiste); delete(BufferNotExiste);
} }
@@ -73,6 +73,9 @@ void BufferManager::OnMessage(int32_t id, int32_t dataID)
{ {
switch (id) switch (id)
{ {
case EDN_MSG__BUFFER_CHANGE_CURRENT:
m_idSelected = dataID;
break;
case EDN_MSG__NEW: case EDN_MSG__NEW:
{ {
int32_t newOne = Create(); int32_t newOne = Create();
@@ -81,6 +84,49 @@ void BufferManager::OnMessage(int32_t id, int32_t dataID)
} }
} }
break; break;
case EDN_MSG__BUFF_ID_CLOSE:
// Check buffer existence
if(true == Exist(dataID)) {
// Get the new display buffer
if (m_idSelected == dataID) {
// Try previous buffer
int32_t destBuffer = -1;
for(int32_t ii=dataID-1; ii >= 0; ii--) {
if (true == Exist(ii) ) {
destBuffer = ii;
break;
}
}
//EDN_DEBUG("new buffer selected : ?? " << destBuffer);
// try next buffer
if (-1 == destBuffer) {
for(int32_t ii=dataID+1; ii < listBuffer.Size(); ii++) {
if (true == Exist(ii) ) {
destBuffer = ii;
break;
}
}
}
//EDN_DEBUG("new buffer selected : ?? " << destBuffer);
// set it to the currect display
SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, destBuffer);
}
//EDN_DEBUG("Remove : " << dataID);
// Remove requested buffer
Remove(dataID);
}
break;
case EDN_MSG__BUFF_ID_SAVE:
// Check buffer existence
if(true == Exist(dataID)) {
// If no name ==> request a Gui display ...
if (Get(dataID)->HaveName() == false) {
SendMessage(EDN_MSG__GUI_SHOW_SAVE_AS, dataID);
} else {
Get(dataID)->Save();
}
}
break;
} }
} }
@@ -101,7 +147,7 @@ void BufferManager::OnMessage(int32_t id, int32_t dataID)
void BufferManager::RemoveAll(void) void BufferManager::RemoveAll(void)
{ {
int32_t i; int32_t i;
for (i=0; i<(int32_t)listBuffer.size(); i++) { for (i=0; i<listBuffer.Size(); i++) {
Remove(i); Remove(i);
} }
SendMessage(EDN_MSG__BUFFER_REMOVE_ALL); SendMessage(EDN_MSG__BUFFER_REMOVE_ALL);
@@ -122,8 +168,8 @@ int32_t BufferManager::Create(void)
// allocate a new Buffer // allocate a new Buffer
Buffer *myBuffer = new BufferText(); Buffer *myBuffer = new BufferText();
// Add at the list of element // Add at the list of element
listBuffer.push_back(myBuffer); listBuffer.PushBack(myBuffer);
int32_t basicID = (int32_t)listBuffer.size() - 1; int32_t basicID = listBuffer.Size() - 1;
SendMessage(EDN_MSG__BUFFER_ADD, basicID); SendMessage(EDN_MSG__BUFFER_ADD, basicID);
return basicID; return basicID;
} }
@@ -139,13 +185,14 @@ int32_t BufferManager::Create(void)
* @todo : check if this file is not curently open and return the old ID * @todo : check if this file is not curently open and return the old ID
* *
*/ */
int32_t BufferManager::Open(Edn::String &filename) int32_t BufferManager::Open(Edn::File &myFile)
{ {
// TODO : Check here if the file is already open ==> and display it if needed
// allocate a new Buffer // allocate a new Buffer
Buffer *myBuffer = new BufferText(filename); Buffer *myBuffer = new BufferText(myFile);
// Add at the list of element // Add at the list of element
listBuffer.push_back(myBuffer); listBuffer.PushBack(myBuffer);
int32_t basicID = (int32_t)listBuffer.size() - 1; int32_t basicID = listBuffer.Size() - 1;
SendMessage(EDN_MSG__BUFFER_ADD, basicID); SendMessage(EDN_MSG__BUFFER_ADD, basicID);
return basicID; return basicID;
} }
@@ -159,7 +206,7 @@ Buffer * BufferManager::Get(int32_t BufferID)
return BufferNotExiste; return BufferNotExiste;
} }
// check if the Buffer existed // check if the Buffer existed
if (BufferID < (int32_t)listBuffer.size()) { if (BufferID < listBuffer.Size()) {
// check if the buffer already existed // check if the buffer already existed
if (NULL != listBuffer[BufferID]) { if (NULL != listBuffer[BufferID]) {
return listBuffer[BufferID]; return listBuffer[BufferID];
@@ -167,7 +214,7 @@ Buffer * BufferManager::Get(int32_t BufferID)
EDN_ERROR("non existing Buffer " << BufferID); EDN_ERROR("non existing Buffer " << BufferID);
} }
} else { } else {
EDN_ERROR("call an non existing Buffer number too hight : " << BufferID << " > " << listBuffer.size()); EDN_ERROR("call an non existing Buffer number too hight : " << BufferID << " > " << listBuffer.Size());
} }
return BufferNotExiste; return BufferNotExiste;
} }
@@ -179,7 +226,7 @@ bool BufferManager::Exist(int32_t BufferID)
return false; return false;
} }
// check if the Buffer existed // check if the Buffer existed
if (BufferID < (int32_t)listBuffer.size()) { if (BufferID < listBuffer.Size()) {
// check if the buffer already existed // check if the buffer already existed
if (NULL != listBuffer[BufferID]) { if (NULL != listBuffer[BufferID]) {
return true; return true;
@@ -189,14 +236,23 @@ bool BufferManager::Exist(int32_t BufferID)
} }
int32_t BufferManager::GetId(Edn::String &filename) bool BufferManager::Exist(Edn::File &myFile )
{
if (-1 == GetId(myFile)) {
return false;
}
return true;
}
int32_t BufferManager::GetId(Edn::File &myFile)
{ {
int32_t iii; int32_t iii;
// check if the Buffer existed // check if the Buffer existed
for (iii=0; iii < (int32_t)listBuffer.size(); iii++) { for (iii=0; iii < listBuffer.Size(); iii++) {
// check if the buffer already existed // check if the buffer already existed
if (NULL != listBuffer[iii]) { if (NULL != listBuffer[iii]) {
if ( listBuffer[iii]->GetName() == filename) { if ( listBuffer[iii]->GetFileName() == myFile) {
return iii; return iii;
} }
} }
@@ -204,19 +260,11 @@ int32_t BufferManager::GetId(Edn::String &filename)
return -1; return -1;
} }
bool BufferManager::Exist(Edn::String &filename)
{
if (-1 == GetId(filename)) {
return false;
}
return true;
}
// return the number of buffer (open in the past) if 5 buffer open and 4 close ==> return 5 // return the number of buffer (open in the past) if 5 buffer open and 4 close ==> return 5
uint32_t BufferManager::Size(void) uint32_t BufferManager::Size(void)
{ {
return listBuffer.size(); return listBuffer.Size();
} }
@@ -234,7 +282,7 @@ bool BufferManager::Remove(int32_t BufferID)
return false; return false;
} }
// check if the Buffer existed // check if the Buffer existed
if (BufferID < (int32_t)listBuffer.size()) { if (BufferID < listBuffer.Size()) {
// check if the buffer already existed // check if the buffer already existed
if (NULL != listBuffer[BufferID]) { if (NULL != listBuffer[BufferID]) {
// TODO : Check if it saved... // TODO : Check if it saved...
@@ -253,7 +301,7 @@ bool BufferManager::Remove(int32_t BufferID)
return false; return false;
} }
} else { } else {
EDN_INFO("call an non existing Buffer number too hight : " << BufferID << " > " << listBuffer.size()); EDN_INFO("call an non existing Buffer number too hight : " << BufferID << " > " << listBuffer.Size());
return false; return false;
} }
} }
@@ -269,7 +317,7 @@ bool BufferManager::Remove(int32_t BufferID)
int32_t BufferManager::WitchBuffer(int32_t iEmeElement) int32_t BufferManager::WitchBuffer(int32_t iEmeElement)
{ {
int32_t i; int32_t i;
for (i=0; i<(int32_t)listBuffer.size(); i++) { for (i=0; i<listBuffer.Size(); i++) {
if (NULL != listBuffer[i]) { if (NULL != listBuffer[i]) {
iEmeElement--; iEmeElement--;
// find the element : // find the element :

View File

@@ -31,8 +31,6 @@
#include "BufferEmpty.h" #include "BufferEmpty.h"
#include "Singleton.h" #include "Singleton.h"
#include "MsgBroadcast.h" #include "MsgBroadcast.h"
#include <vector>
#include <string>
class BufferManager: public Singleton<BufferManager>, public MsgBroadcast class BufferManager: public Singleton<BufferManager>, public MsgBroadcast
{ {
@@ -50,13 +48,13 @@ class BufferManager: public Singleton<BufferManager>, public MsgBroadcast
// create a buffer with no element // create a buffer with no element
int32_t Create(void); int32_t Create(void);
// open curent filename // open curent filename
int32_t Open(Edn::String &filename); int32_t Open(Edn::File &myFile);
int32_t GetSelected(void) { return m_idSelected;}; int32_t GetSelected(void) { return m_idSelected;};
void SetSelected(int32_t id) {m_idSelected = id;}; void SetSelected(int32_t id) {m_idSelected = id;};
Buffer * Get(int32_t BufferID); Buffer * Get(int32_t BufferID);
bool Exist(int32_t BufferID); bool Exist(int32_t BufferID);
bool Exist(Edn::String &filename); bool Exist(Edn::File &myFile);
int32_t GetId(Edn::String &filename); int32_t GetId(Edn::File &myFile);
// return the number of buffer (open in the past) if 5 buffer open and 4 close ==> return 5 // return the number of buffer (open in the past) if 5 buffer open and 4 close ==> return 5
uint32_t Size(void); uint32_t Size(void);
int32_t WitchBuffer(int32_t iEmeElement); int32_t WitchBuffer(int32_t iEmeElement);
@@ -65,7 +63,7 @@ class BufferManager: public Singleton<BufferManager>, public MsgBroadcast
private: private:
std::vector<Buffer*> listBuffer; //!< element List of the char Elements Edn::VectorType<Buffer*> listBuffer; //!< element List of the char Elements
void RemoveAll(void); //!< remove all buffer void RemoveAll(void); //!< remove all buffer
int32_t m_idSelected; int32_t m_idSelected;

View File

@@ -29,6 +29,7 @@
#include "BufferText.h" #include "BufferText.h"
#include "toolsMemory.h" #include "toolsMemory.h"
#include "Edn.h" #include "Edn.h"
#include "RegExp.h"
#undef __class__ #undef __class__
#define __class__ "BufferText" #define __class__ "BufferText"
@@ -36,8 +37,10 @@
const uint32_t nbLineAllocatedInBase = 300; const uint32_t nbLineAllocatedInBase = 300;
extern "C"
{
const char * g_pointerForTheDisplayLine[] = {"%1d", "%2d","%3d","%4d","%5d","%6d","%7d","%8d","%9d","%d"};
}
/** /**
* @brief * @brief
@@ -49,18 +52,8 @@ const uint32_t nbLineAllocatedInBase = 300;
*/ */
void BufferText::BasicInit(void) void BufferText::BasicInit(void)
{ {
static int32_t fileBasicID = 0;
NeedToCleanEndPage = true;
// set the first element that is displayed
m_displayStartBufferPos = 0;
// set basic filename :
filename = "Untitled ";
filename += fileBasicID;
// no name ...
haveName = false;
fileBasicID++;
// set the number of the lineNumber; // set the number of the lineNumber;
nbColoneForLineNumber = 1; m_nbColoneForLineNumber = 1;
// init the link with the buffer manager // init the link with the buffer manager
myColorManager = ColorizeManager::getInstance(); myColorManager = ColorizeManager::getInstance();
// Init Selection mode : // Init Selection mode :
@@ -70,12 +63,32 @@ void BufferText::BasicInit(void)
m_cursorPos = 0; m_cursorPos = 0;
m_cursorPreferredCol = -1; m_cursorPreferredCol = -1;
m_cursorOn = true; m_cursorOn = true;
//m_cursorMode = CURSOR_DISPLAY_MODE_NORMAL;
m_displayStart.x = 0; m_lineWidth = Display::GetFontWidth();
m_displayStart.y = 0; m_lineHeight = Display::GetFontHeight();
m_displaySize.x = 200; }
m_displaySize.y = 20;
m_displayLocalSyntax.idSequence = -1;
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void BufferText::NameChange(void)
{
// Find HL system
//EDN_DEBUG("check name change");
if (true == HighlightManager::getInstance()->Exist(m_fileName)) {
Highlight * myHL = HighlightManager::getInstance()->Get(m_fileName);
// Set the new HL
if (NULL != myHL) {
m_EdnBuf.SetHLSystem(myHL);
}
}
} }
@@ -103,16 +116,15 @@ BufferText::BufferText()
* @return --- * @return ---
* *
*/ */
BufferText::BufferText(Edn::String &newFileName) BufferText::BufferText(Edn::File &fileName) : Buffer(fileName)
{ {
BasicInit(); BasicInit();
EDN_INFO("Add Data from file(" << newFileName.c_str() << ")"); NameChange();
EDN_INFO("Add Data from file(" << GetFileName() << ")");
FILE * myFile = NULL; FILE * myFile = NULL;
// set the filename :
SetName(newFileName);
// try to open the file. if not existed, new file // try to open the file. if not existed, new file
myFile = fopen(newFileName.c_str(), "r"); myFile = fopen(fileName.GetCompleateName().c_str(), "r");
if (NULL != myFile) { if (NULL != myFile) {
m_EdnBuf.DumpFrom(myFile); m_EdnBuf.DumpFrom(myFile);
// close the input file // close the input file
@@ -120,11 +132,10 @@ BufferText::BufferText(Edn::String &newFileName)
SetModify(false); SetModify(false);
} else { } else {
// fichier inexistant... creation d'un nouveaux // fichier inexistant... creation d'un nouveaux
EDN_WARNING("No File ==> created a new one(" << newFileName.c_str() << ")"); EDN_WARNING("No File ==> created a new one(" << GetFileName() << ")");
SetModify(true); SetModify(true);
} }
UpdateWindowsPosition(); UpdateWindowsPosition();
ForceReDraw(true);
} }
@@ -138,9 +149,9 @@ BufferText::BufferText(Edn::String &newFileName)
*/ */
void BufferText::Save(void) void BufferText::Save(void)
{ {
EDN_INFO("Save File : \"" << filename.c_str() << "\"" ); EDN_INFO("Save File : \"" << GetFileName() << "\"" );
FILE * myFile = NULL; FILE * myFile = NULL;
myFile = fopen(filename.c_str(), "w"); myFile = fopen(GetFileName().GetCompleateName().c_str(), "w");
if (NULL != myFile) { if (NULL != myFile) {
m_EdnBuf.DumpIn(myFile); m_EdnBuf.DumpIn(myFile);
fclose(myFile); fclose(myFile);
@@ -186,104 +197,6 @@ void BufferText::SelectionCheckMode(void)
} }
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
Edn::String BufferText::GetName(void)
{
return filename;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
Edn::String BufferText::GetShortName(void)
{
char *ptr = strrchr(filename.c_str(), '/');
if (NULL == ptr) {
ptr = strrchr(filename.c_str(), '\\');
}
Edn::String out = filename;
if (NULL != ptr) {
out = ptr+1;
}
return out;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
Edn::String BufferText::GetFolder(void)
{
char tmpVal[4096];
strncpy(tmpVal, filename.c_str(), 4096);
tmpVal[4096-1] = '\0';
char *ptr = strrchr(tmpVal, '/');
if (NULL == ptr) {
ptr = strrchr(tmpVal, '\\');
}
Edn::String out = "./";
if (NULL != ptr) {
*ptr = '\0';
out = tmpVal;
}
return out;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
bool BufferText::HaveName(void)
{
return haveName;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void BufferText::SetName(Edn::String &newName)
{
filename = newName;
haveName = true;
// Find HL system
if (true == HighlightManager::getInstance()->Exist(newName)) {
Highlight * myHL = HighlightManager::getInstance()->Get(newName);
// Set the new HL
if (NULL != myHL) {
m_EdnBuf.SetHLSystem(myHL);
}
}
}
/** /**
* @brief * @brief
* *
@@ -312,101 +225,86 @@ void BufferText::SetLineDisplay(uint32_t lineNumber)
void BufferText::DrawLineNumber(DrawerManager &drawer,char *myPrint, int32_t lineNumber, int32_t positionY)
void BufferText::DrawLineNumber(DrawerManager &drawer, int32_t lineNumber, int32_t positionY)
{ {
int32_t letterHeight = Display::GetFontHeight();
char tmpLineNumber[50]; char tmpLineNumber[50];
sprintf(tmpLineNumber, myPrint, lineNumber); sprintf(tmpLineNumber, g_pointerForTheDisplayLine[m_nbColoneForLineNumber-1], lineNumber);
drawer.Text(myColorManager->Get(COLOR_CODE_LINE_NUMBER), 1, positionY, tmpLineNumber); drawer.Text(myColorManager->Get(COLOR_CODE_LINE_NUMBER), 1, positionY, tmpLineNumber);
} }
/** /**
* @brief Display the curent buffer with all the probematic imposed by the xharset and the user contraint. * @brief Update internal data of the pointer to display
* *
* @param[in,out] drawer the basic user drawer of EDN. * @param[in,out] ---
* *
* @return * @return ---
* *
*/ */
int32_t BufferText::Display(DrawerManager &drawer) void BufferText::UpdatePointerNumber(void)
{ {
int32_t letterHeight = Display::GetFontHeight();
int32_t letterWidth = Display::GetFontWidth();
// update the number of element that can be displayed
m_displaySize.x = (drawer.GetWidth()/letterWidth) + 1 - nbColoneForLineNumber;;
m_displaySize.y = (drawer.GetHeight()/letterHeight) + 1;
EDN_INFO("main DIPLAY " << m_displaySize.x << " char * " << m_displaySize.y << " char");
int32_t selStart, selEnd, selRectStart, selRectEnd;
bool selIsRect;
int32_t selHave = m_EdnBuf.GetSelectionPos(SELECTION_PRIMARY, selStart, selEnd, selIsRect, selRectStart, selRectEnd);
colorInformation_ts * HLColor = NULL;
//displayLineNumber(drawer);
// get the number of line in the buffer // get the number of line in the buffer
int32_t maxNumberLine = m_EdnBuf.NumberOfLines(); int32_t maxNumberLine = m_EdnBuf.NumberOfLines();
//int32_t maxNumberLine = 2096; //int32_t maxNumberLine = 2096;
char *myPrint = NULL; if (10 > maxNumberLine) { m_nbColoneForLineNumber = 1;
if (10 > maxNumberLine) { nbColoneForLineNumber = 1; myPrint = (char *)"%1d"; } else if (100 > maxNumberLine) { m_nbColoneForLineNumber = 2;
} else if (100 > maxNumberLine) { nbColoneForLineNumber = 2; myPrint = (char *)"%2d"; } else if (1000 > maxNumberLine) { m_nbColoneForLineNumber = 3;
} else if (1000 > maxNumberLine) { nbColoneForLineNumber = 3; myPrint = (char *)"%3d"; } else if (10000 > maxNumberLine) { m_nbColoneForLineNumber = 4;
} else if (10000 > maxNumberLine) { nbColoneForLineNumber = 4; myPrint = (char *)"%4d"; } else if (100000 > maxNumberLine) { m_nbColoneForLineNumber = 5;
} else if (100000 > maxNumberLine) { nbColoneForLineNumber = 5; myPrint = (char *)"%5d"; } else if (1000000 > maxNumberLine) { m_nbColoneForLineNumber = 6;
} else if (1000000 > maxNumberLine) { nbColoneForLineNumber = 6; myPrint = (char *)"%6d"; } else if (1000000 > maxNumberLine) { m_nbColoneForLineNumber = 7;
} else if (1000000 > maxNumberLine) { nbColoneForLineNumber = 7; myPrint = (char *)"%7d"; } else if (10000000 > maxNumberLine) { m_nbColoneForLineNumber = 8;
} else if (10000000 > maxNumberLine) { nbColoneForLineNumber = 8; myPrint = (char *)"%8d"; } else if (100000000 > maxNumberLine) { m_nbColoneForLineNumber = 9;
} else if (100000000 > maxNumberLine) { nbColoneForLineNumber = 9; myPrint = (char *)"%9d"; } else { m_nbColoneForLineNumber = 10;
} else { nbColoneForLineNumber = 10; myPrint = (char *)"%d";
} }
}
uint32_t y = 0;
int32_t iii, new_i; void BufferText::DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor)
// Get color : {
Colorize * myColor = myColorManager->Get("normal");
Colorize * myColorSel = myColorManager->Get("SelectedText"); int32_t letterHeight = Display::GetFontHeight();
color_ts & myColorSpace = myColorManager->Get(COLOR_CODE_SPACE); int32_t letterWidth = Display::GetFontWidth();
color_ts & myColorTab = myColorManager->Get(COLOR_CODE_TAB); int32_t positionY = letterHeight * (anchor.m_lineNumber - anchor.m_displayStart.y - 1);
int32_t idX = 0;
int32_t pixelX = m_nbColoneForLineNumber*letterWidth + 3;
Colorize * myColorNormal = myColorManager->Get("normal");
Colorize * myColorSelected = myColorManager->Get("SelectedText");
Colorize * selectColor = NULL; Colorize * selectColor = NULL;
colorInformation_ts * HLColor = NULL;
// Regenerate the colorizing if necessary ...
displayHLData_ts myDisplayLocalSyntax;
m_EdnBuf.HightlightOneLine(myDisplayLocalSyntax, anchor.m_posStart, anchor.m_posStop);
// clean the current Line
drawer.Rectangle(myColorManager->Get(COLOR_CODE_BASIC_BG), 0, positionY, drawer.GetWidth(), letterHeight);
DrawLineNumber(drawer, anchor.m_lineNumber, positionY);
bool selHave = anchor.m_selectionPosStart == -1 ? false : true;
char displayChar[MAX_EXP_CHAR_LEN]; char displayChar[MAX_EXP_CHAR_LEN];
memset(displayChar, 0, sizeof(char)*MAX_EXP_CHAR_LEN); memset(displayChar, 0, sizeof(char)*MAX_EXP_CHAR_LEN);
int32_t iii;
for (iii=anchor.m_posStart; iii<anchor.m_posStop; ) {
int mylen = m_EdnBuf.Size(); uint32_t currentChar;
int32_t x_base=nbColoneForLineNumber*letterWidth + 3; int32_t savePositionForCursor = iii;
uint32_t xx = 0; int32_t displaywidth = m_EdnBuf.GetExpandedChar(iii, idX, displayChar, currentChar);
int32_t idX = 0; selectColor = myColorNormal;
drawer.Clean(myColorManager->Get(COLOR_CODE_BASIC_BG));
int displayLines = 0;
// Regenerate the colorizing if necessary ...
m_EdnBuf.HightlightGenerateLines(m_displayLocalSyntax, m_displayStartBufferPos, m_displaySize.y);
GTimeVal timeStart;
g_get_current_time(&timeStart);
// draw the lineNumber :
int32_t currentLineID = m_displayStart.y+1;
DrawLineNumber(drawer, myPrint, currentLineID, y);
for (iii=m_displayStartBufferPos; iii<mylen && displayLines < m_displaySize.y ; iii = new_i) {
//EDN_INFO("diplay element=" << iii);
int32_t pixelX = xx*letterWidth + x_base;
int displaywidth;
uint32_t currentChar = '\0';
new_i = iii;
displaywidth = m_EdnBuf.GetExpandedChar(new_i, idX, displayChar, currentChar);
//EDN_INFO("diplay element=" << new_i);
if (currentChar!='\n') {
selectColor = myColor;
//kwow size to display //kwow size to display
int32_t widthToDisplay; int32_t widthToDisplay;
char * tmpDisplayOfset; char * tmpDisplayOfset;
bool inTheScreen = true; bool inTheScreen = true;
if (m_displayStart.x <= idX) { if (anchor.m_displayStart.x <= idX) {
// Normal display // Normal display
tmpDisplayOfset = displayChar; tmpDisplayOfset = displayChar;
widthToDisplay = displaywidth; widthToDisplay = displaywidth;
} else if (m_displayStart.x < idX + displaywidth) { } else if (anchor.m_displayStart.x < idX + displaywidth) {
// special case of partial display : // special case of partial display :
widthToDisplay = idX + displaywidth - m_displayStart.x; widthToDisplay = idX + displaywidth - anchor.m_displayStart.x;
tmpDisplayOfset = displayChar + (displaywidth-widthToDisplay); tmpDisplayOfset = displayChar + (displaywidth-widthToDisplay);
} else { } else {
// Out of range ... // Out of range ...
@@ -415,112 +313,92 @@ int32_t BufferText::Display(DrawerManager &drawer)
inTheScreen = false; inTheScreen = false;
} }
if (true==inTheScreen) { if (true==inTheScreen) {
HLColor = m_EdnBuf.GetElementColorAtPosition(m_displayLocalSyntax, iii); HLColor = m_EdnBuf.GetElementColorAtPosition(myDisplayLocalSyntax, savePositionForCursor);
if (NULL != HLColor) { if (NULL != HLColor) {
if (NULL != HLColor->patern) { if (NULL != HLColor->patern) {
selectColor = HLColor->patern->GetColor(); selectColor = HLColor->patern->GetColor();
} }
} }
// If user want to display space char : overwrite curent color // If user want to display space char : overwrite curent color
if( ' ' == currentChar if( ' ' == currentChar
&& true == globals::IsSetDisplaySpaceChar() ) && true == globals::IsSetDisplaySpaceChar() )
{ {
//selectColor = myColorSel; //selectColor = myColorSelected;
//SpaceText(color_ts & SelectColor, int32_t x, int32_t y,int32_t nbChar) //SpaceText(color_ts & SelectColor, int32_t x, int32_t y,int32_t nbChar)
if( true == selHave if( true == selHave
&& selStart <= iii && anchor.m_selectionPosStart <= iii
&& selEnd > iii) && anchor.m_selectionPosStop > iii)
{ {
drawer.SpaceText(myColorSel->GetBG(), pixelX ,y , 1); drawer.SpaceText(myColorSelected->GetBG(), pixelX ,positionY , 1);
} else if (true == selectColor->HaveBg()) { } else if (true == selectColor->HaveBg()) {
drawer.SpaceText(selectColor->GetBG(), pixelX ,y , 1); drawer.SpaceText(selectColor->GetBG(), pixelX ,positionY , 1);
} else { } else {
drawer.SpaceText(myColorSpace, pixelX ,y , 1); drawer.SpaceText(myColorManager->Get(COLOR_CODE_SPACE), pixelX ,positionY , 1);
} }
} else if( '\t' == currentChar } else if( '\t' == currentChar
&& true == globals::IsSetDisplaySpaceChar() ) && true == globals::IsSetDisplaySpaceChar() )
{ {
if( true == selHave if( true == selHave
&& selStart <= iii && anchor.m_selectionPosStart <= iii
&& selEnd > iii) && anchor.m_selectionPosStop > iii)
{ {
drawer.SpaceText(myColorSel->GetBG(), pixelX ,y , strlen(tmpDisplayOfset)); drawer.SpaceText(myColorSelected->GetBG(), pixelX ,positionY , strlen(tmpDisplayOfset));
} else if (true == selectColor->HaveBg()) { } else if (true == selectColor->HaveBg()) {
drawer.SpaceText(selectColor->GetBG(), pixelX ,y , strlen(tmpDisplayOfset)); drawer.SpaceText(selectColor->GetBG(), pixelX ,positionY , strlen(tmpDisplayOfset));
} else { } else {
drawer.SpaceText(myColorTab, pixelX ,y , strlen(tmpDisplayOfset)); drawer.SpaceText(myColorManager->Get(COLOR_CODE_TAB), pixelX ,positionY , strlen(tmpDisplayOfset));
} }
} else { } else {
if( true == selHave if( true == selHave
&& selStart <= iii && anchor.m_selectionPosStart <= iii
&& selEnd > iii) && anchor.m_selectionPosStop > iii)
{ {
selectColor = myColorSel; selectColor = myColorSelected;
} }
if (currentChar <= 0x7F) { if (currentChar <= 0x7F) {
drawer.Text(selectColor, pixelX ,y, tmpDisplayOfset); drawer.Text(selectColor, pixelX ,positionY, tmpDisplayOfset);
} else { } else {
drawer.Text(selectColor, pixelX ,y, displayChar); drawer.Text(selectColor, pixelX ,positionY, displayChar);
} }
} }
xx+=widthToDisplay;
}
idX += displaywidth;
} }
// display cursor : // display cursor :
if (m_cursorPos == iii) { if (m_cursorPos == savePositionForCursor) {
// display the cursor: // display the cursor:
if (true == m_cursorOn) { if (true == m_cursorOn) {
drawer.Cursor(pixelX, y+letterHeight); drawer.Cursor(pixelX, positionY+letterHeight);
//m_cursorOn = false; //m_cursorOn = false;
} else { } else {
m_cursorOn = true; m_cursorOn = true;
} }
} }
// move to next line ... if (true==inTheScreen) {
if (currentChar=='\n') { pixelX += widthToDisplay*letterWidth;
drawer.EndOfLine(pixelX, y+letterHeight);
drawer.Flush();
xx = 0;
idX =0;
y += letterHeight;
displayLines++;
currentLineID++;
DrawLineNumber(drawer, myPrint, currentLineID, y);
} }
idX += displaywidth;
} }
// special case : the cursor is at the end of the buffer... // special case : the cursor is at the end of the buffer...
if (m_cursorPos == iii) { if (m_cursorPos == iii) {
// display the cursor: // display the cursor:
if (true == m_cursorOn) { if (true == m_cursorOn) {
drawer.Cursor(xx*letterWidth + x_base, y+letterHeight); drawer.Cursor(pixelX, positionY+letterHeight);
m_cursorOn = false; //m_cursorOn = false;
} else { } else {
m_cursorOn = true; m_cursorOn = true;
} }
} }
drawer.Flush();
GTimeVal timeStop;
g_get_current_time(&timeStop);
EDN_DEBUG("Display Generation = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s");
return ERR_NONE;
} }
void BufferText::GetMousePosition(int32_t width, int32_t height, int32_t &x, int32_t &y) void BufferText::GetMousePosition(int32_t width, int32_t height, int32_t &x, int32_t &y)
{ {
x = (width - 3) / Display::GetFontWidth() - nbColoneForLineNumber; x = (width - 3) / Display::GetFontWidth() - m_nbColoneForLineNumber;
y = height / Display::GetFontHeight(); y = height / Display::GetFontHeight();
if (x < 0) { if (x < 0) {
x = 0; x = 0;
} }
x += m_displayStart.x; x += m_AnchorList[AnchorCurrentId()].m_displayStart.x;
y += m_displayStart.y; y += m_AnchorList[AnchorCurrentId()].m_displayStart.y;
//EDN_DEBUG("BufferText::GetMousePosition(" << width << "," << height << "); ==> (" << x << "," << y << ")" ); //EDN_DEBUG("BufferText::GetMousePosition(" << width << "," << height << "); ==> (" << x << "," << y << ")" );
} }
@@ -555,7 +433,6 @@ void BufferText::MouseEvent(int32_t width, int32_t height)
} }
m_EdnBuf.Unselect(SELECTION_PRIMARY); m_EdnBuf.Unselect(SELECTION_PRIMARY);
ForceReDraw(true);
UpdateWindowsPosition(); UpdateWindowsPosition();
} }
} }
@@ -605,7 +482,6 @@ void BufferText::MouseSelectFromCursorTo(int32_t width, int32_t height)
m_EdnBuf.Select(SELECTION_PRIMARY, selStart, m_cursorPos); m_EdnBuf.Select(SELECTION_PRIMARY, selStart, m_cursorPos);
} }
} }
ForceReDraw(true);
UpdateWindowsPosition(); UpdateWindowsPosition();
} }
@@ -625,7 +501,6 @@ void BufferText::MouseEventDouble(void)
if (true == m_EdnBuf.SelectAround(m_cursorPos, beginPos, endPos)) { if (true == m_EdnBuf.SelectAround(m_cursorPos, beginPos, endPos)) {
m_EdnBuf.Select(SELECTION_PRIMARY, beginPos, endPos); m_EdnBuf.Select(SELECTION_PRIMARY, beginPos, endPos);
m_cursorPos = endPos; m_cursorPos = endPos;
ForceReDraw(true);
} }
// no else // no else
} }
@@ -642,7 +517,6 @@ void BufferText::MouseEventTriple(void)
{ {
m_EdnBuf.Select(SELECTION_PRIMARY, m_EdnBuf.StartOfLine(m_cursorPos), m_EdnBuf.EndOfLine(m_cursorPos)); m_EdnBuf.Select(SELECTION_PRIMARY, m_EdnBuf.StartOfLine(m_cursorPos), m_EdnBuf.EndOfLine(m_cursorPos));
m_cursorPos = m_EdnBuf.EndOfLine(m_cursorPos); m_cursorPos = m_EdnBuf.EndOfLine(m_cursorPos);
ForceReDraw(true);
} }
void BufferText::RemoveLine(void) void BufferText::RemoveLine(void)
@@ -658,13 +532,11 @@ void BufferText::SelectAll(void)
{ {
m_EdnBuf.Select(SELECTION_PRIMARY, 0, m_EdnBuf.Size()); m_EdnBuf.Select(SELECTION_PRIMARY, 0, m_EdnBuf.Size());
m_cursorPos = m_EdnBuf.Size(); m_cursorPos = m_EdnBuf.Size();
ForceReDraw(true);
} }
void BufferText::SelectNone(void) void BufferText::SelectNone(void)
{ {
m_EdnBuf.Unselect(SELECTION_PRIMARY); m_EdnBuf.Unselect(SELECTION_PRIMARY);
ForceReDraw(true);
} }
/** /**
@@ -705,44 +577,31 @@ void BufferText::ScrollUp(void)
*/ */
void BufferText::MoveUpDown(int32_t ofset) void BufferText::MoveUpDown(int32_t ofset)
{ {
m_displayLocalSyntax.idSequence = -1; int32_t iii=AnchorCurrentId();
if (ofset >= 0) { if (ofset >= 0) {
int32_t nbLine = m_EdnBuf.NumberOfLines(); int32_t nbLine = m_EdnBuf.NumberOfLines();
if (m_displayStart.y+ofset+3 > nbLine) { if (m_AnchorList[iii].m_displayStart.y+ofset+3 > nbLine) {
m_displayStart.y = nbLine-3; m_AnchorList[iii].m_displayStart.y = nbLine-3;
} else { } else {
m_displayStart.y += ofset; m_AnchorList[iii].m_displayStart.y += ofset;
} }
m_displayStartBufferPos = m_EdnBuf.CountForwardNLines(0, m_displayStart.y); m_AnchorList[iii].m_bufferPos = m_EdnBuf.CountForwardNLines(0, m_AnchorList[iii].m_displayStart.y);
m_AnchorList[iii].m_lineId = m_AnchorList[iii].m_displayStart.y;
} else { } else {
ofset *= -1; ofset *= -1;
if (m_displayStart.y < ofset) { if (m_AnchorList[iii].m_displayStart.y < ofset) {
m_displayStart.y = 0; m_AnchorList[iii].m_displayStart.y = 0;
m_displayStartBufferPos = 0; m_AnchorList[iii].m_bufferPos = 0;
m_AnchorList[iii].m_lineId = 0;
} else { } else {
m_displayStart.y -= ofset; m_AnchorList[iii].m_displayStart.y -= ofset;
m_displayStartBufferPos = m_EdnBuf.CountForwardNLines(0, m_displayStart.y); m_AnchorList[iii].m_bufferPos = m_EdnBuf.CountForwardNLines(0, m_AnchorList[iii].m_displayStart.y);
m_AnchorList[iii].m_lineId = m_AnchorList[iii].m_displayStart.y;
} }
} }
} }
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void BufferText::ForceReDraw(bool allElement)
{
NeedToCleanEndPage = true;
//m_displayLocalSyntax.idSequence = -1;
}
void BufferText::SetInsertPosition(int32_t newPos, bool insertChar) void BufferText::SetInsertPosition(int32_t newPos, bool insertChar)
{ {
int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd; int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
@@ -925,7 +784,7 @@ void BufferText::cursorMove(int32_t gtkKey)
case GDK_Page_Up: case GDK_Page_Up:
# endif # endif
//EDN_INFO("keyEvent : <PAGE-UP>"); //EDN_INFO("keyEvent : <PAGE-UP>");
TextDMoveUp(m_displaySize.x); TextDMoveUp(m_AnchorList[AnchorCurrentId()].m_displaySize.x);
break; break;
# ifdef USE_GTK_VERSION_3_0 # ifdef USE_GTK_VERSION_3_0
case GDK_KEY_Page_Down: case GDK_KEY_Page_Down:
@@ -933,7 +792,7 @@ void BufferText::cursorMove(int32_t gtkKey)
case GDK_Page_Down: case GDK_Page_Down:
# endif # endif
//EDN_INFO("keyEvent : <PAGE-DOWN>"); //EDN_INFO("keyEvent : <PAGE-DOWN>");
TextDMoveDown(m_displaySize.x); TextDMoveDown(m_AnchorList[AnchorCurrentId()].m_displaySize.x);
break; break;
# ifdef USE_GTK_VERSION_3_0 # ifdef USE_GTK_VERSION_3_0
case GDK_KEY_Begin: case GDK_KEY_Begin:
@@ -972,40 +831,38 @@ void BufferText::cursorMove(int32_t gtkKey)
*/ */
void BufferText::UpdateWindowsPosition(bool centerPage) void BufferText::UpdateWindowsPosition(bool centerPage)
{ {
for (int32_t iii=0; iii < m_AnchorList.Size() ; iii++) {
if (centerPage == false) { if (centerPage == false) {
// Display position (Y mode): // Display position (Y mode):
//EDN_INFO("BufferText::UpdateWindowsPosition() m_displayStart(" << m_displayStart.x << "," << m_displayStart.y << ") m_displaySize(" << m_displaySize.x << "," <<m_displaySize.y << ")"); //EDN_INFO(" m_displayStart(" << m_displayStart.x << "," << m_displayStart.y << ") m_displaySize(" << m_displaySize.x << "," <<m_displaySize.y << ")");
position_ts cursorPosition; position_ts cursorPosition;
cursorPosition.y = m_EdnBuf.CountLines(0, m_cursorPos); cursorPosition.y = m_EdnBuf.CountLines(0, m_cursorPos);
int32_t lineStartPos = m_EdnBuf.StartOfLine(m_cursorPos); int32_t lineStartPos = m_EdnBuf.StartOfLine(m_cursorPos);
cursorPosition.x = m_EdnBuf.CountDispChars(lineStartPos, m_cursorPos); cursorPosition.x = m_EdnBuf.CountDispChars(lineStartPos, m_cursorPos);
//EDN_INFO("BufferText::UpdateWindowsPosition() curent cursor position : (" << cursorPosition.x << "," << cursorPosition.y << ")"); //EDN_INFO(" curent cursor position : (" << cursorPosition.x << "," << cursorPosition.y << ")");
if (m_displayStart.y > (int32_t)cursorPosition.y - globals::getNbLineBorder() ) { if (m_AnchorList[iii].m_displayStart.y > (int32_t)cursorPosition.y - globals::getNbLineBorder() ) {
m_displayStart.y = cursorPosition.y - globals::getNbLineBorder(); m_AnchorList[iii].m_displayStart.y = cursorPosition.y - globals::getNbLineBorder();
if (m_displayStart.y < 0) { if (m_AnchorList[iii].m_displayStart.y < 0) {
m_displayStart.y = 0; m_AnchorList[iii].m_displayStart.y = 0;
ForceReDraw(true);
} }
} else if (m_displayStart.y + m_displaySize.y <= (int32_t)cursorPosition.y + globals::getNbLineBorder() ) { } else if (m_AnchorList[iii].m_displayStart.y + m_AnchorList[iii].m_displaySize.y <= (int32_t)cursorPosition.y + globals::getNbLineBorder() ) {
m_displayStart.y = cursorPosition.y - m_displaySize.y + globals::getNbLineBorder() + 1; m_AnchorList[iii].m_displayStart.y = cursorPosition.y - m_AnchorList[iii].m_displaySize.y + globals::getNbLineBorder() + 1;
ForceReDraw(true);
} }
// Display position (X mode): // Display position (X mode):
//EDN_INFO("cursorPosition X : " << cursorPosition.y << " windows " << m_displayStart.y << "=>" << m_displayStart.x + m_displaySize.x); //EDN_INFO("cursorPosition X : " << cursorPosition.y << " windows " << m_displayStart.y << "=>" << m_displayStart.x + m_displaySize.x);
if (m_displayStart.x > cursorPosition.x - globals::getNbColoneBorder() ) { if (m_AnchorList[iii].m_displayStart.x > cursorPosition.x - globals::getNbColoneBorder() ) {
m_displayStart.x = cursorPosition.x - globals::getNbColoneBorder(); m_AnchorList[iii].m_displayStart.x = cursorPosition.x - globals::getNbColoneBorder();
if (m_displayStart.x < 0) { if (m_AnchorList[iii].m_displayStart.x < 0) {
m_displayStart.x = 0; m_AnchorList[iii].m_displayStart.x = 0;
ForceReDraw(true);
} }
} else if (m_displayStart.x + m_displaySize.x <= cursorPosition.x + globals::getNbColoneBorder() ) { } else if (m_AnchorList[iii].m_displayStart.x + m_AnchorList[iii].m_displaySize.x <= cursorPosition.x + globals::getNbColoneBorder() ) {
m_displayStart.x = cursorPosition.x - m_displaySize.x + globals::getNbColoneBorder() + 1; m_AnchorList[iii].m_displayStart.x = cursorPosition.x - m_AnchorList[iii].m_displaySize.x + globals::getNbColoneBorder() + 1;
ForceReDraw(true);
} }
//update the buffer position ID : //update the buffer position ID :
m_displayStartBufferPos = m_EdnBuf.CountForwardNLines(0, m_displayStart.y); m_AnchorList[iii].m_bufferPos = m_EdnBuf.CountForwardNLines(0, m_AnchorList[iii].m_displayStart.y);
m_AnchorList[iii].m_lineId = m_AnchorList[iii].m_displayStart.y;
} else { } else {
// center the line at the middle of the screen : // center the line at the middle of the screen :
position_ts cursorPosition; position_ts cursorPosition;
@@ -1014,16 +871,16 @@ void BufferText::UpdateWindowsPosition(bool centerPage)
//EDN_DEBUG(" cursor position : " << m_cursorPos << " ==> ligne=" << cursorPosition.y); //EDN_DEBUG(" cursor position : " << m_cursorPos << " ==> ligne=" << cursorPosition.y);
cursorPosition.x = 0; cursorPosition.x = 0;
m_displayStart.x = 0; m_AnchorList[iii].m_displayStart.x = 0;
//EDN_DEBUG(" display size : " << m_displaySize.y); //EDN_DEBUG(" display size : " << m_displaySize.y);
m_displayStart.y = cursorPosition.y - m_displaySize.y/2; m_AnchorList[iii].m_displayStart.y = cursorPosition.y - m_AnchorList[iii].m_displaySize.y/2;
m_displayStart.y = edn_max(m_displayStart.y, 0); m_AnchorList[iii].m_displayStart.y = edn_max(m_AnchorList[iii].m_displayStart.y, 0);
m_AnchorList[iii].m_bufferPos = m_EdnBuf.CountForwardNLines(0, m_AnchorList[iii].m_displayStart.y);
m_displayStartBufferPos = m_EdnBuf.CountForwardNLines(0, m_displayStart.y); m_AnchorList[iii].m_lineId = m_AnchorList[iii].m_displayStart.y;
ForceReDraw(true);
//EDN_DEBUG(" display start : " << m_displayStart.x << "x" << m_displayStart.y); //EDN_DEBUG(" display start : " << m_displayStart.x << "x" << m_displayStart.y);
//EDN_DEBUG(" -------------------------------------------------"); //EDN_DEBUG(" -------------------------------------------------");
} }
}
} }
@@ -1046,20 +903,33 @@ void BufferText::AddChar(char * UTF8data)
if (1==size) { if (1==size) {
if (UTF8data[0] == 0x09) { if (UTF8data[0] == 0x09) {
if (false == haveSelectionActive) { if (false == haveSelectionActive) {
EdnVectorBin<int8_t> tmpVect; Edn::VectorType<int8_t> tmpVect;
tmpVect.PushBack(0x09); tmpVect.PushBack(0x09);
m_EdnBuf.Insert(m_cursorPos, tmpVect); m_EdnBuf.Insert(m_cursorPos, tmpVect);
SetInsertPosition(m_cursorPos+1, true); SetInsertPosition(m_cursorPos+1, true);
} else { } else {
if (true == globals::IsSetCtrl() ) { // Indent depend of the multiline in the selection ...
// count the number of line :
int32_t nbSelectedLines = m_EdnBuf.CountLines(SelectionStart, SelectionEnd);
if (0 == nbSelectedLines) {
Edn::VectorType<int8_t> tmpVect;
tmpVect.PushBack(0x09);
m_EdnBuf.ReplaceSelected(SELECTION_PRIMARY, tmpVect);
SetInsertPosition(SelectionStart+tmpVect.Size(), true);
} else {
if (true == globals::IsSetShift() ) {
m_cursorPos = m_EdnBuf.UnIndent(SELECTION_PRIMARY); m_cursorPos = m_EdnBuf.UnIndent(SELECTION_PRIMARY);
} else { } else {
m_cursorPos = m_EdnBuf.Indent(SELECTION_PRIMARY); m_cursorPos = m_EdnBuf.Indent(SELECTION_PRIMARY);
} }
} }
}
actionDone = true; actionDone = true;
} else if (UTF8data[0] == '\n') { } else if (UTF8data[0] == '\n') {
EdnVectorBin<int8_t> tmpVect; Edn::VectorType<int8_t> tmpVect;
if (true == globals::IsSetShift()) {
tmpVect.PushBack('\r');
} else {
tmpVect.PushBack('\n'); tmpVect.PushBack('\n');
// if Auto indent Enable ==> we get the start of the previous line and add it to tne new one // if Auto indent Enable ==> we get the start of the previous line and add it to tne new one
if (true == globals::IsSetAutoIndent() ) { if (true == globals::IsSetAutoIndent() ) {
@@ -1081,6 +951,7 @@ void BufferText::AddChar(char * UTF8data)
} }
} }
} }
}
// Set temporary buffer in the real buffer // Set temporary buffer in the real buffer
if (false == haveSelectionActive) { if (false == haveSelectionActive) {
m_EdnBuf.Insert(m_cursorPos, tmpVect); m_EdnBuf.Insert(m_cursorPos, tmpVect);
@@ -1114,7 +985,7 @@ void BufferText::AddChar(char * UTF8data)
if (false == actionDone) { if (false == actionDone) {
if (true == m_EdnBuf.GetUTF8Mode()) { if (true == m_EdnBuf.GetUTF8Mode()) {
EdnVectorBin<int8_t> tmpVect; Edn::VectorType<int8_t> tmpVect;
int32_t localOfset = strlen(UTF8data); int32_t localOfset = strlen(UTF8data);
tmpVect.PushBack((int8_t*)UTF8data, localOfset); tmpVect.PushBack((int8_t*)UTF8data, localOfset);
if (false == haveSelectionActive) { if (false == haveSelectionActive) {
@@ -1128,8 +999,8 @@ void BufferText::AddChar(char * UTF8data)
// convert in the Good ISO format : // convert in the Good ISO format :
char output_ISO; char output_ISO;
convertUtf8ToIso(m_EdnBuf.GetCharsetType(), UTF8data, output_ISO); convertUtf8ToIso(m_EdnBuf.GetCharsetType(), UTF8data, output_ISO);
printf(" insert : \"%s\"==> 0x%08x=%d ", UTF8data, (unsigned int)output_ISO, (int)output_ISO); //printf(" insert : \"%s\"==> 0x%08x=%d ", UTF8data, (unsigned int)output_ISO, (int)output_ISO);
EdnVectorBin<int8_t> tmpVect; Edn::VectorType<int8_t> tmpVect;
tmpVect.PushBack(output_ISO); tmpVect.PushBack(output_ISO);
if (false == haveSelectionActive) { if (false == haveSelectionActive) {
m_EdnBuf.Insert(m_cursorPos, tmpVect); m_EdnBuf.Insert(m_cursorPos, tmpVect);
@@ -1145,7 +1016,6 @@ void BufferText::AddChar(char * UTF8data)
UpdateWindowsPosition(); UpdateWindowsPosition();
} }
#include "EdnRegExp.h"
int32_t BufferText::FindLine(Edn::String &data) int32_t BufferText::FindLine(Edn::String &data)
{ {
@@ -1153,8 +1023,8 @@ int32_t BufferText::FindLine(Edn::String &data)
EDN_WARNING("no search data"); EDN_WARNING("no search data");
return 0; return 0;
} }
EDN_INFO("Search data line : \"" << data.c_str() << "\""); EDN_INFO("Search data line : \"" << data << "\"");
EdnVectorBin<int8_t> mVectSearch; Edn::VectorType<int8_t> mVectSearch;
mVectSearch = data.GetVector(); mVectSearch = data.GetVector();
//EDN_INFO("search data Forward : startSearchPos=" << startSearchPos ); //EDN_INFO("search data Forward : startSearchPos=" << startSearchPos );
int32_t foundPos; int32_t foundPos;
@@ -1176,9 +1046,24 @@ void BufferText::JumpAtLine(int32_t newLine)
UpdateWindowsPosition(true); UpdateWindowsPosition(true);
} }
/**
* @brief Get the current line (to know where to jump)
*
* @param ---
*
* @return Return the current line number
*
*/
int32_t BufferText::GetCurrentLine(void)
{
return m_EdnBuf.CountLines(0, m_cursorPos);
}
void BufferText::Search(Edn::String &data, bool back, bool caseSensitive, bool wrap, bool regExp) void BufferText::Search(Edn::String &data, bool back, bool caseSensitive, bool wrap, bool regExp)
{ {
EDN_INFO("Search data : \"" << data.c_str() << "\""); EDN_INFO("Search data : \"" << data << "\"");
int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd; int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
bool SelectionIsRect; bool SelectionIsRect;
@@ -1197,7 +1082,7 @@ void BufferText::Search(Edn::String &data, bool back, bool caseSensitive, bool w
EDN_WARNING("no search data"); EDN_WARNING("no search data");
return; return;
} }
EdnVectorBin<int8_t> mVectSearch; Edn::VectorType<int8_t> mVectSearch;
mVectSearch = data.GetVector(); mVectSearch = data.GetVector();
if (false == back) { if (false == back) {
//EDN_INFO("search data Forward : startSearchPos=" << startSearchPos ); //EDN_INFO("search data Forward : startSearchPos=" << startSearchPos );
@@ -1271,9 +1156,9 @@ void BufferText::Replace(Edn::String &data)
bool haveSelectionActive = m_EdnBuf.GetSelectionPos(SELECTION_PRIMARY, SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd); bool haveSelectionActive = m_EdnBuf.GetSelectionPos(SELECTION_PRIMARY, SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
if (true == haveSelectionActive) { if (true == haveSelectionActive) {
// Replace Data : // Replace Data :
// TODO : Reset this : ... m_EdnBuf.ReplaceSelected(SELECTION_PRIMARY, data.GetDirectPointer());//, strlen(data.GetDirectPointer())); Edn::VectorType<int8_t> myData = data.GetVector();
// TODO : Reset this : ... SetInsertPosition(SelectionStart + strlen(data.GetDirectPointer())); m_EdnBuf.ReplaceSelected(SELECTION_PRIMARY, myData);
SetInsertPosition(SelectionStart + myData.Size());
} }
SetModify(true); SetModify(true);
} }
@@ -1289,7 +1174,7 @@ void BufferText::Replace(Edn::String &data)
*/ */
void BufferText::Copy(int8_t clipboardID) void BufferText::Copy(int8_t clipboardID)
{ {
EdnVectorBin<int8_t> mVect; Edn::VectorType<int8_t> mVect;
// get the curent selected data // get the curent selected data
if (true == m_EdnBuf.SelectHasSelection(SELECTION_PRIMARY) ) { if (true == m_EdnBuf.SelectHasSelection(SELECTION_PRIMARY) ) {
m_EdnBuf.GetSelectionText(SELECTION_PRIMARY, mVect); m_EdnBuf.GetSelectionText(SELECTION_PRIMARY, mVect);
@@ -1309,7 +1194,6 @@ void BufferText::Copy(int8_t clipboardID)
*/ */
void BufferText::Cut(int8_t clipboardID) void BufferText::Cut(int8_t clipboardID)
{ {
int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd; int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
bool SelectionIsRect; bool SelectionIsRect;
bool haveSelectionActive = m_EdnBuf.GetSelectionPos(SELECTION_PRIMARY, SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd); bool haveSelectionActive = m_EdnBuf.GetSelectionPos(SELECTION_PRIMARY, SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
@@ -1323,7 +1207,6 @@ void BufferText::Cut(int8_t clipboardID)
m_cursorPos = SelectionStart; m_cursorPos = SelectionStart;
} }
UpdateWindowsPosition(); UpdateWindowsPosition();
ForceReDraw(true);
SetModify(true); SetModify(true);
} }
@@ -1338,7 +1221,7 @@ void BufferText::Cut(int8_t clipboardID)
*/ */
void BufferText::Paste(int8_t clipboardID) void BufferText::Paste(int8_t clipboardID)
{ {
EdnVectorBin<int8_t> mVect; Edn::VectorType<int8_t> mVect;
// copy data from the click board : // copy data from the click board :
ClipBoard::Get(clipboardID, mVect); ClipBoard::Get(clipboardID, mVect);
@@ -1357,7 +1240,6 @@ void BufferText::Paste(int8_t clipboardID)
} }
UpdateWindowsPosition(); UpdateWindowsPosition();
ForceReDraw(true);
SetModify(true); SetModify(true);
} }
@@ -1368,7 +1250,6 @@ void BufferText::Undo(void)
if (newPos >= 0) { if (newPos >= 0) {
SetInsertPosition(newPos, true); SetInsertPosition(newPos, true);
UpdateWindowsPosition(); UpdateWindowsPosition();
ForceReDraw(true);
SetModify(true); SetModify(true);
} }
} }
@@ -1379,7 +1260,6 @@ void BufferText::Redo(void)
if (newPos >= 0) { if (newPos >= 0) {
SetInsertPosition(newPos, true); SetInsertPosition(newPos, true);
UpdateWindowsPosition(); UpdateWindowsPosition();
ForceReDraw(true);
SetModify(true); SetModify(true);
} }
} }
@@ -1388,6 +1268,59 @@ void BufferText::Redo(void)
void BufferText::SetCharset(charset_te newCharset) void BufferText::SetCharset(charset_te newCharset)
{ {
m_EdnBuf.SetCharsetType(newCharset); m_EdnBuf.SetCharsetType(newCharset);
ForceReDraw(true);
} }
bool BufferText::AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor)
{
int32_t localID = AnchorRealId(anchorID);
if (localID >=0) {
// update internal sise of the width of lineID
UpdatePointerNumber();
// Updata uper size of display
anchor.m_displaySize.x = m_AnchorList[localID].m_displaySize.x;
anchor.m_displaySize.y = m_AnchorList[localID].m_displaySize.y;
anchor.m_displayStart.x = m_AnchorList[localID].m_displayStart.x;
anchor.m_displayStart.y = m_AnchorList[localID].m_displayStart.y;
anchor.m_nbIterationMax = anchor.m_displaySize.y;
// update to buffer position
anchor.m_lineNumber = m_AnchorList[localID].m_lineId +1;
anchor.m_posStart = m_AnchorList[localID].m_bufferPos;
if (anchor.m_posStart >= m_EdnBuf.Size()+1) {
return false;
}
anchor.m_posStop = m_EdnBuf.EndOfLine(anchor.m_posStart);
// Update selection current
int32_t selStart, selEnd, selRectStart, selRectEnd;
bool selIsRect;
bool selHave = m_EdnBuf.GetSelectionPos(SELECTION_PRIMARY, selStart, selEnd, selIsRect, selRectStart, selRectEnd);
if (false == selHave){
anchor.m_selectionPosStart = -1;
anchor.m_selectionPosStop = -1;
} else {
anchor.m_selectionPosStart = selStart+1;
anchor.m_selectionPosStop = selEnd+1;
}
EDN_DEBUG("Request display : line=" << anchor.m_lineNumber << " (" << anchor.m_posStart << "," << anchor.m_posStop << ")");
EDN_DEBUG(" ==> select : (" << anchor.m_selectionPosStart << "," << anchor.m_selectionPosStop << ")");
return true;
} else {
return false;
}
}
bool BufferText::AnchorNext(bufferAnchor_ts & anchor)
{
anchor.m_lineNumber++;
anchor.m_posStart = anchor.m_posStop+1;
if (anchor.m_posStart >= m_EdnBuf.Size()+1) {
return false;
}
anchor.m_posStop = m_EdnBuf.EndOfLine(anchor.m_posStart);
anchor.m_nbIterationMax--;
if (anchor.m_nbIterationMax<0) {
return false;
}
return true;
}

View File

@@ -26,8 +26,6 @@
#ifndef __BUFFER_TEXT_H__ #ifndef __BUFFER_TEXT_H__
#define __BUFFER_TEXT_H__ #define __BUFFER_TEXT_H__
#include <vector>
#include <string>
#include "ColorizeManager.h" #include "ColorizeManager.h"
#include "Buffer.h" #include "Buffer.h"
#include "EdnBuf.h" #include "EdnBuf.h"
@@ -38,23 +36,18 @@ typedef enum {
CURSOR_DISPLAY_MODE_NOT_FOCUS, CURSOR_DISPLAY_MODE_NOT_FOCUS,
} cursorDisplayMode_te; } cursorDisplayMode_te;
class BufferText : public Buffer { class BufferText : public Buffer {
public: public:
BufferText(void); BufferText(void);
BufferText(Edn::String &filename); BufferText(Edn::File &fileName);
virtual ~BufferText(void); virtual ~BufferText(void);
Edn::String GetName(void);
Edn::String GetShortName(void);
Edn::String GetFolder(void);
void SetName(Edn::String &newName);
void Save(void); void Save(void);
bool HaveName(void);
void GetInfo(infoStatBuffer_ts &infoToUpdate); void GetInfo(infoStatBuffer_ts &infoToUpdate);
void SetLineDisplay(uint32_t lineNumber); void SetLineDisplay(uint32_t lineNumber);
int32_t Display(DrawerManager &drawer); void DrawLine(DrawerManager &drawer, bufferAnchor_ts &anchor);
void ForceReDraw(bool allElement);
void AddChar(char * UTF8data); void AddChar(char * UTF8data);
void cursorMove(int32_t gtkKey); void cursorMove(int32_t gtkKey);
void MouseSelectFromCursorTo(int32_t width, int32_t height); void MouseSelectFromCursorTo(int32_t width, int32_t height);
@@ -72,6 +65,8 @@ class BufferText : public Buffer {
void Replace(Edn::String &data); void Replace(Edn::String &data);
int32_t FindLine(Edn::String &data); int32_t FindLine(Edn::String &data);
void JumpAtLine(int32_t newLine); void JumpAtLine(int32_t newLine);
int32_t GetCurrentLine(void);
void RemoveLine(void); void RemoveLine(void);
void SelectAll(void); void SelectAll(void);
void SelectNone(void); void SelectNone(void);
@@ -79,29 +74,29 @@ class BufferText : public Buffer {
void Redo(void); void Redo(void);
void SetCharset(charset_te newCharset); void SetCharset(charset_te newCharset);
private: bool AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor);
// naming bool AnchorNext(bufferAnchor_ts & anchor);
Edn::String filename; //!< filename of the curent buffer protected:
bool haveName; //!< to know if the file have a name or NOT void NameChange(void);
// Display
bool NeedToCleanEndPage; //!< if true, the end of the page need to be clean (arrive after a remove line)
uint32_t nbColoneForLineNumber; //!< number of colome used to display the line Number
ColorizeManager * myColorManager; //!< for the background color :
private:
// Display
ColorizeManager * myColorManager; //!< for the background color :
int32_t m_nbColoneForLineNumber; //!< number of colomn use for linenumber display
// Direct buffer IO // Direct buffer IO
EdnBuf m_EdnBuf; //!< buffer associated on this displayer EdnBuf m_EdnBuf; //!< buffer associated on this displayer
position_ts m_displayStart; //!< position where the display is starting
position_ts m_displaySize; //!< number of char displayable in the screan //position_ts m_displayStart; //!< position where the display is starting
int32_t m_displayStartBufferPos; //!< position where the buffer start //position_ts m_displaySize; //!< number of char displayable in the screan
//int32_t m_displayStartBufferPos; //!< position where the buffer start
// Cursor : // Cursor :
int32_t m_cursorPos; //!< position in the buffer of the cursor int32_t m_cursorPos; //!< position in the buffer of the cursor
int32_t m_cursorPreferredCol; //!< colomn of the last up and down ... int32_t m_cursorPreferredCol; //!< colomn of the last up and down ...
bool m_cursorOn; //!< the blink of the cursor ... bool m_cursorOn; //!< the blink of the cursor ...
cursorDisplayMode_te m_cursorMode; //!< type of cursor Selected cursorDisplayMode_te m_cursorMode; //!< type of cursor Selected
displayHLData_ts m_displayLocalSyntax; //!< for the display of the local elements (display HL mode)
// internal function // internal function
void BasicInit(void); void BasicInit(void);
void UpdateWindowsPosition(bool centerPage = false); void UpdateWindowsPosition(bool centerPage = false);
@@ -120,7 +115,9 @@ class BufferText : public Buffer {
void GetMousePosition(int32_t width, int32_t height, int32_t &x, int32_t &y); void GetMousePosition(int32_t width, int32_t height, int32_t &x, int32_t &y);
void MoveUpDown(int32_t ofset); void MoveUpDown(int32_t ofset);
void DrawLineNumber(DrawerManager &drawer,char *myPrint, int32_t lineNumber, int32_t positionY); void DrawLineNumber(DrawerManager &drawer, int32_t lineNumber, int32_t positionY);
void UpdatePointerNumber(void);
}; };

View File

@@ -49,8 +49,8 @@ class Colorize {
Edn::String GetName(void); Edn::String GetName(void);
void SetFgColor(const char *myColor); void SetFgColor(const char *myColor);
void SetBgColor(const char *myColor); void SetBgColor(const char *myColor);
void ApplyFG(cairo_t * cr) { cairo_set_source_rgb(cr, m_colorFG.red, m_colorFG.green, m_colorFG.blue); }; void ApplyFG(cairo_t * cr) { cairo_set_source_rgba(cr, m_colorFG.red, m_colorFG.green, m_colorFG.blue, 1); };
void ApplyBG(cairo_t * cr) { cairo_set_source_rgb(cr, m_colorBG.red, m_colorBG.green, m_colorBG.blue); }; void ApplyBG(cairo_t * cr) { cairo_set_source_rgba(cr, m_colorBG.red, m_colorBG.green, m_colorBG.blue, 1); };
color_ts & GetFG(void) { return m_colorFG; }; color_ts & GetFG(void) { return m_colorFG; };
color_ts & GetBG(void) { return m_colorBG; }; color_ts & GetBG(void) { return m_colorBG; };

View File

@@ -1,6 +1,6 @@
/** /**
******************************************************************************* *******************************************************************************
* @file ColoriseManager.cpp * @file ColorizeManager.cpp
* @brief Editeur De N'ours : Colorising Manager * @brief Editeur De N'ours : Colorising Manager
* @author Edouard DUPIN * @author Edouard DUPIN
* @date 14/12/2010 * @date 14/12/2010
@@ -30,15 +30,40 @@
#define PFX "ColorizeManager " #define PFX "ColorizeManager "
ColorizeManager::ColorizeManager(void) ColorizeManager::ColorizeManager(void) : MsgBroadcast("Colorize Manager", EDN_CAT_COLOR)
{ {
} }
ColorizeManager::~ColorizeManager(void) ColorizeManager::~ColorizeManager(void)
{ {
delete(errorColor); delete(errorColor);
// TODO : delete all color previously
listMyColor.clear(); int32_t i;
// clean all Element
for (i=0; i< listMyColor.Size(); i++) {
if (NULL != listMyColor[i]) {
delete(listMyColor[i]);
listMyColor[i] = NULL;
}
}
// clear the compleate list
listMyColor.Clear();
}
void ColorizeManager::OnMessage(int32_t id, int32_t dataID)
{
switch (id)
{
case EDN_MSG__RELOAD_COLOR_FILE:
{
// Reaload File
// TODO : Check this : Pb in the recopy Edn::String element
Edn::String plop = m_fileColor;
LoadFile(plop.c_str());
}
break;
}
} }
@@ -49,6 +74,20 @@ void ColorizeManager::LoadFile(Edn::String &xmlFilename)
void ColorizeManager::LoadFile(const char * xmlFilename) void ColorizeManager::LoadFile(const char * xmlFilename)
{ {
// Remove all old color :
int32_t i;
// clean all Element
for (i=0; i< listMyColor.Size(); i++) {
if (NULL != listMyColor[i]) {
delete(listMyColor[i]);
listMyColor[i] = NULL;
}
}
// clear the compleate list
listMyColor.Clear();
m_fileColor = xmlFilename;
EDN_DEBUG("open file (COLOR) \"" << xmlFilename << "\" ? = \"" << m_fileColor << "\"");
errorColor = new Colorize(); errorColor = new Colorize();
errorColor->SetBgColor("#000000"); errorColor->SetBgColor("#000000");
errorColor->SetFgColor("#FFFFFF"); errorColor->SetFgColor("#FFFFFF");
@@ -58,22 +97,17 @@ void ColorizeManager::LoadFile(const char * xmlFilename)
// open the curent File // open the curent File
XmlDocument.LoadFile(xmlFilename); XmlDocument.LoadFile(xmlFilename);
TiXmlElement* root = XmlDocument.FirstChildElement( "EdnColor" ); TiXmlElement* root = XmlDocument.FirstChildElement( "EdnColor" );
if (NULL == root ) if (NULL == root ) {
{
EDN_ERROR(PFX"(l ?) main node not find: \"EdnColor\" in \"" << xmlFilename << "\""); EDN_ERROR(PFX"(l ?) main node not find: \"EdnColor\" in \"" << xmlFilename << "\"");
return; return;
} } else {
else
{
TiXmlNode * pNode = root->FirstChild(); TiXmlNode * pNode = root->FirstChild();
while(NULL != pNode) while(NULL != pNode) {
{
if (pNode->Type()==TiXmlNode::TINYXML_COMMENT) { if (pNode->Type()==TiXmlNode::TINYXML_COMMENT) {
// nothing to do, just proceed to next step // nothing to do, just proceed to next step
} else if (!strcmp(pNode->Value(), "gui")) { } else if (!strcmp(pNode->Value(), "gui")) {
TiXmlNode * pGuiNode = pNode->FirstChild(); TiXmlNode * pGuiNode = pNode->FirstChild();
while(NULL != pGuiNode) while(NULL != pGuiNode) {
{
if (pGuiNode->Type()==TiXmlNode::TINYXML_COMMENT) { if (pGuiNode->Type()==TiXmlNode::TINYXML_COMMENT) {
// nothing to do, just proceed to next step // nothing to do, just proceed to next step
} else if (!strcmp(pGuiNode->Value(), "color")) { } else if (!strcmp(pGuiNode->Value(), "color")) {
@@ -181,7 +215,7 @@ void ColorizeManager::LoadFile(const char * xmlFilename)
myNewColor->SetItalic(true); myNewColor->SetItalic(true);
} }
} }
listMyColor.push_back(myNewColor); listMyColor.PushBack(myNewColor);
} else { } else {
EDN_ERROR(PFX"(l "<<pNode->Row()<<") node not suported : \""<<pNode->Value()<<"\" must be [color]"); EDN_ERROR(PFX"(l "<<pNode->Row()<<") node not suported : \""<<pNode->Value()<<"\" must be [color]");
} }
@@ -194,12 +228,14 @@ void ColorizeManager::LoadFile(const char * xmlFilename)
pNode = pNode->NextSibling(); pNode = pNode->NextSibling();
} }
} }
SendMessage(EDN_MSG__COLOR_HAS_CHANGE);
SendMessage(EDN_MSG__USER_DISPLAY_CHANGE);
} }
Colorize *ColorizeManager::Get(const char *colorName) Colorize *ColorizeManager::Get(const char *colorName)
{ {
uint32_t i; int32_t i;
for (i=0; i<listMyColor.size(); i++) { for (i=0; i<listMyColor.Size(); i++) {
Edn::String elementName = listMyColor[i]->GetName(); Edn::String elementName = listMyColor[i]->GetName();
if (elementName == colorName) { if (elementName == colorName) {
return listMyColor[i]; return listMyColor[i];
@@ -227,8 +263,8 @@ color_ts & ColorizeManager::Get(basicColor_te myColor)
bool ColorizeManager::Exist(const char *colorName) bool ColorizeManager::Exist(const char *colorName)
{ {
uint32_t i; int32_t i;
for (i=0; i<listMyColor.size(); i++) { for (i=0; i<listMyColor.Size(); i++) {
Edn::String elementName = listMyColor[i]->GetName(); Edn::String elementName = listMyColor[i]->GetName();
if (elementName == colorName) { if (elementName == colorName) {
return true; return true;
@@ -243,9 +279,9 @@ bool ColorizeManager::Exist(Edn::String &colorName)
void ColorizeManager::DisplayListOfColor(void) void ColorizeManager::DisplayListOfColor(void)
{ {
uint32_t i; int32_t i;
EDN_INFO(PFX"List of ALL COLOR : "); EDN_INFO(PFX"List of ALL COLOR : ");
for (i=0; i<listMyColor.size(); i++) { for (i=0; i<listMyColor.Size(); i++) {
//Edn::String elementName = listMyColor[i]->GetName(); //Edn::String elementName = listMyColor[i]->GetName();
//EDN_INFO(i << " : \"" << elementName.c_str() << "\"" ); //EDN_INFO(i << " : \"" << elementName.c_str() << "\"" );
listMyColor[i]->Display(i); listMyColor[i]->Display(i);

View File

@@ -1,6 +1,6 @@
/** /**
******************************************************************************* *******************************************************************************
* @file ColoriseManager.h * @file ColorizeManager.h
* @brief Editeur De N'ours : Colorising Manager (header) * @brief Editeur De N'ours : Colorising Manager (header)
* @author Edouard DUPIN * @author Edouard DUPIN
* @date 14/12/2010 * @date 14/12/2010
@@ -27,9 +27,9 @@
#define __COLORIZE_MANAGER_H__ #define __COLORIZE_MANAGER_H__
#include "Singleton.h" #include "Singleton.h"
#include <vector>
#include <string>
#include "Colorize.h" #include "Colorize.h"
#include "MsgBroadcast.h"
#include "Edn.h"
typedef enum { typedef enum {
// BASIC color for codeViewer // BASIC color for codeViewer
@@ -50,7 +50,7 @@ typedef enum {
class ColorizeManager: public Singleton<ColorizeManager> class ColorizeManager: public Singleton<ColorizeManager>, public MsgBroadcast
{ {
friend class Singleton<ColorizeManager>; friend class Singleton<ColorizeManager>;
// specific for sigleton system... // specific for sigleton system...
@@ -58,6 +58,8 @@ class ColorizeManager: public Singleton<ColorizeManager>
// Constructeur // Constructeur
ColorizeManager(void); ColorizeManager(void);
~ColorizeManager(void); ~ColorizeManager(void);
public:
void OnMessage(int32_t id, int32_t dataID);
public: public:
void LoadFile(Edn::String &xmlFilename); void LoadFile(Edn::String &xmlFilename);
void LoadFile(const char * xmlFilename); void LoadFile(const char * xmlFilename);
@@ -69,8 +71,9 @@ class ColorizeManager: public Singleton<ColorizeManager>
void DisplayListOfColor(void); void DisplayListOfColor(void);
private: private:
std::vector<Colorize*> listMyColor; //!< List of ALL Color Edn::String m_fileColor;
Colorize* errorColor; Edn::VectorType<Colorize*> listMyColor; //!< List of ALL Color
Colorize * errorColor;
color_ts basicColors[COLOR_NUMBER_MAX]; color_ts basicColors[COLOR_NUMBER_MAX];
}; };

View File

@@ -100,6 +100,10 @@ void BufferView::OnMessage(int32_t id, int32_t dataID)
// change Title : // change Title :
gtk_widget_queue_draw(m_widget); gtk_widget_queue_draw(m_widget);
break; break;
case EDN_MSG__USER_DISPLAY_CHANGE:
// Redraw all the display ...
gtk_widget_queue_draw(m_widget);
break;
} }
} }
@@ -138,6 +142,9 @@ gboolean BufferView::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, g
EDN_INFO("Request a display of : " << self->m_shawableAreaX << "px * "<< self->m_shawableAreaY<<"px"); EDN_INFO("Request a display of : " << self->m_shawableAreaX << "px * "<< self->m_shawableAreaY<<"px");
DrawerManager monDrawer(widget, self->m_shawableAreaX, self->m_shawableAreaY); DrawerManager monDrawer(widget, self->m_shawableAreaX, self->m_shawableAreaY);
// clean buffer
monDrawer.Clean(self->m_colorManager->Get(COLOR_LIST_BG_1));
// get the number of buffer open // get the number of buffer open
int32_t nbBufferOpen = self->m_bufferManager->Size(); int32_t nbBufferOpen = self->m_bufferManager->Size();
int32_t i; int32_t i;
@@ -146,17 +153,17 @@ gboolean BufferView::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, g
basicColor_te selectFG = COLOR_LIST_TEXT_NORMAL; basicColor_te selectFG = COLOR_LIST_TEXT_NORMAL;
basicColor_te selectBG = COLOR_LIST_BG_1; basicColor_te selectBG = COLOR_LIST_BG_1;
for (i=0; i < nbBufferOpen; i++) { for (i=0; i < nbBufferOpen; i++) {
Edn::String name; Edn::File name;
bool isModify; bool isModify;
if (self->m_bufferManager->Exist(i)) { if (self->m_bufferManager->Exist(i)) {
isModify = self->m_bufferManager->Get(i)->IsModify(); isModify = self->m_bufferManager->Get(i)->IsModify();
name = self->m_bufferManager->Get(i)->GetShortName(); name = self->m_bufferManager->Get(i)->GetFileName();
char *tmpModify = (char*)" "; char *tmpModify = (char*)" ";
if (true == isModify) { if (true == isModify) {
tmpModify = (char*)"M"; tmpModify = (char*)"M";
} }
char name2[1024] = ""; char name2[1024] = "";
sprintf(name2, "[%2d](%s) %s", i, tmpModify, name.c_str() ); sprintf(name2, "[%2d](%s) %s", i, tmpModify, name.GetShortFilename().c_str() );
if (true == isModify) { if (true == isModify) {
selectFG = COLOR_LIST_TEXT_MODIFY; selectFG = COLOR_LIST_TEXT_MODIFY;
@@ -187,7 +194,7 @@ gboolean BufferView::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, g
// sur : émis lors du premier affichage de la GtkDrawingArea // sur : <EFBFBD>mis lors du premier affichage de la GtkDrawingArea
gboolean BufferView::CB_displayInit( GtkWidget *widget, gpointer data) gboolean BufferView::CB_displayInit( GtkWidget *widget, gpointer data)
{ {
BufferView * self = reinterpret_cast<BufferView*>(data); BufferView * self = reinterpret_cast<BufferView*>(data);
@@ -249,46 +256,104 @@ gint BufferView::CB_keyboardEvent( GtkWidget *widget, GdkEventKey *event, gpoint
} }
void BufferView::OnPopupEventShow(GtkWidget *menuitem, gpointer data)
{
BufferView * self = reinterpret_cast<BufferView*>(data);
self->SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, self->m_contectMenuSelectID);
self->m_contectMenuSelectID = -1;
}
void BufferView::OnPopupEventClose(GtkWidget *menuitem, gpointer data)
{
BufferView * self = reinterpret_cast<BufferView*>(data);
self->SendMessage(EDN_MSG__BUFF_ID_CLOSE, self->m_contectMenuSelectID);
self->m_contectMenuSelectID = -1;
}
void BufferView::OnPopupEventSave(GtkWidget *menuitem, gpointer data)
{
BufferView * self = reinterpret_cast<BufferView*>(data);
self->SendMessage(EDN_MSG__BUFF_ID_SAVE, self->m_contectMenuSelectID);
self->m_contectMenuSelectID = -1;
}
void BufferView::OnPopupEventSaveAs(GtkWidget *menuitem, gpointer data)
{
BufferView * self = reinterpret_cast<BufferView*>(data);
self->SendMessage(EDN_MSG__GUI_SHOW_SAVE_AS, self->m_contectMenuSelectID);
self->m_contectMenuSelectID = -1;
}
void BufferView::ViewPopupMenu(GtkWidget *parrent, GdkEventButton *event, int32_t BufferID)
{
// Save the slected buffer
m_contectMenuSelectID = BufferID;
if (m_bufferManager->Exist(m_contectMenuSelectID)) {
GtkWidget *menu, *menuitem;
menu = gtk_menu_new();
menuitem = gtk_menu_item_new_with_label("Show");
g_signal_connect( G_OBJECT(menuitem), "activate", G_CALLBACK(OnPopupEventShow), this);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
if (true == m_bufferManager->Get(m_contectMenuSelectID)->HaveName()) {
if (true == m_bufferManager->Get(m_contectMenuSelectID)->IsModify()) {
menuitem = gtk_menu_item_new_with_label("Save");
} else {
menuitem = gtk_menu_item_new_with_label("Force Save");
}
g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(OnPopupEventSave), this);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
}
menuitem = gtk_menu_item_new_with_label("Save As ...");
g_signal_connect( G_OBJECT(menuitem), "activate", G_CALLBACK(OnPopupEventSaveAs), this);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
menuitem = gtk_menu_item_new_with_label("Close");
g_signal_connect( G_OBJECT(menuitem), "activate", G_CALLBACK(OnPopupEventClose), this);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
gtk_widget_show_all(menu);
// Note: event can be NULL here when called from view_onPopupMenu;
// gdk_event_get_time() accepts a NULL argument
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
(event != NULL) ? event->button : 0,
gdk_event_get_time((GdkEvent*)event));
} else {
EDN_ERROR("Buffer does not Exist !!! " << m_contectMenuSelectID);
}
}
gint BufferView::CB_mouseButtonEvent(GtkWidget *widget, GdkEventButton *event, gpointer data) gint BufferView::CB_mouseButtonEvent(GtkWidget *widget, GdkEventButton *event, gpointer data)
{ {
BufferView * self = reinterpret_cast<BufferView*>(data); BufferView * self = reinterpret_cast<BufferView*>(data);
// get focus on the widget // get focus on the widget
gtk_widget_grab_focus(widget); gtk_widget_grab_focus(widget);
if (event->button == 1) { if (event->button == 1) {
/*
if (event->type == GDK_BUTTON_PRESS) { if (event->type == GDK_BUTTON_PRESS) {
EDN_INFO("mouse-event BT1 ==> One Clicked"); EDN_INFO("mouse-event BT1 ==> One Clicked");
}else*/ if (event->type == GDK_2BUTTON_PRESS) { }else if (event->type == GDK_2BUTTON_PRESS) {
//EDN_INFO("mouse-event BT1 ==> Double Clicked %d, %d", (uint32_t)event->x, (uint32_t)event->y); //EDN_INFO("mouse-event BT1 ==> Double Clicked %d, %d", (uint32_t)event->x, (uint32_t)event->y);
uint32_t fontHeight = Display::GetFontHeight(); uint32_t fontHeight = Display::GetFontHeight();
int32_t selectBuf = self->m_bufferManager->WitchBuffer((event->y / fontHeight) + 1); int32_t selectBuf = self->m_bufferManager->WitchBuffer((event->y / fontHeight) + 1);
//EDN_INFO(" plop %d / %d = %d ==> %d", (uint32_t)event->y, fontHeight, ((uint32_t)event->y / fontHeight), selectBuf); //EDN_INFO(" plop %d / %d = %d ==> %d", (uint32_t)event->y, fontHeight, ((uint32_t)event->y / fontHeight), selectBuf);
if ( 0 <= selectBuf) { if ( 0 <= selectBuf) {
self->SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, selectBuf); self->SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, selectBuf);
/*
MainWindows *window = MainWindows::getInstance();
EDN_INFO(" Event on Buffer " << selectBuf);
// set the new seected Buffer
window->SetSelected(selectBuf);
*/
} }
}/* else if (event->type == GDK_3BUTTON_PRESS) {
EDN_INFO("mouse-event BT1 ==> Triple Clicked");
}else if (event->type == GDK_BUTTON_RELEASE) {
EDN_INFO("mouse-event BT1 ==> Realease");
}*/
}/* else if (event->button == 2) {
if (event->type == GDK_BUTTON_PRESS) {
EDN_INFO("mouse-event BT2 PRESS");
} }
} else if (event->button == 3) { } else if (event->button == 3) {
if (event->type == GDK_BUTTON_PRESS) { if (event->type == GDK_BUTTON_PRESS) {
EDN_INFO("mouse-event BT3 PRESS"); EDN_INFO("mouse-event BT3 PRESS");
uint32_t fontHeight = Display::GetFontHeight();
int32_t selectBuf = self->m_bufferManager->WitchBuffer((event->y / fontHeight) + 1);
if ( 0 <= selectBuf) {
self->ViewPopupMenu(widget, event, selectBuf);
}
} }
} else { } else {
//EDN_INFO("mouse-event BT? PRESS"); // not usefull to redraw
}*/ return true;
}
gtk_widget_queue_draw( widget ); gtk_widget_queue_draw( widget );
return true; return true;
} }

View File

@@ -26,8 +26,6 @@
#define __BUFFER_VIEW_H__ #define __BUFFER_VIEW_H__
#include "tools_debug.h" #include "tools_debug.h"
#include <vector>
#include <string>
#include "Singleton.h" #include "Singleton.h"
#include "CodeView.h" #include "CodeView.h"
#include "BufferManager.h" #include "BufferManager.h"
@@ -35,6 +33,7 @@
#include "MsgBroadcast.h" #include "MsgBroadcast.h"
class BufferView : public MsgBroadcast class BufferView : public MsgBroadcast
{ {
public: public:
@@ -53,9 +52,14 @@ class BufferView : public MsgBroadcast
static gint CB_mouseMotionEvent( GtkWidget *widget, GdkEventMotion *event, gpointer data); static gint CB_mouseMotionEvent( GtkWidget *widget, GdkEventMotion *event, gpointer data);
static void CB_EventOnBufferManager(gpointer data); static void CB_EventOnBufferManager(gpointer data);
static void OnPopupEventShow(GtkWidget *menuitem, gpointer data);
static void OnPopupEventClose(GtkWidget *menuitem, gpointer data);
static void OnPopupEventSave(GtkWidget *menuitem, gpointer data);
static void OnPopupEventSaveAs(GtkWidget *menuitem, gpointer data);
private: private:
void ViewPopupMenu(GtkWidget *parrent, GdkEventButton *event, int32_t BufferID);
// main windows widget : // main windows widget :
GtkWidget * m_widget; GtkWidget * m_widget;
// r<>cup<75>ration des proprieter g<>n<EFBFBD>ral... // r<>cup<75>ration des proprieter g<>n<EFBFBD>ral...
@@ -64,6 +68,7 @@ class BufferView : public MsgBroadcast
int32_t m_shawableAreaX; int32_t m_shawableAreaX;
int32_t m_shawableAreaY; int32_t m_shawableAreaY;
int32_t m_selectedID; int32_t m_selectedID;
int32_t m_contectMenuSelectID;
}; };

View File

@@ -38,15 +38,19 @@
CodeView::CodeView(void) : MsgBroadcast("Code View", EDN_CAT_WORK_AREA) CodeView::CodeView(void) : MsgBroadcast("Code View", EDN_CAT_WORK_AREA)
{ {
m_bufferID = -1;
m_buttunOneSelected = false;
m_shawableAreaX = 0;
m_shawableAreaY = 0;
// Init link with the buffer Manager // Init link with the buffer Manager
m_bufferManager = BufferManager::getInstance(); m_bufferManager = BufferManager::getInstance();
m_colorManager = ColorizeManager::getInstance(); m_colorManager = ColorizeManager::getInstance();
static int32_t staticIntLocal = 100;
m_displayUniqueId = staticIntLocal++;
m_bufferID = -1;
m_bufferManager->Get(m_bufferID)->AnchorAdd(m_displayUniqueId);
m_buttunOneSelected = false;
m_shawableAreaX = 0;
m_shawableAreaY = 0;
m_widget = gtk_drawing_area_new(); m_widget = gtk_drawing_area_new();
gtk_widget_set_size_request( m_widget, 200, 100); gtk_widget_set_size_request( m_widget, 200, 100);
@@ -98,17 +102,14 @@ void CodeView::OnMessage(int32_t id, int32_t dataID)
{ {
case EDN_MSG__CURRENT_CHANGE_BUFFER_ID: case EDN_MSG__CURRENT_CHANGE_BUFFER_ID:
//EDN_INFO("Select a new Buffer ... " << dataID); //EDN_INFO("Select a new Buffer ... " << dataID);
m_bufferManager->Get(m_bufferID)->AnchorRm(m_displayUniqueId);
m_bufferID = dataID; m_bufferID = dataID;
m_bufferManager->Get(m_bufferID)->ForceReDraw(true); m_bufferManager->Get(m_bufferID)->AnchorAdd(m_displayUniqueId);
// request the dispplay of the curent Editor // request the dispplay of the curent Editor
SendMessage(EDN_MSG__BUFFER_CHANGE_CURRENT, m_bufferID); SendMessage(EDN_MSG__BUFFER_CHANGE_CURRENT, m_bufferID);
break; break;
case EDN_MSG__CURRENT_SAVE: case EDN_MSG__CURRENT_SAVE:
if (m_bufferManager->Get(m_bufferID)->HaveName() == false) { SendMessage(EDN_MSG__BUFF_ID_SAVE, m_bufferID);
SendMessage(EDN_MSG__GUI_SHOW_SAVE_AS, m_bufferID);
} else {
m_bufferManager->Get(m_bufferID)->Save();
}
break; break;
case EDN_MSG__CURRENT_SAVE_AS: case EDN_MSG__CURRENT_SAVE_AS:
SendMessage(EDN_MSG__GUI_SHOW_SAVE_AS, m_bufferID); SendMessage(EDN_MSG__GUI_SHOW_SAVE_AS, m_bufferID);
@@ -164,9 +165,7 @@ void CodeView::OnMessage(int32_t id, int32_t dataID)
case EDN_MSG__CURRENT_REPLACE_ALL: case EDN_MSG__CURRENT_REPLACE_ALL:
break; break;
case EDN_MSG__CURRENT_CLOSE: case EDN_MSG__CURRENT_CLOSE:
m_bufferManager->Remove(m_bufferID); SendMessage(EDN_MSG__BUFF_ID_CLOSE, m_bufferID);
m_bufferID = -1;
SendMessage(EDN_MSG__BUFFER_CHANGE_CURRENT, m_bufferID);
break; break;
case EDN_MSG__CURRENT_UNDO: case EDN_MSG__CURRENT_UNDO:
m_bufferManager->Get(m_bufferID)->Undo(); m_bufferManager->Get(m_bufferID)->Undo();
@@ -185,12 +184,16 @@ void CodeView::OnMessage(int32_t id, int32_t dataID)
case EDN_MSG__CURRENT_SET_CHARSET: case EDN_MSG__CURRENT_SET_CHARSET:
m_bufferManager->Get(m_bufferID)->SetCharset((charset_te)dataID); m_bufferManager->Get(m_bufferID)->SetCharset((charset_te)dataID);
break; break;
case EDN_MSG__USER_DISPLAY_CHANGE:
// Redraw all the display ... Done under ...
break;
} }
// Force redraw of the widget // Force redraw of the widget
gtk_widget_queue_draw(m_widget); gtk_widget_queue_draw(m_widget);
} }
#define COUNT_TIME plop
gboolean CodeView::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpointer data) gboolean CodeView::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpointer data)
{ {
@@ -200,6 +203,7 @@ gboolean CodeView::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpo
# ifdef USE_GTK_VERSION_3_0 # ifdef USE_GTK_VERSION_3_0
GtkAllocation allocation; GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation); gtk_widget_get_allocation(widget, &allocation);
EDN_INFO("GTK+ request a diplay of : "<< allocation.width <<"px * "<< allocation.height <<"px");
bool needRedrawAll = false; bool needRedrawAll = false;
if (self->m_shawableAreaX != allocation.width) { if (self->m_shawableAreaX != allocation.width) {
needRedrawAll = true; needRedrawAll = true;
@@ -210,6 +214,7 @@ gboolean CodeView::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpo
self->m_shawableAreaY = allocation.height; self->m_shawableAreaY = allocation.height;
} }
# elif defined( USE_GTK_VERSION_2_0) # elif defined( USE_GTK_VERSION_2_0)
EDN_INFO("GTK+ request a diplay of : "<< widget->allocation.width <<"px * "<< widget->allocation.height <<"px");
bool needRedrawAll = false; bool needRedrawAll = false;
if (self->m_shawableAreaX != widget->allocation.width) { if (self->m_shawableAreaX != widget->allocation.width) {
needRedrawAll = true; needRedrawAll = true;
@@ -220,32 +225,44 @@ gboolean CodeView::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpo
self->m_shawableAreaY = widget->allocation.height; self->m_shawableAreaY = widget->allocation.height;
} }
# endif # endif
if (true == needRedrawAll) { EDN_INFO("Edn request a display of : " << self->m_shawableAreaX << "px * "<< self->m_shawableAreaY<<"px");
//updateScrollElement();
self->m_bufferManager->Get(self->m_bufferID)->ForceReDraw(true);
}
EDN_INFO("Request a display of : " << self->m_shawableAreaX << "px * "<< self->m_shawableAreaY<<"px");
/*
EDN_INFO("widget width=%d", widget->allocation.width);
EDN_INFO("widget height=%d", widget->allocation.height);
*/
//EDN_INFO("BufferView Display");
// Get the color Manager : // Get the color Manager :
ColorizeManager *myColorManager = NULL; ColorizeManager *myColorManager = NULL;
myColorManager = ColorizeManager::getInstance(); myColorManager = ColorizeManager::getInstance();
//(void)m_bufferManager->Get(m_bufferID)->Display(m_displayParameters, m_shawableAreaX, m_shawableAreaY);
DrawerManager monDrawer(widget, self->m_shawableAreaX, self->m_shawableAreaY); DrawerManager monDrawer(widget, self->m_shawableAreaX, self->m_shawableAreaY);
//EDN_INFO("Display buffer ID = " << m_bufferID); Buffer * tmpBuf = self->m_bufferManager->Get(self->m_bufferID);
(void)self->m_bufferManager->Get(self->m_bufferID)->Display(monDrawer);
// EDN_WARNING("Must display here ... "); #ifdef COUNT_TIME
GTimeVal timeStart;
g_get_current_time(&timeStart);
#endif
bufferAnchor_ts anchor;
tmpBuf->AnchorSetSize(self->m_displayUniqueId, self->m_shawableAreaX, self->m_shawableAreaY);
bool enableToWrite = tmpBuf->AnchorGet(self->m_displayUniqueId, anchor);
while (true == enableToWrite) {
tmpBuf->DrawLine(monDrawer, anchor);
enableToWrite = tmpBuf->AnchorNext(anchor);
}
monDrawer.Flush();
// Need to clean the end of windows (sometimes)...
/*
if (iii<lineIdEnd+1) {
int32_t positionY = letterHeight * (iii - m_displayStart.y - 1);
drawer.Rectangle(myColorManager->Get(COLOR_CODE_BASIC_BG), 0, positionY, drawer.GetWidth(), letterHeight*(lineIdEnd+1-iii) );
}
*/
#ifdef COUNT_TIME
GTimeVal timeStop;
g_get_current_time(&timeStop);
EDN_DEBUG("Display Generation = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s ==> " << (timeStop.tv_usec - timeStart.tv_usec)/1000. << "ms");
#endif
return TRUE; return TRUE;
} }
// sur : émis lors du premier affichage de la GtkDrawingArea // sur : émis lors du premier affichage de la GtkDrawingArea
gboolean CodeView::CB_displayInit( GtkWidget *widget, gpointer data) gboolean CodeView::CB_displayInit( GtkWidget *widget, gpointer data)
{ {
@@ -253,22 +270,15 @@ gboolean CodeView::CB_displayInit( GtkWidget *widget, gpointer data)
# ifdef USE_GTK_VERSION_3_0 # ifdef USE_GTK_VERSION_3_0
GtkAllocation allocation; GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation); gtk_widget_get_allocation(widget, &allocation);
int32_t size_x = allocation.width; EDN_INFO("GTK+ request a diplay of : "<< allocation.width <<"px * "<< allocation.height <<"px");
int32_t size_y = allocation.height;
self->m_shawableAreaX = allocation.width; self->m_shawableAreaX = allocation.width;
self->m_shawableAreaY = allocation.height; self->m_shawableAreaY = allocation.height;
# elif defined( USE_GTK_VERSION_2_0) # elif defined( USE_GTK_VERSION_2_0)
int32_t size_x = widget->allocation.width; EDN_INFO("GTK+ request a diplay of : "<< widget->allocation.width <<"px * "<< widget->allocation.height <<"px");
int32_t size_y = widget->allocation.height;
self->m_shawableAreaX = widget->allocation.width; self->m_shawableAreaX = widget->allocation.width;
self->m_shawableAreaY = widget->allocation.height; self->m_shawableAreaY = widget->allocation.height;
# endif # endif
EDN_INFO("Request a diplay of : "<< size_x <<"px * "<< size_y <<"px");
gtk_widget_queue_draw( widget ); gtk_widget_queue_draw( widget );
return TRUE; return TRUE;
} }
@@ -358,7 +368,7 @@ gint CodeView::CB_mouseButtonEvent(GtkWidget *widget, GdkEventButton *event, gpo
EDN_INFO("mouse-event BT3 PRESS"); EDN_INFO("mouse-event BT3 PRESS");
} }
} else { } else {
EDN_INFO("mouse-event BT? PRESS"); EDN_INFO("mouse-event BT" << event->type <<" PRESS");
} }
return true; return true;
} }

View File

@@ -54,6 +54,9 @@ class CodeView : public MsgBroadcast
private: private:
// main windows widget : // main windows widget :
GtkWidget * m_widget; GtkWidget * m_widget;
int32_t m_displayUniqueId;
//position_ts m_displayStart; //!< position where the display is starting
//position_ts m_displaySize; //!< number of char displayable in the screan
// récupération des proprieter général... // récupération des proprieter général...
BufferManager * m_bufferManager; BufferManager * m_bufferManager;
ColorizeManager * m_colorManager; ColorizeManager * m_colorManager;

View File

@@ -28,8 +28,7 @@
#include "tools_debug.h" #include "tools_debug.h"
#include "Singleton.h" #include "Singleton.h"
#include <string>
#include <vector>
class MainAreaView: public Singleton<MainAreaView> class MainAreaView: public Singleton<MainAreaView>

View File

@@ -40,15 +40,31 @@ MainWindows::MainWindows(void) : MsgBroadcast("Main Windows", EDN_CAT_GUI)
m_mainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); m_mainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
// select the program icone // select the program icone
gtk_window_set_default_icon_name("text-editor"); GError *err = NULL;
Edn::String iconeFile;
#ifdef NDEBUG
iconeFile = "/usr/share/edn/images/icone.png";
#else
iconeFile = "./data/imagesSources/icone.png";
#endif
GdkPixbuf * icone = gdk_pixbuf_new_from_file(iconeFile.c_str(), &err);
if (err != NULL) {
gtk_window_set_default_icon_name("text-editor");
} else {
gtk_window_set_icon(GTK_WINDOW(m_mainWindow), icone);
}
// Default size open windows // Default size open windows
gtk_window_set_default_size(GTK_WINDOW(m_mainWindow), 800, 600); gtk_window_set_default_size(GTK_WINDOW(m_mainWindow), 800, 600);
// enable the close signal of the windows // enable the close signal of the windows
g_signal_connect(G_OBJECT(m_mainWindow), "delete-event", G_CALLBACK(OnQuit), this); g_signal_connect(G_OBJECT(m_mainWindow), "delete-event", G_CALLBACK(OnQuit), this);
g_signal_connect(G_OBJECT(m_mainWindow), "window-state-event", G_CALLBACK(OnStateChange), this);
//g_signal_connect(G_OBJECT(m_mainWindow), "destroy", G_CALLBACK(OnQuit), this); //g_signal_connect(G_OBJECT(m_mainWindow), "destroy", G_CALLBACK(OnQuit), this);
// remove decoration
//gtk_window_set_decorated(GTK_WINDOW(m_mainWindow), FALSE);
// Create a vertical box for stacking the menu and editor widgets in. // Create a vertical box for stacking the menu and editor widgets in.
GtkWidget *vbox = gtk_vbox_new (FALSE, 0); GtkWidget *vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add(GTK_CONTAINER(m_mainWindow), vbox); gtk_container_add(GTK_CONTAINER(m_mainWindow), vbox);
@@ -57,8 +73,52 @@ MainWindows::MainWindows(void) : MsgBroadcast("Main Windows", EDN_CAT_GUI)
AccelKey::getInstance()->LinkCommonAccel(GTK_WINDOW(m_mainWindow)); AccelKey::getInstance()->LinkCommonAccel(GTK_WINDOW(m_mainWindow));
// Create the menu bar. // Create the menu bar.
#if 0
gtk_box_pack_start( GTK_BOX (vbox), m_MenuBar.GetWidget(), FALSE, FALSE, 0); gtk_box_pack_start( GTK_BOX (vbox), m_MenuBar.GetWidget(), FALSE, FALSE, 0);
#else
GtkWidget *hboxMenu = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start( GTK_BOX (vbox), hboxMenu, FALSE, FALSE, 0);
// Add Exit boutton
Edn::String ExitIconeFile;
#ifdef NDEBUG
ExitIconeFile = "/usr/share/edn/images/delete-24px.png";
#else
ExitIconeFile = "./data/imagesSources/delete-24px.png";
#endif
// TODO : find a good way to change the size of an image
GtkWidget *myImageQuit = gtk_image_new_from_file(ExitIconeFile.c_str());
GtkIconSize mySize = GTK_ICON_SIZE_SMALL_TOOLBAR;
//EDN_DEBUG(" plop : " << mySize);
//gtk_image_get_icon_set( GTK_IMAGE(myImageQuit), NULL, &mySize);
//EDN_DEBUG(" plop : " << mySize);
GtkWidget *event_box = gtk_event_box_new();
gtk_container_add(GTK_CONTAINER(event_box),myImageQuit);
gtk_widget_add_events(event_box,GDK_BUTTON_PRESS_MASK);
g_signal_connect(G_OBJECT(event_box), "button_press_event", G_CALLBACK(OnQuit), this);
gtk_box_pack_start( GTK_BOX(hboxMenu), event_box, FALSE, FALSE, 0);
// add the real menu bar
gtk_box_pack_start( GTK_BOX (hboxMenu), m_MenuBar.GetWidget(), FALSE, FALSE, 0);
GdkColor color;
GtkStateType tmpppppp = GTK_STATE_NORMAL;
//GtkStateType tmpppppp = GTK_STATE_ACTIVE;
//GtkStateType tmpppppp = GTK_STATE_PRELIGHT;
//GtkStateType tmpppppp = GTK_STATE_SELECTED;
//GtkStateType tmpppppp = GTK_STATE_INSENSITIVE;
//gdk_color_parse ("green", &color);
//gtk_widget_modify_fg(m_MenuBar.GetWidget(), tmpppppp, &color);
//gdk_color_parse ("blue", &color);
//gtk_widget_modify_bg(m_MenuBar.GetWidget(), tmpppppp, &color);
gdk_color_parse ("red", &color);
gtk_widget_modify_text(m_MenuBar.GetWidget(), tmpppppp, &color);
//gdk_color_parse ("orange", &color);
gtk_widget_modify_base(m_MenuBar.GetWidget(), tmpppppp, &color);
// Add title
m_internalTitleLabel = gtk_label_new("Edn");
gtk_box_pack_start( GTK_BOX (hboxMenu), m_internalTitleLabel, FALSE, FALSE, 0);
#endif
// ********************************************************** // **********************************************************
// * Horizontal ELEMENTS : * // * Horizontal ELEMENTS : *
// ********************************************************** // **********************************************************
@@ -67,16 +127,16 @@ MainWindows::MainWindows(void) : MsgBroadcast("Main Windows", EDN_CAT_GUI)
gtk_container_add(GTK_CONTAINER (vbox), hbox); gtk_container_add(GTK_CONTAINER (vbox), hbox);
// create the toolbar : // create the toolbar :
# if USE_GTK_VERSION_2_0 # if USE_GTK_VERSION_2_0
gtk_box_pack_start(GTK_BOX(hbox), m_ToolBar.GetWidget(), FALSE, FALSE, 0); //gtk_box_pack_start(GTK_BOX(hbox), m_ToolBar.GetWidget(), FALSE, FALSE, 0);
# endif # endif
// TreeView : // TreeView :
gtk_box_pack_start(GTK_BOX(hbox), m_BufferView.GetMainWidget(), FALSE, TRUE, 1); gtk_box_pack_start(GTK_BOX(hbox), m_BufferView.GetMainWidget(), FALSE, TRUE, 1);
// Tex displayer : // Text displayer :
gtk_box_pack_start( GTK_BOX (hbox), m_CodeView.GetMainWidget(), TRUE, TRUE, 0); gtk_box_pack_start( GTK_BOX (hbox), m_CodeView.GetMainWidget(), TRUE, TRUE, 0);
// Create the status bar // Create the status bar
gtk_box_pack_end(GTK_BOX(vbox), m_StatusBar.GetWidget(), FALSE, FALSE, 0); //gtk_box_pack_end(GTK_BOX(vbox), m_StatusBar.GetWidget(), FALSE, FALSE, 0);
// recursive version of gtk_widget_show // recursive version of gtk_widget_show
gtk_widget_show_all(m_mainWindow); gtk_widget_show_all(m_mainWindow);
@@ -93,15 +153,35 @@ MainWindows::~MainWindows(void)
} }
void MainWindows::SetTitle(Edn::String &fileName, bool isModify)
void MainWindows::SetTitle(Edn::File &fileName, bool isModify)
{ {
Edn::String tmp = ""; Edn::String tmp = "";
if (fileName != "") { if (fileName.GetShortFilename() != "") {
tmp += fileName; tmp += fileName.GetShortFilename();
tmp += " - ";
tmp += fileName.GetFolder();
tmp += " - "; tmp += " - ";
} }
tmp += "Edn"; tmp += "Edn";
gtk_window_set_title(GTK_WINDOW(m_mainWindow), tmp.c_str()); gtk_window_set_title(GTK_WINDOW(m_mainWindow), tmp.c_str());
tmp = " ";
if (fileName.GetShortFilename() != "") {
tmp = fileName.GetFolder();
tmp += "/";
tmp += fileName.GetShortFilename();
} else {
tmp = "Edn";
}
gtk_label_set_text(GTK_LABEL(m_internalTitleLabel), tmp.c_str());
}
void MainWindows::SetNoTitle(void)
{
Edn::String tmp = "Edn";
gtk_window_set_title(GTK_WINDOW(m_mainWindow), tmp.c_str());
gtk_label_set_text(GTK_LABEL(m_internalTitleLabel), tmp.c_str());
} }
void MainWindows::OnMessage(int32_t id, int32_t dataID) void MainWindows::OnMessage(int32_t id, int32_t dataID)
@@ -112,80 +192,46 @@ void MainWindows::OnMessage(int32_t id, int32_t dataID)
// change Title : // change Title :
// TODO : String error when remove the error with -1; // TODO : String error when remove the error with -1;
if (-1 == dataID) { if (-1 == dataID) {
Edn::String plop = ""; SetNoTitle();
SetTitle(plop, false );
} else { } else {
Buffer *mybuf = BufferManager::getInstance()->Get(dataID); Buffer *mybuf = BufferManager::getInstance()->Get(dataID);
if (NULL != mybuf) { if (NULL != mybuf) {
Edn::String plop = mybuf->GetName(); Edn::File plop = mybuf->GetFileName();
SetTitle(plop, mybuf->IsModify() ); SetTitle(plop, mybuf->IsModify() );
} }
} }
break; break;
case EDN_MSG__QUIT:
OnQuit(m_mainWindow, this);
break;
} }
} }
bool MainWindows::OnQuit(GtkWidget *widget, gpointer data) bool MainWindows::OnQuit(GtkWidget *widget, gpointer data)
{ {
EDN_INFO("quit requested"); //MainWindows * self = reinterpret_cast<MainWindows*>(data);
// dlg to confirm the quit event : GeneralSendMessage(EDN_MSG__GUI_SHOW_EXIT_CONFIRMATION);
GtkWidget *p_dialog = gtk_dialog_new_with_buttons("Exit", // Close is not managed here ...
GTK_WINDOW(widget),
GTK_DIALOG_MODAL,
GTK_STOCK_YES, GTK_RESPONSE_YES,
GTK_STOCK_NO, GTK_RESPONSE_NO,
NULL);
GtkWidget *p_label = gtk_label_new ("Do you want exit Edn?");
gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area( GTK_DIALOG(p_dialog) )), p_label, TRUE, TRUE, 0);
gtk_widget_show(p_label);
switch (gtk_dialog_run (GTK_DIALOG (p_dialog)))
{
case GTK_RESPONSE_YES:
gtk_widget_destroy (p_dialog);
break;
case GTK_RESPONSE_NO:
gtk_widget_destroy (p_dialog);
// do not close the windows
return true; return true;
break;
}
gtk_main_quit();
return false;
} }
#if 0 gboolean MainWindows::OnStateChange(GtkWidget *widget, GdkEvent* event, gpointer data)
void MainWindows::OnMenuAbout(wxCommandEvent & WXUNUSED(event))
{ {
//EDN_INFO("MainWindows::OnMenuAbout (event)"); MainWindows * self = reinterpret_cast<MainWindows*>(data);
wxAboutDialogInfo info; EDN_DEBUG("State change");
info.SetName(wxT("edn")); EDN_INFO(" change state mask : " << event->window_state.changed_mask);
info.SetVersion(wxT("0.1.0 pre-Beta")); EDN_INFO(" change state new val : " << event->window_state.new_window_state);
info.SetDescription(wxT("Editeur De N'ours, l'Editeur Desoxyribo-Nucleique\n" if (event->window_state.changed_mask == GDK_WINDOW_STATE_MAXIMIZED) {
"Source Code Editor")); EDN_INFO(" ==> Maximisation change...");
info.SetCopyright(wxT( "Copyright 2010 Edouard DUPIN, all right reserved\n" if (event->window_state.new_window_state == GDK_WINDOW_STATE_MAXIMIZED) {
"This software is distributed in the hope that it will be useful, but WITHOUT\n" EDN_INFO(" ==> ENABLE");
"ANY WARRANTY\n\n" gtk_window_set_decorated(GTK_WINDOW(self->m_mainWindow), FALSE);
"Licence summary : \n" } else {
" You can modify and redistribute the sources code and binaries.\n" EDN_INFO(" ==> DISABLE");
" You can send me the bug-fix\n" gtk_window_set_decorated(GTK_WINDOW(self->m_mainWindow), TRUE);
" You can not earn money with this Software (if the source extract from Edn\n"
" represent less than 50% of original Sources)\n"
"Term of the licence in in the file licence.txt"));
wxAboutBox(info);
}
}
} }
#endif

View File

@@ -51,11 +51,14 @@ class MainWindows: public Singleton<MainWindows>, public MsgBroadcast
GtkWidget * GetWidget(void) { return m_mainWindow;}; GtkWidget * GetWidget(void) { return m_mainWindow;};
void OnMessage(int32_t id, int32_t dataID); void OnMessage(int32_t id, int32_t dataID);
static bool OnQuit(GtkWidget *widget, gpointer data); static bool OnQuit(GtkWidget *widget, gpointer data);
static gboolean OnStateChange(GtkWidget *widget, GdkEvent* event, gpointer data);
private: private:
void SetTitle(Edn::String &fileName, bool isModify); void SetTitle(Edn::File &fileName, bool isModify);
void SetNoTitle(void);
// main windows widget : // main windows widget :
GtkWidget * m_mainWindow; GtkWidget * m_mainWindow;
GtkWidget * m_internalTitleLabel;
BufferView m_BufferView; BufferView m_BufferView;
CodeView m_CodeView; CodeView m_CodeView;
MenuBar m_MenuBar; MenuBar m_MenuBar;

View File

@@ -28,6 +28,7 @@
#include "MenuBar.h" #include "MenuBar.h"
#include "ClipBoard.h" #include "ClipBoard.h"
#include "charset.h" #include "charset.h"
#include "ColorizeManager.h"
#define MENU_MSG #define MENU_MSG
const char * MSG_TogleDisplayChar = "Request a Togle of char displaying"; const char * MSG_TogleDisplayChar = "Request a Togle of char displaying";
@@ -36,6 +37,8 @@ const char * MSG_TogleAutoIndent = "Request a Togle of Auto Indent";
const char * MSG_SetCharsetIso559_1 = "Set ISO 5589-1"; const char * MSG_SetCharsetIso559_1 = "Set ISO 5589-1";
const char * MSG_SetCharsetIso559_15 = "Set ISO 5589-15"; const char * MSG_SetCharsetIso559_15 = "Set ISO 5589-15";
const char * MSG_SetCharsetUTF8 = "Set UTF 8"; const char * MSG_SetCharsetUTF8 = "Set UTF 8";
const char * MSG_LoadColorBlack = "Load Color Black";
const char * MSG_LoadColorWhite = "Load Color White";
#define MSG_LINK(data) #define MSG_LINK(data)
@@ -74,6 +77,26 @@ static void CB_menuInternal(GtkMenuItem *menu_item, gpointer data)
GeneralSendMessage(EDN_MSG__CURRENT_SET_CHARSET, EDN_CHARSET_ISO_8859_15); GeneralSendMessage(EDN_MSG__CURRENT_SET_CHARSET, EDN_CHARSET_ISO_8859_15);
} else if (myPointer == MSG_SetCharsetUTF8) { } else if (myPointer == MSG_SetCharsetUTF8) {
GeneralSendMessage(EDN_MSG__CURRENT_SET_CHARSET, EDN_CHARSET_UTF8); GeneralSendMessage(EDN_MSG__CURRENT_SET_CHARSET, EDN_CHARSET_UTF8);
} else if (myPointer == MSG_LoadColorWhite) {
ColorizeManager * myColorSystem = ColorizeManager::getInstance();
Edn::String homedir;
# ifdef NDEBUG
homedir = "/usr/share/edn/";
# else
homedir = "./data/";
# endif
homedir += "color_white.xml";
myColorSystem->LoadFile(homedir);
} else if (myPointer == MSG_LoadColorBlack) {
ColorizeManager * myColorSystem = ColorizeManager::getInstance();
Edn::String homedir;
# ifdef NDEBUG
homedir = "/usr/share/edn/";
# else
homedir = "./data/";
# endif
homedir += "color_black.xml";
myColorSystem->LoadFile(homedir);
} }
} }
@@ -164,6 +187,11 @@ class MenuBarMain
m_message.PushBack(message); m_message.PushBack(message);
// create ITEM // create ITEM
GtkWidget *tmpWidget = gtk_image_menu_item_new_from_stock( title, AccelKey::getInstance()->GetAccel() ); GtkWidget *tmpWidget = gtk_image_menu_item_new_from_stock( title, AccelKey::getInstance()->GetAccel() );
GdkColor color;
gdk_color_parse ("red", &color);
gtk_widget_modify_fg(tmpWidget, GTK_STATE_NORMAL, &color);
gtk_widget_modify_bg(tmpWidget, GTK_STATE_NORMAL, &color);
gtk_widget_modify_text(tmpWidget, GTK_STATE_NORMAL, &color);
// set grisage : // set grisage :
gtk_widget_set_sensitive(tmpWidget, enable); gtk_widget_set_sensitive(tmpWidget, enable);
// add to the menu : // add to the menu :
@@ -189,7 +217,7 @@ class MenuBarMain
GtkWidget * m_parent; GtkWidget * m_parent;
GtkWidget * m_menu; GtkWidget * m_menu;
GtkWidget * m_menuListe; GtkWidget * m_menuListe;
EdnVectorBin<messageData_ts*> m_message; Edn::VectorType<messageData_ts*> m_message;
}; };
#undef __class__ #undef __class__
@@ -204,12 +232,12 @@ MenuBar::MenuBar(void) : MsgBroadcast("Menu bar", EDN_CAT_GUI)
tmp->AddGen(GTK_STOCK_NEW, "ctrl+n", EDN_MSG__NEW, true); tmp->AddGen(GTK_STOCK_NEW, "ctrl+n", EDN_MSG__NEW, true);
tmp->AddGen(GTK_STOCK_OPEN, "ctrl+o", EDN_MSG__GUI_SHOW_OPEN_FILE, true); tmp->AddGen(GTK_STOCK_OPEN, "ctrl+o", EDN_MSG__GUI_SHOW_OPEN_FILE, true);
tmp->AddSeparator(); tmp->AddSeparator();
tmp->AddGen("Close file", NULL, EDN_MSG__CURRENT_CLOSE, true); tmp->AddGen("Close file", "ctrl+q", EDN_MSG__CURRENT_CLOSE, true);
tmp->AddSeparator(); tmp->AddSeparator();
tmp->AddGen(GTK_STOCK_SAVE, "ctrl+s", EDN_MSG__CURRENT_SAVE, true); tmp->AddGen(GTK_STOCK_SAVE, "ctrl+s", EDN_MSG__CURRENT_SAVE, true);
tmp->AddGen(GTK_STOCK_SAVE_AS, "ctrl+shift+s", EDN_MSG__CURRENT_SAVE_AS, true); tmp->AddGen(GTK_STOCK_SAVE_AS, "ctrl+shift+s", EDN_MSG__CURRENT_SAVE_AS, true);
tmp->AddSeparator(); tmp->AddSeparator();
tmp->AddGen(GTK_STOCK_QUIT, "ctrl+q", EDN_MSG__QUIT, true); tmp->AddGen(GTK_STOCK_QUIT, "ctrl+shift+q", EDN_MSG__GUI_SHOW_EXIT_CONFIRMATION, true);
m_listMenu.PushBack(tmp); m_listMenu.PushBack(tmp);
tmp = new MenuBarMain("_Edit", m_mainWidget); tmp = new MenuBarMain("_Edit", m_mainWidget);
@@ -220,23 +248,16 @@ MenuBar::MenuBar(void) : MsgBroadcast("Menu bar", EDN_CAT_GUI)
tmp->AddGen(GTK_STOCK_COPY, "ctrl+c", EDN_MSG__CURRENT_COPY, true, COPY_STD); tmp->AddGen(GTK_STOCK_COPY, "ctrl+c", EDN_MSG__CURRENT_COPY, true, COPY_STD);
tmp->AddGen(GTK_STOCK_PASTE, "ctrl+v", EDN_MSG__CURRENT_PASTE, true, COPY_STD); tmp->AddGen(GTK_STOCK_PASTE, "ctrl+v", EDN_MSG__CURRENT_PASTE, true, COPY_STD);
// tmp->AddGen(GTK_STOCK_DELETE, NULL); // tmp->AddGen(GTK_STOCK_DELETE, NULL);
tmp->AddGen("Remove line", "ctrl+d", EDN_MSG__CURRENT_REMOVE_LINE, true); tmp->AddGen("Remove line", "ctrl+w", EDN_MSG__CURRENT_REMOVE_LINE, true);
tmp->AddSeparator(); tmp->AddSeparator();
tmp->AddGen(GTK_STOCK_SELECT_ALL, "ctrl+a", EDN_MSG__CURRENT_SELECT_ALL, true); tmp->AddGen(GTK_STOCK_SELECT_ALL, "ctrl+a", EDN_MSG__CURRENT_SELECT_ALL, true);
tmp->AddGen("Unselect", "ctrl+shift+a", EDN_MSG__CURRENT_UN_SELECT, true); tmp->AddGen("Unselect", "ctrl+shift+a", EDN_MSG__CURRENT_UN_SELECT, true);
tmp->AddSeparator();
tmp->AddGen("Goto Line number ...", "ctrl+l", EDN_MSG__GUI_SHOW_GOTO_LINE, true);
// tmp->AddSeparator(); // tmp->AddSeparator();
// tmp->AddGen(GTK_STOCK_PREFERENCES, NULL, EDN_MSG__GUI_SHOW_PREFERENCE, true); // tmp->AddGen(GTK_STOCK_PREFERENCES, NULL, EDN_MSG__GUI_SHOW_PREFERENCE, true);
m_listMenu.PushBack(tmp); m_listMenu.PushBack(tmp);
tmp = new MenuBarMain("Display", m_mainWidget);
tmp->AddInternal("Show space & tabs", NULL, MSG_TogleDisplayChar, true);
tmp->AddInternal("Show end of lines", NULL, MSG_TogleDisplayEOL, true);
tmp->AddInternal("Audo Indent", NULL, MSG_TogleAutoIndent, true);
tmp->AddInternal("Set charset Occidental (ISO-8859-1)", NULL, MSG_SetCharsetIso559_1, true);
tmp->AddInternal("Set charset Occidental (ISO-8859-15)", NULL, MSG_SetCharsetIso559_15, true);
tmp->AddInternal("Set charset Internationnal (UTF 8)", NULL, MSG_SetCharsetUTF8, true);
m_listMenu.PushBack(tmp);
tmp = new MenuBarMain("_Search", m_mainWidget); tmp = new MenuBarMain("_Search", m_mainWidget);
tmp->AddGen(GTK_STOCK_FIND, "ctrl+f", EDN_MSG__GUI_SHOW_SEARCH, true); tmp->AddGen(GTK_STOCK_FIND, "ctrl+f", EDN_MSG__GUI_SHOW_SEARCH, true);
tmp->AddGen(GTK_STOCK_FIND_AND_REPLACE, "ctrl+r", EDN_MSG__GUI_SHOW_REPLACE, true); tmp->AddGen(GTK_STOCK_FIND_AND_REPLACE, "ctrl+r", EDN_MSG__GUI_SHOW_REPLACE, true);
@@ -250,6 +271,21 @@ MenuBar::MenuBar(void) : MsgBroadcast("Menu bar", EDN_CAT_GUI)
// tmp->AddSeparator(); // tmp->AddSeparator();
// tmp->AddGen("Goto Line", "ctrl+l", EDN_MSG__CURRENT_GOTO_LINE, true); // tmp->AddGen("Goto Line", "ctrl+l", EDN_MSG__CURRENT_GOTO_LINE, true);
m_listMenu.PushBack(tmp); m_listMenu.PushBack(tmp);
tmp = new MenuBarMain("Display", m_mainWidget);
tmp->AddInternal("Show space & tabs", NULL, MSG_TogleDisplayChar, true);
tmp->AddInternal("Show end of lines", NULL, MSG_TogleDisplayEOL, true);
tmp->AddInternal("Audo Indent", NULL, MSG_TogleAutoIndent, true);
tmp->AddSeparator();
tmp->AddInternal("Set charset Occidental (ISO-8859-1)", NULL, MSG_SetCharsetIso559_1, true);
tmp->AddInternal("Set charset Occidental (ISO-8859-15)", NULL, MSG_SetCharsetIso559_15, true);
tmp->AddInternal("Set charset Internationnal (UTF 8)", NULL, MSG_SetCharsetUTF8, true);
tmp->AddSeparator();
tmp->AddGen( "Reload Color File", NULL, EDN_MSG__RELOAD_COLOR_FILE, true);
tmp->AddSeparator();
tmp->AddInternal("Set Color Black", NULL, MSG_LoadColorBlack, true);
tmp->AddInternal("Set Color White", NULL, MSG_LoadColorWhite, true);
m_listMenu.PushBack(tmp);
/* /*
tmp = new MenuBarMain("Project", m_mainWidget); tmp = new MenuBarMain("Project", m_mainWidget);
m_listMenu.PushBack(tmp); m_listMenu.PushBack(tmp);
@@ -258,8 +294,8 @@ MenuBar::MenuBar(void) : MsgBroadcast("Menu bar", EDN_CAT_GUI)
tmp->AddGen("load Ctags file", NULL, EDN_MSG__OPEN_CTAGS, true); tmp->AddGen("load Ctags file", NULL, EDN_MSG__OPEN_CTAGS, true);
tmp->AddGen("re-load Ctags file", NULL, EDN_MSG__RELOAD_CTAGS, true); tmp->AddGen("re-load Ctags file", NULL, EDN_MSG__RELOAD_CTAGS, true);
tmp->AddSeparator(); tmp->AddSeparator();
tmp->AddGen("Find Definition", "ctrl+u", EDN_MSG__JUMP_TO_CURRENT_SELECTION, true); tmp->AddGen("Find Definition", "ctrl+d", EDN_MSG__JUMP_TO_CURRENT_SELECTION, true);
tmp->AddGen("Back previous", "ctrl+y", EDN_MSG__JUMP_BACK, true); tmp->AddGen("Back previous", "ctrl+shift+d", EDN_MSG__JUMP_BACK, true);
/* /*
tmp->AddGen("Gestion Ctags", NULL); tmp->AddGen("Gestion Ctags", NULL);
tmp->AddGen("Add Ctags Folder", NULL); tmp->AddGen("Add Ctags Folder", NULL);

View File

@@ -26,7 +26,7 @@
#include "tools_debug.h" #include "tools_debug.h"
#include "tools_globals.h" #include "tools_globals.h"
#include "MsgBroadcast.h" #include "MsgBroadcast.h"
#include "EdnVectorBin.h" #include "VectorType.h"
#include "AccelKey.h" #include "AccelKey.h"
#ifndef __MENU_BAR_H__ #ifndef __MENU_BAR_H__
@@ -46,7 +46,7 @@ class MenuBar: public MsgBroadcast
private: private:
GtkWidget * m_mainWidget; GtkWidget * m_mainWidget;
GtkAccelGroup * m_accelGroup; GtkAccelGroup * m_accelGroup;
EdnVectorBin<MenuBarMain*> m_listMenu; Edn::VectorType<MenuBarMain*> m_listMenu;
}; };

View File

@@ -42,7 +42,7 @@ class ToolBar: public MsgBroadcast
void AddSeparator(void); void AddSeparator(void);
void Add(const char * title, const char * labelHelp, messageType_te id = EDN_MSG__NONE, bool enable = false); void Add(const char * title, const char * labelHelp, messageType_te id = EDN_MSG__NONE, bool enable = false);
GtkWidget * m_mainWidget; GtkWidget * m_mainWidget;
EdnVectorBin<messageData_ts*> m_message; Edn::VectorType<messageData_ts*> m_message;
}; };

View File

@@ -56,13 +56,22 @@ Search::~Search(void)
} }
} }
void Search::Display(void) void Search::Display(GtkWindow *parent)
{ {
if(NULL == m_localDialog) { if(NULL == m_localDialog) {
m_localDialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); m_localDialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
// set dialog not resisable
gtk_window_set_resizable(GTK_WINDOW(m_localDialog), FALSE); gtk_window_set_resizable(GTK_WINDOW(m_localDialog), FALSE);
gtk_window_set_keep_above(GTK_WINDOW(m_localDialog), TRUE); // 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 // select the program icone
//gtk_window_set_default_icon_name("Replace"); //gtk_window_set_default_icon_name("Replace");
@@ -183,9 +192,9 @@ void Search::Display(void)
} else { } else {
gtk_widget_set_sensitive(m_CkMatchCase, true); gtk_widget_set_sensitive(m_CkMatchCase, true);
} }
// Remove data form the search
Edn::String myDataString; Edn::String myDataString = "";
SearchData::GetSearch(myDataString); SearchData::SetSearch(myDataString);
gtk_entry_set_text(GTK_ENTRY(m_searchEntry), myDataString.c_str()); gtk_entry_set_text(GTK_ENTRY(m_searchEntry), myDataString.c_str());
if (0 == strlen(myDataString.c_str())) { if (0 == strlen(myDataString.c_str())) {
m_haveSearchData = false; m_haveSearchData = false;
@@ -203,13 +212,14 @@ void Search::Display(void)
gtk_widget_set_sensitive(m_BtPrevious, m_haveSearchData); gtk_widget_set_sensitive(m_BtPrevious, m_haveSearchData);
gtk_widget_set_sensitive(m_BtNext, m_haveSearchData); gtk_widget_set_sensitive(m_BtNext, m_haveSearchData);
if (false == m_haveSearchData) { // basic no search data
gtk_widget_set_sensitive(m_BtReplace, false); gtk_widget_set_sensitive(m_BtReplace, false);
gtk_widget_set_sensitive(m_BtReplaceAndNext, false); gtk_widget_set_sensitive(m_BtReplaceAndNext, false);
} else {
gtk_widget_set_sensitive(m_BtReplace, m_haveReplaceData);
gtk_widget_set_sensitive(m_BtReplaceAndNext, m_haveReplaceData); // set focus on a specific widget :
} //gtk_window_set_focus(parent, m_searchEntry);
gtk_widget_grab_focus(m_searchEntry);
// display the dialogue box // display the dialogue box
gtk_widget_show_all(m_localDialog); gtk_widget_show_all(m_localDialog);
@@ -318,8 +328,8 @@ void Search::OnEntrySearchChange(GtkWidget *widget, gpointer data)
gtk_widget_set_sensitive(self->m_BtReplace, false); gtk_widget_set_sensitive(self->m_BtReplace, false);
gtk_widget_set_sensitive(self->m_BtReplaceAndNext, false); gtk_widget_set_sensitive(self->m_BtReplaceAndNext, false);
} else { } else {
gtk_widget_set_sensitive(self->m_BtReplace, self->m_haveReplaceData); gtk_widget_set_sensitive(self->m_BtReplace, true);
gtk_widget_set_sensitive(self->m_BtReplaceAndNext, self->m_haveReplaceData); gtk_widget_set_sensitive(self->m_BtReplaceAndNext, true);
} }
} }
} }
@@ -338,7 +348,12 @@ void Search::OnEntryReplaceChange(GtkWidget *widget, gpointer data)
} else { } else {
self->m_haveReplaceData = true; self->m_haveReplaceData = true;
} }
gtk_widget_set_sensitive(self->m_BtReplace, self->m_haveReplaceData); if (false == self->m_haveSearchData) {
gtk_widget_set_sensitive(self->m_BtReplaceAndNext, self->m_haveReplaceData); gtk_widget_set_sensitive(self->m_BtReplace, false);
gtk_widget_set_sensitive(self->m_BtReplaceAndNext, false);
} else {
gtk_widget_set_sensitive(self->m_BtReplace, true);
gtk_widget_set_sensitive(self->m_BtReplaceAndNext, true);
}
} }
} }

View File

@@ -28,8 +28,6 @@
#include "tools_debug.h" #include "tools_debug.h"
#include "Singleton.h" #include "Singleton.h"
#include <string>
#include <vector>
class Search: public Singleton<Search> class Search: public Singleton<Search>
@@ -43,7 +41,7 @@ class Search: public Singleton<Search>
public: public:
void Destroy(void); void Destroy(void);
void Display(void); void Display(GtkWindow *parent);
void Hide(void); void Hide(void);
private: private:

View File

@@ -76,7 +76,7 @@ void WindowsManager::OnMessage(int32_t id, int32_t dataID)
EDN_INFO("Request opening SEARCH"); EDN_INFO("Request opening SEARCH");
{ {
Search *myInstance = Search::getInstance(); Search *myInstance = Search::getInstance();
myInstance->Display(); myInstance->Display(GTK_WINDOW(m_mainWindow->GetWidget()));
} }
break; break;
case EDN_MSG__GUI_SHOW_PREFERENCE: case EDN_MSG__GUI_SHOW_PREFERENCE:
@@ -93,21 +93,21 @@ void WindowsManager::OnMessage(int32_t id, int32_t dataID)
GtkWidget *dialog = gtk_file_chooser_dialog_new( "Open File", NULL, GtkWidget *dialog = gtk_file_chooser_dialog_new( "Open File", NULL,
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, // button text GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_RESPONSE_CANCEL, // response id GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
GTK_STOCK_OPEN, // button text
GTK_RESPONSE_ACCEPT, // response id
NULL); // end button/response list NULL); // end button/response list
// this element did not apear in the miniature of the windows
gtk_window_set_skip_pager_hint(GTK_WINDOW(dialog), TRUE);
if( -1 != m_currentBufferID if( -1 != m_currentBufferID
&& true == myBufferManager->Exist(m_currentBufferID) ) && true == myBufferManager->Exist(m_currentBufferID) )
{ {
Edn::String fileFolder = myBufferManager->Get(m_currentBufferID)->GetFolder(); Edn::File fileName = myBufferManager->Get(m_currentBufferID)->GetFileName();
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER(dialog), fileFolder.c_str()); gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), fileName.GetFolder().c_str());
//gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER(dialog), "Untitled document"); gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), fileName.GetShortFilename().c_str());
} }
if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
{ {
Edn::String myfilename; Edn::File myfilename;
myfilename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog)); myfilename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog));
if (false == myBufferManager->Exist(myfilename) ) { if (false == myBufferManager->Exist(myfilename) ) {
@@ -132,20 +132,20 @@ void WindowsManager::OnMessage(int32_t id, int32_t dataID)
} }
Buffer *myBuffer = BufferManager::getInstance()->Get(idSelected); Buffer *myBuffer = BufferManager::getInstance()->Get(idSelected);
Edn::String tmpString = "Save as file : "; Edn::String tmpString = "Save as file : ";
tmpString += myBuffer->GetShortName().c_str(); tmpString += myBuffer->GetFileName().GetShortFilename().c_str();
GtkWidget *dialog = gtk_file_chooser_dialog_new( tmpString.c_str(), NULL, GtkWidget *dialog = gtk_file_chooser_dialog_new( tmpString.c_str(), NULL,
GTK_FILE_CHOOSER_ACTION_SAVE, GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, // button text GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_RESPONSE_CANCEL, // response id GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
GTK_STOCK_SAVE, // button text
GTK_RESPONSE_ACCEPT, // response id
NULL); // end button/response list NULL); // end button/response list
// this element did not apear in the miniature of the windows
gtk_window_set_skip_pager_hint(GTK_WINDOW(dialog), TRUE);
if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
{ {
Edn::String myfilename; Edn::String myfilename;
myfilename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog)); myfilename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog));
myBuffer->SetName(myfilename); myBuffer->SetFileName(myfilename);
myBuffer->Save(); myBuffer->Save();
SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, idSelected); SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, idSelected);
@@ -154,28 +154,165 @@ void WindowsManager::OnMessage(int32_t id, int32_t dataID)
} }
break; break;
case EDN_MSG__GUI_SHOW_ABOUT: case EDN_MSG__GUI_SHOW_ABOUT:
{
GtkWidget *myDialog = gtk_about_dialog_new();
gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(myDialog), "Edn");
gtk_about_dialog_set_version( GTK_ABOUT_DIALOG(myDialog), VERSION_TAG_NAME);
gtk_about_dialog_set_comments( GTK_ABOUT_DIALOG(myDialog), "Editeur De N'ours\n"
"L'Editeur Desoxyribo-Nucleique.\n"
"Source Code Editor\n"
"Build Time : " VERSION_BUILD_TIME);
gtk_about_dialog_set_copyright( GTK_ABOUT_DIALOG(myDialog), "Copyright 2010 Edouard DUPIN, all right reserved");
gtk_about_dialog_set_license( GTK_ABOUT_DIALOG(myDialog), "This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY\n\n"
"You can:\n"
" * Redistribute the sources code and binaries.\n"
" * Modify the Sources code.\n"
" * Use a part of the sources (less than 50%) in an other software, just write somewhere \"Edn is great\" visible by the user (on your product or on your website with a link to my page).\n"
" * Redistribute the modification only if you want.\n"
" * Send me the bug-fix (it could be great).\n"
" * Pay me a beer or some other things.\n"
" * Print the source code on WC paper ...\n\n"
"You can NOT:\n"
" * Earn money with this Software (But I can).\n"
" * Add malware in the Sources.\n"
" * Do something bad with the sources.\n"
" * Use it to travel in the space with a toaster.\n\n"
"I reserve the right to change this licence. If it change the version of the copy you have keep its own license.");
gtk_about_dialog_set_wrap_license(GTK_ABOUT_DIALOG(myDialog), true);
# if USE_GTK_VERSION_3_0
gtk_about_dialog_set_license_type(GTK_ABOUT_DIALOG(myDialog), GTK_LICENSE_CUSTOM);
# endif
gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(myDialog), "http://HeeroYui.github.com/edn");
gtk_about_dialog_set_website_label(GTK_ABOUT_DIALOG(myDialog), "Edn on github");
const char * listAutor[] = {"Edouard DUPIN", NULL};
gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(myDialog), listAutor);
// Display About
gtk_dialog_run(GTK_DIALOG(myDialog));
gtk_widget_destroy(myDialog);
}
break;
case EDN_MSG__GUI_SHOW_GOTO_LINE:
{ {
// dlg to confirm the quit event : // dlg to confirm the quit event :
GtkWidget *p_dialog = gtk_dialog_new_with_buttons("About", GtkWidget *myDialog = gtk_dialog_new_with_buttons("Goto Line",
NULL, GTK_WINDOW(m_mainWindow->GetWidget()),
GTK_DIALOG_MODAL,
"Jump", GTK_RESPONSE_YES,
GTK_STOCK_QUIT, GTK_RESPONSE_NO,
NULL);
// this element did not apear in the miniature of the windows
gtk_window_set_skip_pager_hint(GTK_WINDOW(myDialog), TRUE);
// Set over main windows
gtk_window_set_transient_for(GTK_WINDOW(myDialog), GTK_WINDOW(m_mainWindow->GetWidget()));
// add writting area
GtkWidget *myContentArea = gtk_dialog_get_content_area( GTK_DIALOG(myDialog));
GtkWidget *myEntry = gtk_entry_new();
gtk_box_pack_start(GTK_BOX(myContentArea), myEntry, TRUE, TRUE, 0);
// Display it
gtk_widget_show_all(myContentArea);
int32_t result = gtk_dialog_run (GTK_DIALOG (myDialog));
// Get data from the gtk entry
const char *myData = gtk_entry_get_text(GTK_ENTRY(myEntry));
if (NULL != myData) {
int32_t lineID=0;
if (1==sscanf(myData, "%d",&lineID)) {
EDN_DEBUG("find in : \"" << myData << "\" = " << lineID);
if(GTK_RESPONSE_YES == result) {
SendMessage(EDN_MSG__CURRENT_GOTO_LINE, lineID-1);
}
} else {
if (GTK_RESPONSE_YES == result) {
EDN_WARNING("find in : \"" << myData << "\" line Number is not correct ");
}
}
} else {
EDN_DEBUG("no line Writen ...");
}
// Remove dialogue
gtk_widget_destroy(myDialog);
}
break;
case EDN_MSG__GUI_SHOW_EXIT_CONFIRMATION:
{
EDN_INFO("quit requested");
// dlg to confirm the quit event :
GtkWidget *p_dialog = gtk_dialog_new_with_buttons("Exit",
GTK_WINDOW(m_mainWindow->GetWidget()),
GTK_DIALOG_MODAL, GTK_DIALOG_MODAL,
GTK_STOCK_YES, GTK_RESPONSE_YES, GTK_STOCK_YES, GTK_RESPONSE_YES,
GTK_STOCK_NO, GTK_RESPONSE_NO, GTK_STOCK_NO, GTK_RESPONSE_NO,
NULL); NULL);
GtkWidget *p_label = gtk_label_new ("Do you want exit Edn?"); GtkWidget *p_label = gtk_label_new ("Do you want exit Edn ?");
gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area( GTK_DIALOG(p_dialog) )), p_label, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area( GTK_DIALOG(p_dialog) )), p_label, TRUE, TRUE, 0);
gtk_widget_show(p_label); gtk_widget_show(p_label);
int32_t result = gtk_dialog_run (GTK_DIALOG (p_dialog));
gtk_widget_destroy(p_dialog); switch (gtk_dialog_run (GTK_DIALOG (p_dialog)))
switch (result)
{ {
case GTK_RESPONSE_YES: case GTK_RESPONSE_YES:
gtk_widget_destroy (p_dialog);
p_dialog = NULL;
{
BufferManager * myBufferMng = BufferManager::getInstance();
for (int32_t iii=0 ; iii<myBufferMng->Size() ; iii++) {
if (true==myBufferMng->Exist(iii) ) {
Buffer * myBuffer = myBufferMng->Get(iii);
if (NULL != myBuffer) {
if (true == myBuffer->IsModify()) {
if (true == myBuffer->HaveName()) {
p_dialog = gtk_dialog_new_with_buttons("Save Before Exit",
GTK_WINDOW(m_mainWindow->GetWidget()),
GTK_DIALOG_MODAL,
GTK_STOCK_SAVE, GTK_RESPONSE_YES,
GTK_STOCK_SAVE_AS, GTK_RESPONSE_ACCEPT,
GTK_STOCK_NO, GTK_RESPONSE_NO,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
NULL);
} else {
p_dialog = gtk_dialog_new_with_buttons("Save Before Exit",
GTK_WINDOW(m_mainWindow->GetWidget()),
GTK_DIALOG_MODAL,
GTK_STOCK_SAVE_AS, GTK_RESPONSE_ACCEPT,
GTK_STOCK_NO, GTK_RESPONSE_NO,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
NULL);
}
char tmpName[1024];
sprintf(tmpName, "Save file \"%s\" ?", myBuffer->GetFileName().GetCompleateName().c_str());
p_label = gtk_label_new(tmpName);
gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area( GTK_DIALOG(p_dialog) )), p_label, TRUE, TRUE, 0);
gtk_widget_show(p_label);
switch (gtk_dialog_run (GTK_DIALOG (p_dialog)))
{
case GTK_RESPONSE_YES:
myBuffer->Save();
break;
case GTK_RESPONSE_ACCEPT:
OnMessage(EDN_MSG__GUI_SHOW_SAVE_AS, iii);
break;
case GTK_RESPONSE_NO:
// nothing to do ...
break;
case GTK_RESPONSE_CANCEL:
gtk_widget_destroy (p_dialog);
return;
break;
}
gtk_widget_destroy (p_dialog);
p_dialog = NULL;
}
}
}
}
}
gtk_main_quit(); gtk_main_quit();
break; break;
case GTK_RESPONSE_NO: case GTK_RESPONSE_NO:
gtk_widget_destroy (p_dialog);
break; break;
} }
} }
break; break;

View File

@@ -33,14 +33,14 @@
#define __class__ "Highlight" #define __class__ "Highlight"
void Highlight::ParseRules(TiXmlNode *child, std::vector<HighlightPattern*> &mListPatern, int32_t level) void Highlight::ParseRules(TiXmlNode *child, Edn::VectorType<HighlightPattern*> &mListPatern, int32_t level)
{ {
// Create the patern ... // Create the patern ...
HighlightPattern *myPattern = new HighlightPattern(); HighlightPattern *myPattern = new HighlightPattern();
// parse under Element // parse under Element
myPattern->ParseRules(child, level); myPattern->ParseRules(child, level);
// add element in the list // add element in the list
mListPatern.push_back(myPattern); mListPatern.PushBack(myPattern);
} }
@@ -52,7 +52,7 @@ Highlight::Highlight(Edn::String &xmlFilename)
// open the curent File // open the curent File
bool loadError = XmlDocument.LoadFile(xmlFilename.c_str()); bool loadError = XmlDocument.LoadFile(xmlFilename.c_str());
if (false == loadError) { if (false == loadError) {
EDN_ERROR( "can not load Hightlight XML: PARSING error: \"" << xmlFilename.c_str() << "\""); EDN_ERROR( "can not load Hightlight XML: PARSING error: \"" << xmlFilename << "\"");
return; return;
} }
TiXmlElement* root = XmlDocument.FirstChildElement( "EdnLang" ); TiXmlElement* root = XmlDocument.FirstChildElement( "EdnLang" );
@@ -72,8 +72,8 @@ Highlight::Highlight(Edn::String &xmlFilename)
const char *myData = child->ToElement()->GetText(); const char *myData = child->ToElement()->GetText();
if (NULL != myData) { if (NULL != myData) {
//EDN_INFO(PFX"(l %d) node fined : %s=\"%s\"", child->Row(), child->Value() , myData); //EDN_INFO(PFX"(l %d) node fined : %s=\"%s\"", child->Row(), child->Value() , myData);
Edn::String myEdnData = myData; Edn::String * myEdnData = new Edn::String(myData);
m_listExtentions.push_back(myEdnData); m_listExtentions.PushBack(myEdnData);
} }
} else if (!strcmp(child->Value(), "pass1")) { } else if (!strcmp(child->Value(), "pass1")) {
// Get sub Nodes ... // Get sub Nodes ...
@@ -113,48 +113,68 @@ Highlight::Highlight(Edn::String &xmlFilename)
Highlight::~Highlight(void) Highlight::~Highlight(void)
{ {
uint32_t i; int32_t i;
// clean all Element // clean all Element
for (i=0; i< m_listHighlightPass1.size(); i++) { for (i=0; i< m_listHighlightPass1.Size(); i++) {
if (NULL != m_listHighlightPass1[i]) {
delete(m_listHighlightPass1[i]); delete(m_listHighlightPass1[i]);
m_listHighlightPass1[i] = NULL;
}
} }
// clear the compleate list // clear the compleate list
m_listHighlightPass1.clear(); m_listHighlightPass1.Clear();
// clean all Element
for (i=0; i< m_listExtentions.Size(); i++) {
if (NULL != m_listExtentions[i]) {
delete(m_listExtentions[i]);
m_listExtentions[i] = NULL;
}
}
// clear the compleate list
m_listExtentions.Clear();
} }
void Highlight::ReloadColor(void)
{
int32_t i;
for (i=0; i< m_listHighlightPass1.Size(); i++) {
if (NULL != m_listHighlightPass1[i]) {
m_listHighlightPass1[i]->ReloadColor();
}
}
for (i=0; i< m_listHighlightPass2.Size(); i++) {
if (NULL != m_listHighlightPass2[i]) {
m_listHighlightPass2[i]->ReloadColor();
}
}
}
bool Highlight::HasExtention(Edn::String &ext) bool Highlight::HasExtention(Edn::String &ext)
{ {
uint32_t i; int32_t i;
for (i=0; i<m_listExtentions.size(); i++) { for (i=0; i<m_listExtentions.Size(); i++) {
if (ext == m_listExtentions[i] ) { if (ext == *m_listExtentions[i] ) {
return true; return true;
} }
} }
return false; return false;
} }
bool Highlight::FileNameCompatible(Edn::String &fileName) bool Highlight::FileNameCompatible(Edn::File &fileName)
{ {
uint32_t i; int32_t i;
int32_t posCopy = fileName.FindBack('/');
Edn::String shortFilename;
if (-1 != posCopy) {
shortFilename = fileName.Extract(posCopy+1);
} else {
shortFilename = fileName;
}
posCopy = shortFilename.FindBack('.');
Edn::String extention; Edn::String extention;
if (-1 != posCopy) { if (true == fileName.HasExtention() ) {
extention = shortFilename.Extract(posCopy); extention = "*.";
extention += fileName.GetExtention();
} else { } else {
extention = shortFilename; extention = fileName.GetShortFilename();
} }
EDN_DEBUG(" try to find : in \"" << fileName.c_str() << "\" shortfilename\"" << shortFilename.c_str() << "\" extention:\"" << extention.c_str() << "\" "); EDN_DEBUG(" try to find : in \"" << fileName << "\" extention:\"" << extention << "\" ");
for (i=0; i<m_listExtentions.size(); i++) { for (i=0; i<m_listExtentions.Size(); i++) {
if (extention == m_listExtentions[i] ) { if (extention == *m_listExtentions[i] ) {
return true; return true;
} }
} }
@@ -164,134 +184,119 @@ bool Highlight::FileNameCompatible(Edn::String &fileName)
void Highlight::Display(void) void Highlight::Display(void)
{ {
uint32_t i; int32_t i;
EDN_INFO("List of ALL Highlight : "); EDN_INFO("List of ALL Highlight : ");
for (i=0; i< m_listExtentions.size(); i++) { for (i=0; i< m_listExtentions.Size(); i++) {
EDN_INFO(" Extention : " << i << " : " << m_listExtentions[i].c_str() ); EDN_INFO(" Extention : " << i << " : " << *m_listExtentions[i] );
} }
// Display all elements // Display all elements
for (i=0; i< m_listHighlightPass1.size(); i++) { for (i=0; i< m_listHighlightPass1.Size(); i++) {
EDN_INFO(" " << i << " Pass 1 : " << m_listHighlightPass1[i]->GetName().c_str() ); EDN_INFO(" " << i << " Pass 1 : " << m_listHighlightPass1[i]->GetName() );
//m_listHighlightPass1[i]->Display(); //m_listHighlightPass1[i]->Display();
} }
// Display all elements // Display all elements
for (i=0; i< m_listHighlightPass2.size(); i++) { for (i=0; i< m_listHighlightPass2.Size(); i++) {
EDN_INFO(" " << i << " Pass 2 : " << m_listHighlightPass2[i]->GetName().c_str() ); EDN_INFO(" " << i << " Pass 2 : " << m_listHighlightPass2[i]->GetName() );
//m_listHighlightPass2[i]->Display(); //m_listHighlightPass2[i]->Display();
} }
} }
// 13h 46min 22s | (l= 214) Highlight::Parse | [II] Find Pattern in the Buffer : (2457,2479)
void Highlight::Parse(int32_t start, int32_t stop, std::vector<colorInformation_ts> &metaData, int32_t &addingPos, EdnVectorBuf &buffer, int32_t elementID) // TODO : Celui qui appelle suprime des element pour rien ... Enfin c'est pas tr<74>grave... Il suffirait juste de suprimer celuis d'avant si il n'est pas terminer...
void Highlight::Parse(int32_t start,
int32_t stop,
Edn::VectorType<colorInformation_ts> &metaData,
int32_t addingPos,
EdnVectorBuf &buffer)
{ {
if (0 > addingPos) { if (0 > addingPos) {
addingPos = 0; addingPos = 0;
} }
/*int32_t emptyId = -1; //EDN_DEBUG("Parse element 0 => " << m_listHighlightPass1.Size() << " ==> position search: (" << start << "," << stop << ")" );
for (i=0; i< (int32_t)metaData.size(); i++) {
}*/
//EDN_DEBUG("Parse element " << elementID << " / " << m_listHighlightPass1.size() << " ==> position search: (" << start << "," << stop << ")" );
if (elementID >= (int32_t)m_listHighlightPass1.size() ){
//EDN_DEBUG("Return at " << elementID << " / " << m_listHighlightPass1.size() );
return;
}
int32_t elementStart = start; int32_t elementStart = start;
int32_t elementStop = stop; int32_t elementStop = stop;
resultFind_te ret = HLP_FIND_OK;
colorInformation_ts resultat; colorInformation_ts resultat;
while (HLP_FIND_ERROR != ret && elementStart<elementStop) { while (elementStart<elementStop) {
ret = m_listHighlightPass1[elementID]->Find(elementStart, elementStop, resultat, buffer); //EDN_DEBUG("Parse element in the buffer id=" << elementStart);
//try to fond the HL in ALL of we have
for (int32_t jjj=0; jjj<m_listHighlightPass1.Size(); jjj++){
resultFind_te ret = HLP_FIND_OK;
//EDN_DEBUG("Parse HL id=" << jjj << " position search: (" << start << "," << buffer.Size() << ")" );
// Stop the search to the end (to get the end of the pattern)
ret = m_listHighlightPass1[jjj]->Find(elementStart, buffer.Size(), resultat, buffer);
if (HLP_FIND_ERROR != ret) { if (HLP_FIND_ERROR != ret) {
//EDN_INFO("Find Pattern in the Buffer : (" << resultat.beginStart << "," << resultat.endStop << ")" ); //EDN_INFO("Find Pattern in the Buffer : (" << resultat.beginStart << "," << resultat.endStop << ")" );
// Remove element in the current List where the current Element have a end inside the next...
int32_t kkk=addingPos;
while(kkk < metaData.Size() ) {
if (metaData[kkk].beginStart <= resultat.endStop) {
// Remove element
//EDN_INFO("Erase element=" << kkk);
metaData.EraseLen(kkk, kkk+1);
// Increase the end of search
if (kkk < metaData.Size()) {
// just befor the end of the next element
elementStop = metaData[kkk].beginStart-1;
} else {
// end of the buffer
elementStop = buffer.Size();
}
} else {
// Not find ==> exit the cycle :
break;
}
}
// Add curent element in the list ... // Add curent element in the list ...
if (HLP_FIND_OK_NO_END == ret) { metaData.Insert(addingPos, resultat);
// find if we have a next element with th save Pointer and not higher the this one
int32_t findNextElement = -1;
int32_t i;
int32_t curentLevel = ((HighlightPattern*)resultat.patern)->GetLevel();
for (i=addingPos; i< (int32_t)metaData.size(); i++) {
if (curentLevel > ((HighlightPattern*)metaData[i].patern)->GetLevel() ) {
//EDN_DEBUG(" -> Find upper element at "<< i );
break;
} else if (curentLevel < ((HighlightPattern*)metaData[i].patern)->GetLevel() ) {
findNextElement = i;
//EDN_DEBUG(" -> Find under element at "<< i );
}
if (metaData[i].patern == resultat.patern)
{
findNextElement = i;
//EDN_DEBUG(" -> Find a same element at "<< i );
break;
}
}
if (-1 != findNextElement) {
// if not find a end, we need to search the end of this one and parse all data inside...
int32_t newEnd = buffer.Size();
if (findNextElement >= (int32_t)metaData.size()-1) {
// Remove old element :
//EDN_DEBUG(" --> Remove : " << addingPos << "==>" << (int32_t)metaData.size() << " (end)" );
metaData.erase(metaData.begin()+addingPos,metaData.end());
} else {
// Remove old element :
//EDN_DEBUG(" --> Remove : " << addingPos << "==>" << findNextElement+1 );
metaData.erase(metaData.begin()+addingPos,metaData.begin()+findNextElement+1);
newEnd = metaData[addingPos].beginStart-1;
}
// Regenerate a local parsing : in a higher range of text
Parse(elementStart, edn_max(newEnd, stop), metaData, addingPos, buffer, elementID);
// Break the curent process, beacause we reparse the data in all range...
return;
} else {
//EDN_DEBUG(" --> No element removed " );
metaData.insert(metaData.begin() + addingPos, resultat);
//EDN_DEBUG("INSERT at "<< addingPos << " S=" << resultat.beginStart << " E=" << resultat.endStop ); //EDN_DEBUG("INSERT at "<< addingPos << " S=" << resultat.beginStart << " E=" << resultat.endStop );
} // Update the current research starting element: (Set position at the end of the current element
} else { elementStart = resultat.endStop-1;
metaData.insert(metaData.begin() + addingPos, resultat); // increment the position of insertion:
//EDN_DEBUG("INSERT at "<< addingPos << " S=" << resultat.beginStart << " E=" << resultat.endStop );
}
// parse the under element :
Parse(elementStart, resultat.beginStart-1, metaData, addingPos, buffer, elementID+1);
addingPos++; addingPos++;
elementStart = resultat.endStop; // We find a pattern ==> Stop search for the current element
break;
} }
} }
// parse the under element : // Go to the next element (and search again ...).
Parse(elementStart, elementStop, metaData, addingPos, buffer, elementID+1); elementStart++;
}
} }
/** /**
* @brief second pass of the hightlight * @brief second pass of the hightlight
* *
*/ */
void Highlight::Parse2(int32_t start, int32_t stop, std::vector<colorInformation_ts> &metaData, EdnVectorBuf &buffer, int32_t elementID) void Highlight::Parse2(int32_t start,
int32_t stop,
Edn::VectorType<colorInformation_ts> &metaData,
EdnVectorBuf &buffer)
{ {
if (elementID >= (int32_t)m_listHighlightPass2.size() ){ //EDN_DEBUG("Parse element 0 => " << m_listHighlightPass2.size() << " ==> position search: (" << start << "," << stop << ")" );
return;
}
int32_t elementStart = start; int32_t elementStart = start;
int32_t elementStop = stop; int32_t elementStop = stop;
resultFind_te ret = HLP_FIND_OK;
colorInformation_ts resultat; colorInformation_ts resultat;
while (HLP_FIND_ERROR != ret && elementStart<elementStop) { while (elementStart<elementStop) {
if (m_listHighlightPass2[elementID]!=NULL) { //EDN_DEBUG("Parse element in the buffer id=" << elementStart);
ret = m_listHighlightPass2[elementID]->Find(elementStart, elementStop, resultat, buffer); //try to fond the HL in ALL of we have
} else { int32_t jjj;
ret = HLP_FIND_ERROR; for (jjj=0; jjj<m_listHighlightPass2.Size(); jjj++){
} resultFind_te ret = HLP_FIND_OK;
//EDN_DEBUG("Parse HL id=" << jjj << " position search: (" << start << "," << buffer.Size() << ")" );
// Stop the search to the end (to get the end of the pattern)
ret = m_listHighlightPass2[jjj]->Find(elementStart, elementStop, resultat, buffer);
if (HLP_FIND_ERROR != ret) { if (HLP_FIND_ERROR != ret) {
//EDN_INFO("Find Pattern in the Buffer : (" << resultat.beginStart << "," << resultat.endStop << ")" ); //EDN_INFO("Find Pattern in the Buffer : (" << resultat.beginStart << "," << resultat.endStop << ")" );
// parse the under element :
Parse2(elementStart, resultat.beginStart, metaData, buffer, elementID+1);
// Add curent element in the list ... // Add curent element in the list ...
metaData.push_back(resultat); metaData.PushBack(resultat);
elementStart = resultat.endStop; elementStart = resultat.endStop-1;
// Exit current cycle
break;
} }
} }
// parse the under element : // Go to the next element (and search again ...).
Parse2(elementStart, elementStop, metaData, buffer, elementID+1); elementStart++;
}
} }

View File

@@ -23,6 +23,7 @@
******************************************************************************* *******************************************************************************
*/ */
#include "Edn.h"
#ifndef __HIGHLIGHT_H__ #ifndef __HIGHLIGHT_H__
#define __HIGHLIGHT_H__ #define __HIGHLIGHT_H__
@@ -42,10 +43,8 @@ extern "C" {
} colorInformation_ts; } colorInformation_ts;
} }
#include <vector>
#include "HighlightPattern.h" #include "HighlightPattern.h"
#include "Colorize.h" #include "Colorize.h"
#include "Edn.h"
#include "EdnVectorBuf.h" #include "EdnVectorBuf.h"
#include "tinyxml.h" #include "tinyxml.h"
@@ -55,17 +54,24 @@ class Highlight {
Highlight(Edn::String &xmlFilename); Highlight(Edn::String &xmlFilename);
~Highlight(void); ~Highlight(void);
bool HasExtention(Edn::String &ext); bool HasExtention(Edn::String &ext);
bool FileNameCompatible(Edn::String &fileName); bool FileNameCompatible(Edn::File &fileName);
void Display(void); void Display(void);
void Parse( int32_t start, int32_t stop, std::vector<colorInformation_ts> &metaData, int32_t &addingPos, EdnVectorBuf &buffer, int32_t elementID=0); void ReloadColor(void);
void Parse2(int32_t start, int32_t stop, std::vector<colorInformation_ts> &metaData, EdnVectorBuf &buffer, int32_t elementID=0); void Parse(int32_t start,
int32_t stop,
Edn::VectorType<colorInformation_ts> &metaData,
int32_t addingPos,
EdnVectorBuf &buffer);
void Parse2(int32_t start,
int32_t stop,
Edn::VectorType<colorInformation_ts> &metaData,
EdnVectorBuf &buffer);
private: private:
void ParseRules(TiXmlNode *child, std::vector<HighlightPattern*> &mListPatern, int32_t level); void ParseRules(TiXmlNode *child, Edn::VectorType<HighlightPattern*> &mListPatern, int32_t level);
Edn::String m_styleName; //!< curent style name (like "c++" or "c" or "script Bash") Edn::String m_styleName; //!< curent style name (like "c++" or "c" or "script Bash")
std::vector<Edn::String> m_listExtentions; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h" Edn::VectorType<Edn::String*> m_listExtentions; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h"
std::vector<HighlightPattern*> m_listHighlightPass1; //!< List of ALL hightlight modules (pass 1 ==> when we load and wride data on the buffer) Edn::VectorType<HighlightPattern*> m_listHighlightPass1; //!< List of ALL hightlight modules (pass 1 ==> when we load and wride data on the buffer)
std::vector<HighlightPattern*> m_listHighlightPass2; //!< List of ALL hightlight modules (pass 2 ==> When we display the buffer( only the display area (100 lines)) ) Edn::VectorType<HighlightPattern*> m_listHighlightPass2; //!< List of ALL hightlight modules (pass 2 ==> When we display the buffer( only the display area (100 lines)) )
}; };

View File

@@ -30,21 +30,45 @@
#undef __class__ #undef __class__
#define __class__ "HighlightManager" #define __class__ "HighlightManager"
HighlightManager::HighlightManager(void) HighlightManager::HighlightManager(void) : MsgBroadcast("Hight-light Manager", EDN_CAT_HL)
{ {
} }
HighlightManager::~HighlightManager(void) HighlightManager::~HighlightManager(void)
{ {
listHighlight.clear(); int32_t i;
// clean all Element
for (i=0; i< listHighlight.Size(); i++) {
if (NULL != listHighlight[i]) {
delete(listHighlight[i]);
listHighlight[i] = NULL;
}
}
// clear the compleate list
listHighlight.Clear();
} }
Highlight *HighlightManager::Get(Edn::String &fileName) void HighlightManager::OnMessage(int32_t id, int32_t dataID)
{ {
uint32_t i; switch (id)
for (i=0; i<listHighlight.size(); i++) { {
case EDN_MSG__COLOR_HAS_CHANGE:
EDN_INFO("UPDATE the color pointer on the HL");
for (int32_t i=0; i<listHighlight.Size(); i++) {
if (NULL != listHighlight[i]) {
listHighlight[i]->ReloadColor();
}
}
break;
}
}
Highlight *HighlightManager::Get(Edn::File &fileName)
{
int32_t i;
for (i=0; i<listHighlight.Size(); i++) {
if (true == listHighlight[i]->FileNameCompatible(fileName) ) { if (true == listHighlight[i]->FileNameCompatible(fileName) ) {
return listHighlight[i]; return listHighlight[i];
} }
@@ -52,14 +76,11 @@ Highlight *HighlightManager::Get(Edn::String &fileName)
return NULL; return NULL;
} }
bool HighlightManager::Exist(Edn::String &fileName) bool HighlightManager::Exist(Edn::File &fileName)
{ {
uint32_t i; if (NULL != Get(fileName) ) {
for (i=0; i<listHighlight.size(); i++) {
if (true == listHighlight[i]->FileNameCompatible(fileName) ) {
return true; return true;
} }
}
return false; return false;
} }
@@ -68,37 +89,51 @@ void HighlightManager::loadLanguages(void)
{ {
Edn::String homedir; Edn::String homedir;
#ifdef NDEBUG #ifdef NDEBUG
homedir = getenv("HOME"); homedir = "/usr/share/edn/";
homedir += "/.edn/";
#else #else
homedir = "./"; homedir = "./data/";
#endif #endif
Edn::String xmlFilename = homedir; Edn::String xmlFilename = homedir;
xmlFilename += "data/lang_c.xml"; xmlFilename += "lang_c.xml";
Highlight *myHightline = new Highlight(xmlFilename); Highlight *myHightline = new Highlight(xmlFilename);
listHighlight.push_back(myHightline); listHighlight.PushBack(myHightline);
xmlFilename = homedir; xmlFilename = homedir;
xmlFilename += "data/lang_boo.xml"; xmlFilename += "lang_boo.xml";
myHightline = new Highlight(xmlFilename); myHightline = new Highlight(xmlFilename);
listHighlight.push_back(myHightline); listHighlight.PushBack(myHightline);
xmlFilename = homedir; xmlFilename = homedir;
xmlFilename += "data/lang_Makefile.xml"; xmlFilename += "lang_Makefile.xml";
myHightline = new Highlight(xmlFilename); myHightline = new Highlight(xmlFilename);
listHighlight.push_back(myHightline); listHighlight.PushBack(myHightline);
xmlFilename = homedir; xmlFilename = homedir;
xmlFilename += "data/lang_asm.xml"; xmlFilename += "lang_asm.xml";
myHightline = new Highlight(xmlFilename); myHightline = new Highlight(xmlFilename);
listHighlight.push_back(myHightline); listHighlight.PushBack(myHightline);
xmlFilename = homedir; xmlFilename = homedir;
xmlFilename += "data/lang_xml.xml"; xmlFilename += "lang_xml.xml";
myHightline = new Highlight(xmlFilename); myHightline = new Highlight(xmlFilename);
listHighlight.push_back(myHightline); listHighlight.PushBack(myHightline);
myHightline->Display(); xmlFilename = homedir;
xmlFilename += "lang_php.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = homedir;
xmlFilename += "lang_bash.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = homedir;
xmlFilename += "lang_matlab.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
//myHightline->Display();
} }

View File

@@ -29,12 +29,11 @@
class HighlightManager; class HighlightManager;
#include "Singleton.h" #include "Singleton.h"
#include <vector> #include "MsgBroadcast.h"
#include <string>
#include "Highlight.h" #include "Highlight.h"
class HighlightManager: public Singleton<HighlightManager> class HighlightManager: public Singleton<HighlightManager>, public MsgBroadcast
{ {
friend class Singleton<HighlightManager>; friend class Singleton<HighlightManager>;
// specific for sigleton system... // specific for sigleton system...
@@ -43,13 +42,15 @@ class HighlightManager: public Singleton<HighlightManager>
HighlightManager(void); HighlightManager(void);
~HighlightManager(void); ~HighlightManager(void);
public:
void OnMessage(int32_t id, int32_t dataID);
public: public:
void loadLanguages(void); void loadLanguages(void);
Highlight * Get(Edn::String &fileName); Highlight * Get(Edn::File &fileName);
bool Exist(Edn::String &fileName); bool Exist(Edn::File &fileName);
private: private:
std::vector<Highlight*> listHighlight; //!< List of ALL hightlight modules Edn::VectorType<Highlight*> listHighlight; //!< List of ALL hightlight modules
}; };
#endif #endif

View File

@@ -39,8 +39,8 @@ HighlightPattern::HighlightPattern(void)
m_multiline = false; m_multiline = false;
ColorizeManager *myColorManager = ColorizeManager::getInstance(); ColorizeManager *myColorManager = ColorizeManager::getInstance();
m_color = myColorManager->Get("normal"); m_color = myColorManager->Get("normal");
m_regExpStart = new EdnRegExp(); m_regExpStart = new EdnRegExp<EdnVectorBuf>();
m_regExpStop = new EdnRegExp(); m_regExpStop = new EdnRegExp<EdnVectorBuf>();
m_escapeChar = 0; m_escapeChar = 0;
} }
@@ -87,6 +87,13 @@ bool HighlightPattern::IsEnable(void)
return true; return true;
} }
void HighlightPattern::ReloadColor(void)
{
ColorizeManager *myColorManager = ColorizeManager::getInstance();
m_color = myColorManager->Get(m_colorName);
}
/** /**
* @brief * @brief
* *
@@ -98,10 +105,10 @@ bool HighlightPattern::IsEnable(void)
void HighlightPattern::Display(void) void HighlightPattern::Display(void)
{ {
/* /*
EDN_INFO("patern : \"" << m_paternName.c_str() << "\" level=" << m_level ); EDN_INFO("patern : \"" << m_paternName << "\" level=" << m_level );
EDN_INFO(" ==> colorName \"" << m_colorName.c_str() << "\""); EDN_INFO(" ==> colorName \"" << m_colorName << "\"");
EDN_INFO(" ==> regExpStart \"" << m_regExpStart->GetRegExp().c_str() << "\""); EDN_INFO(" ==> regExpStart \"" << m_regExpStart->GetRegExp() << "\"");
EDN_INFO(" ==> regExpStop \"" << m_regExpStop->GetRegExp().c_str() << "\""); EDN_INFO(" ==> regExpStop \"" << m_regExpStop->GetRegExp() << "\"");
if (true == m_haveStopPatern) { if (true == m_haveStopPatern) {
EDN_INFO(" ==> stop pattern: YES"); EDN_INFO(" ==> stop pattern: YES");
} else { } else {
@@ -115,7 +122,7 @@ void HighlightPattern::Display(void)
*/ */
// Display all elements // Display all elements
for (int32_t i=0; i< m_subPatern.Size(); i++) { for (int32_t i=0; i< m_subPatern.Size(); i++) {
EDN_INFO(" " << i << " SubPattern : " << m_subPatern[i]->GetName().c_str() ); EDN_INFO(" " << i << " SubPattern : " << m_subPatern[i]->GetName() );
m_subPatern[i]->Display(); m_subPatern[i]->Display();
} }
} }
@@ -190,6 +197,19 @@ void HighlightPattern::ParseRules(TiXmlNode *child, int32_t level)
} }
} }
/**
* @brief Find Element only in the specify start characters and find the end with the range done
*
* @param[in] start First character to search data (if recognise it start here)
* @param[in] stop End of the possibility whe search can continue
* @param[out] resultat Position where find data
* @param[in] buffer : Where to search data
*
* @return HLP_FIND_OK We find a compleate pattern
* @return HLP_FIND_OK_NO_END Xe find a partial pattern (missing end)
* @return HLP_FIND_ERROR Not find the pattern
*/
resultFind_te HighlightPattern::Find(int32_t start, int32_t stop, colorInformation_ts &resultat, EdnVectorBuf &buffer) resultFind_te HighlightPattern::Find(int32_t start, int32_t stop, colorInformation_ts &resultat, EdnVectorBuf &buffer)
{ {
//EDN_DEBUG(" try to find the element"); //EDN_DEBUG(" try to find the element");
@@ -202,7 +222,7 @@ resultFind_te HighlightPattern::Find(int32_t start, int32_t stop, colorInformati
// when we have only one element : // when we have only one element :
if (false == m_haveStopPatern) { if (false == m_haveStopPatern) {
if (true == m_regExpStart->Process(buffer, start, stop)) { if (true == m_regExpStart->ProcessOneElement(buffer, start, stop)) {
resultat.beginStart = m_regExpStart->Start(); resultat.beginStart = m_regExpStart->Start();
resultat.beginStop = m_regExpStart->Stop(); resultat.beginStop = m_regExpStart->Stop();
resultat.endStart = m_regExpStart->Start(); resultat.endStart = m_regExpStart->Start();
@@ -212,7 +232,7 @@ resultFind_te HighlightPattern::Find(int32_t start, int32_t stop, colorInformati
//EDN_DEBUG("NOT find hightlightpatern ..."); //EDN_DEBUG("NOT find hightlightpatern ...");
} else { } else {
// try while we find the first element // try while we find the first element
if (true == m_regExpStart->Process(buffer, start, stop, m_escapeChar)) { if (true == m_regExpStart->ProcessOneElement(buffer, start, stop, m_escapeChar)) {
resultat.beginStart = m_regExpStart->Start(); resultat.beginStart = m_regExpStart->Start();
resultat.beginStop = m_regExpStart->Stop(); resultat.beginStop = m_regExpStart->Stop();
if (true == m_regExpStop->Process(buffer, resultat.beginStop, stop, m_escapeChar)) { if (true == m_regExpStop->Process(buffer, resultat.beginStop, stop, m_escapeChar)) {

View File

@@ -23,16 +23,19 @@
******************************************************************************* *******************************************************************************
*/ */
#include "Highlight.h"
#ifndef __HIGHLIGHT_PATTERN_H__ #ifndef __HIGHLIGHT_PATTERN_H__
#define __HIGHLIGHT_PATTERN_H__ #define __HIGHLIGHT_PATTERN_H__
class HighlightPattern; class HighlightPattern;
#include "Edn.h" #include "Edn.h"
#include "EdnRegExp.h" #include "RegExp.h"
#include "Colorize.h" #include "Colorize.h"
#include "EdnVectorBin.h" #include "VectorType.h"
#include "tinyxml.h" #include "tinyxml.h"
#include "EdnVectorBuf.h"
typedef enum { typedef enum {
HLP_FIND_ERROR, HLP_FIND_ERROR,
@@ -66,18 +69,20 @@ class HighlightPattern {
Colorize * GetColor(void) { return m_color; }; Colorize * GetColor(void) { return m_color; };
void ParseRules(TiXmlNode *child, int32_t level); void ParseRules(TiXmlNode *child, int32_t level);
void ReloadColor(void);
private: private:
int32_t m_level; //!< Level of the pattern ==> this is to overwrite next pattern when we create an higher .... int32_t m_level; //!< Level of the pattern ==> this is to overwrite next pattern when we create an higher ....
Edn::String m_paternName; //!< Current style name (like "c++" or "c" or "script Bash") Edn::String m_paternName; //!< Current style name (like "c++" or "c" or "script Bash")
Edn::String m_colorName; //!< Current color name Edn::String m_colorName; //!< Current color name
Colorize * m_color; //!< Link to the color manager Colorize * m_color; //!< Link to the color manager
EdnRegExp * m_regExpStart; //!< Start of Regular expression EdnRegExp<EdnVectorBuf> * m_regExpStart; //!< Start of Regular expression
EdnRegExp * m_regExpStop; //!< Stop of Regular Expression EdnRegExp<EdnVectorBuf> * m_regExpStop; //!< Stop of Regular Expression
bool m_haveStopPatern; //!< Stop patern presence bool m_haveStopPatern; //!< Stop patern presence
bool m_multiline; //!< The patern is multiline bool m_multiline; //!< The patern is multiline
char m_escapeChar; //!< Escape char to prevent exeit of patern .... char m_escapeChar; //!< Escape char to prevent exeit of patern ....
EdnVectorBin<HighlightPattern *> m_subPatern; //!< Under patern of this one Edn::VectorType<HighlightPattern *> m_subPatern; //!< Under patern of this one
// EdnVectorBin<HighlightPattern *> m_subColor; //!< Under Color in the start RegExp ... // Edn::VectorType<HighlightPattern *> m_subColor; //!< Under Color in the start RegExp ...
}; };
#endif #endif

View File

@@ -99,10 +99,8 @@ void CTagsManager::OnMessage(int32_t id, int32_t dataID)
{ {
GtkWidget *dialog = gtk_file_chooser_dialog_new( "Open Exuberant Ctags File", NULL, GtkWidget *dialog = gtk_file_chooser_dialog_new( "Open Exuberant Ctags File", NULL,
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, // button text GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_RESPONSE_CANCEL, // response id GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
GTK_STOCK_OPEN, // button text
GTK_RESPONSE_ACCEPT, // response id
NULL); // end button/response list NULL); // end button/response list
if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
{ {
@@ -121,7 +119,22 @@ void CTagsManager::OnMessage(int32_t id, int32_t dataID)
JumpTo(); JumpTo();
break; break;
case EDN_MSG__JUMP_BACK: case EDN_MSG__JUMP_BACK:
EDN_INFO("TODO .... jump back"); if (m_historyList.Size() > 0) {
BufferManager *myBufferManager = BufferManager::getInstance();
int32_t id = m_historyList.Size()-1;
if (false == myBufferManager->Exist(*m_historyList[id]) ) {
// need to open the file :
int32_t openID = myBufferManager->Open(*m_historyList[id]);
SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, openID);
} else {
SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, myBufferManager->GetId(*m_historyList[id]));
}
SendMessage(EDN_MSG__CURRENT_GOTO_LINE, m_historyList[id]->GetLineNumber());
// Remove element ....
delete(m_historyList[id]);
m_historyList[id]=NULL;
m_historyList.PopBack();
}
break; break;
} }
@@ -141,7 +154,7 @@ void CTagsManager::LoadTagFile(void)
return; return;
} }
// load (open) the tag file : // load (open) the tag file :
EDN_INFO("try to open tag file : " << m_tagFilename.c_str()); EDN_INFO("try to open tag file : " << m_tagFilename);
m_ctagFile = tagsOpen(m_tagFilename.c_str(), &info); m_ctagFile = tagsOpen(m_tagFilename.c_str(), &info);
if (NULL != m_ctagFile) { if (NULL != m_ctagFile) {
EDN_INFO("open exuberant Ctags file is OK ..."); EDN_INFO("open exuberant Ctags file is OK ...");
@@ -157,21 +170,192 @@ void CTagsManager::AddToHistory(int32_t bufferID)
for(int32_t iii= m_historyPos; iii < m_historyList.Size(); iii++) { for(int32_t iii= m_historyPos; iii < m_historyList.Size(); iii++) {
delete(m_historyList[iii]); delete(m_historyList[iii]);
} }
m_historyList.Erase(m_historyPos, m_historyList.Size() - m_historyPos); m_historyList.EraseLen(m_historyPos, m_historyList.Size() - m_historyPos);
} }
// add the current element // add the current element
BufferManager *myBufferManager = BufferManager::getInstance(); BufferManager *myBufferManager = BufferManager::getInstance();
Edn::String currentFilename = myBufferManager->Get(bufferID)->GetName(); Edn::File currentFilename = myBufferManager->Get(bufferID)->GetFileName();
int32_t currentLineId = 0; }
Edn::File * currentFile = new Edn::File(currentFilename);
enum
{
CTAGS_COL_FILE = 0,
CTAGS_COL_LINE_NUMBER,
CTAGS_NUM_COLS
};
void CTagsManager::cb_row(GtkTreeView *p_treeview,
GtkTreePath * p_path,
GtkTreeViewColumn * p_column,
gpointer data)
{
EDN_DEBUG("event");
CTagsManager * self = reinterpret_cast<CTagsManager*>(data);
gchar * p_file=NULL;
gint lineNumber;
GtkTreeIter iter;
if (gtk_tree_model_get_iter( GTK_TREE_MODEL(self->m_listStore), &iter, p_path))
{
gtk_tree_model_get( GTK_TREE_MODEL(self->m_listStore),
&iter,
CTAGS_COL_FILE, &p_file,
CTAGS_COL_LINE_NUMBER, &lineNumber,
-1 );
EDN_DEBUG("find : " << p_file << ":" << lineNumber);
for (int32_t iii = 0; iii < self->m_currentList.Size() ; iii++) {
if( self->m_currentList[iii].lineID == lineNumber
&& strcmp(self->m_currentList[iii].filename, p_file)==0)
{
g_object_unref( GTK_TREE_MODEL(self->m_listStore));
// Remove dialogue
gtk_widget_destroy(self->m_Dialog);
// Jump ...
self->JumpAtID(iii);
return;
}
}
}
}
GtkWidget * CTagsManager::CreateViewAndModel(void)
{
GtkCellRenderer * renderer;
GtkWidget * view;
view = gtk_tree_view_new();
// Column 1
renderer = gtk_cell_renderer_text_new();
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view),
-1,
"File",
renderer,
"text", CTAGS_COL_FILE,
NULL);
// Column 2
renderer = gtk_cell_renderer_text_new();
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view),
-1,
"lineNumber",
renderer,
"text", CTAGS_COL_LINE_NUMBER,
NULL);
// Set data in the list :
GtkTreeIter iter;
m_listStore = gtk_list_store_new(CTAGS_NUM_COLS, G_TYPE_STRING, G_TYPE_UINT);
// Append a row and fill in some data
for (int32_t iii=0; iii<m_currentList.Size() ; iii++) {
gtk_list_store_append(m_listStore, &iter);
gtk_list_store_set(m_listStore, &iter,
CTAGS_COL_FILE, m_currentList[iii].filename,
CTAGS_COL_LINE_NUMBER, m_currentList[iii].lineID,
-1);
}
gtk_tree_view_set_model( GTK_TREE_VIEW(view), GTK_TREE_MODEL(m_listStore) );
g_signal_connect( G_OBJECT(view), "row-activated", G_CALLBACK(cb_row), /*(gpointer)p_model*/ this );
//g_object_unref(GTK_TREE_MODEL(m_listStore));
return view;
}
int32_t CTagsManager::MultipleJump(void)
{
// dlg to confirm the quit event :
m_Dialog = gtk_dialog_new_with_buttons("C-Tags jump...",
NULL,
GTK_DIALOG_MODAL,
//"Jump", GTK_RESPONSE_YES,
GTK_STOCK_QUIT, GTK_RESPONSE_NO,
NULL);
// Set over main windows
//gtk_window_set_transient_for(GTK_WINDOW(myDialog), GTK_WINDOW(m_mainWindow->GetWidget()));
// add writting area
GtkWidget *myContentArea = gtk_dialog_get_content_area( GTK_DIALOG(m_Dialog));
GtkWidget *listView = CreateViewAndModel();
gtk_box_pack_start(GTK_BOX(myContentArea), listView, TRUE, TRUE, 0);
// Display it
gtk_widget_show_all(myContentArea);
int32_t result = gtk_dialog_run(GTK_DIALOG(m_Dialog));
// Get data from the gtk entry
if (result == GTK_RESPONSE_NO) {
g_object_unref(GTK_TREE_MODEL(m_listStore));
// Remove dialogue
gtk_widget_destroy(m_Dialog);
}
//GtkTreeIter *myIter;
//gtk_tree_selection_get_selected(selection, &model, myIter);
// Remove dialogue
//gtk_widget_destroy(myDialog);
return 0;
}
/*
void BufferView::OnCtagsEventList(GtkWidget *menuitem, gpointer data)
{
//BufferView * self = reinterpret_cast<BufferView*>(data);
//self->SendMessage(EDN_MSG__GUI_SHOW_SAVE_AS, self->m_contectMenuSelectID);
//self->m_contectMenuSelectID = -1;
}
*/
void CTagsManager::JumpAtID(int32_t selectID)
{
BufferManager *myBufferManager = BufferManager::getInstance();
Edn::File myFile = m_currentList[selectID].filename;
EDN_INFO("save curent filename and position : ");
int32_t currentSelected = myBufferManager->GetSelected();
Buffer* tmpBuf = myBufferManager->Get(currentSelected);
if (NULL != tmpBuf) {
Edn::File * bufferFilename = new Edn::File();
*bufferFilename = tmpBuf->GetFileName();
bufferFilename->SetLineNumber(tmpBuf->GetCurrentLine());
m_historyList.PushBack(bufferFilename);
}
EDN_INFO(" OPEN the TAG file Destination : " << myFile );
if (false == myBufferManager->Exist(myFile) ) {
// need to open the file :
int32_t openID = myBufferManager->Open(myFile);
SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, openID);
} else {
SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, myBufferManager->GetId(myFile));
}
/*
int32_t localId = myBufferManager->GetId(myFile);
Edn::String pattern = entry.address.pattern;
EDN_DEBUG("try to find line with : \"" << pattern << "\"" );
if (pattern.Size() > 4) {
pattern.Remove(0,2);
pattern.Remove(pattern.Size()-1,2);
}
// TODO : remove '\' char when needed ...
EDN_DEBUG("try to find line with : \"" << pattern << "\"" );
int32_t destLine = myBufferManager->Get(localId)->FindLine(pattern);
SendMessage(EDN_MSG__CURRENT_GOTO_LINE, destLine);
*/
SendMessage(EDN_MSG__CURRENT_GOTO_LINE, m_currentList[selectID].lineID - 1);
} }
void CTagsManager::JumpTo(void) void CTagsManager::JumpTo(void)
{ {
m_currentList.Clear();
if (NULL != m_ctagFile) { if (NULL != m_ctagFile) {
EdnVectorBin<int8_t> data; Edn::VectorType<int8_t> data;
// get the middle button of the clipboard ==> represent the current selection ... // get the middle button of the clipboard ==> represent the current selection ...
ClipBoard::Get(COPY_MIDDLE_BUTTON, data); ClipBoard::Get(COPY_MIDDLE_BUTTON, data);
if (data.Size() == 0) { if (data.Size() == 0) {
@@ -181,32 +365,37 @@ void CTagsManager::JumpTo(void)
data.PushBack('\0'); data.PushBack('\0');
EDN_INFO("try to find the tag : " << (const char *)&data[0]); EDN_INFO("try to find the tag : " << (const char *)&data[0]);
if (tagsFind (m_ctagFile, &entry, (const char *)&data[0], 0) == TagSuccess) { if (tagsFind (m_ctagFile, &entry, (const char *)&data[0], 0) == TagSuccess) {
//EDN_INFO("find the tag"); tagEntry entrySave = entry;
BufferManager *myBufferManager = BufferManager::getInstance(); int32_t numberOfTags = 0;
// For all tags : Save in an internal Structure :
do {
Edn::String destinationFilename = m_tagFolderBase; Edn::String destinationFilename = m_tagFolderBase;
destinationFilename += entry.file; destinationFilename += entry.file;
EDN_INFO(" OPEN the TAG file Destination : " << destinationFilename.c_str() ); Edn::File myfile = destinationFilename;
if (false == myBufferManager->Exist(destinationFilename) ) { TagListFind_ts myStruct;
// need to open the file : strncpy(myStruct.filename, myfile.GetCompleateName().c_str(), MAX_FILE_NAME);
int32_t openID = myBufferManager->Open(destinationFilename); myStruct.filename[MAX_FILE_NAME-1] = '\0';
SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, openID); strncpy(myStruct.RegExp, entry.address.pattern, MAX_REG_EXP_SEARCH);
myStruct.RegExp[MAX_REG_EXP_SEARCH-1] = '\0';
myStruct.lineID = entry.address.lineNumber;
// at at the corect position
m_currentList.PushBack(myStruct);
PrintTag(&entry, true);
} while (tagsFindNext (m_ctagFile, &entry) == TagSuccess);
if (1==m_currentList.Size() ) {
JumpAtID(0);
} else { } else {
SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, myBufferManager->GetId(destinationFilename)); // Open a choice windows...
int32_t SelectID = MultipleJump();
} }
int32_t localId = myBufferManager->GetId(destinationFilename);
Edn::String pattern = entry.address.pattern;
EDN_DEBUG("try to find line with : \"" << pattern.c_str() << "\"" );
if (pattern.Size() > 4) {
pattern.Remove(0,2);
pattern.Remove(pattern.Size()-1,2);
}
// TODO : remove '\' char when needed ...
EDN_DEBUG("try to find line with : \"" << pattern.c_str() << "\"" );
int32_t destLine = myBufferManager->Get(localId)->FindLine(pattern);
SendMessage(EDN_MSG__CURRENT_GOTO_LINE, destLine);
/* /*
// Display all the element :
do { do {
PrintTag (&entry); PrintTag(&entry, true);
} while (tagsFindNext (m_ctagFile, &entry) == TagSuccess); } while (tagsFindNext (m_ctagFile, &entry) == TagSuccess);
*/ */
} else { } else {
@@ -215,8 +404,12 @@ void CTagsManager::JumpTo(void)
} }
} }
void CTagsManager::PrintTag (const tagEntry *entry) void CTagsManager::PrintTag (const tagEntry *entry, bool small)
{ {
if (small==true) {
EDN_INFO("find Tag file : name=\"" << entry->name << "\" in file=\"" << entry->file
<< "\" at line="<< entry->address.lineNumber);
} else {
int i; int i;
EDN_INFO("find Tag file : name=\"" << entry->name << "\" in file=\"" << entry->file EDN_INFO("find Tag file : name=\"" << entry->name << "\" in file=\"" << entry->file
<< "\" pattern=\"" <<entry->address.pattern << "\" pattern=\"" <<entry->address.pattern
@@ -232,4 +425,5 @@ void CTagsManager::PrintTag (const tagEntry *entry)
for (i = 0 ; i < entry->fields.count ; ++i) { for (i = 0 ; i < entry->fields.count ; ++i) {
EDN_INFO(" " << entry->fields.list[i].key << ":" << entry->fields.list[i].value ); EDN_INFO(" " << entry->fields.list[i].key << ":" << entry->fields.list[i].value );
} }
}
} }

View File

@@ -32,6 +32,14 @@
#include "readtags.h" #include "readtags.h"
#include "Edn.h" #include "Edn.h"
#define MAX_REG_EXP_SEARCH (1024)
typedef struct{
char filename[MAX_FILE_NAME];
char RegExp[MAX_REG_EXP_SEARCH];
int32_t lineID;
} TagListFind_ts;
class CTagsManager: public Singleton<CTagsManager>, public MsgBroadcast class CTagsManager: public Singleton<CTagsManager>, public MsgBroadcast
{ {
@@ -47,8 +55,9 @@ class CTagsManager: public Singleton<CTagsManager>, public MsgBroadcast
private: private:
int32_t m_currentSelectedID; int32_t m_currentSelectedID;
void LoadTagFile(void); void LoadTagFile(void);
int32_t MultipleJump(void);
void JumpTo(void); void JumpTo(void);
void PrintTag(const tagEntry *entry); void PrintTag(const tagEntry *entry, bool small);
Edn::String GetFolder(Edn::String &inputString); Edn::String GetFolder(Edn::String &inputString);
Edn::String m_tagFolderBase; Edn::String m_tagFolderBase;
Edn::String m_tagFilename; Edn::String m_tagFilename;
@@ -56,7 +65,17 @@ class CTagsManager: public Singleton<CTagsManager>, public MsgBroadcast
// history system // history system
void AddToHistory(int32_t bufferID); void AddToHistory(int32_t bufferID);
int32_t m_historyPos; int32_t m_historyPos;
EdnVectorBin<Edn::File*> m_historyList; Edn::VectorType<Edn::File*> m_historyList;
Edn::VectorType<TagListFind_ts> m_currentList;
void JumpAtID(int32_t selectID);
GtkWidget * CreateViewAndModel(void);
static void cb_row (GtkTreeView *p_treeview,
GtkTreePath * p_path,
GtkTreeViewColumn * p_column,
gpointer p_data);
// save data in the list :
GtkListStore * m_listStore;
GtkWidget * m_Dialog;
}; };
#endif #endif

View File

@@ -66,8 +66,6 @@ int main (int argc, char *argv[])
ClipBoard::Init(); ClipBoard::Init();
Display::Init(); Display::Init();
//MainWindows *window = MainWindows::getInstance();
// init ALL Singleton : // init ALL Singleton :
(void)MsgBroadcastCore::getInstance(); (void)MsgBroadcastCore::getInstance();
@@ -80,13 +78,14 @@ int main (int argc, char *argv[])
ColorizeManager *myColorManager = NULL; ColorizeManager *myColorManager = NULL;
myColorManager = ColorizeManager::getInstance(); myColorManager = ColorizeManager::getInstance();
Edn::String homedir; Edn::String homedir;
//homedir = getenv("HOME");
#ifdef NDEBUG #ifdef NDEBUG
homedir = getenv("HOME"); homedir = "/usr/share/edn/";
homedir += "/.edn/";
#else #else
homedir = "./"; homedir = "./data/";
#endif #endif
homedir += "data/color_black.xml"; //homedir += "color_black.xml";
homedir += "color_white.xml";
myColorManager->LoadFile( homedir.c_str() ); myColorManager->LoadFile( homedir.c_str() );
myColorManager->DisplayListOfColor(); myColorManager->DisplayListOfColor();
@@ -110,13 +109,8 @@ int main (int argc, char *argv[])
EDN_INFO("show list of files : "); EDN_INFO("show list of files : ");
for( int32_t i=1 ; i<argc; i++) { for( int32_t i=1 ; i<argc; i++) {
EDN_INFO("need load file : \"" << argv[i] << "\"" ); EDN_INFO("need load file : \"" << argv[i] << "\"" );
Edn::String myfile = ""; Edn::File myfile = (char *)argv[i];
// Special case for the root file origin
if ('/' != argv[i][0]) {
myfile+=cCurrentPath;
myfile+="/";
}
myfile+=(char *)argv[i];
if (false == myBufferManager->Exist(myfile) ) { if (false == myBufferManager->Exist(myfile) ) {
int32_t idBuffOpened = myBufferManager->Open(myfile); int32_t idBuffOpened = myBufferManager->Open(myfile);
if (1==i) { if (1==i) {

View File

@@ -1,179 +0,0 @@
/**
*******************************************************************************
* @file AL_Mutex.c
* @brief Editeur De N'ours : Abstraction Layer Mutex
* @author Edouard DUPIN
* @date 04/12/2010
* @par Project
* Edn
*
* @par Copyright
* Copyright 2010 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
* You can not earn money with this Software (if the source extract from Edn
* represent less than 50% of original Sources)
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include "tools_debug.h"
#include "AL_Mutex.h"
// /usr/include/pthread.h
/**
* @brief initialize the curent Mutex
*
* @param[in,out] pointerMutex Pointer on the mutex that might be init
* @param[in] recursive Enable the possibility that one thread can lock multiple time the same Mutex
*
* @return an standard Error Code (ERR_NONE / ERR_FAIL)
*
*/
erreurCode_te AL_mutex_init(AL_MUTEX * pointerMutex,bool recursive)
{
int systemRet;
pthread_mutexattr_t mutexattr;
erreurCode_te myError= ERR_NONE;
EDN_CHECK_INOUT(pointerMutex);
// init mutex attributes
systemRet = pthread_mutexattr_init(&mutexattr);
if (0 == systemRet) {
if (true == recursive) {
systemRet = pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_RECURSIVE_NP);
EDN_ASSERT(!systemRet, "pthread_mutexattr_settype Error");
}
else {
systemRet = pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_ERRORCHECK_NP);
EDN_ASSERT(!systemRet, "pthread_mutexattr_settype Error");
}
}
if (0 == systemRet) {
systemRet = pthread_mutex_init(pointerMutex, &mutexattr);
EDN_ASSERT(!systemRet, "pthread_mutex_init Error Mutex Init");
if (systemRet) {
myError = ERR_FAIL;
}
}
systemRet = pthread_mutexattr_destroy(&mutexattr);
EDN_ASSERT(0 == systemRet, "pthread_mutexattr_destroy Error");
return myError;
}
/**
* @brief Destroy the current Mutex
*
* @param[in,out] pointerMutex Pointer on the mutex that might be init
*
* @return an standard Error Code (ERR_NONE / ERR_FAIL)
*
*/
erreurCode_te AL_mutex_destroy(AL_MUTEX * pointerMutex)
{
int systemRet;
EDN_CHECK_INOUT(pointerMutex);
systemRet = pthread_mutex_destroy(pointerMutex);
EDN_ASSERT(!systemRet, "pthread_mutex_destroy Error Mutex Destroy");
if (systemRet) {
return ERR_FAIL;
}
return ERR_NONE;
}
/**
* @brief Lock the curent Mutex. Lock call
*
* @param[in,out] pointerMutex Pointer on the mutex that might be init
*
* @return ---
*
*/
void AL_mutex_lock(AL_MUTEX * pointerMutex)
{
int systemRet;
EDN_CHECK_INOUT(pointerMutex);
systemRet = pthread_mutex_lock(pointerMutex);
EDN_ASSERT(!systemRet, "pthread_mutex_lock Error Mutex lock");
}
/**
* @brief Unlock the current Mutex
*
* @param[in,out] pointerMutex Pointer on the mutex that might be init
*
* @return ---
*
*/
void AL_mutex_unlock(AL_MUTEX * pointerMutex)
{
int systemRet;
EDN_CHECK_INOUT(pointerMutex);
systemRet = pthread_mutex_unlock(pointerMutex);
EDN_ASSERT(!systemRet, "pthread_mutex_unlock Error Mutex unlock");
}
/**
* @brief Try the lock of the curent Mutex
*
* @param[in,out] pointerMutex Pointer on the mutex that might be init
*
* @return an standard Error Code (ERR_NONE / ERR_BUSY)
*
*/
erreurCode_te AL_mutex_trylock(AL_MUTEX * pointerMutex)
{
int systemRet;
EDN_CHECK_INOUT(pointerMutex);
systemRet = pthread_mutex_trylock(pointerMutex);
EDN_ASSERT(0==systemRet || EBUSY==systemRet, "pthread_mutex_trylock Error Mutex unlock");
if (EBUSY==systemRet) {
return ERR_BUSY;
}
return ERR_NONE;
}
/**
* @brief try lock in a periode of time
*
* @param[in,out] pointerMutex Pointer on the mutex that might be init
*
* @return an standard Error Code (ERR_NONE / ERR_TIMEOUT)
*
*/
erreurCode_te AL_mutex_timedlock(AL_MUTEX * pointerMutex, int32_t delay)
{
/*
int systemRet;
EDN_CHECK_INOUT(pointerMutex);
if (0 == delay) {
return ERR_NONE;
}
// TODO ... check is it OK...
systemRet = pthread_mutex_timedlock(pointerMutex, delay);
EDN_ASSERT(0 == systemRet || ETIMEDOUT == systemRet, "pthread_mutex_timedlock Error");
if (ETIMEDOUT == systemRet) {
return ERR_TIMEOUT;
}
*/
return ERR_NONE;
}

View File

@@ -35,7 +35,7 @@ note: la copy dans le :
[1..9] : copy interne [1..9] : copy interne
10 : bouton du milieux 10 : bouton du milieux
*/ */
static EdnVectorBin<int8_t> mesCopy[TOTAL_OF_CLICKBOARD]; static Edn::VectorType<int8_t> mesCopy[TOTAL_OF_CLICKBOARD];
void ClipBoard::Init(void) void ClipBoard::Init(void)
@@ -47,13 +47,13 @@ void ClipBoard::Init(void)
} }
void ClipBoard::Set(uint8_t clipboardID, EdnVectorBin<int8_t> &data) void ClipBoard::Set(uint8_t clipboardID, Edn::VectorType<int8_t> &data)
{ {
// check if ID is correct // check if ID is correct
if(clipboardID >= TOTAL_OF_CLICKBOARD) { if(clipboardID >= TOTAL_OF_CLICKBOARD) {
EDN_WARNING("request ClickBoard id error"); EDN_WARNING("request ClickBoard id error");
} else if(0 == data.Size()) { } else if(0 == data.Size()) {
EDN_WARNING("request a copy of nothing"); EDN_INFO("request a copy of nothing");
} else if (COPY_STD == clipboardID) { } else if (COPY_STD == clipboardID) {
GtkClipboard * clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); GtkClipboard * clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
gtk_clipboard_set_text(clipboard, (const gchar*)&data[0], data.Size() ); gtk_clipboard_set_text(clipboard, (const gchar*)&data[0], data.Size() );
@@ -66,7 +66,7 @@ void ClipBoard::Set(uint8_t clipboardID, EdnVectorBin<int8_t> &data)
} }
void ClipBoard::Get(uint8_t clipboardID, EdnVectorBin<int8_t> &data) void ClipBoard::Get(uint8_t clipboardID, Edn::VectorType<int8_t> &data)
{ {
if(clipboardID >= TOTAL_OF_CLICKBOARD) { if(clipboardID >= TOTAL_OF_CLICKBOARD) {
EDN_WARNING("request ClickBoard id error"); EDN_WARNING("request ClickBoard id error");

View File

@@ -27,7 +27,7 @@
#define __CLIP_BOARD_H__ #define __CLIP_BOARD_H__
#include "tools_debug.h" #include "tools_debug.h"
#include "EdnVectorBin.h" #include "VectorType.h"
#define TOTAL_OF_CLICKBOARD (11) #define TOTAL_OF_CLICKBOARD (11)
#define COPY_MIDDLE_BUTTON (10) #define COPY_MIDDLE_BUTTON (10)
@@ -36,8 +36,8 @@
namespace ClipBoard namespace ClipBoard
{ {
void Init(void); void Init(void);
void Set(uint8_t clipboardID, EdnVectorBin<int8_t> &data); void Set(uint8_t clipboardID, Edn::VectorType<int8_t> &data);
void Get(uint8_t clipboardID, EdnVectorBin<int8_t> &data); void Get(uint8_t clipboardID, Edn::VectorType<int8_t> &data);
} }
#endif #endif

View File

@@ -61,13 +61,6 @@ static cairo_font_face_t * m_cairoFont[2][2] = {{NULL, NULL},{ NULL, NULL}};
static cairo_font_face_t * m_cairoFont[2][2] = {{NULL, NULL},{ NULL, NULL}}; static cairo_font_face_t * m_cairoFont[2][2] = {{NULL, NULL},{ NULL, NULL}};
void Display::Init(void) void Display::Init(void)
{ {
/*
charWidth = gdk_char_width(myFont[FONT_ITALIC_YES][FONT_BOLD_NO], 'Z');
EDN_INFO("Font Width = %d", charWidth);
charHeignt = gdk_char_height(myFont[FONT_ITALIC_YES][FONT_BOLD_NO], 'Z');
EDN_INFO("Font Height = %d", charHeignt);
*/
m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_NO] = cairo_toy_font_face_create(POLICE_NAME, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_NO] = cairo_toy_font_face_create(POLICE_NAME, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_NO] = cairo_toy_font_face_create(POLICE_NAME, CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_NORMAL); m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_NO] = cairo_toy_font_face_create(POLICE_NAME, CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_NORMAL);
m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_YES] = cairo_toy_font_face_create(POLICE_NAME, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_YES] = cairo_toy_font_face_create(POLICE_NAME, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
@@ -96,10 +89,10 @@ void Display::Init(void)
void Display::UnInit(void) void Display::UnInit(void)
{ {
// clean the builder... // clean the builder...
free(m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_NO]); cairo_font_face_destroy(m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_NO]);
free(m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_NO]); cairo_font_face_destroy(m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_NO]);
free(m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_YES]); cairo_font_face_destroy(m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_YES]);
free(m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_YES]); cairo_font_face_destroy(m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_YES]);
} }
@@ -166,6 +159,19 @@ DrawerManager::DrawerManager(GtkWidget * widget, int32_t x, int32_t y)
cairo_scale(m_cairo, 1.0, 1.0); cairo_scale(m_cairo, 1.0, 1.0);
m_nbElement = 0;
// http://cairographics.org/FAQ/#clear_a_surface
// http://gtk.developpez.com/faq/?page=gtkwidget#GTK_WIDGET_transparent
//cairo_set_source_rgba(m_cairo, 1, 1, 1, 0);
//cairo_set_operator(m_cairo, CAIRO_OPERATOR_SOURCE);
//cairo_paint(m_cairo);
//cairo_fill(m_cairo);
//cairo_stroke (m_cairo);
} }
@@ -235,7 +241,6 @@ void DrawerManager::Text(color_ts & SelectColorFg, color_ts & SelectColorBg, int
cairo_set_font_face(m_cairo, Display::GetFont(false, false)); cairo_set_font_face(m_cairo, Display::GetFont(false, false));
int32_t letterHeight = Display::GetFontHeight(); int32_t letterHeight = Display::GetFontHeight();
int32_t letterWidth = Display::GetFontWidth(); int32_t letterWidth = Display::GetFontWidth();
int32_t stringLen = strUtf8Len(myText);
DirectRectangle(SelectColorBg, x, y, letterWidth*strlen(myText), letterHeight); DirectRectangle(SelectColorBg, x, y, letterWidth*strlen(myText), letterHeight);
cairo_fill(m_cairo); cairo_fill(m_cairo);
cairo_move_to(m_cairo, x, y+letterHeight-4); cairo_move_to(m_cairo, x, y+letterHeight-4);
@@ -279,16 +284,15 @@ void DrawerManager::SpaceText(color_ts & SelectColor, int32_t x, int32_t y,int32
void DrawerManager::Flush(void) void DrawerManager::Flush(void)
{ {
if (true == m_haveWork) { if (true == m_haveWork) {
//EDN_WARNING("flush : \"" << m_dataToDisplay << "\""); //EDN_WARNING("flush : \"" << m_dataToDisplay << "\"" << " bold=" << m_selectColor->GetBold() << " italic=" << m_selectColor->GetItalic());
m_haveWork = false; m_haveWork = false;
cairo_set_font_face(m_cairo, Display::GetFont(m_selectColor->GetBold(), m_selectColor->GetItalic())); cairo_set_font_face(m_cairo, Display::GetFont(m_selectColor->GetBold(), m_selectColor->GetItalic()));
int32_t letterHeight = Display::GetFontHeight(); int32_t letterHeight = Display::GetFontHeight();
if (true == m_selectColor->HaveBg() ) { if (true == m_selectColor->HaveBg() ) {
int32_t letterWidth = Display::GetFontWidth(); int32_t letterWidth = Display::GetFontWidth();
int32_t stringLen = m_nbElement;
// generate Clean BG: // generate Clean BG:
DirectRectangle(m_selectColor, m_pos.x, m_pos.y, letterWidth*stringLen, letterHeight); DirectRectangle(m_selectColor, m_pos.x, m_pos.y, letterWidth*m_nbElement, letterHeight);
} }
cairo_move_to(m_cairo, m_pos.x, m_pos.y+letterHeight-4); cairo_move_to(m_cairo, m_pos.x, m_pos.y+letterHeight-4);
m_selectColor->ApplyFG(m_cairo); m_selectColor->ApplyFG(m_cairo);
@@ -347,9 +351,10 @@ void DrawerManager::DirectRectangle(Colorize *SelectColor, int32_t x, int32_t y,
// flush // flush
cairo_fill(m_cairo); cairo_fill(m_cairo);
} }
void DrawerManager::DirectRectangle(color_ts &SelectColor, int32_t x, int32_t y, int32_t width, int32_t height) void DrawerManager::DirectRectangle(color_ts &SelectColor, int32_t x, int32_t y, int32_t width, int32_t height)
{ {
cairo_set_source_rgb(m_cairo, SelectColor.red, SelectColor.green, SelectColor.blue); cairo_set_source_rgb(m_cairo, SelectColor.red, SelectColor.green, SelectColor.blue);
// set postion // set postion
cairo_rectangle(m_cairo, x, y, width, height); cairo_rectangle(m_cairo, x, y, width, height);

View File

@@ -26,11 +26,9 @@
#ifndef __TOOLS_DISPLAY_H__ #ifndef __TOOLS_DISPLAY_H__
#define __TOOLS_DISPLAY_H__ #define __TOOLS_DISPLAY_H__
#include "tools_debug.h" #include "tools_debug.h"
#include "Colorize.h" #include "Colorize.h"
#include "ColorizeManager.h" #include "ColorizeManager.h"
#include <string>
#include <vector>
/** /**

View File

@@ -126,7 +126,7 @@ bool EdnBuf::DumpFrom(FILE *myFile)
} }
void EdnBuf::GetAll(EdnVectorBin<int8_t> &text) void EdnBuf::GetAll(Edn::VectorType<int8_t> &text)
{ {
// Clean output vector // Clean output vector
text.Clear(); text.Clear();
@@ -135,9 +135,9 @@ void EdnBuf::GetAll(EdnVectorBin<int8_t> &text)
} }
void EdnBuf::SetAll(EdnVectorBin<int8_t> &text) void EdnBuf::SetAll(Edn::VectorType<int8_t> &text)
{ {
EdnVectorBin<int8_t> deletedText; Edn::VectorType<int8_t> deletedText;
// extract all data of the buffer : // extract all data of the buffer :
GetAll(deletedText); GetAll(deletedText);
@@ -155,7 +155,7 @@ void EdnBuf::SetAll(EdnVectorBin<int8_t> &text)
eventModification(0, m_data.Size(), deletedText); eventModification(0, m_data.Size(), deletedText);
} }
void EdnBuf::GetRange(int32_t start, int32_t end, EdnVectorBin<int8_t> &output) void EdnBuf::GetRange(int32_t start, int32_t end, Edn::VectorType<int8_t> &output)
{ {
// Remove all data ... // Remove all data ...
output.Clear(); output.Clear();
@@ -189,7 +189,7 @@ int8_t EdnBuf::operator[] (int32_t pos)
* @return --- * @return ---
* *
*/ */
void EdnBuf::Insert(int32_t pos, EdnVectorBin<int8_t> &insertText) void EdnBuf::Insert(int32_t pos, Edn::VectorType<int8_t> &insertText)
{ {
// if pos is not contiguous to existing text, make it // if pos is not contiguous to existing text, make it
pos = edn_average(0, pos, m_data.Size() ); pos = edn_average(0, pos, m_data.Size() );
@@ -197,7 +197,7 @@ void EdnBuf::Insert(int32_t pos, EdnVectorBin<int8_t> &insertText)
insert(pos, insertText); insert(pos, insertText);
// Call the redisplay ... // Call the redisplay ...
EdnVectorBin<int8_t> deletedText; Edn::VectorType<int8_t> deletedText;
eventModification(pos, insertText.Size(), deletedText); eventModification(pos, insertText.Size(), deletedText);
} }
@@ -212,9 +212,9 @@ void EdnBuf::Insert(int32_t pos, EdnVectorBin<int8_t> &insertText)
* @return --- * @return ---
* *
*/ */
void EdnBuf::Replace(int32_t start, int32_t end, EdnVectorBin<int8_t> &insertText) void EdnBuf::Replace(int32_t start, int32_t end, Edn::VectorType<int8_t> &insertText)
{ {
EdnVectorBin<int8_t> deletedText; Edn::VectorType<int8_t> deletedText;
GetRange(start, end, deletedText); GetRange(start, end, deletedText);
m_data.Replace(start, end-start, insertText); m_data.Replace(start, end-start, insertText);
// update internal elements // update internal elements
@@ -234,7 +234,7 @@ void EdnBuf::Replace(int32_t start, int32_t end, EdnVectorBin<int8_t> &insertTex
void EdnBuf::Remove(int32_t start, int32_t end) void EdnBuf::Remove(int32_t start, int32_t end)
{ {
EdnVectorBin<int8_t> deletedText; Edn::VectorType<int8_t> deletedText;
// Make sure the arguments make sense // Make sure the arguments make sense
if (start > end) { if (start > end) {
int32_t temp = start; int32_t temp = start;
@@ -265,7 +265,7 @@ int32_t EdnBuf::Indent(selectionType_te select)
// Get Range : // Get Range :
int32_t l_start = StartOfLine(SelectionStart); int32_t l_start = StartOfLine(SelectionStart);
int32_t l_end = EndOfLine(SelectionEnd); int32_t l_end = EndOfLine(SelectionEnd);
EdnVectorBin<int8_t> l_tmpData; Edn::VectorType<int8_t> l_tmpData;
GetRange(l_start, l_end, l_tmpData); GetRange(l_start, l_end, l_tmpData);
l_tmpData.Insert(0, '\n'); l_tmpData.Insert(0, '\n');
@@ -304,7 +304,7 @@ int32_t EdnBuf::UnIndent(selectionType_te select)
// Get Range : // Get Range :
int32_t l_start = StartOfLine(SelectionStart); int32_t l_start = StartOfLine(SelectionStart);
int32_t l_end = EndOfLine(SelectionEnd); int32_t l_end = EndOfLine(SelectionEnd);
EdnVectorBin<int8_t> l_tmpData; Edn::VectorType<int8_t> l_tmpData;
GetRange(l_start, l_end, l_tmpData); GetRange(l_start, l_end, l_tmpData);
l_tmpData.Insert(0, '\n'); l_tmpData.Insert(0, '\n');
@@ -346,7 +346,7 @@ int32_t EdnBuf::UnIndent(selectionType_te select)
* @return --- * @return ---
* *
*/ */
void EdnBuf::GetLineText(int32_t pos, EdnVectorBin<int8_t> &text) void EdnBuf::GetLineText(int32_t pos, Edn::VectorType<int8_t> &text)
{ {
GetRange( StartOfLine(pos), EndOfLine(pos), text); GetRange( StartOfLine(pos), EndOfLine(pos), text);
} }
@@ -666,9 +666,9 @@ int32_t EdnBuf::CountLines(int32_t startPos, int32_t endPos)
* @return number of line found * @return number of line found
* *
*/ */
int32_t EdnBuf::CountLines(EdnVectorBin<int8_t> &data) int32_t EdnBuf::CountLines(Edn::VectorType<int8_t> &data)
{ {
EdnVectorBin<int8_t>::Iterator myPosIt = data.Begin(); Edn::VectorType<int8_t>::Iterator myPosIt = data.Begin();
int32_t lineCount = 0; int32_t lineCount = 0;
while(myPosIt) { while(myPosIt) {
@@ -810,7 +810,7 @@ bool EdnBuf::charMatch(char first, char second, bool caseSensitive)
* @return false ==> not found data * @return false ==> not found data
* *
*/ */
bool EdnBuf::SearchForward(int32_t startPos, EdnVectorBin<int8_t> &searchVect, int32_t *foundPos, bool caseSensitive) bool EdnBuf::SearchForward(int32_t startPos, Edn::VectorType<int8_t> &searchVect, int32_t *foundPos, bool caseSensitive)
{ {
int32_t position; int32_t position;
int32_t searchLen = searchVect.Size(); int32_t searchLen = searchVect.Size();
@@ -851,7 +851,7 @@ bool EdnBuf::SearchForward(int32_t startPos, EdnVectorBin<int8_t> &searchVect, i
* @return false ==> not found data * @return false ==> not found data
* *
*/ */
bool EdnBuf::SearchBackward(int32_t startPos, EdnVectorBin<int8_t> &searchVect, int32_t *foundPos, bool caseSensitive) bool EdnBuf::SearchBackward(int32_t startPos, Edn::VectorType<int8_t> &searchVect, int32_t *foundPos, bool caseSensitive)
{ {
int32_t position; int32_t position;
int32_t searchLen = searchVect.Size(); int32_t searchLen = searchVect.Size();
@@ -977,7 +977,7 @@ bool EdnBuf::SelectAround(int32_t startPos, int32_t &beginPos, int32_t &endPos)
* @return number of element inserted. * @return number of element inserted.
* *
*/ */
int32_t EdnBuf::insert(int32_t pos, EdnVectorBin<int8_t> &insertText) int32_t EdnBuf::insert(int32_t pos, Edn::VectorType<int8_t> &insertText)
{ {
// Insert data in buffer // Insert data in buffer
m_data.Insert(pos, insertText); m_data.Insert(pos, insertText);
@@ -998,7 +998,7 @@ int32_t EdnBuf::insert(int32_t pos, EdnVectorBin<int8_t> &insertText)
* @return --- * @return ---
* *
*/ */
void EdnBuf::eventModification(int32_t pos, int32_t nInserted, EdnVectorBin<int8_t> &deletedText) void EdnBuf::eventModification(int32_t pos, int32_t nInserted, Edn::VectorType<int8_t> &deletedText)
{ {
if( 0 == deletedText.Size() if( 0 == deletedText.Size()
&& 0 == nInserted) && 0 == nInserted)

View File

@@ -67,7 +67,7 @@ typedef enum{
typedef struct { typedef struct {
std::vector<colorInformation_ts> HLData; Edn::VectorType<colorInformation_ts> HLData;
int32_t idSequence; int32_t idSequence;
int32_t posHLPass1; int32_t posHLPass1;
int32_t posHLPass2; int32_t posHLPass2;
@@ -82,21 +82,21 @@ class EdnBuf {
// destructer // destructer
~EdnBuf(void); ~EdnBuf(void);
// public function : // public function :
void GetAll( EdnVectorBin<int8_t> &text); void GetAll( Edn::VectorType<int8_t> &text);
void SetAll( EdnVectorBin<int8_t> &text); void SetAll( Edn::VectorType<int8_t> &text);
void GetRange( int32_t start, int32_t end, EdnVectorBin<int8_t> &output); void GetRange( int32_t start, int32_t end, Edn::VectorType<int8_t> &output);
bool DumpIn( FILE *myFile); bool DumpIn( FILE *myFile);
bool DumpFrom( FILE *myFile); bool DumpFrom( FILE *myFile);
// replace with operator [] ... // replace with operator [] ...
int8_t operator[] (int32_t); int8_t operator[] (int32_t);
void Insert( int32_t pos, EdnVectorBin<int8_t> &insertText); void Insert( int32_t pos, Edn::VectorType<int8_t> &insertText);
void Replace( int32_t start, int32_t end, EdnVectorBin<int8_t> &insertText); void Replace( int32_t start, int32_t end, Edn::VectorType<int8_t> &insertText);
void Remove( int32_t start, int32_t end); void Remove( int32_t start, int32_t end);
int32_t Indent( selectionType_te select); int32_t Indent( selectionType_te select);
int32_t UnIndent( selectionType_te select); int32_t UnIndent( selectionType_te select);
void GetLineText( int32_t pos, EdnVectorBin<int8_t> &text); void GetLineText( int32_t pos, Edn::VectorType<int8_t> &text);
int32_t StartOfLine( int32_t pos); int32_t StartOfLine( int32_t pos);
int32_t EndOfLine( int32_t pos); int32_t EndOfLine( int32_t pos);
@@ -107,12 +107,12 @@ class EdnBuf {
int32_t CountForwardDispChars( int32_t lineStartPos, int32_t nChars); int32_t CountForwardDispChars( int32_t lineStartPos, int32_t nChars);
int32_t CountLines( int32_t startPos, int32_t endPos); int32_t CountLines( int32_t startPos, int32_t endPos);
int32_t CountLines( void); int32_t CountLines( void);
int32_t CountLines( EdnVectorBin<int8_t> &data); int32_t CountLines( Edn::VectorType<int8_t> &data);
int32_t CountForwardNLines( int32_t startPos, int32_t nLines); int32_t CountForwardNLines( int32_t startPos, int32_t nLines);
int32_t CountBackwardNLines( int32_t startPos, int32_t nLines); int32_t CountBackwardNLines( int32_t startPos, int32_t nLines);
bool SearchForward( int32_t startPos, EdnVectorBin<int8_t> &searchVect, int32_t *foundPos, bool caseSensitive = true); bool SearchForward( int32_t startPos, Edn::VectorType<int8_t> &searchVect, int32_t *foundPos, bool caseSensitive = true);
bool SearchBackward( int32_t startPos, EdnVectorBin<int8_t> &searchVect, int32_t *foundPos, bool caseSensitive = true); bool SearchBackward( int32_t startPos, Edn::VectorType<int8_t> &searchVect, int32_t *foundPos, bool caseSensitive = true);
bool SearchForward( int32_t startPos, char searchChar, int32_t *foundPos); bool SearchForward( int32_t startPos, char searchChar, int32_t *foundPos);
bool SearchBackward( 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); bool SelectAround( int32_t startPos, int32_t &beginPos, int32_t &endPos);
@@ -130,9 +130,9 @@ class EdnBuf {
void Unselect( selectionType_te select); void Unselect( selectionType_te select);
void RectSelect( selectionType_te select, int32_t start, int32_t end, int32_t rectStart, int32_t rectEnd); void RectSelect( selectionType_te select, int32_t start, int32_t end, int32_t rectStart, int32_t rectEnd);
bool GetSelectionPos( selectionType_te select, int32_t &start, int32_t &end, bool &isRect, int32_t &rectStart, int32_t &rectEnd); bool GetSelectionPos( selectionType_te select, int32_t &start, int32_t &end, bool &isRect, int32_t &rectStart, int32_t &rectEnd);
void GetSelectionText( selectionType_te select, EdnVectorBin<int8_t> &text); void GetSelectionText( selectionType_te select, Edn::VectorType<int8_t> &text);
void RemoveSelected( selectionType_te select); void RemoveSelected( selectionType_te select);
void ReplaceSelected( selectionType_te select, EdnVectorBin<int8_t> &text); void ReplaceSelected( selectionType_te select, Edn::VectorType<int8_t> &text);
private: private:
// current selection of the buffer // current selection of the buffer
selection m_selectionList[SELECTION_SIZE]; //!< Selection area of the buffer selection m_selectionList[SELECTION_SIZE]; //!< Selection area of the buffer
@@ -143,20 +143,20 @@ class EdnBuf {
// History section : // History section :
// ----------------------------------------- // -----------------------------------------
public: public:
int32_t Undo( void); int32_t Undo(void);
int32_t Redo( void); int32_t Redo(void);
private: private:
bool m_isUndoProcessing; bool m_isUndoProcessing;
bool m_isRedoProcessing; bool m_isRedoProcessing;
EdnVectorBin<EdnBufHistory*> m_historyUndo; Edn::VectorType<EdnBufHistory*> m_historyUndo;
EdnVectorBin<EdnBufHistory*> m_historyRedo; Edn::VectorType<EdnBufHistory*> m_historyRedo;
// ----------------------------------------- // -----------------------------------------
// hightlight section : // hightlight section :
// ----------------------------------------- // -----------------------------------------
private: private:
Highlight * m_Highlight; //!< internal link with the Highlight system Highlight * m_Highlight; //!< internal link with the Highlight system
std::vector<colorInformation_ts> m_HLDataPass1; //!< colorisation position in the current buffer pass 1 Edn::VectorType<colorInformation_ts> m_HLDataPass1; //!< colorisation position in the current buffer pass 1
int32_t m_HLDataSequence; //!< position of the start of line requested by the screen viewer int32_t m_HLDataSequence; //!< position of the start of line requested by the screen viewer
void RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdded); void RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdded);
void GenerateHighLightAt(int32_t pos, int32_t endPos, int32_t addinPos=0); void GenerateHighLightAt(int32_t pos, int32_t endPos, int32_t addinPos=0);
@@ -164,7 +164,8 @@ class EdnBuf {
void FindMainHighLightPosition(int32_t startPos, int32_t endPos, int32_t &startId, int32_t &stopId, bool backPreviousNotEnded); void FindMainHighLightPosition(int32_t startPos, int32_t endPos, int32_t &startId, int32_t &stopId, bool backPreviousNotEnded);
public: public:
void SetHLSystem( Highlight * newHLSystem); void SetHLSystem( Highlight * newHLSystem);
void HightlightGenerateLines(displayHLData_ts & MData, int32_t startPos, int32_t nbLines); void HightlightOneLine(displayHLData_ts & MData, int32_t HLStart, int32_t HLStop);
void HightlightGenerateLines(displayHLData_ts & MData, int32_t startPos, int32_t nbLines); // TODO : deprecated ...
colorInformation_ts * GetElementColorAtPosition(displayHLData_ts & MData, int32_t pos); colorInformation_ts * GetElementColorAtPosition(displayHLData_ts & MData, int32_t pos);
private: private:
colorInformation_ts * GetElementColorAtPosition(int32_t pos, int32_t &starPos); colorInformation_ts * GetElementColorAtPosition(int32_t pos, int32_t &starPos);
@@ -197,14 +198,14 @@ class EdnBuf {
// ----------------------------------------- // -----------------------------------------
private: private:
void findRectSelBoundariesForCopy( int32_t lineStartPos, int32_t rectStart, int32_t rectEnd, int32_t *selStart, int32_t *selEnd); void findRectSelBoundariesForCopy( int32_t lineStartPos, int32_t rectStart, int32_t rectEnd, int32_t *selStart, int32_t *selEnd);
char *getSelectionText( selection &sel); char * getSelectionText( selection &sel);
void removeSelected( selection &sel); void removeSelected( selection &sel);
void replaceSelected( selection &sel, const char *text); void replaceSelected( selection &sel, const char *text);
void eventModification( int32_t pos, int32_t nInserted, EdnVectorBin<int8_t> &deletedText); void eventModification( int32_t pos, int32_t nInserted, Edn::VectorType<int8_t> &deletedText);
int32_t insert( int32_t pos, EdnVectorBin<int8_t> &insertText); int32_t insert( int32_t pos, Edn::VectorType<int8_t> &insertText);
bool charMatch( char first, char second, bool caseSensitive = true); bool charMatch( char first, char second, bool caseSensitive = true);
}; };

View File

@@ -39,7 +39,7 @@ EdnBufHistory::EdnBufHistory(void)
m_nInserted = 0; m_nInserted = 0;
} }
EdnBufHistory::EdnBufHistory(int32_t pos, int32_t nInserted, EdnVectorBin<int8_t> &deletedText) EdnBufHistory::EdnBufHistory(int32_t pos, int32_t nInserted, Edn::VectorType<int8_t> &deletedText)
{ {
//EDN_INFO("EdnBufHistory new + data"); //EDN_INFO("EdnBufHistory new + data");
m_pos = pos; m_pos = pos;
@@ -47,7 +47,7 @@ EdnBufHistory::EdnBufHistory(int32_t pos, int32_t nInserted, EdnVectorBin<int8_t
m_deletedText = deletedText; m_deletedText = deletedText;
} }
void EdnBufHistory::Set(int32_t pos, int32_t nInserted, EdnVectorBin<int8_t> &deletedText) void EdnBufHistory::Set(int32_t pos, int32_t nInserted, Edn::VectorType<int8_t> &deletedText)
{ {
//EDN_INFO("EdnBufHistory new + data"); //EDN_INFO("EdnBufHistory new + data");
m_pos = pos; m_pos = pos;
@@ -75,7 +75,7 @@ int32_t EdnBufHistory::getnbInserted(void)
return m_nInserted; return m_nInserted;
} }
void EdnBufHistory::getData(EdnVectorBin<int8_t> &deletedText) void EdnBufHistory::getData(Edn::VectorType<int8_t> &deletedText)
{ {
deletedText = m_deletedText; deletedText = m_deletedText;
} }

View File

@@ -27,22 +27,22 @@
#define __EDN_BUFFER_HISTORY_H__ #define __EDN_BUFFER_HISTORY_H__
#include "EdnVectorBin.h" #include "VectorType.h"
class EdnBufHistory{ class EdnBufHistory{
public: public:
EdnBufHistory(void); EdnBufHistory(void);
EdnBufHistory(int32_t pos, int32_t nInserted, EdnVectorBin<int8_t> &deletedText); EdnBufHistory(int32_t pos, int32_t nInserted, Edn::VectorType<int8_t> &deletedText);
~EdnBufHistory(void); ~EdnBufHistory(void);
void Set(int32_t pos, int32_t nInserted, EdnVectorBin<int8_t> &deletedText); void Set(int32_t pos, int32_t nInserted, Edn::VectorType<int8_t> &deletedText);
int32_t getPos(void); int32_t getPos(void);
int32_t getnbDeleted(void); int32_t getnbDeleted(void);
int32_t getnbInserted(void); int32_t getnbInserted(void);
void getData(EdnVectorBin<int8_t> &deletedText); void getData(Edn::VectorType<int8_t> &deletedText);
private: private:
int32_t m_pos; int32_t m_pos;
int32_t m_nInserted; int32_t m_nInserted;
EdnVectorBin<int8_t> m_deletedText; Edn::VectorType<int8_t> m_deletedText;
}; };
#endif #endif

View File

@@ -35,12 +35,12 @@ void EdnBuf::SetHLSystem(Highlight * newHLSystem)
{ {
if (m_Highlight != newHLSystem) { if (m_Highlight != newHLSystem) {
m_Highlight = newHLSystem; m_Highlight = newHLSystem;
m_HLDataPass1.clear(); m_HLDataPass1.Clear();
RegenerateHighLightAt(0, 0, m_data.Size()); RegenerateHighLightAt(0, 0, m_data.Size());
} }
} }
// TODO : Check this fuction it have too many conditionnal inside ==> can do a better algo
void EdnBuf::RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdded) void EdnBuf::RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdded)
{ {
GTimeVal timeStart; GTimeVal timeStart;
@@ -60,14 +60,23 @@ void EdnBuf::RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdd
return; return;
} }
// normal case // normal case
EDN_INFO("(pos="<<pos<<", nbDeleted="<<nbDeleted<<", nbAdded=" << nbAdded << "\");"); //EDN_INFO("(pos="<<pos<<", nbDeleted="<<nbDeleted<<", nbAdded=" << nbAdded << "\");");
int32_t i; int32_t i;
/*
for (i=0; i< (int32_t)m_HLDataPass1.Size(); i++) {
Edn::String ploppp;
if (NULL != m_HLDataPass1[i].patern ) {
ploppp = ((HighlightPattern*)m_HLDataPass1[i].patern)->GetName();
}
EDN_DEBUG("HighLight (previous) element id=" << i << " S=" << m_HLDataPass1[i].beginStart << " E=" << m_HLDataPass1[i].endStop << " patern name=" << ploppp );
}
*/
int32_t posEnd = pos + nbDeleted; int32_t posEnd = pos + nbDeleted;
// search position of the old element to reparse IT... // search position of the old element to reparse IT...
int32_t startId; int32_t startId;
int32_t stopId; int32_t stopId;
// clean data if needed // clean data if needed
if (0 != m_HLDataPass1.size()) { if (0 != m_HLDataPass1.Size()) {
// find element previous // find element previous
FindMainHighLightPosition(pos, posEnd, startId, stopId, true); FindMainHighLightPosition(pos, posEnd, startId, stopId, true);
@@ -75,19 +84,37 @@ void EdnBuf::RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdd
if( -1 == startId if( -1 == startId
&& -1 == stopId) && -1 == stopId)
{ {
m_HLDataPass1.clear(); m_HLDataPass1.Clear();
} else if(-1 == startId) { } else if(-1 == startId) {
if (0 == stopId){ if (0 == stopId){
m_HLDataPass1.erase(m_HLDataPass1.begin()); m_HLDataPass1.Erase(0);
//EDN_DEBUG("1 * Erase 0");
} else { } else {
m_HLDataPass1.erase(m_HLDataPass1.begin(),m_HLDataPass1.begin()+stopId); m_HLDataPass1.EraseLen(0,stopId);
//EDN_DEBUG("2 * Erase 0->" << stopId);
} }
} else if(-1 == stopId) { } else if(-1 == stopId) {
m_HLDataPass1.erase(m_HLDataPass1.begin()+startId+1,m_HLDataPass1.end()); //EDN_DEBUG("3 * Erase " << startId+1 << "-> end");
m_HLDataPass1.EraseLen(startId+1, m_HLDataPass1.Size() - startId);
stopId = -1;
} else { } else {
m_HLDataPass1.erase(m_HLDataPass1.begin()+startId+1,m_HLDataPass1.begin()+stopId); int32_t currentSize = m_HLDataPass1.Size();
//EDN_DEBUG("4 * Erase " << startId+1 << "->" << stopId << " in " << currentSize << " elements" );
m_HLDataPass1.EraseLen(startId+1, stopId - startId);
if (stopId == currentSize-1) {
stopId = -1;
} }
EDN_DEBUG("new size=" << (int32_t)m_HLDataPass1.size()-1); }
//EDN_DEBUG("new size=" << (int32_t)m_HLDataPass1.Size()-1);
/*
for (i=0; i< (int32_t)m_HLDataPass1.Size(); i++) {
Edn::String ploppp;
if (NULL != m_HLDataPass1[i].patern ) {
ploppp = ((HighlightPattern*)m_HLDataPass1[i].patern)->GetName();
}
EDN_DEBUG("HighLight (Middle) element id=" << i << " S=" << m_HLDataPass1[i].beginStart << " E=" << m_HLDataPass1[i].endStop << " patern name=" << ploppp );
}
*/
// update position after the range position : // update position after the range position :
int32_t elemStart; int32_t elemStart;
if(-1 == startId) { if(-1 == startId) {
@@ -95,7 +122,7 @@ void EdnBuf::RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdd
} else { } else {
elemStart = startId+1; elemStart = startId+1;
} }
for (i=elemStart; i< (int32_t)m_HLDataPass1.size(); i++) { for (i=elemStart; i< (int32_t)m_HLDataPass1.Size(); i++) {
//EDN_DEBUG("move element=" << i); //EDN_DEBUG("move element=" << i);
m_HLDataPass1[i].beginStart += nbAdded - nbDeleted; m_HLDataPass1[i].beginStart += nbAdded - nbDeleted;
m_HLDataPass1[i].beginStop += nbAdded - nbDeleted; m_HLDataPass1[i].beginStop += nbAdded - nbDeleted;
@@ -113,23 +140,24 @@ void EdnBuf::RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdd
GenerateHighLightAt(0, m_HLDataPass1[0].beginStart, 0); GenerateHighLightAt(0, m_HLDataPass1[0].beginStart, 0);
} else if(-1 == stopId) { } else if(-1 == stopId) {
//EDN_DEBUG("******* Regenerate STOP"); //EDN_DEBUG("******* Regenerate STOP");
GenerateHighLightAt(m_HLDataPass1[m_HLDataPass1.size() -1].endStop, m_data.Size(), m_HLDataPass1.size()); GenerateHighLightAt(m_HLDataPass1[m_HLDataPass1.Size() -1].endStop, m_data.Size(), m_HLDataPass1.Size());
} else { } else {
//EDN_DEBUG("******* Regenerate RANGE"); //EDN_DEBUG("******* Regenerate RANGE");
GenerateHighLightAt(m_HLDataPass1[startId].endStop, m_HLDataPass1[startId+1].beginStart, startId+1); GenerateHighLightAt(m_HLDataPass1[startId].endStop, m_HLDataPass1[startId+1].beginStart, startId+1);
} }
} else { } else {
// Parse the new element ... // Parse the new element ...
//GenerateHighLightAt(pos, nbAdded);
GenerateHighLightAt(0, m_data.Size()); GenerateHighLightAt(0, m_data.Size());
} }
for (i=0; i< (int32_t)m_HLDataPass1.size(); i++) { /*
for (i=0; i< (int32_t)m_HLDataPass1.Size(); i++) {
Edn::String ploppp; Edn::String ploppp;
if (NULL != m_HLDataPass1[i].patern ) { if (NULL != m_HLDataPass1[i].patern ) {
ploppp = ((HighlightPattern*)m_HLDataPass1[i].patern)->GetName(); ploppp = ((HighlightPattern*)m_HLDataPass1[i].patern)->GetName();
} }
//EDN_DEBUG("HighLight element id=" << i << " S=" << m_HLDataPass1[i].beginStart << " E=" << m_HLDataPass1[i].endStop << " patern name=" << ploppp.c_str() ); EDN_DEBUG("HighLight (end) element id=" << i << " S=" << m_HLDataPass1[i].beginStart << " E=" << m_HLDataPass1[i].endStop << " patern name=" << ploppp );
} }
*/
GTimeVal timeStop; GTimeVal timeStop;
g_get_current_time(&timeStop); g_get_current_time(&timeStop);
EDN_DEBUG("HL General = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s"); EDN_DEBUG("HL General = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s");
@@ -177,7 +205,7 @@ void EdnBuf::FindMainHighLightPosition(int32_t startPos, int32_t endPos, int32_t
S=-1 *************** E S=-1 *************** E
*/ */
int32_t i; int32_t i;
for (i=0; i< (int32_t)m_HLDataPass1.size(); i++) { for (i=0; i< (int32_t)m_HLDataPass1.Size(); i++) {
if (m_HLDataPass1[i].endStop > startPos) { if (m_HLDataPass1[i].endStop > startPos) {
break; break;
} }
@@ -198,7 +226,7 @@ void EdnBuf::FindMainHighLightPosition(int32_t startPos, int32_t endPos, int32_t
} else { } else {
elemStart = startId+1; elemStart = startId+1;
} }
for (i=elemStart; i< (int32_t)m_HLDataPass1.size(); i++) { for (i=elemStart; i< (int32_t)m_HLDataPass1.Size(); i++) {
if (m_HLDataPass1[i].beginStart > endPos) if (m_HLDataPass1[i].beginStart > endPos)
{ {
stopId = i; stopId = i;
@@ -206,13 +234,13 @@ void EdnBuf::FindMainHighLightPosition(int32_t startPos, int32_t endPos, int32_t
} }
} }
/* /*
if (-1 != startId && startId < (int32_t)m_HLDataPass1.size()) { if (-1 != startId && startId < (int32_t)m_HLDataPass1.Size()) {
EDN_DEBUG("==> BEGIN : start="<<m_HLDataPass1[startId].beginStart<<", stop="<<m_HLDataPass1[startId].endStop<<" id=" << startId << "/" << (int32_t)m_HLDataPass1.size()-1); EDN_DEBUG("==> BEGIN : start="<<m_HLDataPass1[startId].beginStart<<", stop="<<m_HLDataPass1[startId].endStop<<" id=" << startId << "/" << (int32_t)m_HLDataPass1.Size()-1);
} else { } else {
EDN_DEBUG("==> BEGIN : start=???, stop=??? id=" << startId); EDN_DEBUG("==> BEGIN : start=???, stop=??? id=" << startId);
} }
if (-1 != stopId && stopId < (int32_t)m_HLDataPass1.size()) { if (-1 != stopId && stopId < (int32_t)m_HLDataPass1.Size()) {
EDN_DEBUG("==> END : start="<<m_HLDataPass1[stopId].beginStart<<", stop="<<m_HLDataPass1[stopId].endStop<<" id=" << stopId<< "/" << (int32_t)m_HLDataPass1.size()-1); EDN_DEBUG("==> END : start="<<m_HLDataPass1[stopId].beginStart<<", stop="<<m_HLDataPass1[stopId].endStop<<" id=" << stopId<< "/" << (int32_t)m_HLDataPass1.Size()-1);
} else { } else {
EDN_DEBUG("==> END : start=???, stop=??? id=" << stopId); EDN_DEBUG("==> END : start=???, stop=??? id=" << stopId);
} }
@@ -236,7 +264,7 @@ void EdnBuf::GenerateHighLightAt(int32_t pos, int32_t endPos, int32_t addinPos)
void EdnBuf::CleanHighLight(void) void EdnBuf::CleanHighLight(void)
{ {
// Remove all element in the list... // Remove all element in the list...
m_HLDataPass1.clear(); m_HLDataPass1.Clear();
} }
@@ -244,7 +272,7 @@ colorInformation_ts *EdnBuf::GetElementColorAtPosition(int32_t pos, int32_t &sta
{ {
int32_t i; int32_t i;
int32_t start = edn_max(0, starPos-1); int32_t start = edn_max(0, starPos-1);
for (i=start; i<(int32_t)m_HLDataPass1.size(); i++) { for (i=start; i<(int32_t)m_HLDataPass1.Size(); i++) {
starPos = i; starPos = i;
if( m_HLDataPass1[i].beginStart <= pos if( m_HLDataPass1[i].beginStart <= pos
&& m_HLDataPass1[i].endStop > pos) && m_HLDataPass1[i].endStop > pos)
@@ -258,22 +286,19 @@ colorInformation_ts *EdnBuf::GetElementColorAtPosition(int32_t pos, int32_t &sta
return NULL; return NULL;
} }
//#define COUNT_TIME plop
void EdnBuf::HightlightOneLine(displayHLData_ts & MData, int32_t HLStart, int32_t HLStop)
void EdnBuf::HightlightGenerateLines(displayHLData_ts & MData, int32_t HLStart, int32_t nbLines)
{ {
MData.posHLPass1 = 0; MData.posHLPass1 = 0;
MData.posHLPass2 = 0; MData.posHLPass2 = 0;
if (NULL == m_Highlight) { if (NULL == m_Highlight) {
return; return;
} }
if (MData.idSequence != m_HLDataSequence) { #ifdef COUNT_TIME
GTimeVal timeStart; GTimeVal timeStart;
g_get_current_time(&timeStart); g_get_current_time(&timeStart);
MData.idSequence = m_HLDataSequence; #endif
HLStart = StartOfLine(HLStart);
MData.HLData.clear();
int32_t HLStop = CountForwardNLines(HLStart, nbLines);
int32_t startId, stopId; int32_t startId, stopId;
// find element previous // find element previous
FindMainHighLightPosition(HLStart, HLStop, startId, stopId, true); FindMainHighLightPosition(HLStart, HLStop, startId, stopId, true);
@@ -282,7 +307,7 @@ void EdnBuf::HightlightGenerateLines(displayHLData_ts & MData, int32_t HLStart,
//EDN_DEBUG("List of section between : "<< startId << " & " << stopId); //EDN_DEBUG("List of section between : "<< startId << " & " << stopId);
int32_t endSearch = stopId+1; int32_t endSearch = stopId+1;
if (-1 == stopId) { if (-1 == stopId) {
endSearch = m_HLDataPass1.size(); endSearch = m_HLDataPass1.Size();
} }
for (k=edn_max(startId, 0); k<endSearch; k++) { for (k=edn_max(startId, 0); k<endSearch; k++) {
// empty section : // empty section :
@@ -305,9 +330,77 @@ void EdnBuf::HightlightGenerateLines(displayHLData_ts & MData, int32_t HLStart,
//EDN_DEBUG(" ==> (under section ) k="<<k<<" start="<<m_HLDataPass1[k].beginStart<<" stop="<<m_HLDataPass1[k].endStop << " subSectionOfID=" << 99999999); //EDN_DEBUG(" ==> (under section ) k="<<k<<" start="<<m_HLDataPass1[k].beginStart<<" stop="<<m_HLDataPass1[k].endStop << " subSectionOfID=" << 99999999);
// TODO : ... // TODO : ...
} }
if (endSearch == (int32_t)m_HLDataPass1.size() ){ if (endSearch == (int32_t)m_HLDataPass1.Size() ){
//if( k < (int32_t)m_HLDataPass1.size()) { if (m_HLDataPass1.Size() != 0) {
if (m_HLDataPass1.size() != 0) { //EDN_DEBUG(" ==> (empty section 3 ) k="<<k<<" start="<<m_HLDataPass1[k-1].endStop<<" stop="<<HLStop );
m_Highlight->Parse2(m_HLDataPass1[k-1].endStop,
HLStop,
MData.HLData,
m_data);
} else {
//EDN_DEBUG(" ==> (empty section 4 ) k="<<k<<" start=0 stop="<<HLStop );
m_Highlight->Parse2(0,
HLStop,
MData.HLData,
m_data);
}
}
#ifdef COUNT_TIME
GTimeVal timeStop;
g_get_current_time(&timeStop);
EDN_DEBUG("Display reAnnalyse = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s");
#endif
}
void EdnBuf::HightlightGenerateLines(displayHLData_ts & MData, int32_t HLStart, int32_t nbLines)
{
MData.posHLPass1 = 0;
MData.posHLPass2 = 0;
if (NULL == m_Highlight) {
return;
}
if (MData.idSequence != m_HLDataSequence) {
GTimeVal timeStart;
g_get_current_time(&timeStart);
MData.idSequence = m_HLDataSequence;
HLStart = StartOfLine(HLStart);
MData.HLData.Clear();
int32_t HLStop = CountForwardNLines(HLStart, nbLines);
int32_t startId, stopId;
// find element previous
FindMainHighLightPosition(HLStart, HLStop, startId, stopId, true);
int32_t k;
//EDN_DEBUG("List of section between : "<< startId << " & " << stopId);
int32_t endSearch = stopId+1;
if (-1 == stopId) {
endSearch = m_HLDataPass1.Size();
}
for (k=edn_max(startId, 0); k<endSearch; k++) {
// empty section :
if (0==k) {
if (HLStart < m_HLDataPass1[k].beginStart) {
//EDN_DEBUG(" ==> (empty section 1 ) k="<<k<<" start="<<HLStart<<" stop="<<m_HLDataPass1[k].beginStart );
m_Highlight->Parse2(HLStart,
m_HLDataPass1[k].beginStart,
MData.HLData,
m_data);
} // else : nothing to do ...
} else {
//EDN_DEBUG(" ==> (empty section 2 ) k="<<k<<" start="<<m_HLDataPass1[k-1].endStop<<" stop="<<m_HLDataPass1[k].beginStart );
m_Highlight->Parse2(m_HLDataPass1[k-1].endStop,
m_HLDataPass1[k].beginStart,
MData.HLData,
m_data);
}
// under section :
//EDN_DEBUG(" ==> (under section ) k="<<k<<" start="<<m_HLDataPass1[k].beginStart<<" stop="<<m_HLDataPass1[k].endStop << " subSectionOfID=" << 99999999);
// TODO : ...
}
if (endSearch == (int32_t)m_HLDataPass1.Size() ){
//if( k < (int32_t)m_HLDataPass1.Size()) {
if (m_HLDataPass1.Size() != 0) {
//EDN_DEBUG(" ==> (empty section 3 ) k="<<k<<" start="<<m_HLDataPass1[k-1].endStop<<" stop="<<HLStop ); //EDN_DEBUG(" ==> (empty section 3 ) k="<<k<<" start="<<m_HLDataPass1[k-1].endStop<<" stop="<<HLStop );
m_Highlight->Parse2(m_HLDataPass1[k-1].endStop, m_Highlight->Parse2(m_HLDataPass1[k-1].endStop,
HLStop, HLStop,
@@ -326,7 +419,6 @@ void EdnBuf::HightlightGenerateLines(displayHLData_ts & MData, int32_t HLStart,
g_get_current_time(&timeStop); g_get_current_time(&timeStop);
EDN_DEBUG("Display reAnnalyse = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s"); EDN_DEBUG("Display reAnnalyse = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s");
} }
} }
@@ -334,7 +426,7 @@ colorInformation_ts * EdnBuf::GetElementColorAtPosition(displayHLData_ts & MData
{ {
int32_t i; int32_t i;
int32_t start = edn_max(0, MData.posHLPass2-1); int32_t start = edn_max(0, MData.posHLPass2-1);
for (i=start; i<(int32_t)MData.HLData.size(); i++) { for (i=start; i<(int32_t)MData.HLData.Size(); i++) {
MData.posHLPass2 = i; MData.posHLPass2 = i;
if( MData.HLData[i].beginStart <= pos if( MData.HLData[i].beginStart <= pos
&& MData.HLData[i].endStop > pos) && MData.HLData[i].endStop > pos)

View File

@@ -53,7 +53,7 @@ int32_t EdnBuf::Undo(void)
int32_t pos = m_historyUndo[nbElement]->getPos(); int32_t pos = m_historyUndo[nbElement]->getPos();
int32_t nbDeleted = m_historyUndo[nbElement]->getnbDeleted(); int32_t nbDeleted = m_historyUndo[nbElement]->getnbDeleted();
int32_t nbInserted = m_historyUndo[nbElement]->getnbInserted(); int32_t nbInserted = m_historyUndo[nbElement]->getnbInserted();
EdnVectorBin<int8_t> deletedText; Edn::VectorType<int8_t> deletedText;
m_historyUndo[nbElement]->getData(deletedText); m_historyUndo[nbElement]->getData(deletedText);
m_isUndoProcessing = true; m_isUndoProcessing = true;
if (0 == nbInserted) { if (0 == nbInserted) {
@@ -101,7 +101,7 @@ int32_t EdnBuf::Redo(void)
int32_t pos = m_historyRedo[nbElement]->getPos(); int32_t pos = m_historyRedo[nbElement]->getPos();
int32_t nbDeleted = m_historyRedo[nbElement]->getnbDeleted(); int32_t nbDeleted = m_historyRedo[nbElement]->getnbDeleted();
int32_t nbInserted = m_historyRedo[nbElement]->getnbInserted(); int32_t nbInserted = m_historyRedo[nbElement]->getnbInserted();
EdnVectorBin<int8_t> deletedText; Edn::VectorType<int8_t> deletedText;
m_historyRedo[nbElement]->getData(deletedText); m_historyRedo[nbElement]->getData(deletedText);
m_isRedoProcessing = true; m_isRedoProcessing = true;
if (0 == nbInserted) { if (0 == nbInserted) {

View File

@@ -136,7 +136,7 @@ bool EdnBuf::GetSelectionPos(selectionType_te select, int32_t &start, int32_t &e
* @return --- * @return ---
* *
*/ */
void EdnBuf::GetSelectionText(selectionType_te select, EdnVectorBin<int8_t> &text) void EdnBuf::GetSelectionText(selectionType_te select, Edn::VectorType<int8_t> &text)
{ {
int32_t start, end, rectStart, rectEnd; int32_t start, end, rectStart, rectEnd;
bool isRect; bool isRect;
@@ -198,7 +198,7 @@ void EdnBuf::RemoveSelected(selectionType_te select)
* @return --- * @return ---
* *
*/ */
void EdnBuf::ReplaceSelected(selectionType_te select, EdnVectorBin<int8_t> &text) void EdnBuf::ReplaceSelected(selectionType_te select, Edn::VectorType<int8_t> &text)
{ {
int32_t start, end, rectStart, rectEnd; int32_t start, end, rectStart, rectEnd;
bool isRect; bool isRect;

File diff suppressed because it is too large Load Diff

View File

@@ -1,261 +0,0 @@
/**
*******************************************************************************
* @file EdnRegExp.h
* @brief Editeur De N'ours : Regular expression annalyser (header)
* @author Edouard DUPIN
* @date 04/04/2011
* @par Project
* Edn
*
* @par Copyright
* Copyright 2010 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
* You can not earn money with this Software (if the source extract from Edn
* represent less than 50% of original Sources)
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __EDN_REG_EXP_H__
#define __EDN_REG_EXP_H__
class EdnRegExp;
#include "EdnTree.h"
#include "EdnBuf.h"
#include "EdnVectorBin.h"
#include "EdnVectorBuf.h"
/*
normal mode :
(...) sub element is separate with |
\d Digits [0-9]
\D NOT a digit [^0-9]
\l Letters [a-zA-Z]
\L NOT a Letter [^a-zA-Z]
\s Whitespace [ \t\n\r\f\v]
\S NOT Whitespace [^ \t\n\r\f\v]
\w "Word" character [a-zA-Z0-9_]
\W NOT a "Word" character [^a-zA-Z0-9_]
\@ at the start or the end not in the parsing of element ==> check if \w is not present (other regExp will be <> ...)
[anjdi] or [a-gt-j] range
. dot [^\x00-\x08\x0A-\x1F\x7F]
==> TODO :
$ End / Start of line of line ==> ce sera un truc supl<70>mentaire comme le \@
^in the [] invertion of the range element
multiplicity :
* ==> {0, 2147483647}
? ==> {0, 1}
+ ==> {1, 2147483647}
{x} ==> {x, x}
{x,y} ==> {x, y}
*/
class RegExpNode;
/**
* @brief Node Elements for every-one
*/
class RegExpNode{
public :
RegExpNode(void);
virtual ~RegExpNode(void) { };
virtual int32_t Generate(EdnVectorBin<int16_t> &data, int32_t startPos, int32_t nbElement);
virtual bool Parse(EdnVectorBuf &data, int32_t currentPos, int32_t lenMax, int32_t &findLen);
virtual void Display(int32_t level);
void SetMult(int32_t min, int32_t max);
protected:
int32_t GetMultMin(void) { return m_multipleMin; };
int32_t GetMultMax(void) { return m_multipleMax; };
protected :
int32_t m_multipleMin; //!< minimum repetition (included)
int32_t m_multipleMax; //!< maximum repetition (included)
// Data Section ... (can have no data...)
EdnVectorBin<int16_t> m_RegExpData; //!< data to parse and compare in some case ...
};
class RegExpNodePThese : public RegExpNode {
public :
RegExpNodePThese(void) { };
~RegExpNodePThese(void);
int32_t Generate(EdnVectorBin<int16_t> &data);
bool Parse(EdnVectorBuf &data, int32_t currentPos, int32_t lenMax, int32_t &findLen);
void Display(int32_t level);
protected :
// SubNodes :
EdnVectorBin<RegExpNode*> m_subNode;
//int32_t m_posPthese; //!< position of the element is detected in the output element
};
class RegExpNodePTheseElem : public RegExpNode {
public :
RegExpNodePTheseElem(void) { };
~RegExpNodePTheseElem(void);
int32_t Generate(EdnVectorBin<int16_t> &data);
bool Parse(EdnVectorBuf &data, int32_t currentPos, int32_t lenMax, int32_t &findLen);
void Display(int32_t level);
protected :
// SubNodes :
EdnVectorBin<RegExpNode*> m_subNode;
private :
bool SetMultiplicityOnLastNode(int32_t min, int32_t max);
};
class RegExpNodeValue : public RegExpNode {
public :
RegExpNodeValue(void) { };
~RegExpNodeValue(void) { };
int32_t Generate(EdnVectorBin<int16_t> &data);
bool Parse(EdnVectorBuf &data, int32_t currentPos, int32_t lenMax, int32_t &findLen);
void Display(int32_t level);
protected :
// SubNodes :
EdnVectorBin<char> m_data;
};
class RegExpNodeBracket : public RegExpNode {
public :
RegExpNodeBracket(void) { };
~RegExpNodeBracket(void) { };
int32_t Generate(EdnVectorBin<int16_t> &data);
bool Parse(EdnVectorBuf &data, int32_t currentPos, int32_t lenMax, int32_t &findLen);
void Display(int32_t level);
protected :
// SubNodes :
EdnVectorBin<char> m_data;
};
class RegExpNodeDigit : public RegExpNode {
public :
RegExpNodeDigit(void) { };
~RegExpNodeDigit(void) { };
bool Parse(EdnVectorBuf &data, int32_t currentPos, int32_t lenMax, int32_t &findLen);
void Display(int32_t level);
};
class RegExpNodeDigitNot : public RegExpNode {
public :
RegExpNodeDigitNot(void) { };
~RegExpNodeDigitNot(void) { };
bool Parse(EdnVectorBuf &data, int32_t currentPos, int32_t lenMax, int32_t &findLen);
void Display(int32_t level);
};
class RegExpNodeLetter : public RegExpNode {
public :
RegExpNodeLetter(void) { };
~RegExpNodeLetter(void) { };
bool Parse(EdnVectorBuf &data, int32_t currentPos, int32_t lenMax, int32_t &findLen);
void Display(int32_t level);
};
class RegExpNodeLetterNot : public RegExpNode {
public :
RegExpNodeLetterNot(void) { };
~RegExpNodeLetterNot(void) { };
bool Parse(EdnVectorBuf &data, int32_t currentPos, int32_t lenMax, int32_t &findLen);
void Display(int32_t level);
};
class RegExpNodeWhiteSpace : public RegExpNode {
public :
RegExpNodeWhiteSpace(void) { };
~RegExpNodeWhiteSpace(void) { };
bool Parse(EdnVectorBuf &data, int32_t currentPos, int32_t lenMax, int32_t &findLen);
void Display(int32_t level);
};
class RegExpNodeWhiteSpaceNot : public RegExpNode {
public :
RegExpNodeWhiteSpaceNot(void) { };
~RegExpNodeWhiteSpaceNot(void) { };
bool Parse(EdnVectorBuf &data, int32_t currentPos, int32_t lenMax, int32_t &findLen);
void Display(int32_t level);
};
class RegExpNodeWordChar : public RegExpNode {
public :
RegExpNodeWordChar(void) { };
~RegExpNodeWordChar(void) { };
bool Parse(EdnVectorBuf &data, int32_t currentPos, int32_t lenMax, int32_t &findLen);
void Display(int32_t level);
};
class RegExpNodeWordCharNot : public RegExpNode {
public :
RegExpNodeWordCharNot(void) { };
~RegExpNodeWordCharNot(void) { };
bool Parse(EdnVectorBuf &data, int32_t currentPos, int32_t lenMax, int32_t &findLen);
void Display(int32_t level);
};
class RegExpNodeDot : public RegExpNode {
public :
RegExpNodeDot(void) { };
~RegExpNodeDot(void) { };
bool Parse(EdnVectorBuf &data, int32_t currentPos, int32_t lenMax, int32_t &findLen);
void Display(int32_t level);
};
class RegExpNodeSOL : public RegExpNode {
public :
RegExpNodeSOL(void) { };
~RegExpNodeSOL(void) { };
bool Parse(EdnVectorBuf &data, int32_t currentPos, int32_t lenMax, int32_t &findLen);
void Display(int32_t level);
};
class RegExpNodeEOL : public RegExpNode {
public :
RegExpNodeEOL(void) { };
~RegExpNodeEOL(void) { };
bool Parse(EdnVectorBuf &data, int32_t currentPos, int32_t lenMax, int32_t &findLen);
void Display(int32_t level);
};
typedef struct {
int32_t start;
int32_t stop;
}elementPos_ts;
// Regular expression manager
class EdnRegExp {
// public API :
public:
// create the regular expression
EdnRegExp(const char *exp);
EdnRegExp(Edn::String &exp);
EdnRegExp(void);
~EdnRegExp(void);
void SetRegExp(const char *exp);
void SetRegExp(Edn::String &exp);
Edn::String GetRegExp(void) { return m_expressionRequested;};
bool GetStatus(void) { return m_isOk;};
// process the regular expression
bool Process( EdnVectorBuf &SearchIn,
int32_t startPos,
int32_t endPos,
char escapeChar=0);
int32_t Start(void) { return m_areaFind.start; };
int32_t Stop(void) { return m_areaFind.stop; };
void Display(void);
// internal parameters
private:
Edn::String m_expressionRequested; // TODO : Remove ...
elementPos_ts m_areaFind; //!< position around selection
RegExpNodePThese m_exprRootNode; //!< The tree where data is set
bool m_isOk; //!< Known if we can process with this regExp
bool m_notBeginWithChar; //!< The regular expression must not have previously a char [a-zA-Z0-9_]
bool m_notEndWithChar; //!< The regular expression must not have after the end a char [a-zA-Z0-9_]
// internal access
private:
bool CheckGoodPosition(EdnVectorBin<int16_t> tmpExp, int32_t &pos);
bool CheckGoodPosition(EdnVectorBin<int16_t> tmpExp);
};
#endif

View File

@@ -1,29 +0,0 @@
#include "tools_debug.h"
#include "tools_globals.h"
#include "EdnVectorBin.h"
void TestTemplate(void)
{
EDN_WARNING("Start Template Test ...");
EdnVectorBin<int32_t> plop;
EdnVectorBin<int8_t> plop2;
plop.PushBack(15365);
plop.PushBack(1);
plop.PushBack(2);
plop.PushBack(3);
plop.PushBack(4);
EDN_INFO("data is : " << plop[0]);
EDN_INFO("data is : " << plop[1]);
EDN_INFO("data is : " << plop[2]);
EDN_INFO("data is : " << plop[3]);
plop2.PushBack(65);
EDN_INFO("data is : " << plop2[0]);
}

View File

@@ -1,186 +0,0 @@
/**
*******************************************************************************
* @file EdnTree.h
* @brief Editeur De N'ours : Basic tree in a vector For none expensive tree (template)
* @author Edouard DUPIN
* @date 04/04/2011
* @par Project
* Edn
*
* @par Copyright
* Copyright 2010 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
* You can not earn money with this Software (if the source extract from Edn
* represent less than 50% of original Sources)
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __EDN_TREE_H__
#define __EDN_TREE_H__
#undef __class__
#define __class__ "EdnTreeElement"
template < class T > class EdnTreeElement
{
public:
EdnTreeElement(int32_t parent, int32_t id, T &maNouvelleClass) : elementPtr(NULL), m_parent(parent), m_id(id)
{
elementPtr = new T(maNouvelleClass);
};
~EdnTreeElement(void)
{
delete(elementPtr);
};
EdnTreeElement(const EdnTreeElement &mustCopy ) : elementPtr(NULL), m_parent(mustCopy.m_parent), m_id(mustCopy.m_id)
{
elementPtr = new T(*mustCopy.elementPtr);
}
int32_t GetParrent(void) { return m_parent;};
int32_t GetId(void) { return m_id;};
T* GetPtr() const
{
return elementPtr;
};
private:
T* elementPtr; // pointer on the curent element
int32_t m_parent;
int32_t m_id;
};
#undef __class__
#define __class__ "EdnTree"
#define ROOT_NODE_ID (-1)
template < class T > class EdnTree
{
public:
// constructeur et destructeur
EdnTree(void)
{
m_LastId = 0;
};
~EdnTree(void)
{
};
// Common function ...
int32_t GetNumberNode(void)
{
return m_listElement.size();
};
int32_t GetDepth(void)
{
// TODO : ...
return 0;
};
//!< add an element in the tree
int32_t Add(T &maNouvelleClass, int32_t parent=-1)
{
if (true == CheckPresenceParrent(parent)) {
// create the local element
EdnTreeElement<T> nouvelElement(parent, m_LastId, maNouvelleClass);
// add it in the list
m_listElement.push_back(nouvelElement);
// increment the ID of the element
m_LastId++;
// Add is Ok, in theory ...
return m_LastId-1;
}
return -2;
};
bool Remove(int32_t id)
{
return false;
};
bool Clear(void)
{
return false;
};
T* Get(int32_t id)
{
// try to find ID
int32_t realID = FindElementWithId(id);
// when we find it, check it
if (0 > realID || realID >= m_LastId) {
return NULL;
}
// Return the element :
return m_listElement[realID].GetPtr();
};
std::vector<int32_t> GetListSubNode( int32_t parentId = ROOT_NODE_ID)
{
std::vector<int32_t> res;
int32_t i;
for (i=0; i<(int32_t)m_listElement.size(); i++) {
if (m_listElement[i].GetParrent() == parentId) {
// Add the element ID in the list ...
res.push_back(m_listElement[i].GetId());
}
}
return res;
};
std::vector<int32_t> Root(void)
{
return GetListSubNode(ROOT_NODE_ID);
};
private:
int32_t m_LastId;
std::vector< EdnTreeElement<T> > m_listElement; //!< list of element...
bool CheckPresence(int32_t id)
{
int32_t i;
for (i=0; i<(int32_t)m_listElement.size(); i++) {
if (m_listElement[i].GetId() == id) {
return true;
}
}
return false;
};
bool CheckPresenceParrent(int32_t parrentId)
{
if (ROOT_NODE_ID == parrentId) {
return true;
}
return CheckPresence(parrentId);
};
int32_t FindElementWithId(int32_t id)
{
int32_t i;
for (i=0; i<(int32_t)m_listElement.size(); i++) {
if (m_listElement[i].GetId() == id) {
return i;
}
}
return ROOT_NODE_ID;
};
};
#undef __class__
#define __class__ NULL
#endif

View File

@@ -227,7 +227,7 @@ int8_t& EdnVectorBuf::Get(int32_t pos)
* @return --- * @return ---
* *
*/ */
void EdnVectorBuf::Get(int32_t pos, int32_t nbElement, EdnVectorBin<int8_t> &tmpBuffer) void EdnVectorBuf::Get(int32_t pos, int32_t nbElement, Edn::VectorType<int8_t> &tmpBuffer)
{ {
tmpBuffer.Clear(); tmpBuffer.Clear();
if (pos < m_gapStart) { if (pos < m_gapStart) {
@@ -399,7 +399,7 @@ void EdnVectorBuf::Insert(int32_t pos, const int8_t& item)
* @return --- * @return ---
* *
*/ */
void EdnVectorBuf::Insert(int32_t pos, EdnVectorBin<int8_t>& items) void EdnVectorBuf::Insert(int32_t pos, Edn::VectorType<int8_t>& items)
{ {
if( pos > Size() if( pos > Size()
|| pos < 0 ) { || pos < 0 ) {
@@ -455,7 +455,7 @@ void EdnVectorBuf::Replace(int32_t pos, const int8_t& item)
* @return --- * @return ---
* *
*/ */
void EdnVectorBuf::Replace(int32_t pos, int32_t nbRemoveElement, EdnVectorBin<int8_t>& items) void EdnVectorBuf::Replace(int32_t pos, int32_t nbRemoveElement, Edn::VectorType<int8_t>& items)
{ {
if( pos > Size() if( pos > Size()
|| pos < 0 ) { || pos < 0 ) {
@@ -652,7 +652,7 @@ void TestEdnVectorBuf(void)
myBufferTmp.Display(); myBufferTmp.Display();
plop='m'; plop='m';
EdnVectorBin<int8_t> items; Edn::VectorType<int8_t> items;
items.PushBack('i'); items.PushBack('i');
items.PushBack('j'); items.PushBack('j');
items.PushBack('k'); items.PushBack('k');

View File

@@ -27,7 +27,7 @@
#define __EDN_VECTOR_BUF_H__ #define __EDN_VECTOR_BUF_H__
#include "toolsMemory.h" #include "toolsMemory.h"
#include "EdnVectorBin.h" #include "VectorType.h"
#undef __class__ #undef __class__
#define __class__ "EdnVectorBuf" #define __class__ "EdnVectorBuf"
@@ -272,14 +272,14 @@ class EdnVectorBuf
EdnVectorBuf & operator=( const EdnVectorBuf & Evb); EdnVectorBuf & operator=( const EdnVectorBuf & Evb);
int8_t operator[] (int32_t pos); int8_t operator[] (int32_t pos);
int8_t & Get( int32_t pos); int8_t & Get( int32_t pos);
void Get( int32_t pos, int32_t nbElement, EdnVectorBin<int8_t> &tmpBuffer); void Get( int32_t pos, int32_t nbElement, Edn::VectorType<int8_t> &tmpBuffer);
// insert functions // insert functions
void PushBack( const int8_t& item); void PushBack( const int8_t& item);
void Insert( int32_t pos, const int8_t& item); void Insert( int32_t pos, const int8_t& item);
void Insert( int32_t pos, EdnVectorBin<int8_t>& items); void Insert( int32_t pos, Edn::VectorType<int8_t>& items);
// Remove and insert functions // Remove and insert functions
void Replace( int32_t pos, const int8_t& item); void Replace( int32_t pos, const int8_t& item);
void Replace( int32_t pos, int32_t nbRemoveElement, EdnVectorBin<int8_t>& items); void Replace( int32_t pos, int32_t nbRemoveElement, Edn::VectorType<int8_t>& items);
// Revove fonctions // Revove fonctions
void Remove( int32_t pos, int32_t nbRemoveElement = 1); void Remove( int32_t pos, int32_t nbRemoveElement = 1);
void PopBack( void); void PopBack( void);

View File

@@ -79,8 +79,8 @@ static char * GetMessageChar(messageType_te Id)
{ {
switch(Id) switch(Id)
{ {
MACRO_DISPLAY_MSG(EDN_MSG__QUIT)
MACRO_DISPLAY_MSG(EDN_MSG__BUFFER_CHANGE_CURRENT) MACRO_DISPLAY_MSG(EDN_MSG__BUFFER_CHANGE_CURRENT)
MACRO_DISPLAY_MSG(EDN_MSG__USER_DISPLAY_CHANGE)
MACRO_DISPLAY_MSG(EDN_MSG__GUI_SHOW_MAIN_WINDOWS) MACRO_DISPLAY_MSG(EDN_MSG__GUI_SHOW_MAIN_WINDOWS)
MACRO_DISPLAY_MSG(EDN_MSG__GUI_SHOW_SEARCH) MACRO_DISPLAY_MSG(EDN_MSG__GUI_SHOW_SEARCH)
@@ -90,6 +90,7 @@ static char * GetMessageChar(messageType_te Id)
MACRO_DISPLAY_MSG(EDN_MSG__GUI_SHOW_SAVE_AS) MACRO_DISPLAY_MSG(EDN_MSG__GUI_SHOW_SAVE_AS)
MACRO_DISPLAY_MSG(EDN_MSG__GUI_SHOW_GOTO_LINE) MACRO_DISPLAY_MSG(EDN_MSG__GUI_SHOW_GOTO_LINE)
MACRO_DISPLAY_MSG(EDN_MSG__GUI_SHOW_ABOUT) MACRO_DISPLAY_MSG(EDN_MSG__GUI_SHOW_ABOUT)
MACRO_DISPLAY_MSG(EDN_MSG__GUI_SHOW_EXIT_CONFIRMATION)
MACRO_DISPLAY_MSG(EDN_MSG__BUFFER_REMOVE) MACRO_DISPLAY_MSG(EDN_MSG__BUFFER_REMOVE)
MACRO_DISPLAY_MSG(EDN_MSG__BUFFER_REMOVE_ALL) MACRO_DISPLAY_MSG(EDN_MSG__BUFFER_REMOVE_ALL)
@@ -138,6 +139,12 @@ static char * GetMessageChar(messageType_te Id)
MACRO_DISPLAY_MSG(EDN_MSG__JUMP_TO_CURRENT_SELECTION) MACRO_DISPLAY_MSG(EDN_MSG__JUMP_TO_CURRENT_SELECTION)
MACRO_DISPLAY_MSG(EDN_MSG__JUMP_BACK) MACRO_DISPLAY_MSG(EDN_MSG__JUMP_BACK)
// HL message :
MACRO_DISPLAY_MSG(EDN_MSG__COLOR_HAS_CHANGE)
// Color message :
MACRO_DISPLAY_MSG(EDN_MSG__RELOAD_COLOR_FILE)
default: default:
return (char*)"??"; return (char*)"??";
} }
@@ -161,6 +168,12 @@ static char * GetMessageTypeChar(messageCat_te Id)
return (char*)"GUI_MANAGER"; return (char*)"GUI_MANAGER";
case EDN_CAT_CTAGS: case EDN_CAT_CTAGS:
return (char*)"C-TAGS_MANAGER"; return (char*)"C-TAGS_MANAGER";
case EDN_CAT_MENU_CONTEXT:
return (char*)"MENU CONTEXT";
case EDN_CAT_HL:
return (char*)"HIGHT-LIGHT";
case EDN_CAT_COLOR:
return (char*)"COLOR";
default: default:
return (char*)"??"; return (char*)"??";
} }
@@ -198,6 +211,18 @@ void MsgBroadcastCore::SendMessage(MsgBroadcast * pointerOnSender, messageType_t
&& MSG_TO_CTAGS__STOP >= id ) && MSG_TO_CTAGS__STOP >= id )
{ {
catDest = EDN_CAT_CTAGS; catDest = EDN_CAT_CTAGS;
} else if( MSG_TO_CONTEXT__START <= id
&& MSG_TO_CONTEXT__STOP >= id )
{
catDest = EDN_CAT_MENU_CONTEXT;
} else if( MSG_TO_HL__START <= id
&& MSG_TO_HL__STOP >= id )
{
catDest = EDN_CAT_HL;
} else if( MSG_TO_COLOR__START <= id
&& MSG_TO_COLOR__STOP >= id )
{
catDest = EDN_CAT_COLOR;
} }
myStructMessage.localMessageID = m_messageID++; myStructMessage.localMessageID = m_messageID++;

View File

@@ -38,9 +38,8 @@
// the ID we'll use to identify our event // the ID we'll use to identify our event
typedef enum { typedef enum {
EDN_MSG__NONE = 0, EDN_MSG__NONE = 0,
// Programm is Quitting... close all if needed ...
EDN_MSG__QUIT,
EDN_MSG__BUFFER_CHANGE_CURRENT, // set the new current BUFFER ... EDN_MSG__BUFFER_CHANGE_CURRENT, // set the new current BUFFER ...
EDN_MSG__USER_DISPLAY_CHANGE, // User change the display ==> need to reload all the display depending on color internal
// DESTINATION : GUI_MANAGER // DESTINATION : GUI_MANAGER
MSG_TO_GUI_MANAGER__START, MSG_TO_GUI_MANAGER__START,
@@ -53,6 +52,7 @@ typedef enum {
EDN_MSG__GUI_SHOW_SAVE_AS, EDN_MSG__GUI_SHOW_SAVE_AS,
EDN_MSG__GUI_SHOW_GOTO_LINE, EDN_MSG__GUI_SHOW_GOTO_LINE,
EDN_MSG__GUI_SHOW_ABOUT, EDN_MSG__GUI_SHOW_ABOUT,
EDN_MSG__GUI_SHOW_EXIT_CONFIRMATION,
MSG_TO_GUI_MANAGER__STOP, MSG_TO_GUI_MANAGER__STOP,
// DESTINATION : GUI // DESTINATION : GUI
@@ -121,6 +121,20 @@ typedef enum {
EDN_MSG__JUMP_BACK, EDN_MSG__JUMP_BACK,
MSG_TO_CTAGS__STOP, MSG_TO_CTAGS__STOP,
// DESTINATION : context popup ...
MSG_TO_CONTEXT__START,
MSG_TO_CONTEXT__STOP,
// DESTINATION : highlight system ...
MSG_TO_HL__START,
EDN_MSG__COLOR_HAS_CHANGE,
MSG_TO_HL__STOP,
// DESTINATION : Color System ...
MSG_TO_COLOR__START,
EDN_MSG__RELOAD_COLOR_FILE,
MSG_TO_COLOR__STOP,
}messageType_te; }messageType_te;
@@ -132,6 +146,9 @@ typedef enum {
EDN_CAT_BUFFER_MANAGER, EDN_CAT_BUFFER_MANAGER,
EDN_CAT_GUI_MANAGER, EDN_CAT_GUI_MANAGER,
EDN_CAT_CTAGS, EDN_CAT_CTAGS,
EDN_CAT_MENU_CONTEXT,
EDN_CAT_HL,
EDN_CAT_COLOR,
}messageCat_te; }messageCat_te;
@@ -183,9 +200,9 @@ class MsgBroadcastCore: public Singleton<MsgBroadcastCore>
void RmReceiver(MsgBroadcast * pointerOnReceiver); void RmReceiver(MsgBroadcast * pointerOnReceiver);
private: private:
EdnVectorBin<MsgBroadcast*> m_listMessage; Edn::VectorType<MsgBroadcast*> m_listMessage;
uint32_t m_messageID; uint32_t m_messageID;
EdnVectorBin<messageElement_ts> m_listOfMessage; Edn::VectorType<messageElement_ts> m_listOfMessage;
}; };

View File

@@ -26,19 +26,11 @@
#include "tools_debug.h" #include "tools_debug.h"
#include "toolsMemory.h" #include "toolsMemory.h"
#include "EdnVectorBin.h" //#include "Vector.h" // TODO : Set the vector of edn enable
#include "VectorType.h"
#ifndef __EDN_H__
#define __EDN_H__
#define _IN_NAMESPACE_EDN_ (plop) #include "String.h"
namespace Edn #include "File.h"
{
#include "String.h"
#include "File.h"
}
#undef IN_NAMESPACE_EDN
#endif

View File

@@ -28,12 +28,34 @@
#include "tools_globals.h" #include "tools_globals.h"
#include "Edn.h" #include "Edn.h"
#undef __class__
#define __class__ "Edn::File"
std::ostream& Edn::operator <<(std::ostream &os, const Edn::File &obj)
{
os << obj.m_folder;
os << "/";
os << obj.m_shortFilename;
return os;
}
Edn::File::File(Edn::String &filename, int32_t LineNumber) Edn::File::File(Edn::String &filename, int32_t LineNumber)
{ {
m_lineNumberOpen = 0; m_lineNumberOpen = LineNumber;
SetCompleateName(filename); SetCompleateName(filename);
} }
Edn::File::File(const char *filename, int32_t LineNumber)
{
Edn::String tmpString = filename;
m_lineNumberOpen = LineNumber;
SetCompleateName(tmpString);
}
Edn::File::File(Edn::String &filename, Edn::String &folder, int32_t lineNumber) Edn::File::File(Edn::String &filename, Edn::String &folder, int32_t lineNumber)
{ {
Edn::String tmpString = folder; Edn::String tmpString = folder;
@@ -43,72 +65,182 @@ Edn::File::File(Edn::String &filename, Edn::String &folder, int32_t lineNumber)
m_lineNumberOpen = lineNumber; m_lineNumberOpen = lineNumber;
} }
Edn::File::~File(void) Edn::File::~File(void)
{ {
// nothing to do ... // nothing to do ...
} }
void Edn::File::ExtranctAndName(Edn::String &inputString)
{
m_folder = "";
m_shortFilename = "";
for (int32_t iii=inputString.Size()-1; iii >= 0 ; iii--) { Edn::String Edn::File::GetFolder(void) const
/*
if (inputString[iii] != '/') {
m_shortFilename.Insert(0, inputString[iii]);
} else {
break;
}
*/
}
/*
char tmpVal[4096];
strncpy(tmpVal, inputString.c_str(), 4096);
tmpVal[4096-1] = '\0';
char *ptr = strrchr(tmpVal, '/');
if (NULL == ptr) {
ptr = strrchr(tmpVal, '\\');
}
Edn::String out = "./";
if (NULL != ptr) {
*ptr = '\0';
out = tmpVal;
out+= '/';
}
return out;
*/
}
Edn::String Edn::File::GetFolder(void)
{ {
return m_folder; return m_folder;
} }
Edn::String Edn::File::GetShortFilename(void) Edn::String Edn::File::GetShortFilename(void) const
{ {
return m_shortFilename; return m_shortFilename;
} }
Edn::String Edn::File::GetCompleateName(void) Edn::String Edn::File::GetCompleateName(void) const
{ {
Edn::String out; Edn::String out;
out = m_folder; out = m_folder;
out += '/'; out += '/';
out += m_shortFilename; out += m_shortFilename;
return out;
} }
const Edn::File& Edn::File::operator= (const Edn::File &ednF )
{
if( this != &ednF ) // avoid copy to itself
{
m_folder = ednF.m_folder;
m_shortFilename = ednF.m_shortFilename;
m_lineNumberOpen = ednF.m_lineNumberOpen;
}
return *this;
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
bool Edn::File::operator== (const Edn::File &ednF) const
{
if( this != &ednF ) {
if (ednF.GetCompleateName() == GetCompleateName() ) {
return true;
} else {
return false;
}
return true;
}
return true;
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
bool Edn::File::operator!= (const Edn::File &ednF) const
{
return !(*this == ednF);
}
void Edn::File::SetCompleateName(Edn::String &newFilename) void Edn::File::SetCompleateName(Edn::String &newFilename)
{ {
char buf[MAX_FILE_NAME];
memset(buf, 0, MAX_FILE_NAME);
char * ok;
// Reset ALL DATA :
m_folder = "";
m_shortFilename = "";
m_lineNumberOpen = 0;
EDN_DEBUG("1 :Set Name : " << newFilename );
Edn::String destFilename;
if (newFilename.Size() == 0) {
destFilename = "no-name";
} else {
destFilename = newFilename;
}
EDN_DEBUG("2 : Get file Name : " << destFilename );
if ('/' != *destFilename.c_str()) {
// Get the command came from the running of the program :
char cCurrentPath[FILENAME_MAX];
if (!getcwd(cCurrentPath, FILENAME_MAX)) {
return;
}
cCurrentPath[FILENAME_MAX - 1] = '\0';
Edn::String tmpFilename = destFilename;
destFilename = cCurrentPath;
destFilename += '/';
destFilename += tmpFilename;
}
EDN_DEBUG("3 : Get file Name : " << destFilename );
// Get the real Path of the current File
ok = realpath(destFilename.c_str(), buf);
if (!ok) {
int32_t lastPos = destFilename.FindBack('/');
if (-1 != lastPos) {
// Get the FileName
Edn::String tmpFilename = destFilename.Extract(lastPos+1);
destFilename.Remove(lastPos, destFilename.Size() - lastPos);
EDN_DEBUG("try to find :\"" << destFilename << "\" / \"" << tmpFilename << "\" ");
ok = realpath(destFilename.c_str(), buf);
if (!ok) {
EDN_ERROR("Can not find real Path name of \"" << destFilename << "\"");
m_shortFilename = tmpFilename;
m_folder = destFilename;
} else {
// ALL is OK ...
m_shortFilename = tmpFilename;
m_folder = destFilename;
}
} else {
EDN_WARNING("file : \"" << destFilename << "\" ==> No data???");
// Basic ERROR ...
m_shortFilename = destFilename;
}
} else {
destFilename = buf;
int32_t lastPos = destFilename.FindBack('/');
if (-1 != lastPos) {
m_shortFilename = destFilename.Extract(lastPos+1);
m_folder = destFilename.Extract(0, lastPos);
} else {
// Basic ERROR ...
EDN_WARNING("file : \"" << destFilename << "\" ==> No data???");
m_shortFilename = destFilename;
}
}
EDN_DEBUG("Set FileName :\"" << m_folder << "\" / \"" << m_shortFilename << "\" ");
} }
int32_t Edn::File::GetLineNumber(void) int32_t Edn::File::GetLineNumber(void)
{ {
return m_lineNumberOpen; return m_lineNumberOpen;
} }
void Edn::File::SetLineNumber(int32_t newline)
{
m_lineNumberOpen = newline;
}
bool Edn::File::HasExtention(void)
{
int32_t lastPos = m_shortFilename.FindBack('.');
if( -1 != lastPos // not find the .
&& 0 != lastPos // Find a . at the fist position .jdlskjdfklj ==> hiden file
&& m_shortFilename.Size() != lastPos ) // Remove file ended with .
{
return true;
} else {
return false;
}
}
Edn::String Edn::File::GetExtention(void)
{
Edn::String tmpExt = "";
int32_t lastPos = m_shortFilename.FindBack('.');
if( -1 != lastPos // not find the .
&& 0 != lastPos // Find a . at the fist position .jdlskjdfklj ==> hiden file
&& m_shortFilename.Size() != lastPos ) // Remove file ended with .
{
// Get the FileName
tmpExt = m_shortFilename.Extract(lastPos+1);
}
return tmpExt;
}

View File

@@ -23,31 +23,44 @@
******************************************************************************* *******************************************************************************
*/ */
#ifndef __EDN__FILE_H__
#define __EDN__FILE_H__
#ifndef _IN_NAMESPACE_EDN_ #define MAX_FILE_NAME (10240)
# error This will be include only in "edn.h"
#else
class File namespace Edn
{ {
class File
{
public: public:
File(void) { m_lineNumberOpen=0; } File(void) { m_lineNumberOpen=0; }
File(Edn::String &filename, int32_t LineNumber = 0); File(Edn::String &filename, int32_t LineNumber = 0);
File(const char *filename, int32_t LineNumber = 0);
File(Edn::String &filename, Edn::String &folder, int32_t lineNumber = 0); File(Edn::String &filename, Edn::String &folder, int32_t lineNumber = 0);
~File(void); ~File(void);
Edn::String GetFolder(void); Edn::String GetFolder(void) const;
Edn::String GetShortFilename(void); Edn::String GetShortFilename(void) const;
Edn::String GetCompleateName(void); Edn::String GetCompleateName(void) const;
bool HasExtention(void);
Edn::String GetExtention(void);
int32_t GetLineNumber(void); int32_t GetLineNumber(void);
void SetLineNumber(int32_t newline);
void SetCompleateName(Edn::String &newFilename); void SetCompleateName(Edn::String &newFilename);
const Edn::File& operator= (const Edn::File &ednF );
bool operator== (const Edn::File &ednF ) const;
bool operator!= (const Edn::File &ednF ) const;
friend std::ostream& operator <<( std::ostream &os,const Edn::File &obj);
private : private :
void ExtranctAndName(Edn::String &inputString);
Edn::String m_folder; Edn::String m_folder;
Edn::String m_shortFilename; Edn::String m_shortFilename;
int32_t m_lineNumberOpen; int32_t m_lineNumberOpen;
}; };
std::ostream& operator <<(std::ostream &os, const Edn::File &obj);
}
#endif #endif

View File

@@ -0,0 +1,488 @@
/**
*******************************************************************************
* @file RegExp.cpp
* @brief Editeur De N'ours : Regular expression annalyser (sources)
* @author Edouard DUPIN
* @date 04/04/2011
* @par Project
* Edn
*
* @par Copyright
* Copyright 2010 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
* You can not earn money with this Software (if the source extract from Edn
* represent less than 50% of original Sources)
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include "tools_debug.h"
#include "tools_globals.h"
#include "toolsMemory.h"
#include "RegExp.h"
const convertionTable_ts constConvertionTable[] = {
// haveBackSlash, inputValue, newValue
{ false , '(' , OPCODE_PTHESE_IN},
{ true , '(' , (int16_t)'('},
{ false , ')' , OPCODE_PTHESE_OUT},
{ true , ')' , (int16_t)')'},
{ false , '[' , OPCODE_BRACKET_IN},
{ true , '[' , (int16_t)'['},
{ false , ']' , OPCODE_BRACKET_OUT},
{ true , ']' , (int16_t)']'},
{ false , '{' , OPCODE_BRACE_IN},
{ true , '{' , (int16_t)'{'},
{ false , '}' , OPCODE_BRACE_OUT},
{ true , '}' , (int16_t)'}'},
{ false , '-' , OPCODE_TO},
{ true , '-' , (int16_t)'-'},
{ false , '*' , OPCODE_STAR},
{ true , '*' , (int16_t)'*'},
{ false , '.' , OPCODE_DOT},
{ true , '.' , (int16_t)'.'},
{ false , '?' , OPCODE_QUESTION},
{ true , '?' , (int16_t)'?'},
{ false , '+' , OPCODE_PLUS},
{ true , '+' , (int16_t)'+'},
{ false , '|' , OPCODE_PIPE},
{ true , '|' , (int16_t)'|'},
{ false , '^' , OPCODE_START_OF_LINE},
{ true , '^' , (int16_t)'^'},
{ false , '$' , OPCODE_END_OF_LINE},
{ true , '$' , (int16_t)'$'},
{ true , 'd' , OPCODE_DIGIT},
{ true , 'D' , OPCODE_DIGIT_NOT},
{ true , 'l' , OPCODE_LETTER},
{ true , 'L' , OPCODE_LETTER_NOT},
{ true , 's' , OPCODE_SPACE},
{ true , 'S' , OPCODE_SPACE_NOT},
{ true , 'w' , OPCODE_WORD},
{ true , 'W' , OPCODE_WORD_NOT},
{ true , 'a' , (int16_t)'\a'},
{ true , 'b' , (int16_t)'\b'},
{ true , 'e' , 0x001B}, // Escape character <Esc>
{ true , 'f' , (int16_t)'\f'},
{ true , 'n' , (int16_t)'\n'},
{ true , 'r' , (int16_t)'\r'},
{ true , 't' , (int16_t)'\t'},
{ true , 'v' , (int16_t)'\v'},
{ true , '\\' , (int16_t)'\\'},
{ true , '&' , (int16_t)'&'},
{ true , '0' , (int16_t)'\0'},
{ true , '@' , OPCODE_NO_CHAR},
};
const int32_t constConvertionTableSize = sizeof(constConvertionTable) / sizeof(convertionTable_ts) ;
/**
* @brief Display the internal data of a node
*
* @param[in] data element do display in the console
*
* @return ---
*
*/
void DisplayData(Edn::VectorType<char> &data)
{
int32_t i;
for (i=0; i<(int32_t)data.Size() ; i++) {
std::cout<< (char)(data[i]&0x00FF );
}
}
/**
* @brief Display of a part of the Regexp element
*
* @param[in] data Vector where data is constain
* @param[in] start Position where the display might start
* @param[in] stop Position where the display might stop
*
* @return ---
*
*/
void DisplayElem(Edn::VectorType<int16_t> &data, int32_t start, int32_t stop)
{
int32_t i;
std::cout<< COLOR_NORMAL;
for (i=start; i<(int32_t)data.Size() && i<stop ; i++) {
switch(data[i])
{
case OPCODE_PTHESE_IN: std::cout<<COLOR_RED << (char*)"(" << COLOR_NORMAL; break;
case OPCODE_PTHESE_OUT: std::cout<<COLOR_RED << (char*)")" << COLOR_NORMAL; break;
case OPCODE_BRACKET_IN: std::cout<<COLOR_YELLOW << (char*)"[" << COLOR_NORMAL; break;
case OPCODE_BRACKET_OUT: std::cout<<COLOR_YELLOW << (char*)"]" << COLOR_NORMAL; break;
case OPCODE_TO: std::cout<<COLOR_YELLOW << (char*)"-" << COLOR_NORMAL; break;
case OPCODE_BRACE_IN: std::cout<<COLOR_GREEN << (char*)"{" << COLOR_NORMAL; break;
case OPCODE_BRACE_OUT: std::cout<<COLOR_GREEN << (char*)"}" << COLOR_NORMAL; break;
case OPCODE_STAR: std::cout<<COLOR_BLUE << (char*)"*" << COLOR_NORMAL; break;
case OPCODE_DOT: std::cout<<COLOR_BLUE << (char*)"." << COLOR_NORMAL; break;
case OPCODE_QUESTION: std::cout<<COLOR_BLUE << (char*)"?" << COLOR_NORMAL; break;
case OPCODE_PLUS: std::cout<<COLOR_BLUE << (char*)"+" << COLOR_NORMAL; break;
case OPCODE_PIPE: std::cout<<COLOR_BLUE << (char*)"|" << COLOR_NORMAL; break;
case OPCODE_NO_CHAR: std::cout<<COLOR_MAGENTA << (char*)"@" << COLOR_NORMAL; break;
case OPCODE_START_OF_LINE: std::cout<<COLOR_MAGENTA << (char*)"^" << COLOR_NORMAL; break;
case OPCODE_END_OF_LINE: std::cout<<COLOR_MAGENTA << (char*)"$" << COLOR_NORMAL; break;
case OPCODE_DIGIT: std::cout<<COLOR_MAGENTA << (char*)"\\d" << COLOR_NORMAL; break;
case OPCODE_DIGIT_NOT: std::cout<<COLOR_MAGENTA << (char*)"\\D" << COLOR_NORMAL; break;
case OPCODE_LETTER: std::cout<<COLOR_MAGENTA << (char*)"\\l" << COLOR_NORMAL; break;
case OPCODE_LETTER_NOT: std::cout<<COLOR_MAGENTA << (char*)"\\L" << COLOR_NORMAL; break;
case OPCODE_SPACE: std::cout<<COLOR_MAGENTA << (char*)"\\s" << COLOR_NORMAL; break;
case OPCODE_SPACE_NOT: std::cout<<COLOR_MAGENTA << (char*)"\\S" << COLOR_NORMAL; break;
case OPCODE_WORD: std::cout<<COLOR_MAGENTA << (char*)"\\w" << COLOR_NORMAL; break;
case OPCODE_WORD_NOT: std::cout<<COLOR_MAGENTA << (char*)"\\W" << COLOR_NORMAL; break;
case '\n': std::cout<<COLOR_MAGENTA << (char*)"\\n" << COLOR_NORMAL; break;
case '\t': std::cout<<COLOR_MAGENTA << (char*)"\\t" << COLOR_NORMAL; break;
default: std::cout<< (char)(data[i]&0x00FF ); break;
}
}
}
char * levelSpace(int32_t level)
{
switch(level)
{
case 0: return (char*)"";
case 1: return (char*)" ";
case 2: return (char*)" ";
case 3: return (char*)" ";
case 4: return (char*)" ";
case 5: return (char*)" ";
case 6: return (char*)" ";
case 7: return (char*)" ";
case 8: return (char*)" ";
case 9: return (char*)" ";
case 10: return (char*)" ";
case 11: return (char*)" ";
case 12: return (char*)" ";
case 13: return (char*)" ";
case 14: return (char*)" ";
case 15: return (char*)" ";
case 16: return (char*)" ";
default: return (char*)" ";
}
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
int32_t GetLenOfPTheseElem(Edn::VectorType<int16_t> &data, int32_t startPos)
{
int32_t pos = startPos;
int32_t nbOpen = 0;
// special case of the (...) or | ==> we search '|' or ')'
if( OPCODE_PTHESE_OUT == data[pos]
|| OPCODE_PIPE == data[pos]) {
return 0;
}
// find size ...
while (pos < (int32_t)data.Size() ) {
if(OPCODE_PTHESE_IN == data[pos]) {
// find a sub section :
nbOpen++;
} else if(0 < nbOpen) {
if (OPCODE_PTHESE_OUT == data[pos])
{
nbOpen--;
if (0 > nbOpen) {
EDN_ERROR("Error in the (...) find element at "<< pos);
return -1;
}
}
} else if( OPCODE_PTHESE_OUT == data[pos]
|| OPCODE_PIPE == data[pos])
{
// Find the end of the (...)
// just return the size inside
int32_t sizeInside = pos - startPos;
if (0 >= sizeInside) {
EDN_ERROR("Error in the (...) no data at "<< pos-1);
return -1;
} else {
return sizeInside;
}
}
pos++;
}
return pos - startPos;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
int32_t GetLenOfPThese(Edn::VectorType<int16_t> &data, int32_t startPos)
{
int32_t pos = startPos;
int32_t nbOpen = 0;
// special case of the (...) or | ==> we search '|' or ')'
if( OPCODE_PTHESE_OUT == data[pos]) {
return 0;
} else if( OPCODE_PTHESE_IN == data[pos])
{
pos++;
// find size ...
while (pos < (int32_t)data.Size() ) {
if(OPCODE_PTHESE_IN == data[pos]) {
// find a sub section :
nbOpen++;
} else if(0 < nbOpen) {
if (OPCODE_PTHESE_OUT == data[pos])
{
nbOpen--;
if (0 > nbOpen) {
EDN_ERROR("Error in the (...) find element at "<< pos);
return -1;
}
}
} else if( OPCODE_PTHESE_OUT == data[pos])
{
// Find the end of the (...)
// just return the size inside
int32_t sizeInside = pos - startPos-1;
if (0 >= sizeInside) {
EDN_ERROR("Error in the (...) no data at "<< pos-1);
return -1;
} else {
return sizeInside;
}
}
pos++;
}
} else {
return -1;
}
return 0;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
int32_t GetLenOfBracket(Edn::VectorType<int16_t> &data, int32_t startPos)
{
int32_t pos = startPos;
// special case of the (...) or | ==> we search '|' or ')'
if( OPCODE_BRACKET_OUT == data[pos]) {
return 0;
} else if( OPCODE_BRACKET_IN == data[pos]) {
pos++;
// find size ...
while (pos < (int32_t)data.Size() ) {
if(OPCODE_BRACKET_OUT == data[pos]) {
// Find the end of the [...]
// just return the size inside
int32_t sizeInside = pos - startPos -1 ;
if (0 >= sizeInside) {
EDN_ERROR("Error in the [...] no data at "<< pos-1);
return sizeInside;
} else {
return sizeInside;
}
} else if( OPCODE_TO != data[pos]
&& ( 0 > data[pos]
|| 0xFF < data[pos]) )
{
EDN_ERROR("Error in the [...] not permited element at "<< pos << " '" << (char)data[pos] << "'");
return false;
}
pos++;
}
} else {
return -1;
}
return 0;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
int32_t GetLenOfBrace(Edn::VectorType<int16_t> &data, int32_t startPos)
{
int32_t pos = startPos;
// special case of the (...) or | ==> we search '|' or ')'
if( OPCODE_BRACE_OUT == data[pos]) {
return 0;
} else if( OPCODE_BRACE_IN == data[pos]) {
pos++;
// find size ...
while (pos < (int32_t)data.Size() ) {
if(OPCODE_BRACE_OUT == data[pos]) {
// Find the end of the [...]
// just return the size inside
int32_t sizeInside = pos - startPos -1 ;
if (0 >= sizeInside) {
EDN_ERROR("Error in the {...} no data at "<< pos-1);
return sizeInside;
} else {
return sizeInside;
}
} else if( ',' != data[pos]
&& ( '0' > data[pos]
|| '9' < data[pos]) )
{
EDN_ERROR("Error in the {...} not permited element at "<< pos << " '" << (char)data[pos] << "'");
return false;
}
pos++;
}
} else {
return -1;
}
return 0;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
int32_t GetLenOfNormal(Edn::VectorType<int16_t> &data, int32_t startPos)
{
int32_t pos = startPos;
// find size ...
while (pos < (int32_t)data.Size() ) {
switch(data[pos])
{
case OPCODE_PTHESE_IN:
case OPCODE_PTHESE_OUT:
case OPCODE_BRACKET_IN:
case OPCODE_BRACKET_OUT:
case OPCODE_BRACE_IN:
case OPCODE_BRACE_OUT:
case OPCODE_TO:
case OPCODE_STAR:
case OPCODE_DOT:
case OPCODE_QUESTION:
case OPCODE_PLUS:
case OPCODE_PIPE:
case OPCODE_START_OF_LINE:
case OPCODE_END_OF_LINE:
case OPCODE_DIGIT:
case OPCODE_DIGIT_NOT:
case OPCODE_LETTER:
case OPCODE_LETTER_NOT:
case OPCODE_SPACE:
case OPCODE_SPACE_NOT:
case OPCODE_WORD:
case OPCODE_WORD_NOT:
{
// just return the size inside
int32_t sizeInside = pos - startPos;
if (0 >= sizeInside) {
EDN_ERROR("Error in the normal data : no data ...");
}
return sizeInside;
}
break;
default :
// nothing to do ...
break;
}
pos++;
}
return pos - startPos ;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
bool ParseBrace(Edn::VectorType<int16_t> &data, int32_t &min, int32_t &max)
{
//EDN_INFO("parse {...} in "; DisplayElem(data); );
int32_t k=0;
int32_t firstElement = 0;
int32_t SecondElement = 0;
while(k<data.Size()) {
if (',' == (char)data[k]) {
k++;
break;
} if ('}' == (char)data[k]) {
SecondElement = firstElement;
goto allIsSet;
} else if ('0' <= (char)data[k] && '9' >= (char)data[k]) {
firstElement *=10;
firstElement += (char)data[k] - '0';
} else {
EDN_ERROR("Can not parse this element " << (char)data[k] << " at pos " << k);
return false;
}
k++;
}
if (k==data.Size()) {
SecondElement = firstElement;
}
while(k<data.Size()) {
if (',' == (char)data[k]) {
EDN_ERROR("Can not find a second , in {} at pos " << k);
return false;
} if ('}' == (char)data[k]) {
goto allIsSet;
} else if ('0' <= (char)data[k] && '9' >= (char)data[k]) {
SecondElement *=10;
SecondElement += (char)data[k] - '0';
} else {
EDN_ERROR("Can not parse this element " << (char)data[k] << " at pos " << k);
return false;
}
k++;
}
allIsSet:
if (SecondElement == 0 && firstElement != 0) {
min = 0;
max = firstElement;
} else {
min = firstElement;
max = SecondElement;
}
if (min > max) {
EDN_ERROR("Minimum=" << min << " can not be < maximum=" << max );
return false;
}
return true;
}

File diff suppressed because it is too large Load Diff

View File

@@ -28,8 +28,13 @@
#undef __class__ #undef __class__
#define __class__ "EdnString" #define __class__ "Edn::String"
std::ostream& Edn::operator <<(std::ostream &os, const Edn::String &obj)
{
os << (char*)&obj.m_data[0];
return os;
}
/** /**
* @brief * @brief
@@ -205,7 +210,7 @@ const Edn::String& Edn::String::operator= (const char * inputData)
* @return * @return
* *
*/ */
const Edn::String& Edn::String::operator= (EdnVectorBin<int8_t> inputData) const Edn::String& Edn::String::operator= (Edn::VectorType<int8_t> inputData)
{ {
m_data = inputData; m_data = inputData;
if (m_data.Size()>0) { if (m_data.Size()>0) {
@@ -385,6 +390,9 @@ Edn::String Edn::String::operator+ (const char * inputData)
} }
/** /**
* @brief * @brief
* *
@@ -463,7 +471,7 @@ void Edn::String::Remove(int32_t currentID, int32_t len)
return; return;
} }
// TODO : check the size of the data // TODO : check the size of the data
m_data.Erase(currentID, len); m_data.EraseLen(currentID, len);
} }
@@ -569,13 +577,15 @@ Edn::String Edn::String::Extract(int32_t posStart, int32_t posEnd)
* @return The desired vector with data * @return The desired vector with data
* *
*/ */
EdnVectorBin<int8_t> Edn::String::GetVector(void) Edn::VectorType<int8_t> Edn::String::GetVector(void)
{ {
EdnVectorBin<int8_t> out = m_data; Edn::VectorType<int8_t> out = m_data;
out.PopBack(); out.PopBack();
return out; return out;
} }
/** /**
* @brief Unitary test for the string system * @brief Unitary test for the string system
* *
@@ -592,57 +602,57 @@ void Edn::TestUntaire_String(void)
int32_t iddd = 0; int32_t iddd = 0;
Edn::String * monString = new Edn::String(); Edn::String * monString = new Edn::String();
EDN_INFO("phase : " << iddd++ << " : \"" << monString->c_str() << "\""); EDN_INFO("phase : " << iddd++ << " : \"" << monString << "\"");
delete(monString); delete(monString);
monString = new Edn::String("test de direct data"); monString = new Edn::String("test de direct data");
EDN_INFO("phase : " << iddd++ << " : \"" << monString->c_str() << "\""); EDN_INFO("phase : " << iddd++ << " : \"" << monString << "\"");
delete(monString); delete(monString);
monString = new Edn::String("test de direct data", 7); monString = new Edn::String("test de direct data", 7);
EDN_INFO("phase : " << iddd++ << " : \"" << monString->c_str() << "\""); EDN_INFO("phase : " << iddd++ << " : \"" << monString << "\"");
delete(monString); delete(monString);
int32_t testId = -6789; int32_t testId = -6789;
monString = new Edn::String(testId); monString = new Edn::String(testId);
EDN_INFO("phase : " << iddd++ << " : \"" << monString->c_str() << "\""); EDN_INFO("phase : " << iddd++ << " : \"" << monString << "\"");
delete(monString); delete(monString);
uint32_t testId2 = 12345; uint32_t testId2 = 12345;
monString = new Edn::String((unsigned int)testId2); monString = new Edn::String((unsigned int)testId2);
EDN_INFO("phase : " << iddd++ << " : \"" << monString->c_str() << "\""); EDN_INFO("phase : " << iddd++ << " : \"" << monString << "\"");
delete(monString); delete(monString);
Edn::String plop = "otherString"; Edn::String plop = "otherString";
monString = new Edn::String(plop); monString = new Edn::String(plop);
EDN_INFO("phase : " << iddd++ << " : \"" << monString->c_str() << "\""); EDN_INFO("phase : " << iddd++ << " : \"" << monString << "\"");
delete(monString); delete(monString);
Edn::String s1 = "test de base ..."; Edn::String s1 = "test de base ...";
s1 += s1; s1 += s1;
EDN_INFO("phase : " << iddd++ << " : \"" << s1.c_str() << "\""); EDN_INFO("phase : " << iddd++ << " : \"" << s1 << "\"");
s1 += " plop 2 "; s1 += " plop 2 ";
EDN_INFO("phase : " << iddd++ << " : \"" << s1.c_str() << "\""); EDN_INFO("phase : " << iddd++ << " : \"" << s1 << "\"");
s1 += plop; s1 += plop;
EDN_INFO("phase : " << iddd++ << " : \"" << s1.c_str() << "\""); EDN_INFO("phase : " << iddd++ << " : \"" << s1 << "\"");
s1 = plop; s1 = plop;
EDN_INFO("phase : " << iddd++ << " : \"" << s1.c_str() << "\""); EDN_INFO("phase : " << iddd++ << " : \"" << s1 << "\"");
s1 = "test direct 44"; s1 = "test direct 44";
EDN_INFO("phase : " << iddd++ << " : \"" << s1.c_str() << "\""); EDN_INFO("phase : " << iddd++ << " : \"" << s1 << "\"");
EdnVectorBin<int8_t> vb1; Edn::VectorType<int8_t> vb1;
vb1.PushBack('v'); vb1.PushBack('v');
vb1.PushBack('b'); vb1.PushBack('b');
vb1.PushBack('1'); vb1.PushBack('1');
s1 = vb1; s1 = vb1;
EDN_INFO("phase : " << iddd++ << " : \"" << s1.c_str() << "\""); EDN_INFO("phase : " << iddd++ << " : \"" << s1 << "\"");
vb1.Clear(); vb1.Clear();
vb1.PushBack('v'); vb1.PushBack('v');
vb1.PushBack('b'); vb1.PushBack('b');
vb1.PushBack('2'); vb1.PushBack('2');
vb1.PushBack('\0'); vb1.PushBack('\0');
s1 = vb1; s1 = vb1;
EDN_INFO("phase : " << iddd++ << " : \"" << s1.c_str() << "\""); EDN_INFO("phase : " << iddd++ << " : \"" << s1 << "\"");
if (s1 == "vb2") { if (s1 == "vb2") {
EDN_INFO("phase : " << iddd++ << " : == OK"); EDN_INFO("phase : " << iddd++ << " : == OK");

View File

@@ -22,11 +22,13 @@
* *
******************************************************************************* *******************************************************************************
*/ */
#ifndef __END__STRING_H__
#define __END__STRING_H__
#ifndef _IN_NAMESPACE_EDN_ #include <iostream>
# error This will be include only in "edn.h"
#else
namespace Edn
{
class String class String
{ {
public: public:
@@ -45,7 +47,7 @@
const Edn::String& operator= (const Edn::String &ednS ); // assigment const Edn::String& operator= (const Edn::String &ednS ); // assigment
const Edn::String& operator= (const char * inputData); const Edn::String& operator= (const char * inputData);
const Edn::String& operator= (EdnVectorBin<int8_t> inputData); const Edn::String& operator= (Edn::VectorType<int8_t> inputData);
bool operator== (const Edn::String& ednS) const; // == operator bool operator== (const Edn::String& ednS) const; // == operator
bool operator== (const char * inputData) const; bool operator== (const char * inputData) const;
bool operator!= (const Edn::String& ednS) const; // != operator bool operator!= (const Edn::String& ednS) const; // != operator
@@ -55,7 +57,7 @@
Edn::String operator+ (const Edn::String &ednS); // + operator Edn::String operator+ (const Edn::String &ednS); // + operator
Edn::String operator+ (const char * inputData); Edn::String operator+ (const char * inputData);
//operator const char *() //operator const char *()
friend std::ostream& operator <<( std::ostream &os,const Edn::String &obj);
bool IsEmpty(void) const; bool IsEmpty(void) const;
int32_t Size(void) const; int32_t Size(void) const;
@@ -64,7 +66,7 @@
void Remove(int32_t currentID, int32_t len); void Remove(int32_t currentID, int32_t len);
void Clear(void); void Clear(void);
EdnVectorBin<int8_t> GetVector(void); Edn::VectorType<int8_t> GetVector(void);
char * c_str(void) { return (char*)&m_data[0]; }; char * c_str(void) { return (char*)&m_data[0]; };
// Sting operation : // Sting operation :
@@ -73,10 +75,18 @@
Edn::String Extract(int32_t posStart=0, int32_t posEnd=0x7FFFFFFF); Edn::String Extract(int32_t posStart=0, int32_t posEnd=0x7FFFFFFF);
private : private :
EdnVectorBin<int8_t> m_data; Edn::VectorType<int8_t> m_data;
}; };
void TestUntaire_String(void); void TestUntaire_String(void);
std::ostream& operator <<(std::ostream &os, const Edn::String &obj);
}
#endif #endif

View File

@@ -1,7 +1,7 @@
/** /**
******************************************************************************* *******************************************************************************
* @file EdnEdnVector.h * @file Vector.h
* @brief Editeur De N'ours : Basic EdnVector (template) * @brief Editeur De N'ours : Basic Edn::Vector (template)
* @author Edouard DUPIN * @author Edouard DUPIN
* @date 07/04/2011 * @date 07/04/2011
* @par Project * @par Project
@@ -26,7 +26,7 @@
#define __EDN_EdnVector_H__ #define __EDN_EdnVector_H__
#undef __class__ #undef __class__
#define __class__ "EdnEdnVector" #define __class__ "Edn::Vector"
/** /**
* @brief EdnVector classes ... * @brief EdnVector classes ...
@@ -62,32 +62,35 @@
* ---------- * ----------
* *
*/ */
template<class T, int32_t INC=0> class EdnVector: namespace Edn
{
template<class T, int32_t INC=0> class Vector
{ {
public: public:
class Iterator: class Iterator
{ {
// Private data : // Private data :
private: private:
int32_t m_current; // curent Id on the vector int32_t m_current; // curent Id on the vector
EdnVector<T> * m_EdnVector; // Pointer on the curent element of the vector Edn::Vector<T> * m_Vector; // Pointer on the curent element of the vector
public: public:
/** /**
* @brief Basic itarator constructor with no link with an EdnVector * @brief Basic itarator constructor with no link with an Vector
*/ */
Iterator(): Iterator():
m_current(-1), m_current(-1),
m_EdnVector(NULL) m_Vector(NULL)
{ {
// nothing to do ... // nothing to do ...
} }
/** /**
* @brief Recopy constructor on a specific EdnVector. * @brief Recopy constructor on a specific Vector.
* @param[in] otherIterator The Iterator that might be copy * @param[in] otherIterator The Iterator that might be copy
*/ */
Iterator(const Iterator & otherIterator): Iterator(const Iterator & otherIterator):
m_current(otherIterator.m_current), m_current(otherIterator.m_current),
m_EdnVector(otherIterator.m_EdnVector) m_Vector(otherIterator.m_Vector)
{ {
// nothing to do ... // nothing to do ...
} }
@@ -99,7 +102,7 @@ template<class T, int32_t INC=0> class EdnVector:
Iterator& operator=(const Iterator & otherIterator) Iterator& operator=(const Iterator & otherIterator)
{ {
m_current = otherIterator.m_current; m_current = otherIterator.m_current;
m_EdnVector = otherIterator.m_EdnVector; m_Vector = otherIterator.m_Vector;
return *this; return *this;
} }
/** /**
@@ -108,11 +111,11 @@ template<class T, int32_t INC=0> class EdnVector:
~Iterator() ~Iterator()
{ {
m_current = -1; m_current = -1;
m_EdnVector = NULL; m_Vector = NULL;
} }
/** /**
* @brief basic boolean cast * @brief basic boolean cast
* @return true if the element is present in the EdnVector size * @return true if the element is present in the Vector size
*/ */
operator bool () operator bool ()
{ {
@@ -204,13 +207,13 @@ template<class T, int32_t INC=0> class EdnVector:
* @return --- * @return ---
* *
*/ */
Iterator(EdnVector<T> * EdnVector, int pos): Iterator(Edn::Vector<T> * myVector, int pos):
m_current(pos), m_current(pos),
m_EdnVector(EdnVector) m_Vector(myVector)
{ {
// nothing to do ... // nothing to do ...
} }
friend class EdnVector; friend class Edn::Vector<T>;
}; };
/** /**
@@ -221,7 +224,7 @@ template<class T, int32_t INC=0> class EdnVector:
* @return --- * @return ---
* *
*/ */
EdnVector(int count = 0): Vector(int count = 0):
m_data(NULL), m_data(NULL),
m_count(0), m_count(0),
m_size(0) m_size(0)
@@ -237,15 +240,15 @@ template<class T, int32_t INC=0> class EdnVector:
* @return --- * @return ---
* *
*/ */
EdnVector(const EdnVector<T> & EdnVector): Vector(const Edn::Vector<T> & myVector):
m_size(EdnVector.m_size), m_size(myVector.m_size),
m_count(EdnVector.m_count), m_count(myVector.m_count),
m_data(NULL) m_data(NULL)
{ {
int32_t i; int32_t i;
EDN_MALLOC_CAST(m_data, m_size, T, reinterpret_cast<T*>); EDN_MALLOC_CAST(m_data, m_size, T, reinterpret_cast<T*>);
for(i=0; i<m_count; i++) { for(i=0; i<m_count; i++) {
new (&m_data[i]) T(EdnVector[i]); new (&m_data[i]) T(myVector[i]);
} }
} }
@@ -257,7 +260,7 @@ template<class T, int32_t INC=0> class EdnVector:
* @return --- * @return ---
* *
*/ */
~EdnVector() ~Vector()
{ {
Destroy(); Destroy();
} }
@@ -270,7 +273,7 @@ template<class T, int32_t INC=0> class EdnVector:
* @return --- * @return ---
* *
*/ */
EdnVector& operator=(const EdnVector<T> & EdnVector) Vector& operator=(const Edn::Vector<T> & EdnVector)
{ {
int32_t i; int32_t i;
this->~EdnVector(); this->~EdnVector();
@@ -493,5 +496,11 @@ private:
} }
} }
}; };
}
#undef __class__ #undef __class__
#define __class__ NULL #define __class__ NULL
#endif

View File

@@ -1,7 +1,7 @@
/** /**
******************************************************************************* *******************************************************************************
* @file EdnEdnVectorBin.h * @file VectorType.h
* @brief Editeur De N'ours : Basic EdnVectorBin for direct data insertion (template) * @brief Editeur De N'ours : Basic VectorType for direct data insertion (template)
* @author Edouard DUPIN * @author Edouard DUPIN
* @date 07/04/2011 * @date 07/04/2011
* @par Project * @par Project
@@ -29,15 +29,13 @@
#include "toolsMemory.h" #include "toolsMemory.h"
#undef __class__ #undef __class__
#define __class__ "EdnEdnVectorBin" #define __class__ "Edn::VectorType"
/** /**
* @brief EdnVectorBin classes ... * @brief VectorType classes ...
* *
* @tparam[in] SIZE Size of the current element. * @tparam[in] SIZE Size of the current element.
* *
* @todo : Need to add : popBack / Assign / Insert / Erase / Swap / Clear
*
* m_data * m_data
* <------------ m_dataSize ------------> * <------------ m_dataSize ------------>
* ---------------------------------------- * ----------------------------------------
@@ -65,22 +63,26 @@
* ---------------------------------------- * ----------------------------------------
* *
*/ */
template<typename MY_TYPE=int32_t> class EdnVectorBin
namespace Edn
{
template<typename MY_TYPE=int32_t> class VectorType
{ {
public: public:
class Iterator class Iterator
{ {
// Private data : // Private data :
private: private:
int32_t m_current; // curent Id on the vector int32_t m_current; //!< curent Id on the vector
EdnVectorBin<MY_TYPE> * m_EdnVectorBin; // Pointer on the curent element of the vectorBin VectorType<MY_TYPE> * m_VectorType; //!< Pointer on the curent element of the vectorBin
public: public:
/** /**
* @brief Basic itarator constructor with no link with an EdnVector * @brief Basic itarator constructor with no link with an EdnVector
*/ */
Iterator(): Iterator():
m_current(-1), m_current(-1),
m_EdnVectorBin(NULL) m_VectorType(NULL)
{ {
// nothing to do ... // nothing to do ...
} }
@@ -90,7 +92,7 @@ template<typename MY_TYPE=int32_t> class EdnVectorBin
*/ */
Iterator(const Iterator & otherIterator): Iterator(const Iterator & otherIterator):
m_current(otherIterator.m_current), m_current(otherIterator.m_current),
m_EdnVectorBin(otherIterator.m_EdnVectorBin) m_VectorType(otherIterator.m_VectorType)
{ {
// nothing to do ... // nothing to do ...
} }
@@ -102,7 +104,7 @@ template<typename MY_TYPE=int32_t> class EdnVectorBin
Iterator& operator=(const Iterator & otherIterator) Iterator& operator=(const Iterator & otherIterator)
{ {
m_current = otherIterator.m_current; m_current = otherIterator.m_current;
m_EdnVectorBin = otherIterator.m_EdnVectorBin; m_VectorType = otherIterator.m_VectorType;
return *this; return *this;
} }
/** /**
@@ -111,7 +113,7 @@ template<typename MY_TYPE=int32_t> class EdnVectorBin
~Iterator() ~Iterator()
{ {
m_current = -1; m_current = -1;
m_EdnVectorBin = NULL; m_VectorType = NULL;
} }
/** /**
* @brief basic boolean cast * @brief basic boolean cast
@@ -120,7 +122,7 @@ template<typename MY_TYPE=int32_t> class EdnVectorBin
operator bool () operator bool ()
{ {
if( 0 <= m_current if( 0 <= m_current
&& m_current < m_EdnVectorBin->Size() ) && m_current < m_VectorType->Size() )
{ {
return true; return true;
} else { } else {
@@ -133,8 +135,8 @@ template<typename MY_TYPE=int32_t> class EdnVectorBin
*/ */
Iterator& operator++ () Iterator& operator++ ()
{ {
if( NULL != m_EdnVectorBin if( NULL != m_VectorType
&& m_current < m_EdnVectorBin->Size() ) && m_current < m_VectorType->Size() )
{ {
m_current++; m_current++;
} }
@@ -177,8 +179,8 @@ template<typename MY_TYPE=int32_t> class EdnVectorBin
*/ */
MY_TYPE & operator-> () const MY_TYPE & operator-> () const
{ {
EDN_CHECK_INOUT(m_current >= 0 && m_current < m_EdnVectorBin->Size()); EDN_CHECK_INOUT(m_current >= 0 && m_current < m_VectorType->Size());
return &m_EdnVectorBin->Get(m_current); return &m_VectorType->Get(m_current);
} }
/** /**
* @brief Get reference on the current Element * @brief Get reference on the current Element
@@ -186,8 +188,8 @@ template<typename MY_TYPE=int32_t> class EdnVectorBin
*/ */
MY_TYPE & operator* () const MY_TYPE & operator* () const
{ {
EDN_CHECK_INOUT(m_current >= 0 && m_current < m_EdnVectorBin->Size()); EDN_CHECK_INOUT(m_current >= 0 && m_current < m_VectorType->Size());
return m_EdnVectorBin->Get(m_current); return m_VectorType->Get(m_current);
} }
private: private:
/** /**
@@ -198,13 +200,13 @@ template<typename MY_TYPE=int32_t> class EdnVectorBin
* @return --- * @return ---
* *
*/ */
Iterator(EdnVectorBin<MY_TYPE> * Evb, int32_t pos): Iterator(VectorType<MY_TYPE> * Evb, int32_t pos):
m_current(pos), m_current(pos),
m_EdnVectorBin(Evb) m_VectorType(Evb)
{ {
// nothing to do ... // nothing to do ...
} }
friend class EdnVectorBin; friend class VectorType;
}; };
private: private:
@@ -217,7 +219,7 @@ template<typename MY_TYPE=int32_t> class EdnVectorBin
* @brief Create an empty vector * @brief Create an empty vector
* @param[in] count Minimum request size of the Buffer * @param[in] count Minimum request size of the Buffer
*/ */
EdnVectorBin(int32_t count = 0): VectorType(int32_t count = 0):
m_data(NULL), m_data(NULL),
m_size(0), m_size(0),
m_allocated(0), m_allocated(0),
@@ -230,7 +232,7 @@ template<typename MY_TYPE=int32_t> class EdnVectorBin
* @brief Re-copy constructor (copy all needed data) * @brief Re-copy constructor (copy all needed data)
* @param[in] Evb Vector that might be copy * @param[in] Evb Vector that might be copy
*/ */
EdnVectorBin(const EdnVectorBin<MY_TYPE> & Evb) VectorType(const Edn::VectorType<MY_TYPE> & Evb)
{ {
m_allocated = Evb.m_allocated; m_allocated = Evb.m_allocated;
m_size = Evb.m_size; m_size = Evb.m_size;
@@ -247,7 +249,7 @@ template<typename MY_TYPE=int32_t> class EdnVectorBin
/** /**
* @brief Destructor of the current Class * @brief Destructor of the current Class
*/ */
~EdnVectorBin() ~VectorType()
{ {
if (NULL!=m_data) { if (NULL!=m_data) {
EDN_FREE(m_data); EDN_FREE(m_data);
@@ -263,7 +265,7 @@ template<typename MY_TYPE=int32_t> class EdnVectorBin
* @param[in] Evb Vector that might be copy * @param[in] Evb Vector that might be copy
* @return reference on the curent re-copy vector * @return reference on the curent re-copy vector
*/ */
EdnVectorBin& operator=(const EdnVectorBin<MY_TYPE> & Evb) VectorType& operator=(const Edn::VectorType<MY_TYPE> & Evb)
{ {
//EDN_DEBUG("USE RECOPY vector ... Evb.m_size=" << Evb.m_size << " Evb.m_increment=" << Evb.m_increment); //EDN_DEBUG("USE RECOPY vector ... Evb.m_size=" << Evb.m_size << " Evb.m_increment=" << Evb.m_increment);
if( this != &Evb ) // avoid copy to itself if( this != &Evb ) // avoid copy to itself
@@ -290,7 +292,7 @@ template<typename MY_TYPE=int32_t> class EdnVectorBin
* @brief Add at the Last position of the Vector * @brief Add at the Last position of the Vector
* @param[in] item Element to add at the end of vector * @param[in] item Element to add at the end of vector
*/ */
EdnVectorBin& operator+= (const EdnVectorBin<MY_TYPE> & Evb) // += operator VectorType& operator+= (const Edn::VectorType<MY_TYPE> & Evb) // += operator
{ {
int32_t nbElememt = Evb.Size(); int32_t nbElememt = Evb.Size();
int32_t idx = m_size; int32_t idx = m_size;
@@ -472,7 +474,33 @@ template<typename MY_TYPE=int32_t> class EdnVectorBin
} }
/** /**
* @brief Remove one element * @brief Remove N elements
*
* @param[in] pos Position to remove the data
* @param[in] posEnd Last position number
*
* @return ---
*
*/
void Erase(int32_t pos, int32_t posEnd)
{
if (pos>m_size) {
EDN_ERROR(" can not Erase Element at this position : " << pos << " > " << m_size);
return;
}
if (posEnd>m_size) {
posEnd = m_size;
}
int32_t nbElement = m_size - pos;
int32_t tmpSize = m_size;
// move curent data
memmove((m_data + pos), (m_data + pos + nbElement), (tmpSize - (pos+nbElement))*sizeof(MY_TYPE) );
// Request resize of the current buffer
Resize(m_size-nbElement);
}
/**
* @brief Remove N element
* *
* @param[in] pos Position to remove the data * @param[in] pos Position to remove the data
* @param[in] nbElement number of element to remove * @param[in] nbElement number of element to remove
@@ -480,10 +508,10 @@ template<typename MY_TYPE=int32_t> class EdnVectorBin
* @return --- * @return ---
* *
*/ */
void Erase(int32_t pos, int32_t nbElement) void EraseLen(int32_t pos, int32_t nbElement)
{ {
if (pos>m_size) { if (pos>m_size) {
EDN_ERROR(" can not Erase Element at this position : " << pos << " > " << m_size); EDN_ERROR(" can not Erase Len Element at this position : " << pos << " > " << m_size);
return; return;
} }
if (pos+nbElement>m_size) { if (pos+nbElement>m_size) {
@@ -502,9 +530,9 @@ template<typename MY_TYPE=int32_t> class EdnVectorBin
* @param[in] posEnd End position to extract data * @param[in] posEnd End position to extract data
* @return the extracted vector * @return the extracted vector
*/ */
EdnVectorBin Extract(int32_t posStart = 0, int32_t posEnd=0x7FFFFFFF) VectorType Extract(int32_t posStart = 0, int32_t posEnd=0x7FFFFFFF)
{ {
EdnVectorBin<MY_TYPE> out; VectorType<MY_TYPE> out;
if (posStart < 0) { if (posStart < 0) {
posStart = 0; posStart = 0;
} else if (posStart >= Size() ) { } else if (posStart >= Size() ) {
@@ -633,10 +661,11 @@ template<typename MY_TYPE=int32_t> class EdnVectorBin
// set the new allocation size // set the new allocation size
m_allocated = requestSize; m_allocated = requestSize;
} }
}; };
}
#undef __class__ #undef __class__
#define __class__ NULL #define __class__ NULL
#endif #endif

View File

@@ -101,14 +101,14 @@ void convertUnicodeToIso(charset_te inputCharset, int32_t input_Unicode, char &
} }
int32_t convertIsoToUnicode(charset_te inputCharset, EdnVectorBin<char>& input_ISO, EdnVectorBin<int32_t>& output_Unicode) int32_t convertIsoToUnicode(charset_te inputCharset, Edn::VectorType<char>& input_ISO, Edn::VectorType<int32_t>& output_Unicode)
{ {
EDN_WARNING("TODO : not coded..."); EDN_WARNING("TODO : not coded...");
return 0; return 0;
} }
int32_t convertUnicodeToIso(charset_te inputCharset, EdnVectorBin<int32_t>& input_Unicode, EdnVectorBin<char>& output_ISO) int32_t convertUnicodeToIso(charset_te inputCharset, Edn::VectorType<int32_t>& input_Unicode, Edn::VectorType<char>& output_ISO)
{ {
EDN_WARNING("TODO : not coded..."); EDN_WARNING("TODO : not coded...");
return 0; return 0;
@@ -204,14 +204,14 @@ void convertUtf8ToUnicode(char * input_UTF8, int32_t &output_Unicode)
} }
int32_t convertUnicodeToUtf8(EdnVectorBin<int32_t>& input_Unicode, EdnVectorBin<char>& output_UTF8) int32_t convertUnicodeToUtf8(Edn::VectorType<int32_t>& input_Unicode, Edn::VectorType<char>& output_UTF8)
{ {
EDN_WARNING("TODO : not coded..."); EDN_WARNING("TODO : not coded...");
return 0; return 0;
} }
int32_t convertUtf8ToUnicode(EdnVectorBin<char>& input_UTF8, EdnVectorBin<int32_t>& output_Unicode) int32_t convertUtf8ToUnicode(Edn::VectorType<char>& input_UTF8, Edn::VectorType<int32_t>& output_Unicode)
{ {
EDN_WARNING("TODO : not coded..."); EDN_WARNING("TODO : not coded...");
return 0; return 0;
@@ -239,14 +239,14 @@ void convertUtf8ToIso(charset_te inputCharset, char * input_UTF8, char & output
} }
int32_t convertIsoToUtf8(charset_te inputCharset, EdnVectorBin<char>& input_ISO, EdnVectorBin<char>& output_UTF8) int32_t convertIsoToUtf8(charset_te inputCharset, Edn::VectorType<char>& input_ISO, Edn::VectorType<char>& output_UTF8)
{ {
EDN_WARNING("TODO : not coded..."); EDN_WARNING("TODO : not coded...");
return 0; return 0;
} }
int32_t convertUtf8ToIso(charset_te inputCharset, EdnVectorBin<char>& input_UTF8, EdnVectorBin<char>& output_ISO) int32_t convertUtf8ToIso(charset_te inputCharset, Edn::VectorType<char>& input_UTF8, Edn::VectorType<char>& output_ISO)
{ {
EDN_WARNING("TODO : not coded..."); EDN_WARNING("TODO : not coded...");
return 0; return 0;
@@ -301,6 +301,7 @@ void Utf8_SizeElement(const char * data, int32_t lenMax , uint8_t &size, bool &b
} }
} }
#if 0 // Remove for the moment ...
/** /**
* @brief Get the number of element of the previous UTF8 char (in the curent Buffer) * @brief Get the number of element of the previous UTF8 char (in the curent Buffer)
* *
@@ -349,7 +350,7 @@ static void Utf8_SizePreviousElement(const char * data, int32_t lenMax, uint8_t
size = 1; size = 1;
} }
} }
#endif
/** /**
* @brief * @brief
@@ -421,7 +422,11 @@ static uint32_t Utf8_GetValue(UTF8Element_ts &Element)
int32_t strUtf8Len(const char *input_UTF8) int32_t strUtf8Len(const char *input_UTF8)
{ {
int32_t count = 0; int32_t count = 0;
int32_t size = strlen(input_UTF8); int32_t sizeInput = strlen(input_UTF8);
int32_t size = sizeInput;
if (size>20) {
EDN_DEBUG("check SIZE...");
}
uint8_t tmpSize; uint8_t tmpSize;
bool baseValid; bool baseValid;
while (size > 0) { while (size > 0) {
@@ -592,18 +597,18 @@ void ConvertInput(GdkEventKey *event, char* Utf8Out, bool &controlKey, bool &mov
# elif USE_GTK_VERSION_2_0 # elif USE_GTK_VERSION_2_0
case GDK_KP_Tab: case GDK_KP_Tab:
# endif # endif
// shift + TAB ... same as a tab here ...
case 0xfe20: //GDK_ISO_Left_Tab
case 65289: case 65289:
key = (int32_t)'\t'; key = (int32_t)'\t';
break; break;
# ifdef USE_GTK_VERSION_3_0 # ifdef USE_GTK_VERSION_3_0
case GDK_KEY_KP_Enter: case GDK_KEY_KP_Enter:
key = GDK_KEY_Return;
break;
# elif USE_GTK_VERSION_2_0 # elif USE_GTK_VERSION_2_0
case GDK_KP_Enter: case GDK_KP_Enter:
key = GDK_Return;
break;
# endif # endif
key = '\n';
break;
# ifdef USE_GTK_VERSION_3_0 # ifdef USE_GTK_VERSION_3_0
case GDK_KEY_KP_F1: case GDK_KEY_KP_F1:
case GDK_KEY_F1: case GDK_KEY_F1:
@@ -1037,17 +1042,129 @@ void ConvertInput(GdkEventKey *event, char* Utf8Out, bool &controlKey, bool &mov
# endif # endif
key = 0x08; key = 0x08;
break; break;
# ifdef USE_GTK_VERSION_3_0
case GDK_KEY_dead_grave:
case GDK_KEY_dead_acute:
case GDK_KEY_dead_circumflex:
case GDK_KEY_dead_tilde:
case GDK_KEY_dead_macron:
case GDK_KEY_dead_breve:
case GDK_KEY_dead_abovedot:
case GDK_KEY_dead_diaeresis:
case GDK_KEY_dead_abovering:
case GDK_KEY_dead_doubleacute:
case GDK_KEY_dead_caron:
case GDK_KEY_dead_cedilla:
case GDK_KEY_dead_ogonek:
case GDK_KEY_dead_iota:
case GDK_KEY_dead_voiced_sound:
case GDK_KEY_dead_semivoiced_sound:
case GDK_KEY_dead_belowdot:
case GDK_KEY_dead_hook:
case GDK_KEY_dead_horn:
case GDK_KEY_dead_stroke:
case GDK_KEY_dead_abovecomma:
case GDK_KEY_dead_abovereversedcomma:
case GDK_KEY_dead_doublegrave:
case GDK_KEY_dead_belowring:
case GDK_KEY_dead_belowmacron:
case GDK_KEY_dead_belowcircumflex:
case GDK_KEY_dead_belowtilde:
case GDK_KEY_dead_belowbreve:
case GDK_KEY_dead_belowdiaeresis:
case GDK_KEY_dead_invertedbreve:
case GDK_KEY_dead_belowcomma:
case GDK_KEY_dead_currency:
case GDK_KEY_dead_a:
case GDK_KEY_dead_A:
case GDK_KEY_dead_e:
case GDK_KEY_dead_E:
case GDK_KEY_dead_i:
case GDK_KEY_dead_I:
case GDK_KEY_dead_o:
case GDK_KEY_dead_O:
case GDK_KEY_dead_u:
case GDK_KEY_dead_U:
case GDK_KEY_dead_small_schwa:
case GDK_KEY_dead_capital_schwa:
# elif USE_GTK_VERSION_2_0
case GDK_dead_grave:
case GDK_dead_acute:
case GDK_dead_circumflex:
key = '^';
break;
case GDK_dead_tilde:
case GDK_dead_macron:
case GDK_dead_breve:
case GDK_dead_abovedot:
case GDK_dead_diaeresis:
case GDK_dead_abovering:
case GDK_dead_doubleacute:
case GDK_dead_caron:
case GDK_dead_cedilla:
case GDK_dead_ogonek:
case GDK_dead_iota:
case GDK_dead_voiced_sound:
case GDK_dead_semivoiced_sound:
case GDK_dead_belowdot:
case GDK_dead_hook:
case GDK_dead_horn:
case GDK_dead_stroke:
case GDK_dead_abovecomma:
case GDK_dead_abovereversedcomma:
case GDK_dead_doublegrave:
case GDK_dead_belowring:
case GDK_dead_belowmacron:
case GDK_dead_belowcircumflex:
case GDK_dead_belowtilde:
case GDK_dead_belowbreve:
case GDK_dead_belowdiaeresis:
case GDK_dead_invertedbreve:
case GDK_dead_belowcomma:
case GDK_dead_currency:
key = '?';
break;
case GDK_dead_a:
EDN_INFO("dead a");
//key = 'a';
break;
case GDK_dead_A:
case GDK_dead_e:
case GDK_dead_E:
case GDK_dead_i:
case GDK_dead_I:
case GDK_dead_o:
case GDK_dead_O:
case GDK_dead_u:
case GDK_dead_U:
case GDK_dead_small_schwa:
case GDK_dead_capital_schwa:
# endif
key = '?';
break;
# ifdef USE_GTK_VERSION_3_0
case GDK_KEY_Caps_Lock:
# elif USE_GTK_VERSION_2_0
case GDK_Caps_Lock:
# endif
controlKey = true;
break;
default: default:
break; break;
} }
// Transform in unicode the input : // Transform in unicode the input :
//EDN_INFO("key : " << key);
int32_t unichar = gdk_keyval_to_unicode(key); int32_t unichar = gdk_keyval_to_unicode(key);
//EDN_INFO("unichar : " << unichar);
if (unichar == 0) { if (unichar == 0) {
Utf8Out[0] = (char)key; Utf8Out[0] = (char)key;
Utf8Out[1] = '\0'; Utf8Out[1] = '\0';
//EDN_INFO("NON UTF8 : " << Utf8Out);
} else { } else {
// Generate UTF8 form UniCode // Generate UTF8 form UniCode
convertUnicodeToUtf8(unichar, Utf8Out); convertUnicodeToUtf8(unichar, Utf8Out);
//EDN_INFO("UTF8 : " << Utf8Out);
#if 0 #if 0
printf(" convertUnicodeToUtf8 : \"0x%08x\" ==> unichar=%d %s\n", key, unichar, Utf8Out); printf(" convertUnicodeToUtf8 : \"0x%08x\" ==> unichar=%d %s\n", key, unichar, Utf8Out);
for (int32_t uu=0; uu < strlen(Utf8Out); uu++) { for (int32_t uu=0; uu < strlen(Utf8Out); uu++) {

View File

@@ -26,7 +26,7 @@
#ifndef __CHARSET_H__ #ifndef __CHARSET_H__
#define __CHARSET_H__ #define __CHARSET_H__
#include "EdnVectorBin.h" #include "VectorType.h"
typedef enum { typedef enum {
EDN_CHARSET_UTF8, EDN_CHARSET_UTF8,
@@ -49,18 +49,18 @@ typedef enum {
// transform ISO <==> Unicode // transform ISO <==> Unicode
void convertIsoToUnicode(charset_te inputCharset, char input_ISO, int32_t & output_Unicode); void convertIsoToUnicode(charset_te inputCharset, char input_ISO, int32_t & output_Unicode);
void convertUnicodeToIso(charset_te inputCharset, int32_t input_Unicode, char & output_ISO); void convertUnicodeToIso(charset_te inputCharset, int32_t input_Unicode, char & output_ISO);
int32_t convertIsoToUnicode(charset_te inputCharset, EdnVectorBin<char>& input_ISO, EdnVectorBin<int32_t>& output_Unicode); int32_t convertIsoToUnicode(charset_te inputCharset, Edn::VectorType<char>& input_ISO, Edn::VectorType<int32_t>& output_Unicode);
int32_t convertUnicodeToIso(charset_te inputCharset, EdnVectorBin<int32_t>& input_Unicode, EdnVectorBin<char>& output_ISO); int32_t convertUnicodeToIso(charset_te inputCharset, Edn::VectorType<int32_t>& input_Unicode, Edn::VectorType<char>& output_ISO);
// Transform UTF-8 <==> Unicode // Transform UTF-8 <==> Unicode
void convertUnicodeToUtf8( int32_t input_Unicode, char * output_UTF8); void convertUnicodeToUtf8( int32_t input_Unicode, char * output_UTF8);
void convertUtf8ToUnicode( char * input_UTF8, int32_t& output_Unicode); void convertUtf8ToUnicode( char * input_UTF8, int32_t& output_Unicode);
int32_t convertUnicodeToUtf8( EdnVectorBin<int32_t>& input_Unicode, EdnVectorBin<char>& output_UTF8); int32_t convertUnicodeToUtf8( Edn::VectorType<int32_t>& input_Unicode, Edn::VectorType<char>& output_UTF8);
int32_t convertUtf8ToUnicode( EdnVectorBin<char>& input_UTF8, EdnVectorBin<int32_t>& output_Unicode); int32_t convertUtf8ToUnicode( Edn::VectorType<char>& input_UTF8, Edn::VectorType<int32_t>& output_Unicode);
// Transform ISO <==> UTF-8 // Transform ISO <==> UTF-8
void convertIsoToUtf8( charset_te inputCharset, char input_ISO, char * output_UTF8); void convertIsoToUtf8( charset_te inputCharset, char input_ISO, char * output_UTF8);
void convertUtf8ToIso( charset_te inputCharset, char * input_UTF8, char & output_ISO); void convertUtf8ToIso( charset_te inputCharset, char * input_UTF8, char & output_ISO);
int32_t convertIsoToUtf8( charset_te inputCharset, EdnVectorBin<char>& input_ISO, EdnVectorBin<char>& output_UTF8); int32_t convertIsoToUtf8( charset_te inputCharset, Edn::VectorType<char>& input_ISO, Edn::VectorType<char>& output_UTF8);
int32_t convertUtf8ToIso( charset_te inputCharset, EdnVectorBin<char>& input_UTF8, EdnVectorBin<char>& output_ISO); int32_t convertUtf8ToIso( charset_te inputCharset, Edn::VectorType<char>& input_UTF8, Edn::VectorType<char>& output_ISO);
void Utf8_SizeElement(const char * data, int32_t lenMax , uint8_t &size, bool &baseValid); void Utf8_SizeElement(const char * data, int32_t lenMax , uint8_t &size, bool &baseValid);
int32_t strUtf8Len(const char *input_UTF8); int32_t strUtf8Len(const char *input_UTF8);

View File

@@ -26,14 +26,11 @@
#include "tools_globals.h" #include "tools_globals.h"
#include "ColorizeManager.h" #include "ColorizeManager.h"
#include "MsgBroadcast.h" #include "MsgBroadcast.h"
#include <string>
#undef __class__ #undef __class__
#define __class__ "globals" #define __class__ "globals"
// Variables privé du namespace
static std::string curentFileName = "???";
erreurCode_te globals::init(void) erreurCode_te globals::init(void)
@@ -201,36 +198,3 @@ bool globals::IsSetInsert(void)
/*
* Basic GUI system :
*
*
*
*
*/
void globals::DisplaySystemString(std::vector<int32_t> &data)
{
// Display the copyed data ...
uint32_t i;
EDN_INFO("Display Data : ");
printf(" ========================================================\n");
for(i=0; i<data.size(); i++) {
# ifdef USE_GTK_VERSION_2_0
if (GDK_Return == data[i]) {
# elif USE_GTK_VERSION_3_0
if (GDK_KEY_Return == data[i]) {
# endif
printf("\n = ");
} else {
printf("%c", (char)data[i]);
}
}
printf("\n ========================================================\n");
}

View File

@@ -27,8 +27,6 @@
#define __TOOLS_GLOBALS_H__ #define __TOOLS_GLOBALS_H__
#include "tools_debug.h" #include "tools_debug.h"
#include <string>
#include <vector>
namespace globals namespace globals
{ {
@@ -63,7 +61,6 @@ namespace globals
void UnSetInsert(void); void UnSetInsert(void);
void ToggleInsert(void); void ToggleInsert(void);
bool IsSetInsert(void); bool IsSetInsert(void);
void DisplaySystemString(std::vector<int32_t> &data);
} }
#endif #endif

View File

@@ -1,142 +1,69 @@
/* pour voir les appels system*/ # action a faire (ordonner par r<>vision) :
* 0.2.X :
# For the first realease : - gui : Amelioration du full-screen et du display de base (sans l'entete de la fenetre)
* Syst<73>mes : - gui : display partielle de la fenetre
- Affichage ligne par ligne
- Correction du bug de hl(sub patern empty)
- Verifier si le hldisplay reaserch marche avec l'id et pas l'id-1
- Gestion correct des charsets
* Gui :
- Confirmer avant de fermer
- Demander de sauver
- Controle des droits
- Hl-gui management
- Event quand un fichier ouvert a changer
- Affichage des fichiers binaires
- Ctags phase 1
- Project manager phase 1
# action a faire (ordonner) :
- sys : la methode de close est mauvaise...
- gui : Goto line (need only the gui)
- ctags : Back simple et multiple
- ctags : Multiple files
- sys : search complet, replace complet
- gui : ordonner les fichier ouvert par nom ...
- sys : Mise en place des colorisation de base pour le
* xml
* makefiles
* script bash
* python
* matlab
* java script
* SQL
* Assembleur
- project : list of current files open
- gui : demander l'enregistrement avant de fermer (quand c'est n<>cessaire)
- gui : demande de cr<63>ation de nouveaux fichier ou quiter l'editeur ...
- gui : ascenceur quand n<>cessaire - gui : ascenceur quand n<>cessaire
- gui : Demander la cr<63>ation de nouveaux fichier quand il n'existe pas (a l'ouverture en ligne de commande) - gui : Demander la cr<63>ation de nouveaux fichier quand il n'existe pas (a l'ouverture en ligne de commande)
- Catch Shift+TAB - sys : Mise en place des colorisation de base pour le
- Correction du bug de display quand on vas vers la fin, et mise en place d'un display qui met toujours le meme temps * java script
- Correction du bug des entr<74> bizard tel que les chapot et les guillemets * SQL
- gui : Parameters : et en autre la taille de la police ... et voir pour la r<>cup<75>rer sur le system... et ce serait cool... - sys : replace TAB with space when Tab is pressed
- PB de copier coller sur les <20><> ... - sys : Catch F[1-12] ==> for user personal event
- Charset UTF-8 et iso 8859-15 correcte - BUG : Correction du bug des entr<74> bizard tel que les chapot et les guillemets
- Transformation de charset a la vol<6F> - BUG : de copier coller sur les <20><><EFBFBD> ...
- Charset par defaut - BUG : les caract<63>re multiples type chapot ...
- D<EFBFBD>ction de charset (<28> mettre dans les todo de charset) - BUG : italique non g<>n<EFBFBD>r<EFBFBD>
* 0.3.X :
- SEARCH : get selected text in the search windows
# Text Editor - SEARCH : Select the search windows when call crtl+F
- sys : personal property file in the ~/.edn ou ~/.gnome/edn
- [1] 0% Indent group with Tabulation and shift+tabulation - gui : Ordonner les fichier ouvert par nom ...
- [1] 0% Basic smart indent : Recopy the start of the previous line when return (copy '\t' and ' ') - gui : parameter gui : et en autre la taille de la police ... et voir pour la r<>cup<75>rer sur le system... et ce serait cool...
- [1] 0% Replace Tab with space when press the key - gui : Color list selection
- [1] 0% Request save user when quit the software - gui : Hightlight gui management
- [1] 0% Hide/Display scroll element when not usefull * 0.4.X :
- [1] 0% Regular expression search - sys : Charset UTF-8 et iso 8859-15 correcte
- [1] 80% Colorisation syntaxique - sys : Transformation de charset a la vol<6F>e
- [1] 80% Copier / coller ==> probleme sur les caract<63>res sp<73>ciaux comme <20> <20> <20> ... - sys : Charset par defaut
- [1] 10% Search - Sys : D<>tection de charset (<28> mettre dans les todo de charset)
- [1] 10% Replace ==> regarder les librairies open sources
- [1] 80% Undo / Redo ajout de caract<63>res autre que " ", "\t" et "\n" * 0.5.X :
- [2] 0% Selectionner en colone - prj : list of current files open
- [2] 0% Supression multiple de ligne par la commande ctrl+D - prj : open ctags file
- [3] 0% Multi-file search ==> display it in a result buffer (clickable only) - sys : replace ALL
- [3] 0% basic UTF8 string management ==> bad with the curent buffer - sys : Undo / Redo ajout de caract<63>res autre que " ", "\t" et "\n"
- [5] 0% Replace in all elements of the project file or a part * 0.6.X :
- [5] 0% Multiple Text Editor in the same Time - sys : right management ...
- [5] 0% Support des Macros ==> In python ??? or other ... - HL : Normalyse all the system of regular expression with <> chapot ...
- HL : sub parsing of the reg exp
# Ctags : - sys : update all language
- [1] 100% Parse (use the ctags parser) * 0.7.X :
- [1] 50% Find - sys : Select in colones
- [1] 50% Jump - sys : Select all the same search in the current buffer ... ( HL en vert ou jaune ...)
- [1] 10% History of move (with display) - sys : Multi-file search ==> display it in a result buffer (clickable only)
* 0.9.X :
# Buffer Viewer : - int : Redo all the doxygen ...
- [1] 0% Right menu * 1.0.X :
- [1] 100% Display buffer in color - gui : open file in binary
- [1] 100% Display buffer Saved / not Saved - sys : compare binary files
- [2] 0% Image of the type of buffer (optionnal) - sys : compare normal files
* 1.1.X :
# Configuration : - gui : Display content of a folder
- [1] 0% Creer une IHM pour les configurations de base - gui : add a treeview display
- [1] 0% Creer une IHM pour l'edition du hightliner syntaxique (quand il marchera...) - sys : evenement losqu'un fichier est modifier a l'exterieur...
- [1] 0% Creer une IHM pour les couleurs (voir la lier avec l'IHM pour le hightliner) - sys : image du type de fichier dans le buffer list view
- [1] 0% saugegarde automatique de la configuration ou sur demande... * 1.2.X :
- PRJ : treeview des dossier a ouvrir
# Project manager : - PRJ : GUI de management
- [2] 0% Faire un editeur des dossiers du projet a ouvrir ==> automatiquement ajouter dans les Ctags - PRJ : Save all in project
- [2] 0% Base - SYS : Save all modify files
- [2] 0% Save All * 1.3.X :
- [2] 0% TreeView - sys : version system management (git, cvs, ...)
* 1.4.X :
# Tree View : - SYS : Macro generation and acquisition
- [2] 0% View * 1.5.X :
- [2] 0% Open File - GDB : Acces interne pour un debuggeur ==> comme cgdb ... avec l'acces assembleur en plus
- [2] 0% Jump to the curent File
- [2] 0% Hide CVS / Git / SVN elements
# Diff :
- [4] 0% generate a Diff between files
- [4] 0% same in binary
# Git :
- [4] 0% Diff with the current wersion commited (local)
- [9] 0% Git branch local display (as gitk --all) ...
- [4] 0% view git chawan history ... (git Log)
# CVS :
- [6] 0% check the version with CVS
- [6] 0% commit
- [6] 0% display the Branch
- [6] 0% Select a new repository ...
# Publication :
- [1] 0% faire une publication du logiciel sur le Web... (need a stable version)
- [2] 0% faire un package
# Repository :
- [2] 0% create my own repository (@home)
- [2] 0% manage right with Git
- [2] 0% create a website fot it (@home)
- [2] 0% reserve edn.org
# plugin : (never i think ...)
- [ ] 0% Comprendre comment faire un system avec des plugin (interne et simple)...
- [ ] 0% En c++ compiler seulement, pas d'interface pyton ou autre c'est trop moche.
# notes :
The [x] Represent the version expected of the feature
# Global TODO List:
- [1] 0% EdnString ==> a revoir pour etre plus rapide et plus compl<70>te... et suporter le << et >>
- [1] 0% Remove wxString from the current code...
# note utiles : # note utiles :
http://majutsushi.github.com/tagbar/ ==> je devrais regarder ca pour savoir ce que je peux faire avec du ctags http://majutsushi.github.com/tagbar/ ==> je devrais regarder ca pour savoir ce que je peux faire avec du ctags
CTags : Set the parsing methode : "ctags -R --fields=+n Sources/ /usr/include/gtk-3.0/"

View File

@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<EdnColor version="0.1"> <EdnColor version="0.1">
<gui> <!-- Doivent tous y <20>tre de prf<72>rence ... global system acces --> <gui> <!-- Doivent tous y <20>tre de prf<72>rence ... global system acces -->
<color name="CODE_basicBackgroung" val="#151515"/>
<color name="CODE_space" val="#333333"/> <color name="CODE_space" val="#333333"/>
<color name="CODE_tabulation" val="#444444"/> <color name="CODE_tabulation" val="#444444"/>
<color name="CODE_basicBackgroung" val="#151515"/>
<color name="CODE_cursor" val="#eadd05"/> <color name="CODE_cursor" val="#eadd05"/>
<color name="CODE_lineNumber" val="#fff725"/> <color name="CODE_lineNumber" val="#fff725"/>
<!-- Buffer list property --> <!-- Buffer list property -->
@@ -16,7 +16,6 @@
<syntax> <syntax>
<color name="normal" FG="#EEEEEE"/> <color name="normal" FG="#EEEEEE"/>
<color name="SelectedText" FG="#AAAAAA" BG="#225a09"/> <color name="SelectedText" FG="#AAAAAA" BG="#225a09"/>
<color name="SelectedNoText" BG="#124a00"/>
<color name="error" FG="#FF0000"/> <color name="error" FG="#FF0000"/>
<color name="doubleQuoteText" FG="#00fF00"/> <color name="doubleQuoteText" FG="#00fF00"/>
@@ -34,6 +33,8 @@
<color name="macro" FG="#6c09c8" bold="yes"/> <color name="macro" FG="#6c09c8" bold="yes"/>
<color name="SYNTAX_ERROR" FG="#000000" BG="#FF0000" bold="yes"/> <color name="SYNTAX_ERROR" FG="#000000" BG="#FF0000" bold="yes"/>
<color name="functionName" FG="#24d1e0" bold="yes"/> <color name="functionName" FG="#24d1e0" bold="yes"/>
<color name="TestResultOK" FG="#000000" BG="#00FF00" bold="yes"/>
<color name="TestResultERROR" FG="#000000" BG="#FF0000" bold="yes"/>
</syntax> </syntax>
</EdnColor> </EdnColor>

40
data/color_white.xml Normal file
View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnColor version="0.1">
<gui> <!-- Doivent tous y <20>tre de prf<72>rence ... global system acces -->
<color name="CODE_basicBackgroung" val="#d9d7d7"/>
<color name="CODE_space" val="#b7b6b6"/>
<color name="CODE_tabulation" val="#a7a5a5"/>
<color name="CODE_cursor" val="#2a00ff"/>
<color name="CODE_lineNumber" val="#1a00a0"/>
<!-- Buffer list property -->
<color name="LIST_backgroung1" val="#d9d7d7"/>
<color name="LIST_backgroung2" val="#b7b6b6"/>
<color name="LIST_backgroungSelected" val="#3da3f9"/>
<color name="LIST_textNormal" val="#000000"/>
<color name="LIST_textModify" val="#FF0000"/>
</gui>
<syntax>
<color name="normal" FG="#000000"/>
<color name="SelectedText" FG="#292929" BG="#009ce7"/>
<color name="error" FG="#FF0000"/>
<color name="doubleQuoteText" FG="#008e00"/>
<!-- hightline description : -->
<color name="type" FG="#376d0a" bold="yes"/>
<color name="storageKeyword" FG="#466cb4"/>
<color name="number" FG="#007b00"/>
<color name="systemFunction" FG="#acaa00"/>
<color name="commonDefine" FG="#3c850b"/>
<color name="boolean" FG="#1633a3"/>
<color name="preprocesseur" FG="#ac0000"/>
<color name="comment" FG="#b704b5" italic="yes"/>
<color name="commentDoxygen" FG="#bf3e00" bold="yes" italic="yes"/>
<color name="keyword" FG="#215eb8" bold="yes"/>
<color name="macro" FG="#571793" bold="yes"/>
<color name="SYNTAX_ERROR" FG="#000000" BG="#c20000" bold="yes"/>
<color name="functionName" FG="#09857e" bold="yes"/>
<color name="TestResultOK" FG="#000000" BG="#009c00" bold="yes"/>
<color name="TestResultERROR" FG="#000000" BG="#c20000" bold="yes"/>
</syntax>
</EdnColor>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

View File

@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="c"> <EdnLang version="0.1" lang="Makefiles">
<ext>Makefile</ext> <ext>Makefile</ext>
<ext>.mk</ext> <ext>*.mk</ext>
<ext>*.global</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification --> <pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="my preprocesseur"> <rule name="my preprocesseur">
<color>preprocesseur</color> <color>preprocesseur</color>
@@ -9,9 +10,23 @@
<end>\n</end> <end>\n</end>
<EscapeChar>\</EscapeChar> <EscapeChar>\</EscapeChar>
</rule> </rule>
<rule name="doubleQuteText">
<color>doubleQuoteText</color>
<start>"</start>
<end>"</end>
<EscapeChar>\</EscapeChar>
</rule>
<rule name="simpleQuteText">
<color>doubleQuoteText</color>
<start>'</start>
<end>'</end>
</rule>
</pass1> </pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear --> <pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->
<rule name="my keyword">
<color>keyword</color>
<start>\$\([a-zA-Z_][a-zA-Z0-9_]*\)</start>
</rule>
</pass2> </pass2>
</EdnLang> </EdnLang>

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="Assembleur"> <EdnLang version="0.1" lang="Assembleur">
<ext>.s</ext> <ext>*.s</ext>
<ext>.S</ext> <ext>*.S</ext>
<ext>.asm</ext> <ext>*.asm</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification --> <pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="my comment multiline doxygen"> <rule name="my comment multiline doxygen">
<color>commentDoxygen</color> <color>commentDoxygen</color>

48
data/lang_bash.xml Normal file
View File

@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="Bash script">
<ext>*.sh</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="first line">
<color>commentDoxygen</color>
<start>#!</start>
<end>\n</end>
<EscapeChar>\</EscapeChar>
</rule>
<rule name="comment line">
<color>comment</color>
<start>#</start>
<end>\n</end>
<EscapeChar>\</EscapeChar>
</rule>
<rule name="doubleQuteText">
<color>doubleQuoteText</color>
<start>"</start>
<end>"</end>
<EscapeChar>\</EscapeChar>
</rule>
<rule name="simpleQuteText">
<color>doubleQuoteText</color>
<start>'</start>
<end>'</end>
<!--<EscapeChar>\</EscapeChar>-->
</rule>
</pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->
<rule name="my keyword">
<color>keyword</color>
<start>\@for|done|do|while|in|if|elif|then|else|fi\@</start>
</rule>
<rule name="my Variable">
<color>keyword</color>
<start>[\$]+[a-zA-Z_][a-zA-Z0-9_]*</start>
</rule>
<rule name="Function name">
<color>functionName</color>
<start>function (\w|_)+[ \t]*\(</start>
</rule>
<rule name="condition">
<color>boolean</color>
<start>==|&lt;=|&gt;=|!=|&lt;{1,2}|&gt;{1,2}|&amp;&amp;|\{|\}|</start>
</rule>
</pass2>
</EdnLang>

View File

@@ -1,9 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="c"> <EdnLang version="0.1" lang="boulou log">
<ext>.boo</ext> <ext>*.boo</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification --> <pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
</pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->
<rule name="comment ##"> <rule name="comment ##">
<color>SYNTAX_ERROR</color> <color>SYNTAX_ERROR</color>
<start>##</start> <start>##</start>
@@ -14,5 +12,49 @@
<start>#</start> <start>#</start>
<end>\n</end> <end>\n</end>
</rule> </rule>
<rule name="notes ... ">
<color>preprocesseur</color>
<start>(NOTE|TODO) : </start>
<end>\n</end>
</rule>
<rule name="doubleQuteText">
<color>doubleQuoteText</color>
<start>"</start>
<end>"</end>
<EscapeChar>\</EscapeChar>
</rule>
<rule name="simpleQuteText">
<color>doubleQuoteText</color>
<start>\@'</start>
<end>'</end>
<!--<EscapeChar>\</EscapeChar>-->
</rule>
</pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->
<rule name="pourcentage OK">
<color>TestResultOK</color>
<start>100%</start>
</rule>
<rule name="pourcentage">
<color>number</color>
<start>[0-9]*%</start>
</rule>
<rule name="R<>sultat OK">
<color>TestResultOK</color>
<start>\[( )*(OK|Ok|ok)( )*\]</start>
</rule>
<rule name="resultat en erreur">
<color>TestResultERROR</color>
<start>\[(ERREUR|Erreur|erreur)\]</start>
</rule>
<rule name="resultat vide">
<color>number</color>
<start>\[( )*\]</start>
</rule>
<rule name="notes ... ">
<color>macro</color>
<start>==&gt;</start>
</rule>
</pass2> </pass2>
</EdnLang> </EdnLang>

View File

@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="c"> <EdnLang version="0.1" lang="c">
<ext>.c</ext> <ext>*.c</ext>
<ext>.cpp</ext> <ext>*.cpp</ext>
<ext>.h</ext> <ext>*.h</ext>
<ext>.hpp</ext> <ext>*.hpp</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification --> <pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="my comment multiline doxygen"> <rule name="my comment multiline doxygen">
<color>commentDoxygen</color> <color>commentDoxygen</color>
@@ -111,7 +111,7 @@
</rule> </rule>
<rule name="condition"> <rule name="condition">
<color>boolean</color> <color>boolean</color>
<start>==|&lt;=|&gt;=|!=|&lt;|&gt;|&amp;&amp;|\{|\}|</start> <start>==|&lt;=|&gt;=|!=|&lt;{1,2}|&gt;{1,2}|&amp;&amp;|\{|\}|</start>
</rule> </rule>
<!-- With all elementes : <!-- With all elementes :
<rule name="BIG LETTER"> <rule name="BIG LETTER">

62
data/lang_matlab.xml Normal file
View File

@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="matlab">
<ext>*.m</ext>
<ext>*.M</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="my comment doxygen">
<color>commentDoxygen</color>
<start>%%</start>
<end>\n</end>
</rule>
<rule name="my comment">
<color>comment</color>
<start>%</start>
<end>\n</end>
<EscapeChar>\</EscapeChar>
</rule>
<rule name="doubleQuteText">
<color>doubleQuoteText</color>
<start> "</start>
<end>("|\n)</end>
<EscapeChar>\</EscapeChar>
</rule>
<rule name="simpleQuteText">
<color>doubleQuoteText</color>
<start> '</start>
<end>('|\n)</end>
<!--<EscapeChar>\</EscapeChar>-->
</rule>
<rule name="global inclusion">
<color>preprocesseur</color>
<start>global( |\t)+</start>
<end>\n</end>
<EscapeChar>\</EscapeChar>
</rule>
</pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->
<rule name="my keyword">
<color>keyword</color>
<start>\@return|goto|if|else|case|default|switch|break|continue|while|do|for|otherwise|end\@</start>
</rule>
<rule name="my boolean">
<color>boolean</color>
<start>\@true|false\@</start>
</rule>
<rule name="Function name">
<color>functionName</color>
<start>\@(\w|_)+[ \t]*\(</start>
</rule>
<rule name="condition">
<color>boolean</color>
<start>==|&lt;=|&gt;=|!=|&lt;{1,2}|&gt;{1,2}|&amp;&amp;|\{|\}|</start>
</rule>
<rule name="numeric constant">
<color>number</color>
<start>\@((0(x|X)[0-9a-fA-F]*)|(\d+\.?\d*|\.\d+)((e|E)(\+|\-)?\d+)?)(L|l|UL|ul|u|U|F|f)?\@</start>
</rule>
<rule name="BIG LETTER">
<color>macro</color>
<start>\@[A-Z_][A-Z_0-9]{3,500}\@</start>
</rule>
</pass2>
</EdnLang>

76
data/lang_php.xml Normal file
View File

@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="php: pretty home page">
<ext>*.php</ext>
<ext>*.php3</ext>
<ext>*.php4</ext>
<ext>*.phtml</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="my comment multiline">
<color>comment</color>
<start>/\*</start>
<end>\*/</end>
</rule>
<rule name="my todo comment">
<color>SYNTAX_ERROR</color>
<start>//[ \t]*TODO[ \t]*:</start>
<end>\n</end>
<EscapeChar>\</EscapeChar>
</rule>
<rule name="my comment inline">
<color>comment</color>
<start>#</start>
<end>\n</end>
</rule>
<rule name="my comment">
<color>comment</color>
<start>//</start>
<end>\n</end>
<EscapeChar>\</EscapeChar>
</rule>
<rule name="doubleQuteText">
<color>doubleQuoteText</color>
<start>"</start>
<end>"</end>
<EscapeChar>\</EscapeChar>
</rule>
<rule name="simpleQuteText">
<color>doubleQuoteText</color>
<start>'</start>
<end>'</end>
</rule>
</pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->
<rule name="my keyword">
<color>keyword</color>
<start>[\$]+[a-zA-Z_][a-zA-Z0-9_]*</start>
</rule>
<rule name="my type">
<color>type</color>
<start>\@array|bool|boolean|double|float|int|integer|numeric|object|resource|string|unset\@</start>
</rule>
<rule name="my storage keyword">
<color>storageKeyword</color>
<start>\@abstract|and|as|break|case|catch|class|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|eval|exit|extends|final|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|interface|isset|list|namespace|new|or|print|private|protected|public|require|require_once|return|static|switch|throw|trait|try|unset|use|var|while|xor\@</start>
</rule>
<rule name="my common Define">
<color>commonDefine</color>
<start>\@doubleval|floatval|gettype|intval|print_r|serialize|settype|strval|unserialize|var_dump|var_export\@</start>
</rule>
<rule name="numeric constant">
<color>number</color>
<start>\@((0(x|X)[0-9a-fA-F]*)|(\d+\.?\d*|\.\d+)((e|E)(\+|\-)?\d+)?)(L|l|UL|ul|u|U|F|f)?\@</start>
</rule>
<rule name="my boolean">
<color>boolean</color>
<start>\@true|TRUE|false|FALSE\@</start>
</rule>
<rule name="Function name">
<color>functionName</color>
<start>\@(\w|_)+[ \t]*\(</start>
</rule>
<rule name="condition">
<color>boolean</color>
<start>==|&lt;=|&gt;=|!=|&lt;|&gt;|&amp;&amp;|\{|\}|</start>
</rule>
</pass2>
</EdnLang>

View File

@@ -1,15 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="Assembleur"> <EdnLang version="0.1" lang="XML">
<ext>.xml</ext> <ext>*.xml</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification --> <pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="Comment"> <rule name="Comment">
<color>comment</color> <color>comment</color>
<start>&lt;!\-\-</start> <start>&lt;!\-\-</start>
<end>\-\-&gt;</end> <end>\-\-&gt;</end>
</rule> </rule>
<rule name="doubleQuteText">
<color>doubleQuoteText</color>
<start>"</start>
<end>"</end>
<EscapeChar>\</EscapeChar>
</rule>
<rule name="simpleQuteText">
<color>doubleQuoteText</color>
<start>\@'</start>
<end>('|\n)</end>
<!--<EscapeChar>\</EscapeChar>-->
</rule>
</pass1> </pass1>
<pass2> <pass2>
<rule name="special Balise">
<color>error</color>
<start>&lt;\?\w*|\?&gt;</start>
</rule>
<rule name="normale Balise">
<color>functionName</color>
<start>&lt;/\w*|&lt;\w*|/&gt;|&gt;</start>
</rule>
</pass2> </pass2>
</EdnLang> </EdnLang>

View File

@@ -21,7 +21,6 @@ You can NOT:
- Add malware in the Sources. - Add malware in the Sources.
- Do something bad with the sources. - Do something bad with the sources.
- Use it to travel in the space with a toaster. - Use it to travel in the space with a toaster.
- Write Java sources code with this software.
I reserve the right to change this licence. If it change the version of the copy you have keep its own license I reserve the right to change this license. If it change the version of the copy you have keep its own license

2041
tags

File diff suppressed because it is too large Load Diff

1026
test2.c

File diff suppressed because it is too large Load Diff

143
test_transparence.c Normal file
View File

@@ -0,0 +1,143 @@
// gcc test_transparence.c -o out `pkg-config --cflags --libs gtk+-3.0` -DUSE_GTK_VERSION_3_0
// gcc test_transparence.c -o out `pkg-config --cflags --libs gtk+-2.0` -DUSE_GTK_VERSION_2_0
// includes system, malloc, EXIT_SUCCESS
#include <stdlib.h>
// includes fopen, fwrite, fseek, ftell
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <assert.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <cairo.h>
static void screen_changed(GtkWidget *widget, GdkScreen *old_screen, gpointer user_data);
static gboolean expose(GtkWidget *widget, GdkEventExpose *event, gpointer user_data);
static void clicked(GtkWindow *win, GdkEventButton *event, gpointer user_data);
#if USE_GTK_VERSION_3_0
const GdkRGBA color = { 1.0, 1.0, 0.0, 0.0};
#endif
int main(int argc, char **argv)
{
gtk_init(&argc, &argv);
GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
gtk_window_set_default_size(GTK_WINDOW(window), 400, 400);
gtk_window_set_title(GTK_WINDOW(window), "Alpha Demo");
g_signal_connect(G_OBJECT(window), "delete-event", gtk_main_quit, NULL);
gtk_widget_set_app_paintable(window, TRUE);
# if USE_GTK_VERSION_3_0
g_signal_connect(G_OBJECT(window), "draw", G_CALLBACK(expose), NULL);
# elif USE_GTK_VERSION_2_0
g_signal_connect(G_OBJECT(window), "expose-event", G_CALLBACK(expose), NULL);
# endif
g_signal_connect(G_OBJECT(window), "screen-changed", G_CALLBACK(screen_changed), NULL);
# if USE_GTK_VERSION_3_0
GtkStyleContext *context;
GdkRGBA rgba;
context = gtk_widget_get_style_context(window);
gtk_style_context_get_background_color(context, GTK_STATE_FLAG_NORMAL,
&rgba);
gtk_widget_override_background_color(window,
GTK_STATE_FLAG_NORMAL, &rgba);
/*
gtk_widget_override_background_color(window,
GTK_STATE_FLAG_NORMAL,// | GTK_STATE_FLAG_ACTIVE | GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_INSENSITIVE | GTK_STATE_FLAG_INCONSISTENT | GTK_STATE_FLAG_FOCUSED,
&color);
gtk_widget_override_color(window,
GTK_STATE_FLAG_NORMAL,// | GTK_STATE_FLAG_ACTIVE | GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_INSENSITIVE | GTK_STATE_FLAG_INCONSISTENT | GTK_STATE_FLAG_FOCUSED,
&color);
*/
#endif
gtk_window_set_decorated(GTK_WINDOW(window), FALSE);
gtk_widget_add_events(window, GDK_BUTTON_PRESS_MASK);
g_signal_connect(G_OBJECT(window), "button-press-event", G_CALLBACK(clicked), NULL);
GtkWidget* fixed_container = gtk_fixed_new();
gtk_container_add(GTK_CONTAINER(window), fixed_container);
GtkWidget* button = gtk_button_new_with_label("button1");
gtk_widget_set_size_request(button, 100, 100);
gtk_container_add(GTK_CONTAINER(fixed_container), button);
screen_changed(window, NULL, NULL);
gtk_widget_show_all(window);
gtk_main();
return 0;
}
gboolean supports_alpha = FALSE;
static void screen_changed(GtkWidget *widget, GdkScreen *old_screen, gpointer userdata)
{
/* To check if the display supports alpha channels, get the colormap */
# ifdef USE_GTK_VERSION_2_0
GdkScreen *screen = gtk_widget_get_screen(widget);
GdkColormap *colormap = gdk_screen_get_rgba_colormap(screen);
if (!colormap)
{
printf("Your screen does not support alpha channels!\n");
colormap = gdk_screen_get_rgb_colormap(screen);
supports_alpha = FALSE;
}
else
{
printf("Your screen supports alpha channels!\n");
supports_alpha = TRUE;
}
gtk_widget_set_colormap(widget, colormap);
#endif
/*
gtk_widget_override_background_color(widget,
GTK_STATE_FLAG_NORMAL,// | GTK_STATE_FLAG_ACTIVE | GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_INSENSITIVE | GTK_STATE_FLAG_INCONSISTENT | GTK_STATE_FLAG_FOCUSED,
&color);
gtk_widget_override_color(widget,
GTK_STATE_FLAG_NORMAL,// | GTK_STATE_FLAG_ACTIVE | GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_INSENSITIVE | GTK_STATE_FLAG_INCONSISTENT | GTK_STATE_FLAG_FOCUSED,
&color);
*/
}
static gboolean expose(GtkWidget *widget, GdkEventExpose *event, gpointer userdata)
{
return FALSE;
# if USE_GTK_VERSION_3_0
cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(widget));
# elif USE_GTK_VERSION_2_0
cairo_t *cr = gdk_cairo_create(widget->window);
# endif
if (TRUE == supports_alpha)
cairo_set_source_rgba (cr, 0.0, 0.0, 1.0, 0.3); /* transparent */
else
cairo_set_source_rgb (cr, 1.0, 0.0, 0.0); /* opaque white */
/* draw the background */
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_paint (cr);
cairo_destroy(cr);
return FALSE;
}
static void clicked(GtkWindow *win, GdkEventButton *event, gpointer user_data)
{
/* toggle window manager frames */
gtk_window_set_decorated(win, !gtk_window_get_decorated(win));
}