228 Commits
0.1.3 ... 0.3.8

Author SHA1 Message Date
450fc0532d [DEBUG] correction of the read write access in the buffer system 2012-11-08 08:43:18 +01:00
841f23a2db [DEV] permit to change the display 2012-11-06 18:08:44 +01:00
858fd3a428 [DEV] cghange the basic Idea of the basic env variable 2012-11-04 15:46:13 +01:00
4514239076 [DEV] Change error display in the manager 2012-11-02 18:06:14 +01:00
8fdeb39b5a [DEV] update to etk::FSNode 2012-11-01 10:48:27 +01:00
eac1f8f594 [DEV] update the config file and the project management 2012-10-27 17:43:10 +02:00
0ba1c33525 [DEV] change the compilation Basic flag in the basic makefile 2012-10-27 01:25:51 +02:00
e88bfb0f0b [DEV] start the copy of files 2012-10-26 18:02:27 +02:00
2031631b77 [DEV] Change the ETK vector and matrix 2012-10-26 16:56:53 +02:00
708e8794a0 [DEBUG] set back an other font to display for test 2012-10-25 18:12:23 +02:00
64edc96eb0 [DEV] add glsl file parsing 2012-10-25 12:05:36 +02:00
79d95a8554 [DEBUG] lower the level debug of the Undo Redo when empty 2012-10-25 11:55:01 +02:00
377662c3a0 [DEBUG] missing copy of the share 2012-10-24 09:23:42 +02:00
8afe7a16f8 [DEV] change the environement of the short-cut ==> only on the code-viewer 2012-10-23 17:47:31 +02:00
2266ba7040 [DEV] Do not display more text than needed 2012-10-19 15:18:20 +02:00
2e96e5bfb1 Reorder the buffer list system 2012-10-18 11:09:19 +02:00
667fe86dc7 [DEV] display line of the CTAGS 2012-10-17 13:31:09 +02:00
e383600df6 [DEV] the Ctags is now availlable inmultiple files 2012-10-17 10:24:23 +02:00
33a36fa0f7 [DEV][CTAGS] integration of the first ewol display version 2012-10-16 18:32:21 +02:00
7aa4f9ae4d [DEV] set the reload of the shader 2012-10-11 18:05:56 +02:00
ecced51f81 small modif in the debug log 2012-10-09 18:00:44 +02:00
6e2df2dc77 Set the distance field test in compilation flags 2012-10-09 09:40:11 +02:00
fc129e2745 update config 2012-09-14 17:24:31 +02:00
5696539e2d cange android system generation 2012-09-12 18:24:26 +02:00
dbcde77a61 change config files* 2012-09-11 18:22:05 +02:00
e5e2ccc56f change android compialtion 2012-09-09 23:39:08 +02:00
dab060c4fe display of the special font work.... 2012-09-07 16:31:49 +02:00
3bdc96097c display big distance field 2012-09-06 18:42:57 +02:00
6ed410d936 First test of the distance field methode for the font 2012-09-06 02:48:41 +02:00
9587e21498 the android specific file is compile internly at ewol 2012-09-04 10:14:32 +02:00
244b83ed16 Change makefile principe and rework the mouse position event 2012-08-31 16:46:57 +02:00
27db00a6f6 some Windows correction 2012-08-31 01:30:34 +02:00
d4f313a54d Request of openGl 2 done corectly 2012-08-30 13:36:27 +02:00
29a5f34a3a update manifest to force request of openGL ES 2 2012-08-30 01:27:04 +02:00
4a916418d7 some change on ewol 2012-08-28 18:11:17 +02:00
f51ea408fa change the resources manager system 2012-08-26 22:44:33 +02:00
cd3968dd20 codeView error in touche mode specific system 2012-08-23 14:12:22 +02:00
76cd7bef21 Ewol change the idea of how the Font are managed 2012-08-22 18:18:59 +02:00
e27720372b remove management of color from etk to agg lib 2012-08-21 18:17:09 +02:00
6f10243046 update to ewol 0.3.4 ==> change the arbo 2012-08-20 18:12:14 +02:00
ae9c0f8eeb adapt at the new OS abstraction 2012-08-19 16:56:59 +02:00
699564e17f change the clipboard system (normalisation and standardisation 2012-08-18 21:06:21 +02:00
0fc8934d93 ewol change his time API 2012-08-16 18:22:10 +02:00
04c86769d6 Reorganise the internal data of this repository 2012-08-15 23:11:44 +02:00
d3e963749b change install on PC basic folder 2012-08-15 11:48:23 +02:00
9640f3c527 change the color_ts in a better class anc rename VectorType in Vector 2012-08-14 16:11:09 +02:00
c992d4a830 orthograph correction of redraw 2012-08-14 08:58:56 +02:00
761fabbac8 direct remove of the widget to simplify the system 2012-08-13 18:00:30 +02:00
2a7a0d0d9b remove the double buffering 2012-08-10 17:27:32 +02:00
c36a9d21f3 Simplify makefiles 2012-08-10 12:11:28 +02:00
96047c36e8 Compilation on Android availlable 2012-08-09 18:33:35 +02:00
a20f3e4063 Revert "STANDARD ==> remove vector type and replace with std::vector (done but sone assertion)" ==> bad idea
This reverts commit 4012d75279.
2012-08-09 14:26:30 +02:00
7ee4747cc2 DEV : try to compile Android directly 2012-08-08 18:22:01 +02:00
4012d75279 STANDARD ==> remove vector type and replace with std::vector (done but sone assertion) 2012-08-07 18:05:02 +02:00
d58bda6896 back compile android 2012-07-25 21:55:34 +02:00
64be551b35 simplify the EObject class 2012-07-24 17:48:18 +02:00
53c34d0894 add About at the parametyer display 2012-07-24 13:01:40 +02:00
9de7bafcb5 First parameter display 2012-07-23 17:21:44 +02:00
1d3ed3f200 update the readme documentation 2012-07-23 14:59:19 +02:00
694e73a29c installer no more availlable due to the new buld system 2012-07-23 09:02:51 +02:00
0dbef0d349 start update avancement.boo 2012-07-22 22:19:57 +02:00
4e7eac1399 Gui is back to normal 2012-07-20 14:37:46 +02:00
12cd1db0e1 first step to update to the OpenGl real orientation 2012-07-19 18:13:21 +02:00
ae2bea1918 Update to the new drawing mode 2012-07-19 16:54:44 +02:00
d1708610c7 Start of the dev of the Parameter section 2012-07-18 18:21:21 +02:00
628c10ff3a Change the close position of the search windows 2012-07-17 13:27:16 +02:00
e10e633949 update the focus metode to the search windows 2012-07-17 13:25:33 +02:00
750e663eca update to the new compilation system for Linux 2012-07-16 17:59:56 +02:00
33c6de5450 small bug 2012-07-13 18:12:14 +02:00
0d4b7188c0 add highlight of the .in files 2012-07-10 12:28:28 +02:00
10d0fb5674 Better search bar 2012-07-03 16:59:22 +02:00
fee00e79c7 set search element in basic image ... 2012-07-02 17:40:49 +02:00
7146a00371 try to simplify 'buffer' manager 2012-07-01 21:43:57 +02:00
2e974251fa Search is back 2012-07-01 17:54:50 +02:00
0d79b55112 remove etkFloat_t element and coord2D_ts with float and Vector2D<float> 2012-07-01 10:13:24 +02:00
df8d2772da add lua parser 2012-05-30 14:16:45 +02:00
aea60950ff Change the image needed in edn 2012-05-29 12:57:07 +02:00
a210af5627 [BREAK compatibility] Update to the new input call function 2012-05-22 09:49:11 +02:00
c594be7a5f scrolling bar in codeView 2012-05-15 13:03:45 +02:00
d19586c4d8 nomenclature of space corection 2012-05-13 21:28:59 +02:00
e5a06889b6 Missing File.svg 2012-05-13 09:46:33 +02:00
4676ea0a63 Remove unnedded code in the application interface 2012-05-13 09:44:18 +02:00
8e4e0a52b6 Correction of the buffer remove ==> no more selectable buffer 2012-05-12 08:58:05 +02:00
65b0fc5b19 select the good buffer when opening a new file 2012-05-10 17:48:23 +02:00
f390a594a3 Not open a file previously opened 2012-05-10 17:47:52 +02:00
bbb1ea0a93 Save the Display position for every buffer opened to restore the position the next time 2012-05-10 16:01:03 +02:00
277045cde4 Corection of the basic install script 2012-05-10 12:00:22 +02:00
11e10e6db8 Add the search element needed 2012-05-10 11:57:24 +02:00
c2729b4c67 Remove the Buffer ID and the modification state ==> earn space 2012-05-10 11:51:51 +02:00
6340cc409e Compilation error on Linux and Android correction 2012-05-10 11:50:58 +02:00
4821093048 Rework search icone to work corectly 2012-05-10 11:50:11 +02:00
a904f30b34 add a simple install script and corection of the release folder selection 2012-05-02 18:22:32 +02:00
21b786f920 better buffer display and select the good folder in the open file 2012-04-29 15:19:36 +02:00
a0f3beba5c add debug mode in the compilation of the application 2012-04-25 18:47:34 +02:00
a3c58a6c33 Add the maximum size of the current text edition 2012-04-24 13:36:25 +02:00
845232656b Moving the scrolling windows is ok when moving cursor 2012-04-24 13:17:04 +02:00
cd2b72d369 change some file position 2012-04-24 09:42:14 +02:00
5cc4a1a779 Change the color management use uint32_t instead of 4 float 2012-04-23 17:05:56 +02:00
586cd62f44 Some change in the organisation files 2012-04-23 13:03:55 +02:00
5d1837eb69 Normalisation with etk application 2012-04-23 10:15:43 +02:00
247aac0684 missing flag 2012-04-18 18:13:37 +02:00
13e2af9125 Charset management is back 2012-04-17 11:01:26 +02:00
dde852cbe1 Select all/none, Undo/Redo 2012-04-16 17:38:48 +02:00
a01c87e49b Some change in EWOL 2012-04-11 01:35:55 +02:00
28ddde0c83 Remove local clipboard and better scolling in codeView 2012-04-05 18:28:15 +02:00
5e86641caf Copy/cut/paste is back 2012-04-05 16:16:08 +02:00
c75fb80736 work on the copy/past on ewol 2012-04-04 18:18:27 +02:00
f2bcd9052b Update the basic Makefile 2012-03-29 17:48:48 +02:00
de9d630fee work fine is back on android 2012-03-29 10:01:00 +02:00
a99eba9a1f Add some svg files and display it in the menu 2012-03-28 18:11:43 +02:00
2997133eee Update to the new system of internal patch for -RTTI in debug mode 2012-03-14 09:26:14 +01:00
495cab7d27 adapte the EObject type management 2012-03-13 14:37:05 +01:00
e6ee6e0cd1 Log name error 2012-03-12 17:59:56 +01:00
3372645356 simple comment 2012-03-11 20:49:35 +01:00
188bd69f06 ewol normalisation 2012-03-09 18:08:08 +01:00
0ab5588a93 Remove deprecated type 2012-03-08 18:01:50 +01:00
df3c97b17e minor modif 2012-03-05 00:09:47 +01:00
03cb9d7cbd clean the buffer text 2012-03-02 16:42:44 +01:00
c8b9b37c8e corection of the pointer mouse event 2012-03-02 09:47:33 +01:00
75f56d52d4 Strat simplify of the buffer access 2012-03-01 18:23:45 +01:00
f6f8679b76 Rework of EWOL (Step 3) 2012-02-29 18:06:08 +01:00
ae113a8a2f Rework of EWOL (Step 2) 2012-02-28 18:22:49 +01:00
45f37a0c4b Rework of EWOL (Step 1) 2012-02-27 18:15:56 +01:00
02e7de2397 Display the frst line number 2012-02-24 17:24:53 +01:00
ea344225e3 add the really basic shortcut ... 2012-02-24 12:45:39 +01:00
40d6de087b change text display 2012-02-23 22:34:12 +01:00
7bf7668686 change the filename in the title 2012-02-23 18:05:57 +01:00
e2e0fc25d3 change the clipping with the viewport 2012-02-23 13:43:57 +01:00
9f2718f97a remove the last singleton to create the basic namespace 2012-02-20 20:30:26 +01:00
a943ddd4f7 start remove of singleton 2012-02-19 22:33:43 +01:00
fced6df123 error android compilation for the reintrepreted cast 2012-02-19 18:52:17 +01:00
a4d314723d Better display 2012-02-19 15:48:08 +01:00
f716055c40 Remove all the capabilities at the Widget main classes 2012-02-18 22:20:53 +01:00
0a11251ccc Optimise the display of the CodeViewer ==> usable on Android 2012-02-18 15:56:00 +01:00
0d0afec709 Display the processing time of the text buffer 2012-02-18 11:50:29 +01:00
1894f56217 Change tree ==> simplify 2012-02-18 00:35:15 +01:00
4e7491e5fc display of menu correct 2012-02-17 18:25:38 +01:00
dc73285cb7 update to the new menu 2012-02-16 23:29:48 +01:00
5d7870248d Some update 2012-02-16 18:18:04 +01:00
4b16540744 Remove old test 2012-02-15 23:07:55 +01:00
f0cda0de78 Change the Sting un Unicode management 2012-02-15 16:23:20 +01:00
e21e7e7c21 add save as and start of Unicode string adaptation 2012-02-14 19:29:53 +01:00
cd84475aea Uniformisation of the UNICODE in the soft 2012-02-13 18:03:09 +01:00
71fa38d61e remove dead code 2012-02-12 22:36:59 +01:00
fdd4ddf978 manage the tablette scrolling 2012-02-11 11:18:27 +01:00
f610c23638 Remove deprecated code 2012-02-10 18:20:03 +01:00
610afddc9d Update the message list and open/Save(as) files 2012-02-09 17:20:52 +01:00
4038dd74af Add basic close and save event generation 2012-02-08 18:05:19 +01:00
8ba3e2e3d4 Change the redraw methode of the code viewer ==> reparse every time needed the line in the buffer for the second pass of highlight 2012-02-07 18:04:15 +01:00
7734a8ce36 start Abstraction of the scrooling windows 2012-02-06 17:59:48 +01:00
d088866891 change the system to open file message 2012-02-05 22:03:36 +01:00
0341795cbb Add the display of the buffer list and change some generic event of the edn system.
Add the text display with a different font ==> must rework all the event X/Y position of the mouse
2012-02-03 18:14:45 +01:00
9e0720b476 Add the cmdline argument in the init 2012-02-02 18:19:31 +01:00
8bce8893e8 Change the basic font 2012-02-01 18:24:23 +01:00
d2cb4a47b7 Change message system and threaded the system 2012-01-31 18:26:04 +01:00
65b288813e corrction of the missing log in android and remove the pb with the rotation remove context of open GL 2012-01-27 02:04:02 +01:00
7bad5d42f2 Start to add the thread between the interface and the system 2012-01-26 18:13:43 +01:00
fda95289bd try error 2012-01-25 23:32:14 +01:00
102e11b74a First port of edn on the android platform ==> can do nothing but not crach every 10 second 2012-01-25 18:30:33 +01:00
ee80871434 Add the display of the space and tabulation 2012-01-24 23:50:23 +01:00
43c3092fe3 update the methode of calculation of the mouse event 2012-01-24 23:35:17 +01:00
d05d82ba7b Display is now ready to manage the Unicode and the multiple size font 2012-01-24 17:54:16 +01:00
6052df85dc bad day 2012-01-23 12:41:40 +01:00
a9eb976b48 Remove Keybord special key to the abstraction layer 2012-01-19 18:14:57 +01:00
411bf03e74 Correction of the CR comming from X11 2012-01-18 22:56:14 +01:00
a53903d628 Start the change of the display methode 2012-01-18 18:54:55 +01:00
f3bf0b557c Display none Mono-space Text 2012-01-18 14:31:33 +01:00
6f6b0a6f7f Add shortcut and management of move event in codeViewer 2012-01-17 15:35:34 +01:00
43d8aaef48 Display a correct cursor 2012-01-17 09:52:50 +01:00
9c9eac7d37 Text background correction done 2012-01-17 09:39:38 +01:00
c61876b919 Some correction of the Display color is now availlable 2012-01-16 14:37:28 +01:00
10ceb14268 Add and remove char in the buffer 2012-01-15 16:09:32 +01:00
8c014312c6 Scrool up and down and click availlable ==> no display 2012-01-15 15:42:01 +01:00
01868a2114 First display in open GL 2012-01-15 14:15:24 +01:00
bd7aa98324 Starting integration of the main display in EWOL system 2012-01-13 13:06:15 +01:00
70837bd769 First compilation of edn with ewol ==> did not work at all 2012-01-11 15:27:18 +01:00
2d355d05c6 First move for ewol adaptation 2012-01-11 12:51:26 +01:00
a6e583f8c9 Remove deprecated files before the ewol adaptation 2012-01-11 12:08:00 +01:00
870e127932 Add java language parsing based on C language.
Yes I did not like JAVA, but I needed it for the Android application
2011-12-01 09:59:46 +01:00
a351fe72bd Add Edn at the list of the gnome software 2011-11-24 16:50:04 +01:00
9b7707cf9a Display: change the internal title display 2011-11-02 09:09:20 +01:00
heero
a03fb96dc9 Display: corection of the first line selection error 2011-10-16 15:17:45 +02:00
863fab113b add patch correction done in branch display line by line
stop the developpement of the display line by line because it did not work corectly and was a little cpu leacher, the display has maany error and the comphehention is hard.
2011-10-11 14:06:36 +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
269 changed files with 20047 additions and 28151 deletions

12
.gitignore vendored
View File

@@ -2,11 +2,9 @@
###################################
# folders
###################################
CVS
.svn
Object/
doxygen/API/
doxygen/ALL/
.gitk-tmp.*
out/
Sources/ewolAndroidAbstraction.cpp
###################################
# backup files
@@ -26,9 +24,7 @@ doxygen/ALL/
*.o
*.so
*.pyc
edn
edn_debug
edn_release
tags
###################################
# Packages #

339
Makefile
View File

@@ -1,300 +1,59 @@
##################################################################################################################
# #
# Fichier : Makefile #
# #
# Type : Makefile d'un programme complet #
# #
# Auteur : Heero Yui #
# #
# Evolutions : Date Auteur Raison #
# 2010-01-29 Heero Yui Mise en place d'un makefile ultra simple #
# 2011-07-14 Heero Yui Rework the current dorder includion (simplification) #
# #
# Notes : This makefile might be edited with an editor compatible with escape char and carrer return #
# char #
# #
# Concu Pour le projet edn #
# #
##################################################################################################################
export F_GRAS=
export F_INVERSER=
export F_SOUSLIGNER=
export F_NORMALE=
export F_NOIR=
export F_ROUGE=
export F_VERT=
export F_MARRON=
export F_BLUE=
export F_VIOLET=
export F_CYAN=
export F_GRIS=
export CADRE_HAUT_BAS=' $(F_INVERSER) $(F_NORMALE)'
export CADRE_COTERS='
#############################################################################"
# main makefile for a basic application
# this is minimal application main makefile
#############################################################################"
VERSION_TAG=$(shell git describe --tags)
# Project name ==> generate the application name [a-z] <== make attention at the case this generate error on Android compilation
PROJECT_NAME=edn
VERSION_BUILD_TIME=$(shell date)
#Can be manny things, but limit whith no space no special char and no Maj ... [a-z]
# com : Commercial
# net : Network??
# org : Organisation
# gov : Governement
# mil : Military
# edu : Education
# pri : Private
# museum : ...
PROJECT_COMPAGNY_TYPE=org
###############################################################################
### Compilateur base system ###
###############################################################################
CXX=g++
CC=gcc
# Compagny name of the project [a-zA-Z0-9 \-]
PROJECT_COMPAGNY_NAME=Edouard DUPIN
# List of mainainer that might be contact in problem case : "Mr NAME Surname<mail@host.com>" "second ..."
PROJECT_MAINTAINER="Mr DUPIN Edouard <yui.heero@gmail.com>"
###############################################################################
### Compilation Define ###
###############################################################################
ifeq ("$(DEBUG)", "0")
DEFINE= -DEDN_DEBUG_LEVEL=1 -DNDEBUG -DVERSION_TAG_NAME="\"$(VERSION_TAG)-debug\""
else
DEFINE= -DEDN_DEBUG_LEVEL=3 -DVERSION_TAG_NAME="\"$(VERSION_TAG)-release\""
endif
# the icon of the project is all time needed ... if it is not present the ewol icon might be set (must be a .png file) (and no space in the fileName and filePath)
PROJECT_ICON=$(shell pwd)/data/icon.png
GTKFLAGS=
ifeq ($(shell if `pkg-config --exists gtk+-3.0` ; then echo "yes"; else echo "no"; fi), yes)
GTKFLAGS= `pkg-config --cflags --libs gtk+-3.0` -DUSE_GTK_VERSION_3_0
else
ifeq ($(shell if `pkg-config --exists gtk+-2.0` ; then echo "yes"; else echo "no"; fi), yes)
GTKFLAGS= `pkg-config --cflags --libs gtk+-2.0` -DUSE_GTK_VERSION_2_0
else
$(error No GTK 3.0 or 2.0 librairies ...)
endif
# project section : (must be separate by coma
# refer to : http://packages.debian.org/sid/
# admin cli-mono comm database debian-installer
# debug doc editors electronics devel embedded
# fonts games gnome gnu-r gnustep graphics
# hamradio haskell httpd interpreters java
# kde kernel libdevel libs lisp localization
# mail math misc net news ocaml oldlibs otherosfs
# perl php python ruby science shells sound tex
# text utils vcs video virtual web x11 xfce zope ...
PROJECT_SECTION=Development,Editors
###############################################################################
### Basic Cfags ###
###############################################################################
# basic GTK librairy
CXXFLAGS= $(GTKFLAGS)
# Linux thread system
CXXFLAGS+= -lpthread
# Enable debug (cgdb edn)
CXXFLAGS+= -g -O0
#CXXFLAGS+= -O2
# display all flags
CXXFLAGS+= -Wall
# ...
CXXFLAGS+= -D_REENTRANT
# internal defines
CXXFLAGS+= $(DEFINE)
CFLAGS= $(CXXFLAGS) -std=c99
# basic GTK librairy
LDFLAGS= $(GTKFLAGS)
# Linux thread system
LDFLAGS+= -lpthread
# Dynamic connection of the CALLBACK of the GUI
LDFLAGS+= -Wl,--export-dynamic
###############################################################################
### Project Name ###
###############################################################################
PROG_NAME=edn
###############################################################################
### Basic Project description Files ###
###############################################################################
FILE_DIRECTORY=Sources
OUTPUT_NAME_RELEASE=$(PROG_NAME)_release
OUTPUT_NAME_DEBUG=$(PROG_NAME)_debug
OBJECT_DIR=Object
ifeq ("$(DEBUG)", "0")
OBJECT_DIRECTORY=$(OBJECT_DIR)/release
OUTPUT_NAME = $(OUTPUT_NAME_RELEASE)
else
OBJECT_DIRECTORY=$(OBJECT_DIR)/debug
OUTPUT_NAME = $(OUTPUT_NAME_DEBUG)
endif
###############################################################################
### Generique dependency ###
###############################################################################
MAKE_DEPENDENCE=Makefile
###############################################################################
### Files Listes ###
###############################################################################
# tiny XML (extern OPEN Sources) :
CXXFILES = tools/tinyXML/tinyxml.cpp \
tools/tinyXML/tinyxmlparser.cpp \
tools/tinyXML/tinyxmlerror.cpp \
tools/tinyXML/tinystr.cpp
# ExuberantCtags reading file tools (extern OPEN Sources) :
CXXFILES+= ctags/readtags.cpp \
ctags/CTagsManager.cpp
# Globals debug tool:
CXXFILES+= tools/debug/tools_debug.cpp \
tools/globals/tools_globals.cpp \
tools/memory/toolsMemory.cpp
# Buffers internal:
CXXFILES+= tools/EdnTemplate/EdnVectorBuf.cpp \
tools/EdnBuf/EdnBuf.cpp \
tools/EdnBuf/EdnBuf_HighLight.cpp \
tools/EdnBuf/EdnBuf_History.cpp \
tools/EdnBuf/EdnBuf_Selection.cpp \
tools/EdnBuf/EdnBufHistory.cpp
# Tools internal:
CXXFILES+= tools/AL/AL_Mutex.cpp \
tools/Display/Display.cpp \
tools/ClipBoard/ClipBoard.cpp \
tools/MsgBroadcast/MsgBroadcast.cpp \
tools/MsgBroadcast/AccelKey.cpp \
tools/charset/charsetTable.cpp \
tools/charset/charset.cpp \
tools/NameSpaceEdn/File.cpp \
tools/NameSpaceEdn/String.cpp \
tools/NameSpaceEdn/RegExp.cpp
# Gui:
CXXFILES+= CustumWidget/BufferView/BufferView.cpp \
CustumWidget/CodeView/CodeView.cpp \
GuiTools/WindowsManager/WindowsManager.cpp \
GuiTools/MainWindows/MainWindows.cpp \
GuiTools/MainWindows/StatusBar.cpp \
GuiTools/MainWindows/MenuBar.cpp \
GuiTools/MainWindows/ToolBar.cpp \
GuiTools/Search/Search.cpp \
GuiTools/Search/SearchData.cpp \
GuiTools/MenuContext/MenuContext.cpp
# Basic Interface :
CXXFILES+= Buffer/Buffer.cpp \
Buffer/BufferText.cpp \
Buffer/BufferEmpty.cpp \
Buffer/BufferManager.cpp \
Colorize/Colorize.cpp \
Colorize/ColorizeManager.cpp \
Highlight/HighlightPattern.cpp \
Highlight/Highlight.cpp \
Highlight/HighlightManager.cpp
# Main entry file :
CXXFILES+= init.cpp
###############################################################################
### Liste of folder where .h can be ###
###############################################################################
LISTE_MODULES = $(dir $(CXXFILES))
INCLUDE_DIRECTORY = $(addprefix -I$(FILE_DIRECTORY)/, $(LISTE_MODULES))
###############################################################################
### Build Object Files List ###
###############################################################################
OBJ = $(addprefix $(OBJECT_DIRECTORY)/, $(CXXFILES:.cpp=.o))
###############################################################################
### Main Part of Makefile ###
###############################################################################
all: build
-include $(OBJ:.o=.d)
build: .encadrer .versionFile $(OUTPUT_NAME)
.encadrer:
@echo $(CADRE_HAUT_BAS)
@echo $(CADRE_COTERS)
@echo '
DEBUT DE COMPILATION DU PROGRAMME :'$(CADRE_COTERS)
@echo '
Repertoire Sources : $(FILE_DIRECTORY)/'$(CADRE_COTERS)
@echo '
Repertoire object : $(OBJECT_DIRECTORY)/'$(CADRE_COTERS)
@echo '
Binaire de sortie : $(F_VIOLET)$(OUTPUT_NAME) / $(OUTPUT_NAME)-stripped$(F_NORMALE)'$(CADRE_COTERS)
@echo $(CADRE_COTERS)
@echo $(CADRE_HAUT_BAS)
@mkdir -p $(addprefix $(OBJECT_DIRECTORY)/, $(LISTE_MODULES))
@mkdir -p ~/.bin
FILE_IMAGES= data/imagesSources/*.png
.versionFile :
@rm -f $(OBJECT_DIRECTORY)/GuiTools/WindowsManager/WindowsManager.o
# Tool used to create a binary version of every element png or other needed by the application
pngToCpp: tools/pngToCpp/pngToCpp.c
@echo $(F_ROUGE)"
(bin) $@"$(F_NORMALE)
@$(CXX) $< -o $@
@strip -s $@
# Generate basic
$(FILE_DIRECTORY)/GuiTools/myImage.cpp: $(FILE_IMAGES) $(MAKE_DEPENDENCE) pngToCpp
@echo $(F_BLUE)"
(.cpp) *.png ==> $@"$(F_NORMALE)
@./pngToCpp $@ $(FILE_IMAGES)
# build C++
$(OBJECT_DIRECTORY)/%.o: $(FILE_DIRECTORY)/%.cpp $(MAKE_DEPENDENCE)
@echo $(F_VERT)"
(.o) $<"$(F_NORMALE)
@$(CXX) $< -c -o $@ $(INCLUDE_DIRECTORY) $(CXXFLAGS) -MMD
# build binary Release Mode
$(OUTPUT_NAME_RELEASE): $(OBJ) $(MAKE_DEPENDENCE)
@echo $(F_ROUGE)"
(bin) $@ "$(F_NORMALE)
@$(CXX) $(OBJ) $(LDFLAGS) -o $@
@cp $@ $(PROG_NAME)
# build binary Debug Mode
$(OUTPUT_NAME_DEBUG): $(OBJ) $(MAKE_DEPENDENCE)
@echo $(F_ROUGE)"
(bin) $@ "$(F_NORMALE)
@$(CXX) $(OBJ) $(LDFLAGS) -o $@
@cp $@ $(PROG_NAME)
clean:
@echo $(CADRE_HAUT_BAS)
@echo ' CLEANING : $(F_VIOLET)$(OUTPUT_NAME)$(F_NORMALE)'$(CADRE_COTERS)
@echo $(CADRE_HAUT_BAS)
@echo Remove Folder : $(OBJECT_DIR)
@rm -rf $(OBJECT_DIR)
@echo Remove File : $(PROG_NAME) $(OUTPUT_NAME_DEBUG) $(OUTPUT_NAME_RELEASE)
@rm -f $(PROG_NAME) $(OUTPUT_NAME_DEBUG) $(OUTPUT_NAME_RELEASE)
@echo Remove File : pngToCpp
@rm -f pngToCpp
@echo Remove File : $(FILE_DIRECTORY)/GuiTools/myImage.*
@rm -f $(FILE_DIRECTORY)/GuiTools/myImage.*
@echo Remove doxygen files : doxygen/*
@rm -rf doxygen
@rm -f doxygen.log
@echo Remove temporary files *.bck
@rm -f `find . -name "*.bck"`
count:
wc -l Makefile `find $(FILE_DIRECTORY)/ -name "*.cpp"` `find $(FILE_DIRECTORY)/ -name "*.h"`
install: .encadrer .versionFile $(OUTPUT_NAME_RELEASE)
@echo $(CADRE_HAUT_BAS)
# project prority
# required : Packages which are necessary for the proper functioning of the system (usually, this means that dpkg functionality depends on these packages). Removing a required package may cause your system to become totally broken and you may not even be able to use dpkg to put things back, so only do so if you know what you are doing. Systems with only the required packages are probably unusable, but they do have enough functionality to allow the sysadmin to boot and install more software.
# important : Important programs, including those which one would expect to find on any Unix-like system. If the expectation is that an experienced Unix person who found it missing would say "What on earth is going on, where is foo?", it must be an important package.[6] Other packages without which the system will not run well or be usable must also have priority important. This does not include Emacs, the X Window System, TeX or any other large applications. The important packages are just a bare minimum of commonly-expected and necessary tools.
# standard : These packages provide a reasonably small but not too limited character-mode system. This is what will be installed by default if the user doesn't select anything else. It doesn't include many large applications.
# optional : (In a sense everything that isn't required is optional, but that's not what is meant here.) This is all the software that you might reasonably want to install if you didn't know what it was and don't have specialized requirements. This is a much larger system and includes the X Window System, a full TeX distribution, and many applications. Note that optional packages should not conflict with each other.
# extra : This contains all packages that conflict with others with required, important, standard or optional priorities, or are only likely to be useful if you already know what they are or have specialized requirements (such as packages containing only detached debugging symbols).
PROJECT_PRIORITY=optional
# description of the current project inside quote and no \n
PROJECT_DESCRIPTION="Text editor for sources code with ctags management"
# Add package needed :
# current user packages
USER_PACKAGES =$(shell pwd)/Sources/
# Add ewol packages
USER_PACKAGES+=$(shell realpath $(shell pwd)/../ewol/Sources/)
# include basic makefile for ewol generic toolchain
include $(shell pwd)/../ewol/Build/Makefile.mk

21
README
View File

@@ -1,21 +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.
I reserve the right to change this licence. If it change the version of the copy you have keep its own license

68
README.md Normal file
View File

@@ -0,0 +1,68 @@
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 :
mkdir yourDevFolder
cd yourDevFolder
git clone git://github.com/HeeroYui/ewol.git
cd ewol
git submodule init
git submodule update
cd ..
git clone git://github.com/HeeroYui/edn.git
cd edn
(debug) Compile software & Run debug version:
make DEBUG=1
or
make CLANG=1 DEBUG=1
cp -r ../ewol/share/* share/
./out_LINUX/debug/obj/usr/bin/edn -l6 yourFile.txt
Note : -l6 corespond at the LOG level to display
(release) Compile software & install & run:
make
./install.sh
edn exemple.txt
(Android) Compile software & install
cd yourDevFolder
mkdir andoid
cd android
download here in "sdk" and "ndk" the coresponding SDK and NDK of Android:
http://developer.android.com/tools/sdk/ndk/index.html
http://developer.android.com/sdk/index.html
==> you need to download sub package of the NDK (refer to the NDK doccumentation) but only supported android version >4.0
cd ../edn
make PLATFORM=Android
make PLATFORM=Android install
License (like GPL)
==================
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

44
Sources/Android.mk Normal file
View File

@@ -0,0 +1,44 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# load the common sources file of the platform
include $(LOCAL_PATH)/file.mk
LOCAL_CONFIG_FILES := Config.in
# name of the librairy
ifeq ($(CONFIG___EWOL_APPL_NAME__),$(empty))
LOCAL_MODULE := edn
else
LOCAL_MODULE := $(call convert-special-char,$(CONFIG___EWOL_APPL_NAME__))
endif
# get the tag of the current project :
LOCAL_VERSION_TAG=$(shell cd $(LOCAL_PATH) ; git describe --tags)
LOCAL_VERSION_TAG_SHORT=$(shell cd $(LOCAL_PATH) ; git describe --tags --abbrev=0)
$(info $(LOCAL_MODULE) version TAG : $(LOCAL_VERSION_TAG))
# name of the dependency
LOCAL_LIBRARIES := ewol freetype libpng parsersvg tinyxml lua etk libzip
LOCAL_C_INCLUDES := $(LOCAL_PATH) $(addprefix $(LOCAL_PATH)/, $(sort $(dir $(FILE_LIST))))
LOCAL_SRC_FILES := $(FILE_LIST)
LOCAL_LDLIBS := -llog -landroid
ifeq ($(DEBUG),1)
LOCAL_CFLAGS := -D__MODE__Touch \
-DPROJECT_NAME="\"$(LOCAL_MODULE)\"" \
-DAPPL_VERSION_TAG_NAME="\"$(LOCAL_VERSION_TAG_SHORT)-$(BUILD_DIRECTORY_MODE)\""
else
LOCAL_CFLAGS := -D__MODE__Touch \
-DMODE_RELEASE \
-DPROJECT_NAME="\"$(LOCAL_MODULE)\"" \
-DAPPL_VERSION_TAG_NAME="\"$(LOCAL_VERSION_TAG_SHORT)-$(BUILD_DIRECTORY_MODE)\""
endif
include $(BUILD_SHARED_LIBRARY)

View File

@@ -1,435 +0,0 @@
/**
*******************************************************************************
* @file Buffer.c
* @brief Editeur De N'ours : Text Buffer
* @author Edouard DUPIN
* @date 08/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 "tools_globals.h"
#include "Buffer.h"
#include "BufferManager.h"
#undef __class__
#define __class__ "Buffer"
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
Buffer::Buffer()
{
m_fileModify = true;
m_haveName = false;
Edn::String mString = "No-Name";
m_fileName.SetCompleateName(mString);
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
Buffer::Buffer(Edn::String &newFileName)
{
m_fileModify = false;
m_haveName = true;
m_fileName.SetCompleateName(newFileName);
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
Buffer::~Buffer(void)
{
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
bool Buffer::IsModify(void)
{
return m_fileModify;
}
void Buffer::SetModify(bool status)
{
if (status != m_fileModify) {
m_fileModify = status;
GeneralSendMessage(EDN_MSG__BUFFER_CHANGE_MODIFY);
}
}
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
*
* @param[in,out] ---
*
* @return ---
*
*/
// TODO : ne marche plus ...
void Buffer::Save(void)
{
// nothing to do
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void Buffer::GetInfo(infoStatBuffer_ts &infoToUpdate)
{
// nothing to do
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void Buffer::SetLineDisplay(uint32_t lineNumber)
{
// nothing to do
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
int32_t Buffer::Display(DrawerManager &drawer)
{
return ERR_NONE;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
* @todo : Set the move up and DOWN...
*
*/
void Buffer::MouseSelectFromCursorTo(int32_t width, int32_t height)
{
// nothing to do
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void Buffer::MouseEvent(int32_t width, int32_t height)
{
// nothing to do
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void Buffer::MouseEventDouble(void)
{
// nothing to do
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void Buffer::MouseEventTriple(void)
{
// nothing to do
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void Buffer::ScrollDown(void)
{
// nothing to do
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void Buffer::ScrollUp(void)
{
// nothing to do
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void Buffer::ForceReDraw(bool allElement)
{
// nothing to do
}
void Buffer::cursorMove(int32_t gtkKey)
{
// nothing to do
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void Buffer::AddChar(char * UTF8data)
{
// nothing to do
}
void Buffer::Search(Edn::String &data, bool back, bool caseSensitive, bool wrap, bool regExp)
{
// nothing to do
}
void Buffer::Replace(Edn::String &data)
{
// nothing to do
}
int32_t Buffer::FindLine(Edn::String &data)
{
// nothing to do
}
void Buffer::JumpAtLine(int32_t newLine)
{
// nothing to do
}
/**
* @brief request a copy of the selection in the named clipBoard ID
*
* @param[in] clipboardID Id of the buffer we want to get data [0..10] (0 copy normal / 10 middle button)
*
* @return ---
*
*/
void Buffer::Copy(int8_t clipboardID)
{
// nothing to do
}
/**
* @brief Request a copy and a remove of the curent selection in the named clipBoard ID
*
* @param[in] clipboardID Id of the buffer we want to get data [0..10] (0 copy normal / 10 middle button)
*
* @return ---
*
*/
void Buffer::Cut(int8_t clipboardID)
{
// nothing to do
}
/**
* @brief request the past of a specific clipboard on the curent position or selection
*
* @param[in] clipboardID Id of the buffer we want to get data [0..10] (0 copy normal / 10 middle button)
*
* @return ---
*
*/
void Buffer::Paste(int8_t clipboardID)
{
// nothing to do
}
void Buffer::RemoveLine(void)
{
// nothing to do
}
void Buffer::SelectAll(void)
{
// nothing to do
}
void Buffer::SelectNone(void)
{
// nothing to do
}
void Buffer::Undo(void)
{
// nothing to do
}
void Buffer::Redo(void)
{
// nothing to do
}

View File

@@ -1,99 +0,0 @@
/**
*******************************************************************************
* @file Buffer.h
* @brief Editeur De N'ours : Text Buffer (header)
* @author Edouard DUPIN
* @date 08/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.
*
*******************************************************************************
*/
#ifndef __BUFFER_H__
#define __BUFFER_H__
#include <string>
#include "Display.h"
#include "charset.h"
#include "Edn.h"
typedef struct{
uint32_t nbTotalLine; //!< Number of line in the buffer
uint32_t nbTotalColomn; //!< Number of line in the buffer
uint32_t startLineDisplay; //!< First line display.
uint32_t startColomnDisplay; //!< First Colomn displayed
uint32_t diplayableColomn; //!< NB colomn that can be displayed
uint32_t diplayableLine; //!< NB Line that can be displayed
}infoStatBuffer_ts;
class Buffer {
public:
Buffer(void);
Buffer(Edn::String &filename);
virtual ~Buffer(void);
Edn::File GetFileName(void);
virtual Edn::String GetName(void);
virtual Edn::String GetShortName(void);
virtual Edn::String GetFolder(void);
virtual void SetName(Edn::String &newName);
virtual void Save(void);
virtual bool HaveName(void);
bool IsModify(void);
protected:
void SetModify(bool status);
public:
virtual void GetInfo(infoStatBuffer_ts &infoToUpdate);
virtual void SetLineDisplay(uint32_t lineNumber);
virtual int32_t Display(DrawerManager &drawer);
virtual void ForceReDraw(bool allElement);
virtual void AddChar(char * UTF8data);
virtual void cursorMove(int32_t gtkKey);
virtual void MouseSelectFromCursorTo(int32_t width, int32_t height);
virtual void MouseEvent(int32_t width, int32_t height);
virtual void MouseEventDouble(void);
virtual void MouseEventTriple(void);
virtual void ScrollDown(void);
virtual void ScrollUp(void);
virtual void RemoveLine(void);
virtual void SelectAll(void);
virtual void SelectNone(void);
virtual void Undo(void);
virtual void Redo(void);
virtual void SetCharset(charset_te newCharset) {};
//virtual void SelectAll(void);
virtual void Copy(int8_t clipboardID);
virtual void Cut(int8_t clipboardID);
virtual void Paste(int8_t clipboardID);
virtual void Search(Edn::String &data, bool back, bool caseSensitive, bool wrap, bool regExp);
virtual void Replace(Edn::String &data);
virtual int32_t FindLine(Edn::String &data);
virtual void JumpAtLine(int32_t newLine);
protected:
bool m_fileModify;
Edn::File m_fileName;
bool m_haveName; //!< to know if the file have a name or NOT
};
#endif

View File

@@ -1,98 +0,0 @@
/**
*******************************************************************************
* @file BufferEmpty.cpp
* @brief Editeur De N'ours : Text Buffer (edit For No buffer Display)
* @author Edouard DUPIN
* @date 19/01/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 "BufferEmpty.h"
#include "ColorizeManager.h"
#include "MainWindows.h"
#undef __class__
#define __class__ "BufferEmpty"
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
BufferEmpty::BufferEmpty()
{
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
BufferEmpty::~BufferEmpty(void)
{
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
int32_t BufferEmpty::Display(DrawerManager &drawer)
{
ColorizeManager * myColorManager = ColorizeManager::getInstance();
// Get color :
Colorize *myColor = NULL;
// Clean Buffer
drawer.Clean(myColorManager->Get(COLOR_CODE_BASIC_BG) );
myColor = myColorManager->Get("normal");
// Draw the 2 comments Lines :
drawer.Text(myColor, 20,20, "edn - Editeur De N'ours, l'Editeur Desoxyribo-Nucleique");
//drawer.Flush();
myColor = myColorManager->Get("commentDoxygen");
drawer.Text(myColor, 20,25 + Display::GetFontHeight(), "No Buffer Availlable to display");
drawer.Flush();
/*
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;
}

View File

@@ -1,334 +0,0 @@
/**
*******************************************************************************
* @file BufferManager.cpp
* @brief Editeur De N'ours : Text Buffer manager (sources)
* @author Edouard DUPIN
* @date 08/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 "tools_globals.h"
#include "BufferManager.h"
//#include "MsgBroadcast.h"
#undef __class__
#define __class__ "BufferManager"
// Constructeur
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
BufferManager::BufferManager(void) : MsgBroadcast("Buffer Manager", EDN_CAT_BUFFER_MANAGER)
{
// nothing to do ...
BufferNotExiste = new BufferEmpty();
m_idSelected = -1;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
BufferManager::~BufferManager(void)
{
//clean All Buffer
EDN_INFO("~BufferManager::RemoveAll();");
RemoveAll();
// clear The list of Buffer
EDN_INFO("~BufferManager::listBuffer.Clear();");
listBuffer.Clear();
EDN_INFO("~BufferManager::delete(BufferNotExiste);");
delete(BufferNotExiste);
}
void BufferManager::OnMessage(int32_t id, int32_t dataID)
{
switch (id)
{
case EDN_MSG__BUFFER_CHANGE_CURRENT:
m_idSelected = dataID;
break;
case EDN_MSG__NEW:
{
int32_t newOne = Create();
if (-1 != newOne) {
SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, newOne);
}
}
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;
}
}
/**
* @brief Remove all buffer opened
*
* @param[in,out] ---
*
* @return ---
*
*/
void BufferManager::RemoveAll(void)
{
int32_t i;
for (i=0; i<listBuffer.Size(); i++) {
Remove(i);
}
SendMessage(EDN_MSG__BUFFER_REMOVE_ALL);
}
/**
* @brief Create a new buffer with no name and empty
*
* @param[in,out] ---
*
* @return The ID of the curent buffer where the file is loaded
*
*/
int32_t BufferManager::Create(void)
{
// allocate a new Buffer
Buffer *myBuffer = new BufferText();
// Add at the list of element
listBuffer.PushBack(myBuffer);
int32_t basicID = listBuffer.Size() - 1;
SendMessage(EDN_MSG__BUFFER_ADD, basicID);
return basicID;
}
/**
* @brief open a file with the name set in parameters
*
* @param[in] filename curent filename
*
* @return The ID of the curent buffer where the file is loaded
*
* @todo : check if this file is not curently open and return the old ID
*
*/
int32_t BufferManager::Open(Edn::String &filename)
{
// allocate a new Buffer
Buffer *myBuffer = new BufferText(filename);
// Add at the list of element
listBuffer.PushBack(myBuffer);
int32_t basicID = listBuffer.Size() - 1;
SendMessage(EDN_MSG__BUFFER_ADD, basicID);
return basicID;
}
Buffer * BufferManager::Get(int32_t BufferID)
{
// possible special case : -1;
if (-1 >= BufferID) {
return BufferNotExiste;
}
// check if the Buffer existed
if (BufferID < listBuffer.Size()) {
// check if the buffer already existed
if (NULL != listBuffer[BufferID]) {
return listBuffer[BufferID];
} else {
EDN_ERROR("non existing Buffer " << BufferID);
}
} else {
EDN_ERROR("call an non existing Buffer number too hight : " << BufferID << " > " << listBuffer.Size());
}
return BufferNotExiste;
}
bool BufferManager::Exist(int32_t BufferID)
{
if (-1 >= BufferID) {
return false;
}
// check if the Buffer existed
if (BufferID < listBuffer.Size()) {
// check if the buffer already existed
if (NULL != listBuffer[BufferID]) {
return true;
}
}
return false;
}
int32_t BufferManager::GetId(Edn::String &filename)
{
int32_t iii;
// check if the Buffer existed
for (iii=0; iii < listBuffer.Size(); iii++) {
// check if the buffer already existed
if (NULL != listBuffer[iii]) {
if ( listBuffer[iii]->GetName() == filename) {
return iii;
}
}
}
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
uint32_t BufferManager::Size(void)
{
return listBuffer.Size();
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
bool BufferManager::Remove(int32_t BufferID)
{
if (-1 >= BufferID) {
return false;
}
// check if the Buffer existed
if (BufferID < listBuffer.Size()) {
// check if the buffer already existed
if (NULL != listBuffer[BufferID]) {
// TODO : Check if it saved...
/*
if (false == IsSaved(BufferID) ) {
EDN_INFO("Buffer " << BufferID << " : Not Saved", BufferID);
}
*/
// Delete the Buffer
delete( listBuffer[BufferID] );
listBuffer[BufferID] = NULL;
SendMessage(EDN_MSG__BUFFER_REMOVE, BufferID);
return true;
} else {
EDN_INFO("non existing Buffer " << BufferID);
return false;
}
} else {
EDN_INFO("call an non existing Buffer number too hight : " << BufferID << " > " << listBuffer.Size());
return false;
}
}
/**
* @brief to get the element 14 in the buffer
*
* @param[in,out] ---
*
* @return ---
*
*/
int32_t BufferManager::WitchBuffer(int32_t iEmeElement)
{
int32_t i;
for (i=0; i<listBuffer.Size(); i++) {
if (NULL != listBuffer[i]) {
iEmeElement--;
// find the element :
if (0 == iEmeElement) {
return i;
}
}
}
return -1;
}

View File

@@ -1,74 +0,0 @@
/**
*******************************************************************************
* @file BufferManager.h
* @brief Editeur De N'ours : Text Buffer (header)
* @author Edouard DUPIN
* @date 08/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.
*
*******************************************************************************
*/
#ifndef __BUFFER_MANAGER_H__
#define __BUFFER_MANAGER_H__
#include "Buffer.h"
#include "BufferText.h"
#include "BufferEmpty.h"
#include "Singleton.h"
#include "MsgBroadcast.h"
class BufferManager: public Singleton<BufferManager>, public MsgBroadcast
{
friend class Singleton<BufferManager>;
// specific for sigleton system...
private:
// Constructeur
BufferManager(void);
~BufferManager(void);
public:
void OnMessage(int32_t id, int32_t dataID);
// return the ID of the buffer allocated
// create a buffer with no element
int32_t Create(void);
// open curent filename
int32_t Open(Edn::String &filename);
int32_t GetSelected(void) { return m_idSelected;};
void SetSelected(int32_t id) {m_idSelected = id;};
Buffer * Get(int32_t BufferID);
bool Exist(int32_t BufferID);
bool Exist(Edn::String &filename);
int32_t GetId(Edn::String &filename);
// return the number of buffer (open in the past) if 5 buffer open and 4 close ==> return 5
uint32_t Size(void);
int32_t WitchBuffer(int32_t iEmeElement);
bool Remove(int32_t BufferID);
private:
Edn::VectorType<Buffer*> listBuffer; //!< element List of the char Elements
void RemoveAll(void); //!< remove all buffer
int32_t m_idSelected;
Buffer * BufferNotExiste; //!< When an error arrive in get buffer we return the Error buffer (not writable)
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,129 +0,0 @@
/**
*******************************************************************************
* @file BufferText.h
* @brief Editeur De N'ours : Text Buffer (edit only ASCII text File) (header)
* @author Edouard DUPIN
* @date 19/01/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_TEXT_H__
#define __BUFFER_TEXT_H__
#include <vector>
#include <string>
#include "ColorizeManager.h"
#include "Buffer.h"
#include "EdnBuf.h"
typedef enum {
CURSOR_DISPLAY_MODE_NORMAL = 259,
CURSOR_DISPLAY_MODE_INSERT,
CURSOR_DISPLAY_MODE_NOT_FOCUS,
} cursorDisplayMode_te;
class BufferText : public Buffer {
public:
BufferText(void);
BufferText(Edn::String &filename);
virtual ~BufferText(void);
Edn::String GetName(void);
Edn::String GetShortName(void);
Edn::String GetFolder(void);
void SetName(Edn::String &newName);
void Save(void);
bool HaveName(void);
void GetInfo(infoStatBuffer_ts &infoToUpdate);
void SetLineDisplay(uint32_t lineNumber);
int32_t Display(DrawerManager &drawer);
void ForceReDraw(bool allElement);
void AddChar(char * UTF8data);
void cursorMove(int32_t gtkKey);
void MouseSelectFromCursorTo(int32_t width, int32_t height);
void MouseEvent(int32_t width, int32_t height);
void MouseEventDouble(void);
void MouseEventTriple(void);
void ScrollDown(void);
void ScrollUp(void);
void Copy(int8_t clipboardID);
void Cut(int8_t clipboardID);
void Paste(int8_t clipboardID);
void Search(Edn::String &data, bool back, bool caseSensitive, bool wrap, bool regExp);
void Replace(Edn::String &data);
int32_t FindLine(Edn::String &data);
void JumpAtLine(int32_t newLine);
void RemoveLine(void);
void SelectAll(void);
void SelectNone(void);
void Undo(void);
void Redo(void);
void SetCharset(charset_te newCharset);
private:
// naming
Edn::String filename; //!< filename of the curent buffer
bool haveName; //!< to know if the file have a name or NOT
// 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 :
// Direct buffer IO
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
int32_t m_displayStartBufferPos; //!< position where the buffer start
// Cursor :
int32_t m_cursorPos; //!< position in the buffer of the cursor
int32_t m_cursorPreferredCol; //!< colomn of the last up and down ...
bool m_cursorOn; //!< the blink of the cursor ...
cursorDisplayMode_te m_cursorMode; //!< type of cursor Selected
displayHLData_ts m_displayLocalSyntax; //!< for the display of the local elements (display HL mode)
// internal function
void BasicInit(void);
void UpdateWindowsPosition(bool centerPage = false);
void displayLineNumber(DrawerManager &drawer);
void CleanSelectLine(void);
void SelectionStart(void);
void SelectionEnd(void);
void SelectionCheckMode(void);
void CheckAndUpdateLineForModification(uint32_t lineID);
bool TextDMoveUp(int32_t offset);
bool TextDMoveDown(int32_t offset);
void SetInsertPosition(int32_t newPosition, bool insertChar = false);
void GetMousePosition(int32_t width, int32_t height, int32_t &x, int32_t &y);
void MoveUpDown(int32_t ofset);
void DrawLineNumber(DrawerManager &drawer,char *myPrint, int32_t lineNumber, int32_t positionY);
};
#endif

View File

@@ -1,256 +0,0 @@
/**
*******************************************************************************
* @file ColoriseManager.cpp
* @brief Editeur De N'ours : Colorising Manager
* @author Edouard DUPIN
* @date 14/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 "tools_globals.h"
#include "ColorizeManager.h"
#include "tinyxml.h"
#define PFX "ColorizeManager "
ColorizeManager::ColorizeManager(void)
{
}
ColorizeManager::~ColorizeManager(void)
{
delete(errorColor);
// TODO : delete all color previously
listMyColor.clear();
}
void ColorizeManager::LoadFile(Edn::String &xmlFilename)
{
LoadFile(xmlFilename.c_str());
}
void ColorizeManager::LoadFile(const char * xmlFilename)
{
errorColor = new Colorize();
errorColor->SetBgColor("#000000");
errorColor->SetFgColor("#FFFFFF");
// allocate the document in the stack
TiXmlDocument XmlDocument;
// open the curent File
XmlDocument.LoadFile(xmlFilename);
TiXmlElement* root = XmlDocument.FirstChildElement( "EdnColor" );
if (NULL == root )
{
EDN_ERROR(PFX"(l ?) main node not find: \"EdnColor\" in \"" << xmlFilename << "\"");
return;
}
else
{
TiXmlNode * pNode = root->FirstChild();
while(NULL != pNode)
{
if (pNode->Type()==TiXmlNode::TINYXML_COMMENT) {
// nothing to do, just proceed to next step
} else if (!strcmp(pNode->Value(), "gui")) {
TiXmlNode * pGuiNode = pNode->FirstChild();
while(NULL != pGuiNode)
{
if (pGuiNode->Type()==TiXmlNode::TINYXML_COMMENT) {
// nothing to do, just proceed to next step
} else if (!strcmp(pGuiNode->Value(), "color")) {
//--------------------------------------------------------------------------------------------
//<color name="basicBackground" val="#000000"/>
//--------------------------------------------------------------------------------------------
const char *colorName = pGuiNode->ToElement()->Attribute("name");
int32_t id = 0;
if (NULL == colorName) {
EDN_ERROR("(l "<< pGuiNode->Row() <<") node with no name");
// get next node element
pGuiNode = pGuiNode->NextSibling();
continue;
}
if (!strcmp(colorName, "CODE_space")) {
id = COLOR_CODE_SPACE;
} else if (!strcmp(colorName, "CODE_tabulation")) {
id = COLOR_CODE_TAB;
} else if (!strcmp(colorName, "CODE_basicBackgroung")) {
id = COLOR_CODE_BASIC_BG;
} else if (!strcmp(colorName, "CODE_cursor")) {
id = COLOR_CODE_CURSOR;
} else if (!strcmp(colorName, "CODE_lineNumber")) {
id = COLOR_CODE_LINE_NUMBER;
} else if (!strcmp(colorName, "LIST_backgroung1")) {
id = COLOR_LIST_BG_1;
} else if (!strcmp(colorName, "LIST_backgroung2")) {
id = COLOR_LIST_BG_2;
} else if (!strcmp(colorName, "LIST_backgroungSelected")) {
id = COLOR_LIST_BG_SELECTED;
} else if (!strcmp(colorName, "LIST_textNormal")) {
id = COLOR_LIST_TEXT_NORMAL;
} else if (!strcmp(colorName, "LIST_textModify")) {
id = COLOR_LIST_TEXT_MODIFY;
} else {
EDN_ERROR("(l "<<pGuiNode->Row()<<") Unknown basic gui color : \"" << colorName << "\"" );
// get next node element
pGuiNode = pGuiNode->NextSibling();
continue;
}
const char *color = pGuiNode->ToElement()->Attribute("val");
if (NULL != color) {
unsigned int r=0;
unsigned int v=0;
unsigned int b=0;
sscanf(color, "#%02x%02x%02x", &r,&v,&b);
basicColors[id].red = (float)r/255.0;
basicColors[id].green = (float)v/255.0;
basicColors[id].blue = (float)b/255.0;
/*
EDN_INFO(" Specify color for system ID="<< id );
EDN_INFO(" " << color << " ==> r="<< r <<" v="<< v <<" b="<< b );
EDN_INFO(" " << color << " ==> r="<< basicColors[id].red <<" v="<< basicColors[id].green <<" b="<< basicColors[id].blue );
*/
}
} else {
EDN_ERROR("(l "<<pGuiNode->Row()<<") node not suported : \""<<pGuiNode->Value()<<"\" must be [color]");
}
// get next node element
pGuiNode = pGuiNode->NextSibling();
}
} else if (!strcmp(pNode->Value(), "syntax")) {
TiXmlNode * pGuiNode = pNode->FirstChild();
while(NULL != pGuiNode)
{
if (pGuiNode->Type()==TiXmlNode::TINYXML_COMMENT) {
// nothing to do, just proceed to next step
} else if (!strcmp(pGuiNode->Value(), "color")) {
Colorize *myNewColor = new Colorize();
//--------------------------------------------------------------------------------------------
//<color name="basicBackground" FG="#000000" BG="#000000" bold="no" italic="no"/>
//--------------------------------------------------------------------------------------------
// get the name of the Chaine
const char *colorName = pGuiNode->ToElement()->Attribute("name");
if (NULL == colorName) {
EDN_ERROR(PFX"(l "<< pGuiNode->Row() <<") node with no name");
// get next node element
pGuiNode = pGuiNode->NextSibling();
continue;
} else {
myNewColor->SetName(colorName);
//EDN_INFO(PFX"Add a new color in the panel : \"%s\"", colorName);
}
const char *colorBG = pGuiNode->ToElement()->Attribute("BG");
if (NULL != colorBG) {
myNewColor->SetBgColor(colorBG);
}
const char *colorFG = pGuiNode->ToElement()->Attribute("FG");
if (NULL != colorFG) {
myNewColor->SetFgColor(colorFG);
}
const char *bold = pGuiNode->ToElement()->Attribute("bold");
if (NULL != bold) {
if(0 == strcmp(bold, "yes") ) {
myNewColor->SetBold(true);
}
}
const char *italic = pGuiNode->ToElement()->Attribute("italic");
if (NULL != italic) {
if(0 == strcmp(italic, "yes") ) {
myNewColor->SetItalic(true);
}
}
listMyColor.push_back(myNewColor);
} else {
EDN_ERROR(PFX"(l "<<pNode->Row()<<") node not suported : \""<<pNode->Value()<<"\" must be [color]");
}
pGuiNode = pGuiNode->NextSibling();
}
} else {
EDN_ERROR(PFX"(l "<<pNode->Row()<<") node not suported : \""<<pNode->Value()<<"\" must be [gui,syntax]");
}
// get next node element
pNode = pNode->NextSibling();
}
}
}
Colorize *ColorizeManager::Get(const char *colorName)
{
uint32_t i;
for (i=0; i<listMyColor.size(); i++) {
Edn::String elementName = listMyColor[i]->GetName();
if (elementName == colorName) {
return listMyColor[i];
}
}
EDN_ERROR(PFX"Color does not Existed ["<< colorName<<"]" );
// an error
return errorColor;
}
Colorize *ColorizeManager::Get(Edn::String &colorName)
{
return Get(colorName.c_str());
}
color_ts & ColorizeManager::Get(basicColor_te myColor)
{
if (myColor < COLOR_NUMBER_MAX) {
return basicColors[myColor];
} else {
return basicColors[0];
}
}
bool ColorizeManager::Exist(const char *colorName)
{
uint32_t i;
for (i=0; i<listMyColor.size(); i++) {
Edn::String elementName = listMyColor[i]->GetName();
if (elementName == colorName) {
return true;
}
}
return false;
}
bool ColorizeManager::Exist(Edn::String &colorName)
{
return Exist(colorName.c_str());
}
void ColorizeManager::DisplayListOfColor(void)
{
uint32_t i;
EDN_INFO(PFX"List of ALL COLOR : ");
for (i=0; i<listMyColor.size(); i++) {
//Edn::String elementName = listMyColor[i]->GetName();
//EDN_INFO(i << " : \"" << elementName.c_str() << "\"" );
listMyColor[i]->Display(i);
}
}

23
Sources/Config.in Normal file
View File

@@ -0,0 +1,23 @@
menu "General"
if __VIDEO__OPENGL_ES_2
choice
prompt "Buffer text configuration"
default APPL_BUFFER_FONT_NORMAL
help
Buffer display mode :
0 : Basic Sprite font mode.
==> Old standard mode fast but need to reaload distint font for every size
1 : Distance Field.
==> New theoric mode for the display of the font ==> really slow but insteresting ...
config APPL_BUFFER_FONT_NORMAL
bool "0: Basic Sprite font mode"
config APPL_BUFFER_FONT_DISTANCE_FIELD
bool "1: Distance Field"
endchoice
endif
if __VIDEO__OPENGL_ES_1
config APPL_BUFFER_FONT_NORMAL
bool
default y
endif
endmenu

View File

@@ -1,395 +0,0 @@
/**
*******************************************************************************
* @file BufferViewer.cpp
* @brief Editeur De N'ours : main textViewer diplayer
* @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 "tools_globals.h"
#include "Display.h"
#include "BufferView.h"
#include "BufferManager.h"
#include "ColorizeManager.h"
#include "MainWindows.h"
#undef __class__
#define __class__ "BufferView"
BufferView::BufferView(void) : MsgBroadcast("Buffer View", EDN_CAT_GUI)
{
m_shawableAreaX = 0;
m_shawableAreaY = 0;
// Init link with the buffer Manager
m_bufferManager = BufferManager::getInstance();
m_colorManager = ColorizeManager::getInstance();
m_menuContext = MenuContext::getInstance();
m_widget = gtk_drawing_area_new();
gtk_widget_set_size_request( m_widget, 250, 100);
gtk_widget_add_events( m_widget,
GDK_KEY_PRESS_MASK
| GDK_BUTTON_PRESS_MASK
| GDK_BUTTON_RELEASE_MASK
| GDK_POINTER_MOTION_MASK
| GDK_POINTER_MOTION_HINT_MASK);
# ifdef USE_GTK_VERSION_3_0
g_object_set(m_widget,"can-focus", TRUE, NULL);
# elif defined( USE_GTK_VERSION_2_0 )
GTK_WIDGET_SET_FLAGS(m_widget, GTK_CAN_FOCUS);
# endif
// Focus Event
g_signal_connect( G_OBJECT(m_widget), "focus_in_event", G_CALLBACK(CB_focusGet), this);
g_signal_connect( G_OBJECT(m_widget), "focus_out_event", G_CALLBACK(CB_focusLost), this);
// Keyboard Event
g_signal_connect_after( G_OBJECT(m_widget), "key_press_event", G_CALLBACK(CB_keyboardEvent), this);
g_signal_connect_after( G_OBJECT(m_widget), "key_release_event", G_CALLBACK(CB_keyboardEvent), this);
// Mouse Event
g_signal_connect( G_OBJECT(m_widget), "button_press_event", G_CALLBACK(CB_mouseButtonEvent), this);
g_signal_connect( G_OBJECT(m_widget), "button_release_event", G_CALLBACK(CB_mouseButtonEvent), this);
g_signal_connect( G_OBJECT(m_widget), "motion_notify_event", G_CALLBACK(CB_mouseMotionEvent), this);
// Display Event
g_signal_connect( G_OBJECT(m_widget), "realize", G_CALLBACK(CB_displayInit), this);
# ifdef USE_GTK_VERSION_3_0
g_signal_connect( G_OBJECT(m_widget), "draw", G_CALLBACK(CB_displayDraw), this);
# elif defined( USE_GTK_VERSION_2_0 )
g_signal_connect( G_OBJECT(m_widget), "expose_event", G_CALLBACK(CB_displayDraw), this);
# endif
m_selectedID = -1;
}
BufferView::~BufferView(void)
{
}
GtkWidget * BufferView::GetMainWidget(void)
{
return m_widget;
}
void BufferView::OnMessage(int32_t id, int32_t dataID)
{
switch (id)
{
case EDN_MSG__BUFFER_CHANGE_CURRENT:
m_selectedID = dataID;
case EDN_MSG__BUFFER_CHANGE_STATE:
case EDN_MSG__BUFFER_CHANGE_NAME:
case EDN_MSG__BUFFER_CHANGE_MODIFY:
// change Title :
gtk_widget_queue_draw(m_widget);
break;
}
}
gboolean BufferView::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
BufferView * self = reinterpret_cast<BufferView*>(data);
# ifdef USE_GTK_VERSION_3_0
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
bool needRedrawAll = false;
if (self->m_shawableAreaX != allocation.width) {
needRedrawAll = true;
self->m_shawableAreaX = allocation.width;
}
if (self->m_shawableAreaY != allocation.height) {
needRedrawAll = true;
self->m_shawableAreaY = allocation.height;
}
# elif defined( USE_GTK_VERSION_2_0)
bool needRedrawAll = false;
if (self->m_shawableAreaX != widget->allocation.width) {
needRedrawAll = true;
self->m_shawableAreaX = widget->allocation.width;
}
if (self->m_shawableAreaY != widget->allocation.height) {
needRedrawAll = true;
self->m_shawableAreaY = widget->allocation.height;
}
#endif
if (true == needRedrawAll) {
//myBuffer->ForceReDraw(true);
}
EDN_INFO("==========================================================================");
EDN_INFO("Request a display of : " << self->m_shawableAreaX << "px * "<< self->m_shawableAreaY<<"px");
DrawerManager monDrawer(widget, self->m_shawableAreaX, self->m_shawableAreaY);
// get the number of buffer open
int32_t nbBufferOpen = self->m_bufferManager->Size();
int32_t i;
uint32_t lineID = 0;
uint32_t fontHeight = Display::GetFontHeight();
basicColor_te selectFG = COLOR_LIST_TEXT_NORMAL;
basicColor_te selectBG = COLOR_LIST_BG_1;
for (i=0; i < nbBufferOpen; i++) {
Edn::String name;
bool isModify;
if (self->m_bufferManager->Exist(i)) {
isModify = self->m_bufferManager->Get(i)->IsModify();
name = self->m_bufferManager->Get(i)->GetShortName();
char *tmpModify = (char*)" ";
if (true == isModify) {
tmpModify = (char*)"M";
}
char name2[1024] = "";
sprintf(name2, "[%2d](%s) %s", i, tmpModify, name.c_str() );
if (true == isModify) {
selectFG = COLOR_LIST_TEXT_MODIFY;
} else {
selectFG = COLOR_LIST_TEXT_NORMAL;
}
if (lineID%2==0) {
selectBG = COLOR_LIST_BG_1;
} else {
selectBG = COLOR_LIST_BG_2;
}
if (self->m_selectedID == i) {
selectBG = COLOR_LIST_BG_SELECTED;
}
EDN_INFO("color fg=" << selectFG << " bg="<< selectBG);
monDrawer.Rectangle(self->m_colorManager->Get(selectBG), 0, lineID*fontHeight, self->m_shawableAreaX, Display::GetFontHeight());
monDrawer.Text(self->m_colorManager->Get(selectFG), 2, lineID*fontHeight, name2);
monDrawer.Flush();
lineID ++;
}
}
return TRUE;
}
// sur : <20>mis lors du premier affichage de la GtkDrawingArea
gboolean BufferView::CB_displayInit( GtkWidget *widget, gpointer data)
{
BufferView * self = reinterpret_cast<BufferView*>(data);
# ifdef USE_GTK_VERSION_3_0
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
int32_t size_x = allocation.width;
int32_t size_y = allocation.height;
self->m_shawableAreaX = allocation.width;
self->m_shawableAreaY = allocation.height;
# elif defined( USE_GTK_VERSION_2_0)
int32_t size_x = widget->allocation.width;
int32_t size_y = widget->allocation.height;
self->m_shawableAreaX = widget->allocation.width;
self->m_shawableAreaY = widget->allocation.height;
# endif
EDN_INFO("Request a diplay of : " << size_x << "px * " << size_y << "px");
//Display::InitDisplayParam(self->m_displayParameters, widget, 700, 1200);
gtk_widget_queue_draw( widget );
return TRUE;
}
gint BufferView::CB_focusGet( GtkWidget *widget, GdkEventFocus *event, gpointer data)
{
//BufferView * self = reinterpret_cast<BufferView*>(data);
# ifdef USE_GTK_VERSION_2_0
GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
# endif
EDN_INFO("Focus - In");
gtk_widget_queue_draw( widget );
return FALSE;
}
gint BufferView::CB_focusLost( GtkWidget *widget, GdkEventFocus *event, gpointer data)
{
BufferView * self = reinterpret_cast<BufferView*>(data);
# ifdef USE_GTK_VERSION_2_0
GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS);
# endif
EDN_INFO("Focus - out");
self->m_menuContext->Hide();
return FALSE;
}
gint BufferView::CB_keyboardEvent( GtkWidget *widget, GdkEventKey *event, gpointer data)
{
//BufferView * self = reinterpret_cast<BufferView*>(data);
if(event->type == GDK_KEY_PRESS) {
gtk_widget_queue_draw( widget );
}
return true;
}
void BufferView::OnPopupEventShow(GtkWidget *menuitem, gpointer data)
{
BufferView * self = reinterpret_cast<BufferView*>(data);
self->SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, self->m_contectMenuSelectID);
}
void BufferView::OnPopupEventClose(GtkWidget *menuitem, gpointer data)
{
BufferView * self = reinterpret_cast<BufferView*>(data);
self->SendMessage(EDN_MSG__BUFF_ID_CLOSE, self->m_contectMenuSelectID);
}
void BufferView::OnPopupEventSave(GtkWidget *menuitem, gpointer data)
{
BufferView * self = reinterpret_cast<BufferView*>(data);
self->SendMessage(EDN_MSG__BUFF_ID_SAVE, self->m_contectMenuSelectID);
}
void BufferView::OnPopupEventSaveAs(GtkWidget *menuitem, gpointer data)
{
BufferView * self = reinterpret_cast<BufferView*>(data);
self->SendMessage(EDN_MSG__GUI_SHOW_SAVE_AS, self->m_contectMenuSelectID);
}
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)
{
BufferView * self = reinterpret_cast<BufferView*>(data);
if (event->type != GDK_BUTTON_RELEASE) {
self->m_menuContext->Hide();
}
// get focus on the widget
gtk_widget_grab_focus(widget);
if (event->button == 1) {
if (event->type == GDK_BUTTON_PRESS) {
EDN_INFO("mouse-event BT1 ==> One Clicked");
}else if (event->type == GDK_2BUTTON_PRESS) {
//EDN_INFO("mouse-event BT1 ==> Double Clicked %d, %d", (uint32_t)event->x, (uint32_t)event->y);
uint32_t fontHeight = Display::GetFontHeight();
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);
if ( 0 <= 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");
self->m_menuContext->Show(event->x, event->y, false);
}
*/
} else if (event->button == 3) {
if (event->type == GDK_BUTTON_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 {
EDN_INFO("mouse-event BT? PRESS");
}
gtk_widget_queue_draw( widget );
return true;
}
gint BufferView::CB_mouseMotionEvent( GtkWidget *widget, GdkEventMotion *event, gpointer data)
{
//BufferView * self = reinterpret_cast<BufferView*>(data);
/*
if (true == ButtunOneSelected) {
int x, y;
GdkModifierType state;
if (event->is_hint) {
gdk_window_get_pointer(event->window, &x, &y, &state);
} else {
x = event->x;
y = event->y;
state = (GdkModifierType)event->state;
}
EDN_INFO("mouse-motion BT1 %d, %d", x, y);
}
*/
return true;
}

View File

@@ -1,81 +0,0 @@
/**
*******************************************************************************
* @file BufferView.h
* @brief Editeur De N'ours : main List Buffer Viewer (header)
* @author Edouard DUPIN
* @date 09/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.
*
*******************************************************************************
*/
#ifndef __BUFFER_VIEW_H__
#define __BUFFER_VIEW_H__
#include "tools_debug.h"
#include <vector>
#include <string>
#include "Singleton.h"
#include "CodeView.h"
#include "BufferManager.h"
#include "Display.h"
#include "MsgBroadcast.h"
#include "MenuContext.h"
class BufferView : public MsgBroadcast
{
public:
// Constructeur
BufferView(void);
~BufferView(void);
GtkWidget *GetMainWidget(void);
void OnMessage(int32_t id, int32_t dataID);
// sur : GTK+ callback :
static gboolean CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpointer data);
static gboolean CB_displayInit( GtkWidget *widget, gpointer data);
static gint CB_focusGet( GtkWidget *widget, GdkEventFocus *event, gpointer data);
static gint CB_focusLost( GtkWidget *widget, GdkEventFocus *event, gpointer data);
static gint CB_keyboardEvent( GtkWidget *widget, GdkEventKey *event, gpointer data);
static gint CB_mouseButtonEvent(GtkWidget *widget, GdkEventButton *event, gpointer data);
static gint CB_mouseMotionEvent( GtkWidget *widget, GdkEventMotion *event, 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:
void ViewPopupMenu(GtkWidget *parrent, GdkEventButton *event, int32_t BufferID);
// main windows widget :
GtkWidget * m_widget;
// r<>cup<75>ration des proprieter g<>n<EFBFBD>ral...
BufferManager * m_bufferManager;
ColorizeManager * m_colorManager;
MenuContext * m_menuContext;
int32_t m_shawableAreaX;
int32_t m_shawableAreaY;
int32_t m_selectedID;
int32_t m_contectMenuSelectID;
};
#endif

View File

@@ -1,419 +0,0 @@
/**
*******************************************************************************
* @file CodeView.cpp
* @brief Editeur De N'ours : Code Viewer Widget
* This is an abstraction
* @author Edouard DUPIN
* @date 05/01/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 "CodeView.h"
#include "tools_debug.h"
#include "tools_globals.h"
#include "Display.h"
#include "CodeView.h"
#include "BufferManager.h"
#include "ColorizeManager.h"
#include "ClipBoard.h"
#include "SearchData.h"
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
m_bufferManager = BufferManager::getInstance();
m_colorManager = ColorizeManager::getInstance();
m_menuContext = MenuContext::getInstance();
m_widget = gtk_drawing_area_new();
gtk_widget_set_size_request( m_widget, 200, 100);
gtk_widget_add_events( m_widget,
GDK_KEY_PRESS_MASK
| GDK_BUTTON_PRESS_MASK
| GDK_BUTTON_RELEASE_MASK
| GDK_POINTER_MOTION_MASK
| GDK_POINTER_MOTION_HINT_MASK);
# ifdef USE_GTK_VERSION_3_0
g_object_set(m_widget,"can-focus", TRUE, NULL);
# elif defined( USE_GTK_VERSION_2_0 )
GTK_WIDGET_SET_FLAGS(m_widget, GTK_CAN_FOCUS);
# endif
// Focus Event
g_signal_connect( G_OBJECT(m_widget), "focus_in_event", G_CALLBACK(CB_focusGet), this);
g_signal_connect( G_OBJECT(m_widget), "focus_out_event", G_CALLBACK(CB_focusLost), this);
// Keyboard Event
g_signal_connect_after( G_OBJECT(m_widget), "key_press_event", G_CALLBACK(CB_keyboardEvent), this);
g_signal_connect_after( G_OBJECT(m_widget), "key_release_event", G_CALLBACK(CB_keyboardEvent), this);
// Mouse Event
g_signal_connect( G_OBJECT(m_widget), "button_press_event", G_CALLBACK(CB_mouseButtonEvent), this);
g_signal_connect( G_OBJECT(m_widget), "button_release_event", G_CALLBACK(CB_mouseButtonEvent), this);
g_signal_connect( G_OBJECT(m_widget), "motion_notify_event", G_CALLBACK(CB_mouseMotionEvent), this);
g_signal_connect( G_OBJECT(m_widget), "scroll-event", G_CALLBACK(CB_mouseScrollEvent), this);
// Display Event
g_signal_connect( G_OBJECT(m_widget), "realize", G_CALLBACK(CB_displayInit), this);
# ifdef USE_GTK_VERSION_3_0
g_signal_connect( G_OBJECT(m_widget), "draw", G_CALLBACK(CB_displayDraw), this);
# elif defined( USE_GTK_VERSION_2_0 )
g_signal_connect( G_OBJECT(m_widget), "expose_event", G_CALLBACK(CB_displayDraw), this);
# endif
}
CodeView::~CodeView(void)
{
}
GtkWidget * CodeView::GetMainWidget(void)
{
return m_widget;
}
void CodeView::OnMessage(int32_t id, int32_t dataID)
{
switch (id)
{
case EDN_MSG__CURRENT_CHANGE_BUFFER_ID:
//EDN_INFO("Select a new Buffer ... " << dataID);
m_bufferID = dataID;
m_bufferManager->Get(m_bufferID)->ForceReDraw(true);
// request the dispplay of the curent Editor
SendMessage(EDN_MSG__BUFFER_CHANGE_CURRENT, m_bufferID);
break;
case EDN_MSG__CURRENT_SAVE:
SendMessage(EDN_MSG__BUFF_ID_SAVE, m_bufferID);
break;
case EDN_MSG__CURRENT_SAVE_AS:
SendMessage(EDN_MSG__GUI_SHOW_SAVE_AS, m_bufferID);
break;
case EDN_MSG__CURRENT_REMOVE_LINE:
m_bufferManager->Get(m_bufferID)->RemoveLine();
break;
case EDN_MSG__CURRENT_SELECT_ALL:
m_bufferManager->Get(m_bufferID)->SelectAll();
break;
case EDN_MSG__CURRENT_UN_SELECT:
m_bufferManager->Get(m_bufferID)->SelectNone();
break;
case EDN_MSG__CURRENT_COPY:
if (dataID == -1) {
dataID = COPY_STD;
}
m_bufferManager->Get(m_bufferID)->Copy(dataID);
break;
case EDN_MSG__CURRENT_CUT:
if (dataID == -1) {
dataID = COPY_STD;
}
m_bufferManager->Get(m_bufferID)->Cut(dataID);
break;
case EDN_MSG__CURRENT_PASTE:
if (dataID == -1) {
dataID = COPY_STD;
}
m_bufferManager->Get(m_bufferID)->Paste(dataID);
break;
case EDN_MSG__CURRENT_FIND_PREVIOUS:
{
Edn::String myDataString;
SearchData::GetSearch(myDataString);
m_bufferManager->Get(m_bufferID)->Search(myDataString, true, SearchData::GetCase(), SearchData::GetWrap(), SearchData::GetRegExp() );
}
break;
case EDN_MSG__CURRENT_FIND_NEXT:
{
Edn::String myDataString;
SearchData::GetSearch(myDataString);
m_bufferManager->Get(m_bufferID)->Search(myDataString, false, SearchData::GetCase(), SearchData::GetWrap(), SearchData::GetRegExp() );
}
break;
case EDN_MSG__CURRENT_REPLACE:
{
Edn::String myDataString;
SearchData::GetReplace(myDataString);
m_bufferManager->Get(m_bufferID)->Replace(myDataString);
}
break;
case EDN_MSG__CURRENT_REPLACE_ALL:
break;
case EDN_MSG__CURRENT_CLOSE:
SendMessage(EDN_MSG__BUFF_ID_CLOSE, m_bufferID);
break;
case EDN_MSG__CURRENT_UNDO:
m_bufferManager->Get(m_bufferID)->Undo();
break;
case EDN_MSG__CURRENT_REDO:
m_bufferManager->Get(m_bufferID)->Redo();
break;
case EDN_MSG__CURRENT_GOTO_LINE:
if (dataID<0) {
dataID = 0;
}
m_bufferManager->Get(m_bufferID)->JumpAtLine(dataID);
break;
case EDN_MSG__REFRESH_DISPLAY:
break;
case EDN_MSG__CURRENT_SET_CHARSET:
m_bufferManager->Get(m_bufferID)->SetCharset((charset_te)dataID);
break;
}
// Force redraw of the widget
gtk_widget_queue_draw(m_widget);
}
gboolean CodeView::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
CodeView * self = reinterpret_cast<CodeView*>(data);
//EDN_INFO("displayDraw_cb");
# ifdef USE_GTK_VERSION_3_0
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
bool needRedrawAll = false;
if (self->m_shawableAreaX != allocation.width) {
needRedrawAll = true;
self->m_shawableAreaX = allocation.width;
}
if (self->m_shawableAreaY != allocation.height) {
needRedrawAll = true;
self->m_shawableAreaY = allocation.height;
}
# elif defined( USE_GTK_VERSION_2_0)
bool needRedrawAll = false;
if (self->m_shawableAreaX != widget->allocation.width) {
needRedrawAll = true;
self->m_shawableAreaX = widget->allocation.width;
}
if (self->m_shawableAreaY != widget->allocation.height) {
needRedrawAll = true;
self->m_shawableAreaY = widget->allocation.height;
}
# endif
if (true == needRedrawAll) {
//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 :
ColorizeManager *myColorManager = NULL;
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);
//EDN_INFO("Display buffer ID = " << m_bufferID);
(void)self->m_bufferManager->Get(self->m_bufferID)->Display(monDrawer);
// EDN_WARNING("Must display here ... ");
return TRUE;
}
// sur : émis lors du premier affichage de la GtkDrawingArea
gboolean CodeView::CB_displayInit( GtkWidget *widget, gpointer data)
{
CodeView * self = reinterpret_cast<CodeView*>(data);
# ifdef USE_GTK_VERSION_3_0
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
int32_t size_x = allocation.width;
int32_t size_y = allocation.height;
self->m_shawableAreaX = allocation.width;
self->m_shawableAreaY = allocation.height;
# elif defined( USE_GTK_VERSION_2_0)
int32_t size_x = widget->allocation.width;
int32_t size_y = widget->allocation.height;
self->m_shawableAreaX = widget->allocation.width;
self->m_shawableAreaY = widget->allocation.height;
# endif
EDN_INFO("Request a diplay of : "<< size_x <<"px * "<< size_y <<"px");
gtk_widget_queue_draw( widget );
return TRUE;
}
gint CodeView::CB_focusGet( GtkWidget *widget, GdkEventFocus *event, gpointer data)
{
CodeView * self = reinterpret_cast<CodeView*>(data);
# ifdef USE_GTK_VERSION_2_0
GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
# endif
self->SendMessage(EDN_MSG__BUFFER_CHANGE_CURRENT, self->m_bufferID);
EDN_INFO("Focus - In");
return FALSE;
}
gint CodeView::CB_focusLost( GtkWidget *widget, GdkEventFocus *event, gpointer data)
{
//CodeView * self = reinterpret_cast<CodeView*>(data);
# ifdef USE_GTK_VERSION_2_0
GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS);
# endif
EDN_INFO("Focus - out");
return FALSE;
}
gint CodeView::CB_keyboardEvent(GtkWidget *widget, GdkEventKey *event, gpointer data)
{
CodeView * self = reinterpret_cast<CodeView*>(data);
char Utf8Out[10];
bool controlKey;
bool moveKey;
int32_t key;
// Convert input key :
ConvertInput(event, Utf8Out, controlKey, moveKey, key);
if(event->type == GDK_KEY_PRESS) {
if(false==controlKey) {
self->m_bufferManager->Get(self->m_bufferID)->AddChar(Utf8Out);
gtk_widget_queue_draw( widget );
} else if (true == moveKey) {
self->m_bufferManager->Get(self->m_bufferID)->cursorMove(key);
gtk_widget_queue_draw( widget );
}
}
return true;
}
gint CodeView::CB_mouseButtonEvent(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
CodeView * self = reinterpret_cast<CodeView*>(data);
// get focus on the widget
gtk_widget_grab_focus(widget);
if (event->button == 1) {
if (event->type == GDK_BUTTON_PRESS) {
//EDN_INFO("mouse-event BT1 ==> One Clicked %d, %d", (uint32_t)event->x, (uint32_t)event->y);
self->m_bufferManager->Get(self->m_bufferID)->MouseEvent(event->x, event->y);
gtk_widget_queue_draw( widget );
self->m_buttunOneSelected = true;
}else if (event->type == GDK_2BUTTON_PRESS) {
//EDN_INFO("mouse-event BT1 ==> Double Clicked %d, %d", (uint32_t)event->x, (uint32_t)event->y);
self->m_bufferManager->Get(self->m_bufferID)->MouseEventDouble();
gtk_widget_queue_draw( widget );
self->m_buttunOneSelected = true;
}else if (event->type == GDK_3BUTTON_PRESS) {
//EDN_INFO("mouse-event BT1 ==> Triple Clicked");
self->m_bufferManager->Get(self->m_bufferID)->MouseEventTriple();
gtk_widget_queue_draw( widget );
self->m_buttunOneSelected = true;
}else if (event->type == GDK_BUTTON_RELEASE) {
//EDN_INFO("mouse-event BT1 ==> Realease");
self->m_buttunOneSelected = false;
self->m_bufferManager->Get(self->m_bufferID)->Copy(COPY_MIDDLE_BUTTON);
}
} else if (event->button == 2) {
if (event->type == GDK_BUTTON_PRESS) {
EDN_INFO("mouse-event BT2 PRESS");
self->m_bufferManager->Get(self->m_bufferID)->MouseEvent(event->x, event->y);
self->m_bufferManager->Get(self->m_bufferID)->Paste(COPY_MIDDLE_BUTTON);
gtk_widget_queue_draw(widget);
}
} else if (event->button == 3) {
if (event->type == GDK_BUTTON_PRESS) {
EDN_INFO("mouse-event BT3 PRESS");
}
} else {
EDN_INFO("mouse-event BT" << event->type <<" PRESS");
}
return true;
}
gint CodeView::CB_mouseMotionEvent( GtkWidget *widget, GdkEventMotion *event, gpointer data)
{
CodeView * self = reinterpret_cast<CodeView*>(data);
if (true == self->m_buttunOneSelected) {
int x, y;
GdkModifierType state;
if (event->is_hint) {
gdk_window_get_pointer(event->window, &x, &y, &state);
} else {
x = event->x;
y = event->y;
state = (GdkModifierType)event->state;
}
if (x<0) {
x = 0;
}
if (y<0) {
y = 0;
}
//EDN_INFO("mouse-motion BT1 %d, %d", x, y);
self->m_bufferManager->Get(self->m_bufferID)->MouseSelectFromCursorTo(x, y);
gtk_widget_queue_draw( widget );
}
return true;
}
gint CodeView::CB_mouseScrollEvent( GtkWidget *widget, GdkEventScroll *event, gpointer data)
{
CodeView * self = reinterpret_cast<CodeView*>(data);
if (event->direction == GDK_SCROLL_UP)
{
// up code
//EDN_INFO("mouse-event GDK_SCROLL_UP");
self->m_bufferManager->Get(self->m_bufferID)->ScrollUp();
gtk_widget_queue_draw( widget );
}
else if (event->direction == GDK_SCROLL_DOWN)
{
// down code
//EDN_INFO("mouse-event GDK_SCROLL_DOWN");
self->m_bufferManager->Get(self->m_bufferID)->ScrollDown();
gtk_widget_queue_draw( widget );
} else {
EDN_INFO("mouse-event SCROLL");
}
return true;
}

View File

@@ -1,69 +0,0 @@
/**
*******************************************************************************
* @file CodeView.h
* @brief Editeur De N'ours : Code Viewer Widget (header)
* @author Edouard DUPIN
* @date 05/01/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 __CODE_VIEW_H__
#define __CODE_VIEW_H__
#include "tools_debug.h"
#include "Singleton.h"
#include "CodeView.h"
#include "BufferManager.h"
#include "Display.h"
#include "MsgBroadcast.h"
#include "MenuContext.h"
class CodeView : public MsgBroadcast
{
public:
// Constructeur
CodeView(void);
~CodeView(void);
void OnMessage(int32_t id, int32_t dataID);
GtkWidget *GetMainWidget(void);
// sur : GTK+ callback :
static gboolean CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpointer data);
static gboolean CB_displayInit( GtkWidget *widget, gpointer data);
static gint CB_focusGet( GtkWidget *widget, GdkEventFocus *event, gpointer data);
static gint CB_focusLost( GtkWidget *widget, GdkEventFocus *event, gpointer data);
static gint CB_keyboardEvent( GtkWidget *widget, GdkEventKey *event, gpointer data);
static gint CB_mouseButtonEvent(GtkWidget *widget, GdkEventButton *event, gpointer data);
static gint CB_mouseMotionEvent( GtkWidget *widget, GdkEventMotion *event, gpointer data);
static gint CB_mouseScrollEvent( GtkWidget *widget, GdkEventScroll *event, gpointer data);
private:
// main windows widget :
GtkWidget * m_widget;
// récupération des proprieter général...
BufferManager * m_bufferManager;
ColorizeManager * m_colorManager;
MenuContext * m_menuContext;
int32_t m_shawableAreaX;
int32_t m_shawableAreaY;
int32_t m_bufferID;
bool m_buttunOneSelected;
};
#endif

View File

@@ -1,60 +0,0 @@
/**
*******************************************************************************
* @file Search.h
* @brief Editeur De N'ours : Search system (header)
* @author Edouard DUPIN
* @date 03/01/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 __SEARCH_H__
#define __SEARCH_H__
#include "tools_debug.h"
#include "Singleton.h"
#include <string>
#include <vector>
class MainAreaView: public Singleton<MainAreaView>
{
friend class Singleton<MainAreaView>;
// specific for sigleton system...
private:
// Constructeur
MainAreaView(void);
~MainAreaView(void);
public:
GtkWidget * GetWidget(void);
void SplitV(void); // split current window vertically (max 1 by section)
void SplitH(void); // split current window horizontaly (max 3)
void Remove(void); // remove current selected element
//ViewArea * GetCurent(void); // Get a pointer on the current displayed area
private:
GtkWidget * m_localDialog; //!< local dialog element
ViewArea * m_EntrySearch[6];
uint8_t m_CurentSelected
};
#endif

View File

@@ -1,191 +0,0 @@
/**
*******************************************************************************
* @file MainWindows.cpp
* @brief Editeur De N'ours : main Windows diplayer (Sources)
* @author Edouard DUPIN
* @date 04/01/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 "MainWindows.h"
#include "CodeView.h"
#include "ClipBoard.h"
#include "BufferView.h"
#include "AccelKey.h"
#undef __class__
#define __class__ "MainWindows"
MainWindows::MainWindows(void) : MsgBroadcast("Main Windows", EDN_CAT_GUI)
{
m_mainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
// select the program icone
gtk_window_set_default_icon_name("text-editor");
// Default size open windows
gtk_window_set_default_size(GTK_WINDOW(m_mainWindow), 800, 600);
// 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), "destroy", G_CALLBACK(OnQuit), this);
// Create a vertical box for stacking the menu and editor widgets in.
GtkWidget *vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add(GTK_CONTAINER(m_mainWindow), vbox);
// Set key Accelerator :
AccelKey::getInstance()->LinkCommonAccel(GTK_WINDOW(m_mainWindow));
// Create the menu bar.
gtk_box_pack_start( GTK_BOX (vbox), m_MenuBar.GetWidget(), FALSE, FALSE, 0);
// **********************************************************
// * Horizontal ELEMENTS : *
// **********************************************************
// Create a vertical box for stacking the menu and editor widgets in.
GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
gtk_container_add(GTK_CONTAINER (vbox), hbox);
// create the toolbar :
# if USE_GTK_VERSION_2_0
gtk_box_pack_start(GTK_BOX(hbox), m_ToolBar.GetWidget(), FALSE, FALSE, 0);
# endif
// TreeView :
gtk_box_pack_start(GTK_BOX(hbox), m_BufferView.GetMainWidget(), FALSE, TRUE, 1);
// Tex displayer :
gtk_box_pack_start( GTK_BOX (hbox), m_CodeView.GetMainWidget(), TRUE, TRUE, 0);
// Create the status bar
gtk_box_pack_end(GTK_BOX(vbox), m_StatusBar.GetWidget(), FALSE, FALSE, 0);
// recursive version of gtk_widget_show
gtk_widget_show_all(m_mainWindow);
}
MainWindows::~MainWindows(void)
{
/*
if (NULL != m_DlgSearch) {
delete m_DlgSearch;
}
*/
}
void MainWindows::SetTitle(Edn::String &fileName, bool isModify)
{
Edn::String tmp = "";
if (fileName != "") {
tmp += fileName;
tmp += " - ";
}
tmp += "Edn";
gtk_window_set_title(GTK_WINDOW(m_mainWindow), tmp.c_str());
}
void MainWindows::OnMessage(int32_t id, int32_t dataID)
{
switch (id)
{
case EDN_MSG__BUFFER_CHANGE_CURRENT:
// change Title :
// TODO : String error when remove the error with -1;
if (-1 == dataID) {
Edn::String plop = "";
SetTitle(plop, false );
} else {
Buffer *mybuf = BufferManager::getInstance()->Get(dataID);
if (NULL != mybuf) {
Edn::String plop = mybuf->GetName();
SetTitle(plop, mybuf->IsModify() );
}
}
break;
case EDN_MSG__QUIT:
OnQuit(m_mainWindow, this);
break;
}
}
bool MainWindows::OnQuit(GtkWidget *widget, gpointer data)
{
EDN_INFO("quit requested");
// dlg to confirm the quit event :
GtkWidget *p_dialog = gtk_dialog_new_with_buttons("Exit",
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;
break;
}
gtk_main_quit();
return false;
}
#if 0
void MainWindows::OnMenuAbout(wxCommandEvent & WXUNUSED(event))
{
//EDN_INFO("MainWindows::OnMenuAbout (event)");
wxAboutDialogInfo info;
info.SetName(wxT("edn"));
info.SetVersion(wxT("0.1.0 pre-Beta"));
info.SetDescription(wxT("Editeur De N'ours, l'Editeur Desoxyribo-Nucleique\n"
"Source Code Editor"));
info.SetCopyright(wxT( "Copyright 2010 Edouard DUPIN, all right reserved\n"
"This software is distributed in the hope that it will be useful, but WITHOUT\n"
"ANY WARRANTY\n\n"
"Licence summary : \n"
" You can modify and redistribute the sources code and binaries.\n"
" You can send me the bug-fix\n"
" 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

@@ -1,68 +0,0 @@
/**
*******************************************************************************
* @file MainWindows.h
* @brief Editeur De N'ours : main Windows diplayer (header)
* @author Edouard DUPIN
* @date 04/01/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 "Singleton.h"
#include "MsgBroadcast.h"
#include "CodeView.h"
#include "BufferView.h"
#include "BufferManager.h"
#include "MenuBar.h"
#include "StatusBar.h"
#include "ToolBar.h"
#ifndef __MAIN_WINDOWS_H__
#define __MAIN_WINDOWS_H__
class MainWindows: public Singleton<MainWindows>, public MsgBroadcast
{
friend class Singleton<MainWindows>;
// specific for sigleton system...
private:
// Constructeur
MainWindows(void);
~MainWindows(void);
public:
GtkWidget * GetWidget(void) { return m_mainWindow;};
void OnMessage(int32_t id, int32_t dataID);
static bool OnQuit(GtkWidget *widget, gpointer data);
private:
void SetTitle(Edn::String &fileName, bool isModify);
// main windows widget :
GtkWidget * m_mainWindow;
BufferView m_BufferView;
CodeView m_CodeView;
MenuBar m_MenuBar;
StatusBar m_StatusBar;
ToolBar m_ToolBar;
};
#endif

View File

@@ -1,352 +0,0 @@
/**
*******************************************************************************
* @file MenuBar.cpp
* @brief Editeur De N'ours : abstraction of the menu bar (Sources)
* @author Edouard DUPIN
* @date 17/06/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 "MenuBar.h"
#include "ClipBoard.h"
#include "charset.h"
#define MENU_MSG
const char * MSG_TogleDisplayChar = "Request a Togle of char displaying";
const char * MSG_TogleDisplayEOL = "Request a Togle of displaying EndOfLine";
const char * MSG_TogleAutoIndent = "Request a Togle of Auto Indent";
const char * MSG_SetCharsetIso559_1 = "Set ISO 5589-1";
const char * MSG_SetCharsetIso559_15 = "Set ISO 5589-15";
const char * MSG_SetCharsetUTF8 = "Set UTF 8";
#define MSG_LINK(data)
static void CB_menuGenerique(GtkMenuItem *menu_item, gpointer data)
{
//EDN_INFO("basic menue_event");
messageData_ts * msg = (messageData_ts*)data;
GeneralSendMessage(msg->msgId, msg->dataId);
}
static void CB_menuInternal(GtkMenuItem *menu_item, gpointer data)
{
//EDN_INFO("basic menue_event");
const char * myPointer = (const char*)data;
if (myPointer == MSG_TogleDisplayChar) {
if (globals::IsSetDisplaySpaceChar() == true) {
globals::SetDisplaySpaceChar(false);
} else {
globals::SetDisplaySpaceChar(true);
}
} else if (myPointer == MSG_TogleDisplayEOL) {
if (globals::IsSetDisplayEndOfLine() == true) {
globals::SetDisplayEndOfLine(false);
} else {
globals::SetDisplayEndOfLine(true);
}
} else if (myPointer == MSG_TogleAutoIndent) {
if (globals::IsSetAutoIndent() == true) {
globals::SetAutoIndent(false);
} else {
globals::SetAutoIndent(true);
}
} else if (myPointer == MSG_SetCharsetIso559_1) {
GeneralSendMessage(EDN_MSG__CURRENT_SET_CHARSET, EDN_CHARSET_ISO_8859_1);
} else if (myPointer == MSG_SetCharsetIso559_15) {
GeneralSendMessage(EDN_MSG__CURRENT_SET_CHARSET, EDN_CHARSET_ISO_8859_15);
} else if (myPointer == MSG_SetCharsetUTF8) {
GeneralSendMessage(EDN_MSG__CURRENT_SET_CHARSET, EDN_CHARSET_UTF8);
}
}
#undef __class__
#define __class__ "MenuBarMain"
class MenuBarMain
{
public:
MenuBarMain(const char * title, GtkWidget * parent) : m_parent(NULL), m_menu(NULL), m_menuListe(NULL)
{
m_parent = parent;
m_menu = gtk_menu_item_new_with_mnemonic(title);
gtk_menu_shell_append( GTK_MENU_SHELL (parent), m_menu);
}
~MenuBarMain(void)
{
}
private:
void CheckSubMenu(void)
{
if (NULL == m_menuListe) {
m_menuListe = gtk_menu_new();
if (NULL != m_menuListe) {
gtk_menu_item_set_submenu( GTK_MENU_ITEM (m_menu), m_menuListe);
} else {
EDN_ERROR("Can not create sub menu");
}
}
}
public:
void AddInternal(const char * title, const char * accelKey, const char * msg, bool enable = false)
{
CheckSubMenu();
if (NULL == m_menuListe) {
return;
}
// create ITEM
GtkWidget *tmpWidget = gtk_menu_item_new_with_mnemonic(title);
// set grisage :
gtk_widget_set_sensitive(tmpWidget, enable);
// add to the menu :
gtk_menu_shell_append(GTK_MENU_SHELL(m_menuListe), tmpWidget);
// accel KEY :
AccelKey::getInstance()->SetAccel(tmpWidget, (char *)accelKey);
// set callback
g_signal_connect(G_OBJECT(tmpWidget), "activate", G_CALLBACK(CB_menuInternal), (void*)msg);
}
void Add(const char * title, const char * accelKey, messageType_te id = EDN_MSG__NONE, bool enable = false, int32_t dataSpecificID = -1)
{
CheckSubMenu();
if (NULL == m_menuListe) {
return;
}
messageData_ts * message = new messageData_ts;
message->msgId = id;
message->dataId = dataSpecificID;
m_message.PushBack(message);
// create ITEM
GtkWidget *tmpWidget = gtk_menu_item_new_with_mnemonic(title);
// set grisage :
gtk_widget_set_sensitive(tmpWidget, enable);
// add to the menu :
gtk_menu_shell_append(GTK_MENU_SHELL(m_menuListe), tmpWidget);
// accel KEY :
AccelKey::getInstance()->SetAccel(tmpWidget, (char *)accelKey);
// set callback
if(EDN_MSG__NONE!=id) {
g_signal_connect(G_OBJECT(tmpWidget), "activate", G_CALLBACK(CB_menuGenerique), message);
}
}
void AddGen(const char * title, const char * accelKey, messageType_te id = EDN_MSG__NONE, bool enable = false, int32_t dataSpecificID = -1)
{
CheckSubMenu();
if (NULL == m_menuListe) {
return;
}
messageData_ts * message = new messageData_ts;
message->msgId = id;
message->dataId = dataSpecificID;
m_message.PushBack(message);
// create ITEM
GtkWidget *tmpWidget = gtk_image_menu_item_new_from_stock( title, AccelKey::getInstance()->GetAccel() );
// set grisage :
gtk_widget_set_sensitive(tmpWidget, enable);
// add to the menu :
gtk_menu_shell_append(GTK_MENU_SHELL(m_menuListe), tmpWidget);
// accel KEY :
AccelKey::getInstance()->SetAccel(tmpWidget, (char *)accelKey);
// set callback
if(EDN_MSG__NONE!=id) {
g_signal_connect(G_OBJECT(tmpWidget), "activate", G_CALLBACK(CB_menuGenerique), message);
}
}
void AddSeparator(void)
{
CheckSubMenu();
if (NULL == m_menuListe) {
return;
}
gtk_menu_shell_append(GTK_MENU_SHELL (m_menuListe), gtk_separator_menu_item_new() );
}
private:
GtkWidget * m_parent;
GtkWidget * m_menu;
GtkWidget * m_menuListe;
Edn::VectorType<messageData_ts*> m_message;
};
#undef __class__
#define __class__ "MenuBar"
MenuBar::MenuBar(void) : MsgBroadcast("Menu bar", EDN_CAT_GUI)
{
m_mainWidget = gtk_menu_bar_new();
MenuBarMain *tmp = NULL;
tmp = new MenuBarMain("_File", m_mainWidget);
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->AddSeparator();
tmp->AddGen("Close file", NULL, EDN_MSG__CURRENT_CLOSE, true);
tmp->AddSeparator();
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->AddSeparator();
tmp->AddGen(GTK_STOCK_QUIT, "ctrl+q", EDN_MSG__QUIT, true);
m_listMenu.PushBack(tmp);
tmp = new MenuBarMain("_Edit", m_mainWidget);
tmp->AddGen(GTK_STOCK_UNDO, "ctrl+z", EDN_MSG__CURRENT_UNDO, true);
tmp->AddGen(GTK_STOCK_REDO, "ctrl+shift+z", EDN_MSG__CURRENT_REDO, true);
tmp->AddSeparator();
tmp->AddGen(GTK_STOCK_CUT, "ctrl+x", EDN_MSG__CURRENT_CUT, 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_DELETE, NULL);
tmp->AddGen("Remove line", "ctrl+d", EDN_MSG__CURRENT_REMOVE_LINE, true);
tmp->AddSeparator();
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->AddSeparator();
tmp->AddGen("Goto Line number ...", "ctrl+l", EDN_MSG__GUI_SHOW_GOTO_LINE, true);
// tmp->AddSeparator();
// tmp->AddGen(GTK_STOCK_PREFERENCES, NULL, EDN_MSG__GUI_SHOW_PREFERENCE, true);
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->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->AddSeparator();
tmp->AddGen("Find next", "ctrl+h", EDN_MSG__CURRENT_FIND_NEXT, true);
tmp->AddGen("Find previous", "ctrl+shift+h", EDN_MSG__CURRENT_FIND_PREVIOUS, true);
// tmp->AddGen("Find old next", "ctrl+g", EDN_MSG__CURRENT_FIND_OLD_NEXT, true);
// tmp->AddGen("Find old previous", "ctrl+shift+g", EDN_MSG__CURRENT_FIND_OLD_PREVIOUS, true);
// tmp->AddSeparator();
// tmp->AddGen("Suprimer colorisation", NULL);
// tmp->AddSeparator();
// tmp->AddGen("Goto Line", "ctrl+l", EDN_MSG__CURRENT_GOTO_LINE, true);
m_listMenu.PushBack(tmp);
/*
tmp = new MenuBarMain("Project", m_mainWidget);
m_listMenu.PushBack(tmp);
*/
tmp = new MenuBarMain("Ctags", m_mainWidget);
tmp->AddGen("load Ctags file", NULL, EDN_MSG__OPEN_CTAGS, true);
tmp->AddGen("re-load Ctags file", NULL, EDN_MSG__RELOAD_CTAGS, true);
tmp->AddSeparator();
tmp->AddGen("Find Definition", "ctrl+u", EDN_MSG__JUMP_TO_CURRENT_SELECTION, true);
tmp->AddGen("Back previous", "ctrl+y", EDN_MSG__JUMP_BACK, true);
/*
tmp->AddGen("Gestion Ctags", NULL);
tmp->AddGen("Add Ctags Folder", NULL);
tmp->AddSeparator();
tmp->AddGen("Trouver la definition", NULL);
tmp->AddGen("Trouver la declaration", NULL);
tmp->AddGen("Retour...", NULL);
tmp->AddSeparator();
tmp->AddGen("Tout desactiver", NULL);
*/
m_listMenu.PushBack(tmp);
/*
tmp = new MenuBarMain("Macros", m_mainWidget);
m_listMenu.PushBack(tmp);
*/
/*
tmp = new MenuBarMain("Tools", m_mainWidget);
tmp->AddGen("Execute Commande", "ctrl+e");
tmp->AddGen("Set Command", NULL);
m_listMenu.PushBack(tmp);
*/
tmp = new MenuBarMain("Internal ClipBoard", m_mainWidget);
// tmp->AddGen("Cut 1", "ctrl+alt+1", EDN_MSG__CURRENT_CUT, true, 1);
tmp->AddGen("Copy 1", "ctrl+1", EDN_MSG__CURRENT_COPY, true, 1);
tmp->AddGen("Paste 1", "alt+1", EDN_MSG__CURRENT_PASTE, true, 1);
tmp->AddSeparator();
// tmp->AddGen("Cut 2", "ctrl+alt+2", EDN_MSG__CURRENT_CUT, true, 2);
tmp->AddGen("Copy 2", "ctrl+2", EDN_MSG__CURRENT_COPY, true, 2);
tmp->AddGen("Paste 2", "alt+2", EDN_MSG__CURRENT_PASTE, true, 2);
tmp->AddSeparator();
// tmp->AddGen("Cut 3", "ctrl+alt+3", EDN_MSG__CURRENT_CUT, true, 3);
tmp->AddGen("Copy 3", "ctrl+3", EDN_MSG__CURRENT_COPY, true, 3);
tmp->AddGen("Paste 3", "alt+3", EDN_MSG__CURRENT_PASTE, true, 3);
tmp->AddSeparator();
// tmp->AddGen("Cut 4", "ctrl+alt+4", EDN_MSG__CURRENT_CUT, true, 4);
tmp->AddGen("Copy 4", "ctrl+4", EDN_MSG__CURRENT_COPY, true, 4);
tmp->AddGen("Paste 4", "alt+4", EDN_MSG__CURRENT_PASTE, true, 4);
tmp->AddSeparator();
// tmp->AddGen("Cut 5", "ctrl+alt+5", EDN_MSG__CURRENT_CUT, true, 5);
tmp->AddGen("Copy 5", "ctrl+5", EDN_MSG__CURRENT_COPY, true, 5);
tmp->AddGen("Paste 5", "alt+5", EDN_MSG__CURRENT_PASTE, true, 5);
tmp->AddSeparator();
// tmp->AddGen("Cut 6", "ctrl+alt+6", EDN_MSG__CURRENT_CUT, true, 6);
tmp->AddGen("Copy 6", "ctrl+6", EDN_MSG__CURRENT_COPY, true, 6);
tmp->AddGen("Paste 6", "alt+6", EDN_MSG__CURRENT_PASTE, true, 6);
tmp->AddSeparator();
// tmp->AddGen("Cut 7", "ctrl+alt+7", EDN_MSG__CURRENT_CUT, true, 7);
tmp->AddGen("Copy 7", "ctrl+7", EDN_MSG__CURRENT_COPY, true, 7);
tmp->AddGen("Paste 7", "alt+7", EDN_MSG__CURRENT_PASTE, true, 7);
tmp->AddSeparator();
// tmp->AddGen("Cut 8", "ctrl+alt+8", EDN_MSG__CURRENT_CUT, true, 8);
tmp->AddGen("Copy 8", "ctrl+8", EDN_MSG__CURRENT_COPY, true, 8);
tmp->AddGen("Paste 8", "alt+8", EDN_MSG__CURRENT_PASTE, true, 8);
tmp->AddSeparator();
// tmp->AddGen("Cut 9", "ctrl+alt+9", EDN_MSG__CURRENT_CUT, true, 9);
tmp->AddGen("Copy 9", "ctrl+9", EDN_MSG__CURRENT_COPY, true, 9);
tmp->AddGen("Paste 9", "alt+9", EDN_MSG__CURRENT_PASTE, true, 9);
m_listMenu.PushBack(tmp);
tmp = new MenuBarMain("Help", m_mainWidget);
tmp->AddGen("help display", NULL, EDN_MSG__OPEN_CTAGS, false);
tmp->AddSeparator();
tmp->AddGen("About ...", NULL, EDN_MSG__GUI_SHOW_ABOUT, true);
/*
tmp->AddGen("Gestion Ctags", NULL);
tmp->AddGen("Add Ctags Folder", NULL);
tmp->AddSeparator();
tmp->AddGen("Trouver la definition", NULL);
tmp->AddGen("Trouver la declaration", NULL);
tmp->AddGen("Retour...", NULL);
tmp->AddSeparator();
tmp->AddGen("Tout desactiver", NULL);
*/
m_listMenu.PushBack(tmp);
}
MenuBar::~MenuBar(void)
{
}
void MenuBar::OnMessage(int32_t id, int32_t dataID)
{
//EDN_INFO("ReceiveMessage");
}

View File

@@ -1,53 +0,0 @@
/**
*******************************************************************************
* @file MenuBar.h
* @brief Editeur De N'ours : abstraction of the menu bar (Header)
* @author Edouard DUPIN
* @date 17/06/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 "MsgBroadcast.h"
#include "VectorType.h"
#include "AccelKey.h"
#ifndef __MENU_BAR_H__
#define __MENU_BAR_H__
class MenuBarMain;
class MenuBar: public MsgBroadcast
{
public:
// Constructeur
MenuBar(void);
~MenuBar(void);
GtkWidget * GetWidget(void) { return m_mainWidget; };
void OnMessage(int32_t id, int32_t dataID);
private:
GtkWidget * m_mainWidget;
GtkAccelGroup * m_accelGroup;
Edn::VectorType<MenuBarMain*> m_listMenu;
};
#endif

View File

@@ -1,52 +0,0 @@
/**
*******************************************************************************
* @file StatusBar.cpp
* @brief Editeur De N'ours : abstraction of the status bar (Sources)
* @author Edouard DUPIN
* @date 17/06/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 "StatusBar.h"
StatusBar::StatusBar(void) : MsgBroadcast("Status bar", EDN_CAT_GUI)
{
m_mainWidget = gtk_statusbar_new();
// pas tr<74>s bien compris pourquoi mais ca marche...
m_iContextId = gtk_statusbar_get_context_id(GTK_STATUSBAR(m_mainWidget), "ExitMsg");
// ajout d'un message :
gtk_statusbar_push(GTK_STATUSBAR (m_mainWidget), GPOINTER_TO_INT(m_iContextId), "Edn Editeur de n'ours");
// Supression du pr<70>c<EFBFBD>dent message :
//gtk_statusbar_pop(GTK_STATUSBAR(m_mainWidget), GPOINTER_TO_INT(m_iContextId));
}
StatusBar::~StatusBar(void)
{
}
void StatusBar::OnMessage(int32_t id, int32_t dataID)
{
//EDN_INFO("ReceiveMessage");
}

View File

@@ -1,46 +0,0 @@
/**
*******************************************************************************
* @file StatusBar.h
* @brief Editeur De N'ours : abstraction of the status bar (Header)
* @author Edouard DUPIN
* @date 17/06/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 "MsgBroadcast.h"
#ifndef __STATUS_BAR_H__
#define __STATUS_BAR_H__
class StatusBar: public MsgBroadcast
{
public:
// Constructeur
StatusBar(void);
~StatusBar(void);
GtkWidget * GetWidget(void) { return m_mainWidget; };
void OnMessage(int32_t id, int32_t dataID);
private:
GtkWidget * m_mainWidget;
guint m_iContextId;
};
#endif

View File

@@ -1,93 +0,0 @@
/**
*******************************************************************************
* @file ToolBar.cpp
* @brief Editeur De N'ours : abstraction of the tool bar (Sources)
* @author Edouard DUPIN
* @date 17/06/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 "ToolBar.h"
#include "ClipBoard.h"
static void CB_menuGenerique(GtkMenuItem *menu_item, gpointer data)
{
//EDN_INFO("basic menue_event");
messageData_ts * msg = (messageData_ts*)data;
// broacast message :
GeneralSendMessage(msg->msgId, msg->dataId);
}
ToolBar::ToolBar(void) : MsgBroadcast("Tool bar", EDN_CAT_GUI)
{
m_mainWidget = gtk_toolbar_new();
# ifdef USE_GTK_VERSION_2_0
gtk_toolbar_set_orientation(GTK_TOOLBAR(m_mainWidget), GTK_ORIENTATION_VERTICAL);
# endif
// Modification de la taille des icones
gtk_toolbar_set_icon_size(GTK_TOOLBAR(m_mainWidget), GTK_ICON_SIZE_BUTTON);
// Affichage uniquement des icones
gtk_toolbar_set_style(GTK_TOOLBAR(m_mainWidget), GTK_TOOLBAR_ICONS);
Add(GTK_STOCK_NEW, "Nouveau", EDN_MSG__NEW);
Add(GTK_STOCK_OPEN, "Ouvrir", EDN_MSG__GUI_SHOW_OPEN_FILE);
AddSeparator();
Add(GTK_STOCK_SAVE, "Enregistrer", EDN_MSG__CURRENT_SAVE);
Add(GTK_STOCK_SAVE_AS, "Enregistrer sous", EDN_MSG__CURRENT_SAVE_AS);
AddSeparator();
Add(GTK_STOCK_QUIT, "Quitter");
}
ToolBar::~ToolBar(void)
{
}
void ToolBar::OnMessage(int32_t id, int32_t dataID)
{
//EDN_INFO("ReceiveMessage");
}
void ToolBar::AddSeparator(void)
{
# ifdef USE_GTK_VERSION_3_0
# elif defined( USE_GTK_VERSION_2_0)
gtk_toolbar_append_space(GTK_TOOLBAR(m_mainWidget));
# endif
}
void ToolBar::Add(const char * title, const char * labelHelp, messageType_te id, bool enable)
{
messageData_ts * message = new messageData_ts;
message->msgId = id;
message->dataId = -1;
m_message.PushBack(message);
# ifdef USE_GTK_VERSION_3_0
# elif defined( USE_GTK_VERSION_2_0)
gtk_toolbar_insert_stock(GTK_TOOLBAR(m_mainWidget), title, labelHelp, NULL, G_CALLBACK(CB_menuGenerique), message, -1);
# endif
}

View File

@@ -1,49 +0,0 @@
/**
*******************************************************************************
* @file ToolBar.h
* @brief Editeur De N'ours : abstraction of the tool bar (Header)
* @author Edouard DUPIN
* @date 17/06/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 "MsgBroadcast.h"
#ifndef __TOOL_BAR_H__
#define __TOOL_BAR_H__
class ToolBar: public MsgBroadcast
{
public:
// Constructeur
ToolBar(void);
~ToolBar(void);
GtkWidget * GetWidget(void) { return m_mainWidget; };
void OnMessage(int32_t id, int32_t dataID);
private:
void AddSeparator(void);
void Add(const char * title, const char * labelHelp, messageType_te id = EDN_MSG__NONE, bool enable = false);
GtkWidget * m_mainWidget;
Edn::VectorType<messageData_ts*> m_message;
};
#endif

View File

@@ -1,490 +0,0 @@
/**
*******************************************************************************
* @file MenuContext.cpp
* @brief Editeur De N'ours : special Menu (left button or normal menu) (Sources)
* @author Edouard DUPIN
* @date 22/07/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 "MenuContext.h"
#undef __class__
#define __class__ "MenuContext"
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
MenuContext::MenuContext(void) : MsgBroadcast("Menu Context", EDN_CAT_MENU_CONTEXT)
{
//m_currentBufferID = -1;
m_dialog = NULL;
m_shawableSize.x=200;
m_shawableSize.y=200;
// Init link with the buffer Manager
m_bufferManager = BufferManager::getInstance();
m_colorManager = ColorizeManager::getInstance();
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
MenuContext::~MenuContext(void)
{
if(NULL != m_dialog) {
gtk_widget_destroy(m_dialog);
m_dialog = NULL;
}
}
void MenuContext::OnMessage(int32_t id, int32_t dataID)
{
switch (id)
{
/*
case EDN_MSG__BUFFER_CHANGE_CURRENT:
m_currentBufferID = dataID;
break;
*/
}
}
void MenuContext::Clear(void)
{
}
void MenuContext::AddCommonElem(int32_t id)
{
}
void MenuContext::AddSpecificElem(Edn::String &text)
{
}
/* This is called when we need to draw the windows contents */
static gboolean expose (GtkWidget *widget, GdkEventExpose *event, gpointer userdata)
{
gint width;
gint height;
cairo_t *cr = NULL;
# if USE_GTK_VERSION_3_0
cr = gdk_cairo_create(gtk_widget_get_window(widget));
# elif USE_GTK_VERSION_2_0
cr = gdk_cairo_create(widget->window);
# endif
//if (supports_alpha)
{
// transparent
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.0);
}
/*
else
{
// opaque white
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
}
*/
/* draw the background */
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_paint (cr);
/* draw a circle */
//gtk_window_get_size (GTK_WINDOW (widget), &width, &height);
//cairo_set_source_rgba (cr, 1, 0.2, 0.2, 0.6);
//cairo_arc (cr, width / 2, height / 2, (width < height ? width : height) / 2 - 8 , 0, 2 * 3.14);
//cairo_fill (cr);
//cairo_stroke (cr);
//cairo_paint (cr);
cairo_destroy (cr);
return FALSE;
}
// http://zetcode.com/tutorials/cairographicstutorial/transparency/
void MenuContext::Show(int32_t x, int32_t y, bool top)
{
if(NULL != m_dialog) {
gtk_widget_destroy(m_dialog);
m_dialog = NULL;
}
m_dialog = gtk_window_new(GTK_WINDOW_POPUP);
//m_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
// Set the dialog on top of the selected windows
//gtk_window_set_transient_for(GTK_WINDOW(m_dialog), parent);
// unset the border of the windows
//gtk_window_set_decorated(GTK_WINDOW(m_dialog), FALSE);
EDN_INFO("Set position X=" << x+2 << " Y=" << y+27);
# if USE_GTK_VERSION_3_0
gtk_window_move(GTK_WINDOW(m_dialog), x+2, y+27);
# elif USE_GTK_VERSION_2_0
gtk_widget_set_uposition(m_dialog, x+2, y+27);
# endif
#if 0
/* sdsfsdf */
gtk_widget_set_app_paintable (m_dialog, TRUE);
# ifdef USE_GTK_VERSION_3_0
g_signal_connect( G_OBJECT(m_dialog), "draw", G_CALLBACK(expose), this);
# elif defined( USE_GTK_VERSION_2_0 )
g_signal_connect( G_OBJECT(m_dialog), "expose_event", G_CALLBACK(expose), this);
# endif
#endif
//gtk_window_set_opacity(GTK_WINDOW(m_dialog), 0.25);
// 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), "destroy", G_CALLBACK(OnQuit), this);
/*
// Create a vertical box for stacking the menu and editor widgets in.
GtkWidget *vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add(GTK_CONTAINER(m_dialog), vbox);
GtkWidget *myLabel = gtk_label_new("plop 1 ");
gtk_container_add(GTK_CONTAINER(vbox), myLabel);
myLabel = gtk_label_new("plop 2 ");
gtk_container_add(GTK_CONTAINER(vbox), myLabel);
*/
// Set key Accelerator :
//AccelKey::getInstance()->LinkCommonAccel(GTK_WINDOW(m_dialog));
// Create the menu bar.
//gtk_box_pack_start( GTK_BOX (vbox), m_MenuBar.GetWidget(), FALSE, FALSE, 0);
m_widget = gtk_drawing_area_new();
//gtk_window_set_opacity(GTK_WINDOW(m_widget), 0.8);
gtk_widget_set_size_request( m_widget, 250, 100);
gtk_widget_add_events( m_widget,
GDK_KEY_PRESS_MASK
| GDK_BUTTON_PRESS_MASK
| GDK_BUTTON_RELEASE_MASK
| GDK_POINTER_MOTION_MASK
| GDK_POINTER_MOTION_HINT_MASK);
# ifdef USE_GTK_VERSION_3_0
g_object_set(m_widget,"can-focus", TRUE, NULL);
# elif defined( USE_GTK_VERSION_2_0 )
GTK_WIDGET_SET_FLAGS(m_widget, GTK_CAN_FOCUS);
# endif
// Focus Event
g_signal_connect( G_OBJECT(m_widget), "focus_in_event", G_CALLBACK(CB_focusGet), this);
g_signal_connect( G_OBJECT(m_widget), "focus_out_event", G_CALLBACK(CB_focusLost), this);
// Keyboard Event
g_signal_connect_after( G_OBJECT(m_widget), "key_press_event", G_CALLBACK(CB_keyboardEvent), this);
g_signal_connect_after( G_OBJECT(m_widget), "key_release_event", G_CALLBACK(CB_keyboardEvent), this);
// Mouse Event
g_signal_connect( G_OBJECT(m_widget), "button_press_event", G_CALLBACK(CB_mouseButtonEvent), this);
g_signal_connect( G_OBJECT(m_widget), "button_release_event", G_CALLBACK(CB_mouseButtonEvent), this);
g_signal_connect( G_OBJECT(m_widget), "motion_notify_event", G_CALLBACK(CB_mouseMotionEvent), this);
// Display Event
g_signal_connect( G_OBJECT(m_widget), "realize", G_CALLBACK(CB_displayInit), this);
# ifdef USE_GTK_VERSION_3_0
g_signal_connect( G_OBJECT(m_widget), "draw", G_CALLBACK(CB_displayDraw), this);
# elif defined( USE_GTK_VERSION_2_0 )
g_signal_connect( G_OBJECT(m_widget), "expose_event", G_CALLBACK(CB_displayDraw), this);
# endif
gtk_container_add(GTK_CONTAINER(m_dialog), m_widget);
// recursive version of gtk_widget_show
gtk_widget_show_all(m_dialog);
// Set the Focus
gtk_widget_grab_focus(m_widget);
}
void MenuContext::Hide(void)
{
if(NULL != m_dialog) {
gtk_widget_destroy(m_dialog);
m_dialog = NULL;
}
}
gboolean MenuContext::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
MenuContext * self = reinterpret_cast<MenuContext*>(data);
# ifdef USE_GTK_VERSION_3_0
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
if (self->m_shawableSize.x != allocation.width) {
self->m_shawableSize.x = allocation.width;
}
if (self->m_shawableSize.y != allocation.height) {
self->m_shawableSize.y = allocation.height;
}
# elif defined( USE_GTK_VERSION_2_0)
if (self->m_shawableSize.x != widget->allocation.width) {
self->m_shawableSize.x = widget->allocation.width;
}
if (self->m_shawableSize.y != widget->allocation.height) {
self->m_shawableSize.y = widget->allocation.height;
}
# endif
EDN_INFO("Request a display of : " << self->m_shawableSize.x << "px * "<< self->m_shawableSize.y<<"px");
DrawerManager monDrawer(widget, self->m_shawableSize.x, self->m_shawableSize.y);
// get the number of buffer open
int32_t nbBufferOpen = self->m_bufferManager->Size();
int32_t i;
uint32_t lineID = 0;
uint32_t fontHeight = Display::GetFontHeight();
basicColor_te selectFG = COLOR_LIST_TEXT_NORMAL;
basicColor_te selectBG = COLOR_LIST_BG_1;
Edn::VectorType<Edn::String *> myData;
Edn::String * plop = new Edn::String("Save");
myData.PushBack(plop);
plop = new Edn::String("Show");
myData.PushBack(plop);
plop = new Edn::String("Close");
myData.PushBack(plop);
for (i=0; i < myData.Size(); i++) {
selectFG = COLOR_LIST_TEXT_NORMAL;
if (lineID%2==0) {
selectBG = COLOR_LIST_BG_1;
} else {
selectBG = COLOR_LIST_BG_2;
}
monDrawer.Rectangle(self->m_colorManager->Get(selectBG), 0, lineID*fontHeight, self->m_shawableSize.x, Display::GetFontHeight());
monDrawer.Text(self->m_colorManager->Get(selectFG), 2, lineID*fontHeight, myData[i]->c_str());
monDrawer.Flush();
lineID ++;
}
return TRUE;
}
gboolean MenuContext::CB_displayDraw2( GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
MenuContext * self = reinterpret_cast<MenuContext*>(data);
gint width;
gint height;
cairo_t *cr = NULL;
# if USE_GTK_VERSION_3_0
cr = gdk_cairo_create(gtk_widget_get_window(widget));
# elif USE_GTK_VERSION_2_0
cr = gdk_cairo_create(widget->window);
# endif
// transparent
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.0);
/* draw the background */
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_paint (cr);
/* draw a circle */
gtk_window_get_size (GTK_WINDOW(widget), &width, &height);
cairo_set_source_rgba (cr, 1, 0.2, 0.2, 0.6);
cairo_arc (cr, width / 2, height / 2, (width < height ? width : height) / 2 - 8 , 0, 2 * 3.14);
cairo_fill (cr);
cairo_stroke (cr);
cairo_paint (cr);
cairo_destroy (cr);
return FALSE;
}
// sur : <20>mis lors du premier affichage de la GtkDrawingArea
gboolean MenuContext::CB_displayInit( GtkWidget *widget, gpointer data)
{
MenuContext * self = reinterpret_cast<MenuContext*>(data);
# ifdef USE_GTK_VERSION_3_0
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
int32_t size_x = allocation.width;
int32_t size_y = allocation.height;
self->m_shawableSize.x = allocation.width;
self->m_shawableSize.y = allocation.height;
# elif defined( USE_GTK_VERSION_2_0)
int32_t size_x = widget->allocation.width;
int32_t size_y = widget->allocation.height;
self->m_shawableSize.x = widget->allocation.width;
self->m_shawableSize.y = widget->allocation.height;
# endif
EDN_INFO("Request a diplay of : " << size_x << "px * " << size_y << "px");
gtk_widget_queue_draw( widget );
return TRUE;
}
gint MenuContext::CB_focusGet( GtkWidget *widget, GdkEventFocus *event, gpointer data)
{
//MenuContext * self = reinterpret_cast<MenuContext*>(data);
# ifdef USE_GTK_VERSION_2_0
GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_FOCUS);
# endif
EDN_INFO("Focus - In");
gtk_widget_queue_draw( widget );
return FALSE;
}
gint MenuContext::CB_focusLost( GtkWidget *widget, GdkEventFocus *event, gpointer data)
{
MenuContext * self = reinterpret_cast<MenuContext*>(data);
# ifdef USE_GTK_VERSION_2_0
GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_FOCUS);
# endif
EDN_INFO("Focus - out");
self->Hide();
return FALSE;
}
gint MenuContext::CB_keyboardEvent( GtkWidget *widget, GdkEventKey *event, gpointer data)
{
//MenuContext * self = reinterpret_cast<MenuContext*>(data);
if(event->type == GDK_KEY_PRESS) {
gtk_widget_queue_draw( widget );
}
return true;
}
gint MenuContext::CB_mouseButtonEvent(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
MenuContext * self = reinterpret_cast<MenuContext*>(data);
// get focus on the widget
gtk_widget_grab_focus(widget);
if (event->button == 1) {
/*
if (event->type == GDK_BUTTON_PRESS) {
EDN_INFO("mouse-event BT1 ==> One Clicked");
}else*/ if (event->type == GDK_2BUTTON_PRESS) {
//EDN_INFO("mouse-event BT1 ==> Double Clicked %d, %d", (uint32_t)event->x, (uint32_t)event->y);
uint32_t fontHeight = Display::GetFontHeight();
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);
if ( 0 <= 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");
self->m_menuContext->Show(event->x, event->y, false);
}
} else if (event->button == 3) {
if (event->type == GDK_BUTTON_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) {
// TODO : Find a simple methode
int32_t windowsPosX, windowsPosY;
gtk_window_get_position(GTK_WINDOW(gtk_widget_get_toplevel(widget)), &windowsPosX, &windowsPosY);
//EDN_INFO("windowsPosX=" << windowsPosX << " windowsPosY=" << windowsPosY);
int32_t widgetPosX, widgetPosY;
gtk_widget_translate_coordinates(widget, gtk_widget_get_toplevel(widget), 0, 0, &widgetPosX, &widgetPosY);
//EDN_INFO("widgetPosX=" << widgetPosX << " widgetPosY=" << widgetPosY);
self->m_menuContext->Show(self->m_shawableAreaX+2+widgetPosX+windowsPosX, ((int32_t)(event->y / fontHeight)*fontHeight)+(fontHeight/2)+widgetPosY+windowsPosY, false);
}
}
}*/ else {
EDN_INFO("mouse-event BT? PRESS");
}
gtk_widget_queue_draw( widget );
return true;
}
gint MenuContext::CB_mouseMotionEvent( GtkWidget *widget, GdkEventMotion *event, gpointer data)
{
//MenuContexterView * self = reinterpret_cast<MenuContext*>(data);
/*
if (true == ButtunOneSelected) {
int x, y;
GdkModifierType state;
if (event->is_hint) {
gdk_window_get_pointer(event->window, &x, &y, &state);
} else {
x = event->x;
y = event->y;
state = (GdkModifierType)event->state;
}
EDN_INFO("mouse-motion BT1 %d, %d", x, y);
}
*/
return true;
}

View File

@@ -1,72 +0,0 @@
/**
*******************************************************************************
* @file MenuContext.h
* @brief Editeur De N'ours : special Menu (left button or normal menu) (header)
* @author Edouard DUPIN
* @date 22/07/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 __MENU_CONTEXT_H__
#define __MENU_CONTEXT_H__
#include "Singleton.h"
#include "MsgBroadcast.h"
#include "Edn.h"
#include "BufferManager.h"
#include "ColorizeManager.h"
class MenuContext: public Singleton<MenuContext>, public MsgBroadcast
{
friend class Singleton<MenuContext>;
// specific for sigleton system...
private:
// Constructeur
MenuContext(void);
~MenuContext(void);
public:
void OnMessage(int32_t id, int32_t dataID);
// sur : GTK+ callback :
static gboolean CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpointer data);
static gboolean CB_displayDraw2( GtkWidget *widget, GdkEventExpose *event, gpointer data);
static gboolean CB_displayInit( GtkWidget *widget, gpointer data);
static gint CB_focusGet( GtkWidget *widget, GdkEventFocus *event, gpointer data);
static gint CB_focusLost( GtkWidget *widget, GdkEventFocus *event, gpointer data);
static gint CB_keyboardEvent( GtkWidget *widget, GdkEventKey *event, gpointer data);
static gint CB_mouseButtonEvent(GtkWidget *widget, GdkEventButton *event, gpointer data);
static gint CB_mouseMotionEvent( GtkWidget *widget, GdkEventMotion *event, gpointer data);
static void CB_EventOnBufferManager(gpointer data);
static void CB_ScreenChange(GtkWidget *widget, GdkScreen *old_screen, gpointer userdata);
public:
void Clear(void);
void AddCommonElem(int32_t id);
void AddSpecificElem(Edn::String &text);
void Show(int32_t x, int32_t y, bool top);
void Hide(void);
private:
BufferManager * m_bufferManager;
ColorizeManager * m_colorManager;
GtkWidget * m_dialog;
GtkWidget * m_widget;
position_ts m_requestedPos;
position_ts m_shawableSize;
};
#endif

View File

@@ -1,350 +0,0 @@
/**
*******************************************************************************
* @file Search.cpp
* @brief Editeur De N'ours : Search system
* @author Edouard DUPIN
* @date 03/01/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_globals.h"
#include "Search.h"
#include "SearchData.h"
#include "BufferManager.h"
#include "MainWindows.h"
#include "MsgBroadcast.h"
#undef __class__
#define __class__ "Search"
Search::Search(void)
: m_localDialog(NULL),
m_searchLabel(NULL),
m_searchEntry(NULL),
m_replaceLabel(NULL),
m_replaceEntry(NULL),
m_CkMatchCase(NULL),
m_CkWrapAround(NULL)
{
// nothing to do ...
}
Search::~Search(void)
{
if (NULL!=m_localDialog) {
gtk_widget_hide(m_localDialog);
gtk_widget_destroy(m_localDialog);
m_localDialog = NULL;
}
}
void Search::Display(GtkWindow *parent)
{
if(NULL == m_localDialog) {
m_localDialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
// set dialog not resisable
gtk_window_set_resizable(GTK_WINDOW(m_localDialog), FALSE);
// set the windows alwais on top of every all system windows
//gtk_window_set_keep_above(GTK_WINDOW(m_localDialog), TRUE);
// Set the dialog on top of the selected windows
gtk_window_set_transient_for(GTK_WINDOW(m_localDialog), parent);
// set the dialog on the top right
gtk_window_set_gravity(GTK_WINDOW(m_localDialog), GDK_GRAVITY_NORTH_EAST);
// select the program icone
//gtk_window_set_default_icon_name("Replace");
// set default title :
gtk_window_set_title(GTK_WINDOW(m_localDialog), "Search / Replace");
// Default size open windows
//gtk_window_set_default_size(GTK_WINDOW(m_localDialog), 300, 400);
// enable the close signal of the windows
g_signal_connect(G_OBJECT(m_localDialog), "destroy", G_CALLBACK(OnButtonQuit), this);
// Create a vertical box for stacking the menu and editor widgets in.
GtkWidget *vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add(GTK_CONTAINER(m_localDialog), vbox);
// Set key Accelerator :
//AccelKey::getInstance()->LinkCommonAccel(GTK_WINDOW(m_localDialog));
// **********************************************************
// * Search Entry
// **********************************************************
{
GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
gtk_container_add(GTK_CONTAINER (vbox), hbox);
// search label
m_searchLabel = gtk_label_new("Search ");
gtk_box_pack_start(GTK_BOX(hbox), m_searchLabel, FALSE, TRUE, 0);
// Search entry
m_searchEntry = gtk_entry_new();
gtk_box_pack_start(GTK_BOX(hbox), m_searchEntry, TRUE, TRUE, 0);
// Connect signals :
g_signal_connect(G_OBJECT(m_searchEntry), "activate", G_CALLBACK(OnButtonNext), this);
g_signal_connect(G_OBJECT(m_searchEntry), "changed", G_CALLBACK(OnEntrySearchChange), this);
}
// **********************************************************
// * Replace Entry
// **********************************************************
{
GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
gtk_container_add(GTK_CONTAINER (vbox), hbox);
// search label
m_replaceLabel = gtk_label_new("Replace");
gtk_box_pack_start(GTK_BOX(hbox), m_replaceLabel, FALSE, TRUE, 0);
// Search entry
m_replaceEntry = gtk_entry_new();
gtk_box_pack_start(GTK_BOX(hbox), m_replaceEntry, TRUE, TRUE, 0);
// Connect signals :
g_signal_connect(G_OBJECT(m_replaceEntry), "changed", G_CALLBACK(OnEntryReplaceChange), this);
}
// **********************************************************
// * mode Selection
// **********************************************************
m_CkMatchCase = gtk_check_button_new_with_label("Case Sensitive");
gtk_container_add(GTK_CONTAINER (vbox), m_CkMatchCase);
m_CkWrapAround = gtk_check_button_new_with_label("Wrap arround");
gtk_container_add(GTK_CONTAINER (vbox), m_CkWrapAround);
m_CkRegularExpression = gtk_check_button_new_with_label("Regular Expression");
gtk_container_add(GTK_CONTAINER (vbox), m_CkRegularExpression);
// connect signals :
g_signal_connect(G_OBJECT(m_CkMatchCase), "activate", G_CALLBACK(OnCheckBoxEventCase), this);
g_signal_connect(G_OBJECT(m_CkMatchCase), "clicked", G_CALLBACK(OnCheckBoxEventCase), this);
g_signal_connect(G_OBJECT(m_CkWrapAround), "activate", G_CALLBACK(OnCheckBoxEventWrap), this);
g_signal_connect(G_OBJECT(m_CkWrapAround), "clicked", G_CALLBACK(OnCheckBoxEventWrap), this);
g_signal_connect(G_OBJECT(m_CkRegularExpression), "activate", G_CALLBACK(OnCheckBoxEventRegExp), this);
g_signal_connect(G_OBJECT(m_CkRegularExpression), "clicked", G_CALLBACK(OnCheckBoxEventRegExp), this);
// **********************************************************
// * Search / Replace button
// **********************************************************
{
GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
gtk_container_add(GTK_CONTAINER (vbox), hbox);
// Find previous
m_BtPrevious = gtk_button_new_with_label("Previous");
gtk_container_add(GTK_CONTAINER (hbox), m_BtPrevious);
// Find Next
m_BtNext = gtk_button_new_with_label("Next");
gtk_container_add(GTK_CONTAINER (hbox), m_BtNext);
// Replace
m_BtReplace = gtk_button_new_with_label("Replace");
gtk_container_add(GTK_CONTAINER (hbox), m_BtReplace);
// Replace & next
m_BtReplaceAndNext = gtk_button_new_with_label("Replace & Find");
gtk_container_add(GTK_CONTAINER (hbox), m_BtReplaceAndNext);
// Exit
m_BtQuit = gtk_button_new_with_label("Close");
gtk_container_add(GTK_CONTAINER (hbox), m_BtQuit);
// Connect signals :
g_signal_connect(G_OBJECT(m_BtPrevious), "activate", G_CALLBACK(OnButtonPrevious), this);
g_signal_connect(G_OBJECT(m_BtPrevious), "released", G_CALLBACK(OnButtonPrevious), this);
g_signal_connect(G_OBJECT(m_BtNext), "activate", G_CALLBACK(OnButtonNext), this);
g_signal_connect(G_OBJECT(m_BtNext), "released", G_CALLBACK(OnButtonNext), this);
g_signal_connect(G_OBJECT(m_BtReplace), "activate", G_CALLBACK(OnButtonReplace), this);
g_signal_connect(G_OBJECT(m_BtReplace), "released", G_CALLBACK(OnButtonReplace), this);
g_signal_connect(G_OBJECT(m_BtReplaceAndNext), "activate", G_CALLBACK(OnButtonReplaceAndNext), this);
g_signal_connect(G_OBJECT(m_BtReplaceAndNext), "released", G_CALLBACK(OnButtonReplaceAndNext), this);
g_signal_connect(G_OBJECT(m_BtQuit), "activate", G_CALLBACK(OnButtonQuit), this);
g_signal_connect(G_OBJECT(m_BtQuit), "released", G_CALLBACK(OnButtonQuit), this);
}
// recursive version of gtk_widget_show
gtk_widget_show_all(m_localDialog);
}
if(NULL == m_localDialog) {
EDN_ERROR("No search-dialog instance");
} else {
// update datas :
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_CkWrapAround), SearchData::GetWrap());
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_CkMatchCase), SearchData::GetCase());
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_CkRegularExpression), SearchData::GetRegExp());
if (true == SearchData::GetRegExp()) {
gtk_widget_set_sensitive(m_CkMatchCase, false);
} else {
gtk_widget_set_sensitive(m_CkMatchCase, true);
}
Edn::String myDataString;
SearchData::GetSearch(myDataString);
gtk_entry_set_text(GTK_ENTRY(m_searchEntry), myDataString.c_str());
if (0 == strlen(myDataString.c_str())) {
m_haveSearchData = false;
} else {
m_haveSearchData = true;
}
SearchData::GetReplace(myDataString);
gtk_entry_set_text(GTK_ENTRY(m_replaceEntry), myDataString.c_str());
if (0 == strlen(myDataString.c_str())) {
m_haveReplaceData = false;
} else {
m_haveReplaceData = true;
}
gtk_widget_set_sensitive(m_BtPrevious, m_haveSearchData);
gtk_widget_set_sensitive(m_BtNext, m_haveSearchData);
if (false == m_haveSearchData) {
gtk_widget_set_sensitive(m_BtReplace, 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);
}
// display the dialogue box
gtk_widget_show_all(m_localDialog);
// hide regular expression
gtk_widget_hide(m_CkRegularExpression);
}
}
void Search::Destroy(void)
{
if (NULL!=m_localDialog) {
gtk_widget_destroy(m_localDialog);
m_localDialog = NULL;
}
}
void Search::Hide(void)
{
gtk_widget_hide(m_localDialog);
}
void Search::OnButtonPrevious(GtkWidget *widget, gpointer data)
{
//EDN_INFO("CALLBACK");
GeneralSendMessage(EDN_MSG__CURRENT_FIND_PREVIOUS);
}
void Search::OnButtonNext(GtkWidget *widget, gpointer data)
{
//EDN_INFO("CALLBACK");
GeneralSendMessage(EDN_MSG__CURRENT_FIND_NEXT);
}
void Search::OnButtonReplace(GtkWidget *widget, gpointer data)
{
//EDN_INFO("CALLBACK");
GeneralSendMessage(EDN_MSG__CURRENT_REPLACE);
}
void Search::OnButtonReplaceAndNext(GtkWidget *widget, gpointer data)
{
//EDN_INFO("CALLBACK");
GeneralSendMessage(EDN_MSG__CURRENT_REPLACE);
GeneralSendMessage(EDN_MSG__CURRENT_FIND_NEXT);
}
void Search::OnButtonQuit(GtkWidget *widget, gpointer data)
{
//EDN_INFO("CALLBACK");
Search * self = reinterpret_cast<Search*>(data);
self->Destroy();
}
void Search::OnCheckBoxEventWrap(GtkWidget *widget, gpointer data)
{
//EDN_INFO("CALLBACK");
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
SearchData::SetWrap(true);
} else {
SearchData::SetWrap(false);
}
}
void Search::OnCheckBoxEventCase(GtkWidget *widget, gpointer data)
{
//EDN_INFO("CALLBACK");
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
SearchData::SetCase(true);
} else {
SearchData::SetCase(false);
}
}
void Search::OnCheckBoxEventRegExp(GtkWidget *widget, gpointer data)
{
//EDN_INFO("CALLBACK");
Search * self = reinterpret_cast<Search*>(data);
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
SearchData::SetRegExp(true);
gtk_widget_set_sensitive(self->m_CkMatchCase, false);
} else {
SearchData::SetRegExp(false);
gtk_widget_set_sensitive(self->m_CkMatchCase, true);
}
}
void Search::OnEntrySearchChange(GtkWidget *widget, gpointer data)
{
//EDN_INFO("CALLBACK");
Search * self = reinterpret_cast<Search*>(data);
// update research data
const char *testData = gtk_entry_get_text(GTK_ENTRY(widget));
if (NULL != testData) {
Edn::String myDataString = testData;
SearchData::SetSearch(myDataString);
if (0 == strlen(testData)) {
self->m_haveSearchData = false;
} else {
self->m_haveSearchData = true;
}
gtk_widget_set_sensitive(self->m_BtPrevious, self->m_haveSearchData);
gtk_widget_set_sensitive(self->m_BtNext, self->m_haveSearchData);
if (false == self->m_haveSearchData) {
gtk_widget_set_sensitive(self->m_BtReplace, false);
gtk_widget_set_sensitive(self->m_BtReplaceAndNext, false);
} else {
gtk_widget_set_sensitive(self->m_BtReplace, self->m_haveReplaceData);
gtk_widget_set_sensitive(self->m_BtReplaceAndNext, self->m_haveReplaceData);
}
}
}
void Search::OnEntryReplaceChange(GtkWidget *widget, gpointer data)
{
//EDN_INFO("CALLBACK");
Search * self = reinterpret_cast<Search*>(data);
// update replace data
const char *testData = gtk_entry_get_text(GTK_ENTRY(widget));
if (NULL != testData) {
Edn::String myDataString = testData;
SearchData::SetReplace(myDataString);
if (0 == strlen(testData)) {
self->m_haveReplaceData = false;
} else {
self->m_haveReplaceData = true;
}
gtk_widget_set_sensitive(self->m_BtReplace, self->m_haveReplaceData);
gtk_widget_set_sensitive(self->m_BtReplaceAndNext, self->m_haveReplaceData);
}
}

View File

@@ -1,86 +0,0 @@
/**
*******************************************************************************
* @file Search.h
* @brief Editeur De N'ours : Search system (header)
* @author Edouard DUPIN
* @date 03/01/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 __SEARCH_H__
#define __SEARCH_H__
#include "tools_debug.h"
#include "Singleton.h"
#include <string>
#include <vector>
class Search: public Singleton<Search>
{
friend class Singleton<Search>;
// specific for sigleton system...
private:
// Constructeur
Search(void);
~Search(void);
public:
void Destroy(void);
void Display(GtkWindow *parent);
void Hide(void);
private:
GtkWidget * m_localDialog; //!< local dialog element
// entry
GtkWidget * m_searchLabel; //!< gtk label of the search section
GtkWidget * m_searchEntry; //!< gtk entry of the search section
GtkWidget * m_replaceLabel; //!< gtk label of the replace section
GtkWidget * m_replaceEntry; //!< gtk entry of the replace section
// checkbox
GtkWidget * m_CkMatchCase; //!< tick of the case matching
GtkWidget * m_CkWrapAround; //!< tick of the wrap the file
GtkWidget * m_CkRegularExpression; //!< the test is a regular expression
// button
GtkWidget * m_BtPrevious; //!< Button Previous
GtkWidget * m_BtNext; //!< Button Next
GtkWidget * m_BtReplace; //!< Button Replace
GtkWidget * m_BtReplaceAndNext; //!< Button Replace and find next
GtkWidget * m_BtQuit; //!< Button Quit
bool m_haveSearchData;
bool m_haveReplaceData;
// CallBack for GTK+ gui
private :
static void OnButtonPrevious(GtkWidget *widget, gpointer user_data);
static void OnButtonNext(GtkWidget *widget, gpointer user_data);
static void OnButtonReplace(GtkWidget *widget, gpointer user_data);
static void OnButtonReplaceAndNext(GtkWidget *widget, gpointer user_data);
static void OnButtonQuit(GtkWidget *widget, gpointer user_data);
static void OnCheckBoxEventCase(GtkWidget *widget, gpointer user_data);
static void OnCheckBoxEventWrap(GtkWidget *widget, gpointer user_data);
static void OnCheckBoxEventRegExp(GtkWidget *widget, gpointer user_data);
static void OnEntrySearchChange(GtkWidget *widget, gpointer user_data);
static void OnEntryReplaceChange(GtkWidget *widget, gpointer user_data);
};
#endif

View File

@@ -1,246 +0,0 @@
/**
*******************************************************************************
* @file WindowsManager.cpp
* @brief Editeur De N'ours : Windows creation, pop up, destruction ... (Sources)
* @author Edouard DUPIN
* @date 20/06/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 "WindowsManager.h"
#include "MainWindows.h"
#include "Edn.h"
#include "Search.h"
#undef __class__
#define __class__ "WindowsManager"
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
WindowsManager::WindowsManager(void) : MsgBroadcast("Windows Manager", EDN_CAT_GUI_MANAGER)
{
m_currentBufferID = -1;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
WindowsManager::~WindowsManager(void)
{
}
void WindowsManager::OnMessage(int32_t id, int32_t dataID)
{
switch (id)
{
case EDN_MSG__BUFFER_CHANGE_CURRENT:
m_currentBufferID = dataID;
break;
case EDN_MSG__GUI_SHOW_MAIN_WINDOWS:
EDN_INFO("Request opening MAIN_WINDOWS");
m_mainWindow = MainWindows::getInstance();
break;
case EDN_MSG__GUI_SHOW_SEARCH:
EDN_INFO("Request opening SEARCH");
{
Search *myInstance = Search::getInstance();
myInstance->Display(GTK_WINDOW(m_mainWindow->GetWidget()));
}
break;
case EDN_MSG__GUI_SHOW_PREFERENCE:
EDN_INFO("Request opening PREFERENCE");
break;
case EDN_MSG__GUI_SHOW_REPLACE:
EDN_INFO("Request opening REPLACE");
break;
case EDN_MSG__GUI_SHOW_OPEN_FILE:
EDN_INFO("Request opening OPEN_FILE");
{
BufferManager *myBufferManager = NULL;
myBufferManager = BufferManager::getInstance();
GtkWidget *dialog = gtk_file_chooser_dialog_new( "Open File", NULL,
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, // button text
GTK_RESPONSE_CANCEL, // response id
GTK_STOCK_OPEN, // button text
GTK_RESPONSE_ACCEPT, // response id
NULL); // end button/response list
if( -1 != m_currentBufferID
&& true == myBufferManager->Exist(m_currentBufferID) )
{
Edn::String fileFolder = myBufferManager->Get(m_currentBufferID)->GetFolder();
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER(dialog), fileFolder.c_str());
//gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER(dialog), "Untitled document");
}
if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
{
Edn::String myfilename;
myfilename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog));
if (false == myBufferManager->Exist(myfilename) ) {
int32_t openID = myBufferManager->Open(myfilename);
SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, openID);
} else {
SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, myBufferManager->GetId(myfilename));
}
}
gtk_widget_destroy(dialog);
}
break;
case EDN_MSG__GUI_SHOW_SAVE_AS:
EDN_INFO("Request opening SAVE_AS");
// save only if one element is selected
if (BufferManager::getInstance()->Size() > 0) {
int32_t idSelected;
if(-1 == dataID) {
idSelected = BufferManager::getInstance()->GetSelected();
} else {
idSelected = dataID;
}
Buffer *myBuffer = BufferManager::getInstance()->Get(idSelected);
Edn::String tmpString = "Save as file : ";
tmpString += myBuffer->GetShortName().c_str();
GtkWidget *dialog = gtk_file_chooser_dialog_new( tmpString.c_str(), NULL,
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, // button text
GTK_RESPONSE_CANCEL, // response id
GTK_STOCK_SAVE, // button text
GTK_RESPONSE_ACCEPT, // response id
NULL); // end button/response list
if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
{
Edn::String myfilename;
myfilename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog));
myBuffer->SetName(myfilename);
myBuffer->Save();
SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, idSelected);
}
gtk_widget_destroy(dialog); // implicitly hides dialog
}
break;
case EDN_MSG__GUI_SHOW_ABOUT:
{
// dlg to confirm the quit event :
GtkWidget *myDialog = gtk_dialog_new_with_buttons("About",
NULL,
GTK_DIALOG_MODAL,
GTK_STOCK_QUIT, GTK_RESPONSE_NO,
NULL);
GtkWidget *myContentArea = gtk_dialog_get_content_area( GTK_DIALOG(myDialog));
GtkWidget *myLabel = gtk_label_new("");
gtk_label_set_markup (GTK_LABEL (myLabel),
"<b>Name :</b> Edn\n"
"<b>Version :</b> " VERSION_TAG_NAME "\n"
"<b>Build Time :</b> " VERSION_BUILD_TIME "\n\n"
"<b>Description :</b> Editeur De N'ours, l'Editeur Desoxyribo-Nucleique\n"
" Source Code Editor\n\n"
"<b>Copyright 2010 Edouard DUPIN, all right reserved</b>\n\n"
"<b>Terms of license : </b>\n"
"This software is distributed in the hope that it will be useful, but \n"
"WITHOUT ANY WARRANTY\n"
" <b>You can:</b>\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,\n"
" just write somewhere \"Edn is great\" visible by the user (on \n"
" 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"
" <b>You can NOT:</b>\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"
"I reserve the right to change this licence. If it change the version of \n"
"the copy you have keep its own license.\n\n"
"<b>Sources : </b> git://github.com/HeeroYui/edn.git ");
gtk_box_pack_start(GTK_BOX(myContentArea), myLabel, TRUE, TRUE, 0);
gtk_widget_show_all(myContentArea);
int32_t result = gtk_dialog_run (GTK_DIALOG (myDialog));
gtk_widget_destroy(myDialog);
switch (result)
{
case GTK_RESPONSE_NO:
break;
}
}
break;
case EDN_MSG__GUI_SHOW_GOTO_LINE:
{
// dlg to confirm the quit event :
GtkWidget *myDialog = gtk_dialog_new_with_buttons("Goto Line",
GTK_WINDOW(m_mainWindow->GetWidget()),
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(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;
}
}

View File

@@ -1,297 +0,0 @@
/**
*******************************************************************************
* @file Highlight.c
* @brief Editeur De N'ours : Hightlightning Specific
* @author Edouard DUPIN
* @date 14/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 "tools_globals.h"
#include "Highlight.h"
#include "tinyxml.h"
#undef __class__
#define __class__ "Highlight"
void Highlight::ParseRules(TiXmlNode *child, std::vector<HighlightPattern*> &mListPatern, int32_t level)
{
// Create the patern ...
HighlightPattern *myPattern = new HighlightPattern();
// parse under Element
myPattern->ParseRules(child, level);
// add element in the list
mListPatern.push_back(myPattern);
}
Highlight::Highlight(Edn::String &xmlFilename)
{
TiXmlDocument XmlDocument;
// open the curent File
bool loadError = XmlDocument.LoadFile(xmlFilename.c_str());
if (false == loadError) {
EDN_ERROR( "can not load Hightlight XML: PARSING error: \"" << xmlFilename.c_str() << "\"");
return;
}
TiXmlElement* root = XmlDocument.FirstChildElement( "EdnLang" );
if (NULL == root) {
EDN_ERROR( "can not load Hightlight XML: main node not find: \"EdnLang\"");
return;
}
int32_t level1 = 0;
int32_t level2 = 0;
TiXmlNode * child = root->FirstChild();
while(NULL != child)
{
if (child->Type()==TiXmlNode::TINYXML_COMMENT) {
// nothing to do ...
} else if (!strcmp(child->Value(), "ext")) {
const char *myData = child->ToElement()->GetText();
if (NULL != myData) {
//EDN_INFO(PFX"(l %d) node fined : %s=\"%s\"", child->Row(), child->Value() , myData);
Edn::String myEdnData = myData;
m_listExtentions.push_back(myEdnData);
}
} else if (!strcmp(child->Value(), "pass1")) {
// Get sub Nodes ...
TiXmlNode *passChild = child->FirstChild();
while (NULL != passChild) {
if (passChild->Type()==TiXmlNode::TINYXML_COMMENT) {
// nothing to do ...
} else if (!strcmp(passChild->Value(), "rule")) {
ParseRules(passChild, m_listHighlightPass1, level1++);
} else {
EDN_ERROR("(l "<< passChild->Row() << ") node not suported : \""<< passChild->Value() << "\" must be [rule]" );
}
// get the next node element :
passChild = passChild->NextSibling();
}
} else if (!strcmp(child->Value(), "pass2")) {
// Get sub Nodes ...
TiXmlNode *passChild = child->FirstChild();
while (NULL != passChild) {
if (passChild->Type()==TiXmlNode::TINYXML_COMMENT) {
// nothing to do ...
} else if (!strcmp(passChild->Value(), "rule")) {
ParseRules(passChild, m_listHighlightPass2, level2++);
} else {
EDN_ERROR("(l "<< passChild->Row() << ") node not suported : \""<< passChild->Value() << "\" must be [rule]" );
}
// get the next node element :
passChild = passChild->NextSibling();
}
} else {
EDN_ERROR("(l "<< child->Row() << ") node not suported : \""<< child->Value() << "\" must be [ext,pass1,pass2]" );
}
// get the next node element :
child = child->NextSibling();
}
}
Highlight::~Highlight(void)
{
uint32_t i;
// clean all Element
for (i=0; i< m_listHighlightPass1.size(); i++) {
delete(m_listHighlightPass1[i]);
}
// clear the compleate list
m_listHighlightPass1.clear();
}
bool Highlight::HasExtention(Edn::String &ext)
{
uint32_t i;
for (i=0; i<m_listExtentions.size(); i++) {
if (ext == m_listExtentions[i] ) {
return true;
}
}
return false;
}
bool Highlight::FileNameCompatible(Edn::String &fileName)
{
uint32_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;
if (-1 != posCopy) {
extention = shortFilename.Extract(posCopy);
} else {
extention = shortFilename;
}
EDN_DEBUG(" try to find : in \"" << fileName.c_str() << "\" shortfilename\"" << shortFilename.c_str() << "\" extention:\"" << extention.c_str() << "\" ");
for (i=0; i<m_listExtentions.size(); i++) {
if (extention == m_listExtentions[i] ) {
return true;
}
}
return false;
}
void Highlight::Display(void)
{
uint32_t i;
EDN_INFO("List of ALL Highlight : ");
for (i=0; i< m_listExtentions.size(); i++) {
EDN_INFO(" Extention : " << i << " : " << m_listExtentions[i].c_str() );
}
// Display all elements
for (i=0; i< m_listHighlightPass1.size(); i++) {
EDN_INFO(" " << i << " Pass 1 : " << m_listHighlightPass1[i]->GetName().c_str() );
//m_listHighlightPass1[i]->Display();
}
// Display all elements
for (i=0; i< m_listHighlightPass2.size(); i++) {
EDN_INFO(" " << i << " Pass 2 : " << m_listHighlightPass2[i]->GetName().c_str() );
//m_listHighlightPass2[i]->Display();
}
}
void Highlight::Parse(int32_t start, int32_t stop, std::vector<colorInformation_ts> &metaData, int32_t &addingPos, EdnVectorBuf &buffer, int32_t elementID)
{
if (0 > addingPos) {
addingPos = 0;
}
/*int32_t emptyId = -1;
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 elementStop = stop;
resultFind_te ret = HLP_FIND_OK;
colorInformation_ts resultat;
while (HLP_FIND_ERROR != ret && elementStart<elementStop) {
ret = m_listHighlightPass1[elementID]->Find(elementStart, elementStop, resultat, buffer);
if (HLP_FIND_ERROR != ret) {
//EDN_INFO("Find Pattern in the Buffer : (" << resultat.beginStart << "," << resultat.endStop << ")" );
// Add curent element in the list ...
if (HLP_FIND_OK_NO_END == ret) {
// 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 );
}
} else {
metaData.insert(metaData.begin() + addingPos, resultat);
//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++;
elementStart = resultat.endStop;
}
}
// parse the under element :
Parse(elementStart, elementStop, metaData, addingPos, buffer, elementID+1);
}
/**
* @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)
{
if (elementID >= (int32_t)m_listHighlightPass2.size() ){
return;
}
int32_t elementStart = start;
int32_t elementStop = stop;
resultFind_te ret = HLP_FIND_OK;
colorInformation_ts resultat;
while (HLP_FIND_ERROR != ret && elementStart<elementStop) {
if (m_listHighlightPass2[elementID]!=NULL) {
ret = m_listHighlightPass2[elementID]->Find(elementStart, elementStop, resultat, buffer);
} else {
ret = HLP_FIND_ERROR;
}
if (HLP_FIND_ERROR != ret) {
//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 ...
metaData.push_back(resultat);
elementStart = resultat.endStop;
}
}
// parse the under element :
Parse2(elementStart, elementStop, metaData, buffer, elementID+1);
}

View File

@@ -1,108 +0,0 @@
/**
*******************************************************************************
* @file HighlightManager.cpp
* @brief Editeur De N'ours : Hightlining Manager
* @author Edouard DUPIN
* @date 16/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 "tools_globals.h"
#include "HighlightManager.h"
#undef __class__
#define __class__ "HighlightManager"
HighlightManager::HighlightManager(void)
{
}
HighlightManager::~HighlightManager(void)
{
listHighlight.clear();
}
Highlight *HighlightManager::Get(Edn::String &fileName)
{
uint32_t i;
for (i=0; i<listHighlight.size(); i++) {
if (true == listHighlight[i]->FileNameCompatible(fileName) ) {
return listHighlight[i];
}
}
return NULL;
}
bool HighlightManager::Exist(Edn::String &fileName)
{
uint32_t i;
for (i=0; i<listHighlight.size(); i++) {
if (true == listHighlight[i]->FileNameCompatible(fileName) ) {
return true;
}
}
return false;
}
void HighlightManager::loadLanguages(void)
{
Edn::String homedir;
#ifdef NDEBUG
homedir = "/usr/share/edn/";
#else
homedir = "./data/";
#endif
Edn::String xmlFilename = homedir;
xmlFilename += "lang_c.xml";
Highlight *myHightline = new Highlight(xmlFilename);
listHighlight.push_back(myHightline);
xmlFilename = homedir;
xmlFilename += "lang_boo.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.push_back(myHightline);
xmlFilename = homedir;
xmlFilename += "lang_Makefile.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.push_back(myHightline);
xmlFilename = homedir;
xmlFilename += "lang_asm.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.push_back(myHightline);
xmlFilename = homedir;
xmlFilename += "lang_xml.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.push_back(myHightline);
xmlFilename = homedir;
xmlFilename += "lang_php.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.push_back(myHightline);
myHightline->Display();
}

42
Sources/Linux.mk Normal file
View File

@@ -0,0 +1,42 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# load the common sources file of the platform
include $(LOCAL_PATH)/file.mk
LOCAL_CONFIG_FILES := Config.in
# name of the librairy
ifeq ($(CONFIG___EWOL_APPL_NAME__),$(empty))
LOCAL_MODULE := edn
else
LOCAL_MODULE := $(call convert-special-char,$(CONFIG___EWOL_APPL_NAME__))
endif
# get the tag of the current project :
LOCAL_VERSION_TAG=$(shell cd $(LOCAL_PATH) ; git describe --tags)
LOCAL_VERSION_TAG_SHORT=$(shell cd $(LOCAL_PATH) ; git describe --tags --abbrev=0)
$(info $(LOCAL_MODULE) version TAG : $(LOCAL_VERSION_TAG))
# name of the dependency
LOCAL_STATIC_LIBRARIES := ewol
LOCAL_C_INCLUDES := $(LOCAL_PATH) $(addprefix $(LOCAL_PATH)/, $(sort $(dir $(FILE_LIST))))
LOCAL_SRC_FILES := $(FILE_LIST)
LOCAL_LDLIBS :=
ifeq ($(DEBUG),1)
LOCAL_CFLAGS := -DPROJECT_NAME="\"$(LOCAL_MODULE)\"" \
-DAPPL_VERSION_TAG_NAME="\"$(LOCAL_VERSION_TAG_SHORT)-$(BUILD_DIRECTORY_MODE)\""
else
LOCAL_CFLAGS := -DMODE_RELEASE \
-DPROJECT_NAME="\"$(LOCAL_MODULE)\"" \
-DAPPL_VERSION_TAG_NAME="\"$(LOCAL_VERSION_TAG_SHORT)-$(BUILD_DIRECTORY_MODE)\""
endif
include $(BUILD_EXECUTABLE)

41
Sources/Windows.mk Normal file
View File

@@ -0,0 +1,41 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# load the common sources file of the platform
include $(LOCAL_PATH)/file.mk
LOCAL_CONFIG_FILES := Config.in
# name of the librairy
ifeq ($(CONFIG___EWOL_APPL_NAME__),$(empty))
LOCAL_MODULE := edn
else
LOCAL_MODULE := $(call convert-special-char,$(CONFIG___EWOL_APPL_NAME__))
endif
# get the tag of the current project :
LOCAL_VERSION_TAG=$(shell cd $(LOCAL_PATH) ; git describe --tags)
LOCAL_VERSION_TAG_SHORT=$(shell cd $(LOCAL_PATH) ; git describe --tags --abbrev=0)
$(info $(LOCAL_MODULE) version TAG : $(LOCAL_VERSION_TAG))
# name of the dependency
LOCAL_STATIC_LIBRARIES := ewol
LOCAL_C_INCLUDES := $(LOCAL_PATH) $(addprefix $(LOCAL_PATH)/, $(sort $(dir $(FILE_LIST))))
LOCAL_SRC_FILES := $(FILE_LIST)
LOCAL_LDLIBS :=
ifeq ($(DEBUG),1)
LOCAL_CFLAGS := -DPROJECT_NAME="\"$(LOCAL_MODULE)\"" \
-DAPPL_VERSION_TAG_NAME="\"$(LOCAL_VERSION_TAG_SHORT)-$(BUILD_DIRECTORY_MODE)\""
else
LOCAL_CFLAGS := -DMODE_RELEASE \
-DPROJECT_NAME="\"$(LOCAL_MODULE)\"" \
-DAPPL_VERSION_TAG_NAME="\"$(LOCAL_VERSION_TAG_SHORT)-$(BUILD_DIRECTORY_MODE)\""
endif
include $(BUILD_EXECUTABLE)

View File

@@ -0,0 +1,140 @@
/**
*******************************************************************************
* @file Buffer.c
* @brief Editeur De N'ours : Text Buffer
* @author Edouard DUPIN
* @date 08/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 <appl/Debug.h>
#include <appl/global.h>
#include <Buffer.h>
#include <BufferManager.h>
#include <ewol/eObject/EObject.h>
#undef __class__
#define __class__ "Buffer"
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
Buffer::Buffer()
{
static int32_t fileBasicID = 0;
m_updatePositionRequested = false;
m_fileModify = true;
m_haveName = false;
etk::UString mString = "Untitle - ";
mString += fileBasicID++;
EWOL_DEBUG("Create buffer try name : \"" << mString << "\"");
SetFileName(mString);
m_haveName = false;
EWOL_DEBUG("Create buffer with name : " << m_fileName );
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
Buffer::Buffer(etk::FSNode &newName)
{
m_fileModify = false;
EWOL_DEBUG("Create buffer try name : \"" << newName << "\"");
SetFileName(newName);
EWOL_DEBUG("Create buffer with name : " << m_fileName );
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
Buffer::~Buffer(void)
{
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
bool Buffer::IsModify(void)
{
return m_fileModify;
}
void Buffer::SetModify(bool status)
{
if (status != m_fileModify) {
m_fileModify = status;
// TODO : Remove from here
etk::UString data = "Modify";
ewol::EObjectMessageMultiCast::AnonymousSend(ednMsgBufferState, data);
}
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
bool Buffer::NeedToUpdateDisplayPosition(void)
{
bool tmpVal = m_updatePositionRequested;
m_updatePositionRequested = false;
return tmpVal;
}
etk::Vector2D<float> Buffer::GetBorderSize(void)
{
etk::Vector2D<float> tmpVal;
tmpVal.x = 30;
tmpVal.y = 30;
return tmpVal;
}
etk::Vector2D<float> Buffer::GetPosition(int32_t fontId,bool& centerRequested)
{
centerRequested = false;
etk::Vector2D<float> tmpVal;
tmpVal.x = 0;
tmpVal.y = 0;
return tmpVal;
}

View File

@@ -0,0 +1,149 @@
/**
*******************************************************************************
* @file Buffer.h
* @brief Editeur De N'ours : Text Buffer (header)
* @author Edouard DUPIN
* @date 08/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.
*
*******************************************************************************
*/
#ifndef __BUFFER_H__
#define __BUFFER_H__
#include <etk/UString.h>
#include <etk/os/FSNode.h>
#include <etk/unicode.h>
#include <ewol/ewol.h>
typedef struct{
uint32_t nbTotalLine; //!< Number of line in the buffer
uint32_t nbTotalColomn; //!< Number of line in the buffer
uint32_t startLineDisplay; //!< First line display.
uint32_t startColomnDisplay; //!< First Colomn displayed
uint32_t diplayableColomn; //!< NB colomn that can be displayed
uint32_t diplayableLine; //!< NB Line that can be displayed
}infoStatBuffer_ts;
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
#define TEXT_DISPLAY_TYPE OObject2DTextShader
#else
#define TEXT_DISPLAY_TYPE OObject2DTextColored
#endif
class Buffer {
public:
Buffer(void);
Buffer(etk::FSNode &newName);
virtual ~Buffer(void);
etk::FSNode GetFileName(void)
{
return m_fileName;
};
void SetFileName(etk::FSNode &newName)
{
m_fileName = newName;
m_haveName = true;
NameChange();
};
void SetFileName(etk::UString &newName)
{
m_fileName.SetName(newName);
m_haveName = true;
NameChange();
};
bool HaveName(void)
{
return m_haveName;
}
virtual void Save(void) {};
bool IsModify(void);
protected:
void SetModify(bool status);
virtual void NameChange(void) { /*APPL_DEBUG("check name change ==> no HL change possible");*/};
public:
virtual void GetInfo(infoStatBuffer_ts &infoToUpdate) {};
virtual void SetLineDisplay(uint32_t lineNumber) {};
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
virtual int32_t Display(ewol::TEXT_DISPLAY_TYPE& OOText,
ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY)
#else
virtual int32_t Display(ewol::TEXT_DISPLAY_TYPE& OOTextNormal,
ewol::TEXT_DISPLAY_TYPE& OOTextBold,
ewol::TEXT_DISPLAY_TYPE& OOTextItalic,
ewol::TEXT_DISPLAY_TYPE& OOTextBoldItalic,
ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY)
#endif
{
return ERR_NONE;
}
virtual void AddChar(uniChar_t unicodeData) {};
virtual void cursorMove(ewol::eventKbMoveType_te moveTypeEvent) {};
virtual void MouseSelectFromCursorTo(etk::Vector2D<float> pos) {};
virtual void MouseEvent(etk::Vector2D<float> pos) {};
virtual void MouseEventDouble(void) {};
virtual void MouseEventTriple(void) {};
virtual void RemoveLine(void) {};
virtual void SelectAll(void) {};
virtual void SelectNone(void) {};
virtual void Undo(void) {};
virtual void Redo(void) {};
virtual void SetCharset(unicode::charset_te newCharset) {};
//virtual void SelectAll(void);
virtual void Copy(ewol::clipBoard::clipboardListe_te clipboardID) {};
virtual void Cut(ewol::clipBoard::clipboardListe_te clipboardID) {};
virtual void Paste(ewol::clipBoard::clipboardListe_te clipboardID) {};
virtual void Search(etk::UString &data, bool back, bool caseSensitive, bool wrap, bool regExp) {};
virtual void Replace(etk::UString &data) {};
virtual int32_t FindLine(etk::UString &data) { return 0; };
virtual void JumpAtLine(int32_t newLine) {};
virtual int32_t GetCurrentLine(void) { return 0; };
virtual int32_t GetNumberOfLine(void) { return 1; };
// moving with cursor change position:
private:
bool m_updatePositionRequested; //!< if a position xhange in the windows ...
etk::Vector2D<float> m_maximumSize; //!< current maxSize of the buffer
protected:
void RequestUpdateOfThePosition(void) { m_updatePositionRequested = true; };
void SetMaximumSize(etk::Vector2D<float> maxSize) { m_maximumSize = maxSize; };
public:
bool NeedToUpdateDisplayPosition(void);
virtual etk::Vector2D<float> GetBorderSize(void); // this is to requested the minimum size for the buffer that is not consider as visible ...
virtual etk::Vector2D<float> GetPosition(int32_t fontId, bool& centerRequested);
etk::Vector2D<float> GetMaxSize(void) { return m_maximumSize; };
protected:
bool m_fileModify; //!<
// naming
etk::FSNode m_fileName; //!< filename of the curent buffer
bool m_haveName; //!< to know if the file have a name or NOT
};
#endif

View File

@@ -0,0 +1,127 @@
/**
*******************************************************************************
* @file BufferEmpty.cpp
* @brief Editeur De N'ours : Text Buffer (edit For No buffer Display)
* @author Edouard DUPIN
* @date 19/01/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 <appl/Debug.h>
#include <appl/global.h>
#include <BufferEmpty.h>
#include <ColorizeManager.h>
#include <MainWindows.h>
#undef __class__
#define __class__ "BufferEmpty"
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
BufferEmpty::BufferEmpty()
{
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
BufferEmpty::~BufferEmpty(void)
{
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
int32_t BufferEmpty::Display(ewol::TEXT_DISPLAY_TYPE& OOText,
ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY)
#else
int32_t BufferEmpty::Display(ewol::TEXT_DISPLAY_TYPE& OOTextNormal,
ewol::TEXT_DISPLAY_TYPE& OOTextBold,
ewol::TEXT_DISPLAY_TYPE& OOTextItalic,
ewol::TEXT_DISPLAY_TYPE& OOTextBoldItalic,
ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY)
#endif
{
// Get color :
Colorize *myColor = NULL;
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
int32_t letterHeight = OOText.GetHeight();
#else
int32_t letterHeight = OOTextNormal.GetHeight();
#endif
etk::Vector2D<float> textPos;
textPos.x = 20;
textPos.y = sizeY - 20 - letterHeight;
etk::UString tmpDisplay ;
myColor = ColorizeManager::Get("normal");
tmpDisplay = "edn - Editeur De N'ours";
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
OOText.SetColor(myColor->GetFG());
OOText.SetBold(true);
OOText.SetItalic(false);
OOText.Text(textPos, tmpDisplay);
#else
OOTextBold.SetColor(myColor->GetFG());
OOTextBold.Text(textPos, tmpDisplay);
#endif
myColor = ColorizeManager::Get("commentDoxygen");
textPos.y = (int32_t)(textPos.y - letterHeight*1.30);
tmpDisplay = "No Buffer Availlable to display";
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
OOText.SetBold(false);
OOText.SetItalic(false);
OOText.SetColor(myColor->GetFG());
OOText.Text(textPos, tmpDisplay);
#else
OOTextNormal.SetColor(myColor->GetFG());
OOTextNormal.Text(textPos, tmpDisplay);
#endif
OOColored.SetColor(draw::color::white);
OOColored.Rectangle( 0, 0, sizeX, sizeY);
return ERR_NONE;
}

View File

@@ -0,0 +1,52 @@
/**
*******************************************************************************
* @file BufferEmpty.h
* @brief Editeur De N'ours : Text Buffer (edit For No buffer Display) (header)
* @author Edouard DUPIN
* @date 19/01/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_EMPTY_H__
#define __BUFFER_EMPTY_H__
#include <Buffer.h>
class BufferEmpty : public Buffer {
public:
BufferEmpty(void);
virtual ~BufferEmpty(void);
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
int32_t Display(ewol::TEXT_DISPLAY_TYPE& OOText,
ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY);
#else
int32_t Display(ewol::TEXT_DISPLAY_TYPE& OOTextNormal,
ewol::TEXT_DISPLAY_TYPE& OOTextBold,
ewol::TEXT_DISPLAY_TYPE& OOTextItalic,
ewol::TEXT_DISPLAY_TYPE& OOTextBoldItalic,
ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY);
#endif
};
#endif

View File

@@ -0,0 +1,609 @@
/**
*******************************************************************************
* @file BufferManager.cpp
* @brief Editeur De N'ours : Text Buffer manager (sources)
* @author Edouard DUPIN
* @date 08/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 <appl/Debug.h>
#include <appl/global.h>
#include <BufferManager.h>
#include <ewol/eObject/EObject.h>
#include <ewol/eObject/EObjectManager.h>
#undef __class__
#define __class__ "classBufferManager"
class classBufferManager: public ewol::EObject
{
public:
// Constructeur
classBufferManager(void);
~classBufferManager(void);
/**
* @brief Get the current Object type of the EObject
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
* @param[in] objectType type description
* @return true if the object is compatible, otherwise false
*/
const char * const GetObjectType(void)
{
return "ApplBufferManager";
}
public:
/**
* @brief Receive a message from an other EObject with a specific eventId and data
* @param[in] CallerObject Pointer on the EObject that information came from
* @param[in] eventId Message registered by this class
* @param[in] data Data registered by this class
* @return ---
*/
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
private:
// return the ID of the buffer allocated
// create a buffer with no element
int32_t Create(void);
// open curent filename
int32_t Open(etk::FSNode &myFile);
bool Remove(int32_t BufferID);
public:
int32_t GetSelected(void) { return m_idSelected;};
//void SetSelected(int32_t id) {m_idSelected = id;};
Buffer * Get(int32_t BufferID);
bool Exist(int32_t BufferID);
bool Exist(etk::FSNode &myFile);
int32_t GetId(etk::FSNode &myFile);
// return the number of buffer (open in the past) if 5 buffer open and 4 close ==> return 5
uint32_t Size(void);
uint32_t SizeOpen(void);
int32_t WitchBuffer(int32_t iEmeElement);
private:
etk::Vector<Buffer*> listBuffer; //!< element List of the char Elements
void RemoveAll(void); //!< remove all buffer
int32_t m_idSelected;
Buffer * BufferNotExiste; //!< When an error arrive in get buffer we return the Error buffer (not writable)
};
// Constructeur
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
classBufferManager::classBufferManager(void)
{
// nothing to do ...
BufferNotExiste = new BufferEmpty();
m_idSelected = -1;
RegisterMultiCast(ednMsgGuiNew);
RegisterMultiCast(ednMsgOpenFile);
RegisterMultiCast(ednMsgGuiClose);
RegisterMultiCast(ednMsgGuiSave);
RegisterMultiCast(ednMsgCodeViewSelectedId);
RegisterMultiCast(ednMsgBufferId);
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
classBufferManager::~classBufferManager(void)
{
//clean All Buffer
APPL_INFO("~classBufferManager::RemoveAll();");
RemoveAll();
// clear The list of Buffer
APPL_INFO("~classBufferManager::listBuffer.Clear();");
listBuffer.Clear();
APPL_INFO("~classBufferManager::delete(BufferNotExiste);");
delete(BufferNotExiste);
}
/**
* @brief Receive a message from an other EObject with a specific eventId and data
* @param[in] CallerObject Pointer on the EObject that information came from
* @param[in] eventId Message registered by this class
* @param[in] data Data registered by this class
* @return ---
*/
void classBufferManager::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
{
ewol::EObject::OnReceiveMessage(CallerObject, eventId, data);
if (eventId == ednMsgBufferId) {
// select a new buffer ID :
if (data == "") {
APPL_ERROR("Request select buffer ID = \"\" ");
} else {
int32_t newID = -1;
sscanf(data.c_str(), "%d", &newID);
if(true == Exist(newID)) {
m_idSelected = newID;
} else {
m_idSelected = -1;
APPL_ERROR("Request a non existant ID : " << newID << " reset to -1...");
}
}
} else if (eventId == ednMsgGuiNew) {
int32_t newOne = Create();
if (-1 != newOne) {
m_idSelected = newOne;
SendMultiCast(ednMsgBufferId, m_idSelected);
SendMultiCast(ednMsgBufferListChange);
}
} else if (eventId == ednMsgOpenFile) {
if (data != "" ) {
etk::FSNode myFile(data);
APPL_DEBUG("request open file = \"" <<data << "\" ?= \"" << myFile << "\"");
int32_t newOne = Open(myFile);
if (-1 != newOne) {
m_idSelected = newOne;
SendMultiCast(ednMsgBufferId, m_idSelected);
SendMultiCast(ednMsgBufferListChange);
} else {
// TODO : notify user that we can not open the request file...
APPL_ERROR("Can not open the file : \"" << myFile << "\"");
}
}
} else if (eventId == ednMsgGuiSave) {
if (data == "") {
APPL_ERROR("Null data for close file ... ");
} else {
if (data == "current") {
// Check buffer existence
if(true == Exist(m_idSelected)) {
// If no name ==> request a Gui display ...
if (Get(m_idSelected)->HaveName() == false) {
SendMultiCast(ednMsgGuiSaveAs, "current");
} else {
Get(m_idSelected)->Save();
}
}
} else {
int32_t newId;
sscanf(data.c_str(), "%d", &newId);
if (false == Exist(newId)) {
APPL_ERROR("Request a save As with a non existant ID=" << newId);
} else {
// If no name ==> request a Gui display ...
if (Get(newId)->HaveName() == false) {
SendMultiCast(ednMsgGuiSaveAs, newId);
} else {
Get(m_idSelected)->Save();
}
}
SendMultiCast(ednMsgBufferState, "saved");
}
}
} else if (eventId == ednMsgGuiClose) {
if (data == "") {
APPL_ERROR("Null data for close file ... ");
} else {
if (data == "All") {
} else {
int32_t closeID = -1;
if (data == "current") {
closeID = m_idSelected;
APPL_DEBUG("Close specific buffer ID" << closeID);
} else {
// close specific buffer ...
sscanf(data.c_str(), "%d", &closeID);
APPL_DEBUG("Close specific buffer ID="<< closeID);
}
if(true == Exist(closeID)) {
// Get the new display buffer
if (m_idSelected == closeID) {
// Try previous buffer
int32_t destBuffer = -1;
for(int32_t ii=closeID-1; ii >= 0; ii--) {
if (true == Exist(ii) ) {
destBuffer = ii;
break;
}
}
// try next buffer
if (-1 == destBuffer) {
for(int32_t ii=closeID+1; ii < listBuffer.Size(); ii++) {
if (true == Exist(ii) ) {
destBuffer = ii;
break;
}
}
}
// set it to the currect display
m_idSelected = destBuffer;
SendMultiCast(ednMsgBufferId, destBuffer);
}
// Remove requested buffer
Remove(closeID);
SendMultiCast(ednMsgBufferListChange);
} else {
APPL_ERROR("Request Close of a non existant ID : " << closeID);
}
}
}
} else if (eventId == ednMsgCodeViewSelectedId) {
//Change the selected buffer
if (data == "") {
APPL_ERROR("Null data for changing buffer ID file ... ");
} else {
int32_t newId;
sscanf(data.c_str(), "%d", &newId);
if (true == Exist(newId)) {
m_idSelected = newId;
} else {
APPL_ERROR("code biew request the selection of an non -existant buffer ==> reset to -1");
m_idSelected = -1;
}
SendMultiCast(ednMsgBufferId, m_idSelected);
SendMultiCast(ednMsgBufferListChange);
}
}
/*
switch (id)
{
// Check buffer existence
if(true == Exist(dataID)) {
// If no name ==> request a Gui display ...
if (Get(dataID)->HaveName() == false) {
SendMessage(APPL_MSG__GUI_SHOW_SAVE_AS, dataID);
} else {
Get(dataID)->Save();
}
}
break;
}
*/
}
/**
* @brief Remove all buffer opened
*
* @param[in,out] ---
*
* @return ---
*
*/
void classBufferManager::RemoveAll(void)
{
int32_t i;
for (i=0; i<listBuffer.Size(); i++) {
Remove(i);
}
SendMultiCast(ednMsgGuiClose, "All");
}
/**
* @brief Create a new buffer with no name and empty
*
* @param[in,out] ---
*
* @return The ID of the curent buffer where the file is loaded
*
*/
int32_t classBufferManager::Create(void)
{
// allocate a new Buffer
Buffer *myBuffer = new BufferText();
// Add at the list of element
listBuffer.PushBack(myBuffer);
int32_t basicID = listBuffer.Size() - 1;
return basicID;
}
/**
* @brief open a file with the name set in parameters
*
* @param[in] filename curent filename
*
* @return The ID of the curent buffer where the file is loaded
*
* @todo : check if this file is not curently open and return the old ID
*
*/
int32_t classBufferManager::Open(etk::FSNode &myFile)
{
if (false == Exist(myFile)) {
// allocate a new Buffer
Buffer *myBuffer = new BufferText(myFile);
// Add at the list of element
listBuffer.PushBack(myBuffer);
return listBuffer.Size() - 1;
} else {
// the buffer already existed ==> we open it ...
return GetId(myFile);
}
}
Buffer * classBufferManager::Get(int32_t BufferID)
{
// possible special case : -1;
if (-1 >= BufferID) {
return BufferNotExiste;
}
// check if the Buffer existed
if (BufferID < listBuffer.Size()) {
// check if the buffer already existed
if (NULL != listBuffer[BufferID]) {
return listBuffer[BufferID];
} else {
APPL_ERROR("non existing Buffer " << BufferID);
}
} else {
APPL_ERROR("call an non existing Buffer number too hight : " << BufferID << " > " << listBuffer.Size());
}
return BufferNotExiste;
}
bool classBufferManager::Exist(int32_t BufferID)
{
if (-1 >= BufferID) {
return false;
}
// check if the Buffer existed
if (BufferID < listBuffer.Size()) {
// check if the buffer already existed
if (NULL != listBuffer[BufferID]) {
return true;
}
}
return false;
}
bool classBufferManager::Exist(etk::FSNode &myFile )
{
if (-1 == GetId(myFile)) {
return false;
}
return true;
}
int32_t classBufferManager::GetId(etk::FSNode &myFile)
{
int32_t iii;
// check if the Buffer existed
for (iii=0; iii < listBuffer.Size(); iii++) {
// check if the buffer already existed
if (NULL != listBuffer[iii]) {
if ( listBuffer[iii]->GetFileName() == myFile) {
return iii;
}
}
}
return -1;
}
// return the number of buffer (open in the past) if 5 buffer open and 4 close ==> return 5
uint32_t classBufferManager::Size(void)
{
return listBuffer.Size();
}
// nb of opens file Now ...
uint32_t classBufferManager::SizeOpen(void)
{
uint32_t jjj = 0;
// check if the Buffer existed
for (int32_t iii=0; iii<listBuffer.Size(); iii++) {
// check if the buffer already existed
if (NULL != listBuffer[iii]) {
jjj++;
}
}
return jjj;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
bool classBufferManager::Remove(int32_t BufferID)
{
if (-1 >= BufferID) {
return false;
}
// check if the Buffer existed
if (BufferID < listBuffer.Size()) {
// check if the buffer already existed
if (NULL != listBuffer[BufferID]) {
// TODO : Check if it saved...
/*
if (false == IsSaved(BufferID) ) {
APPL_INFO("Buffer " << BufferID << " : Not Saved", BufferID);
}
*/
// Delete the Buffer
delete( listBuffer[BufferID] );
listBuffer[BufferID] = NULL;
/*
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferListChange);
*/
return true;
} else {
APPL_INFO("non existing Buffer " << BufferID);
return false;
}
} else {
APPL_INFO("call an non existing Buffer number too hight : " << BufferID << " > " << listBuffer.Size());
return false;
}
}
/**
* @brief to get the element 14 in the buffer
*
* @param[in,out] ---
*
* @return ---
*
*/
int32_t classBufferManager::WitchBuffer(int32_t iEmeElement)
{
int32_t i;
for (i=0; i<listBuffer.Size(); i++) {
if (NULL != listBuffer[i]) {
iEmeElement--;
// find the element :
if (0 == iEmeElement) {
return i;
}
}
}
return -1;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Namespace part :
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static classBufferManager * localManager = NULL;
void BufferManager::Init(void)
{
if (NULL != localManager) {
EWOL_ERROR("classBufferManager ==> already exist, just unlink the previous ...");
localManager = NULL;
}
localManager = new classBufferManager();
if (NULL == localManager) {
EWOL_CRITICAL("Allocation of classBufferManager not done ...");
}
}
void BufferManager::UnInit(void)
{
if (NULL == localManager) {
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
return;
}
delete(localManager);
localManager = NULL;
}
int32_t BufferManager::GetSelected(void)
{
if (NULL == localManager) {
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
return -1;
}
return localManager->GetSelected();
}
Buffer * BufferManager::Get(int32_t BufferID)
{
if (NULL == localManager) {
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
return NULL;
}
return localManager->Get(BufferID);
}
bool BufferManager::Exist(int32_t BufferID)
{
if (NULL == localManager) {
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
return false;
}
return localManager->Exist(BufferID);
}
bool BufferManager::Exist(etk::FSNode &myFile)
{
if (NULL == localManager) {
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
return false;
}
return localManager->Exist(myFile);
}
int32_t BufferManager::GetId(etk::FSNode &myFile)
{
if (NULL == localManager) {
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
return -1;
}
return localManager->GetId(myFile);
}
uint32_t BufferManager::Size(void)
{
if (NULL == localManager) {
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
return 0;
}
return localManager->Size();
}
uint32_t BufferManager::SizeOpen(void)
{
if (NULL == localManager) {
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
return 0;
}
return localManager->SizeOpen();
}
int32_t BufferManager::WitchBuffer(int32_t iEmeElement)
{
if (NULL == localManager) {
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
return -1;
}
return localManager->WitchBuffer(iEmeElement);
}

View File

@@ -0,0 +1,51 @@
/**
*******************************************************************************
* @file BufferManager.h
* @brief Editeur De N'ours : Text Buffer (header)
* @author Edouard DUPIN
* @date 08/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.
*
*******************************************************************************
*/
#ifndef __BUFFER_MANAGER_H__
#define __BUFFER_MANAGER_H__
#include <Buffer.h>
#include <BufferText.h>
#include <BufferEmpty.h>
#include <appl/globalMsg.h>
#include <ewol/widget/Widget.h>
namespace BufferManager
{
void Init(void);
void UnInit(void);
int32_t GetSelected(void);
Buffer * Get(int32_t BufferID);
bool Exist(int32_t BufferID);
bool Exist(etk::FSNode &myFile);
int32_t GetId(etk::FSNode &myFile);
// return the number of buffer (open in the past) if 5 buffer open and 4 close ==> return 5
uint32_t Size(void);
uint32_t SizeOpen(void);
int32_t WitchBuffer(int32_t iEmeElement);
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,130 @@
/**
*******************************************************************************
* @file BufferText.h
* @brief Editeur De N'ours : Text Buffer (edit only ASCII text File) (header)
* @author Edouard DUPIN
* @date 19/01/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_TEXT_H__
#define __BUFFER_TEXT_H__
#include "ColorizeManager.h"
#include "Buffer.h"
#include "EdnBuf.h"
typedef enum {
CURSOR_DISPLAY_MODE_NORMAL = 259,
CURSOR_DISPLAY_MODE_INSERT,
CURSOR_DISPLAY_MODE_NOT_FOCUS,
} cursorDisplayMode_te;
class CharElement
{
public:
int16_t m_yOffset;
int16_t m_xOffset;
int16_t m_ySize;
int32_t m_bufferPos;
};
class BufferText : public Buffer {
public:
BufferText(void);
BufferText(etk::FSNode &fileName);
virtual ~BufferText(void);
void Save(void);
void GetInfo(infoStatBuffer_ts &infoToUpdate);
void SetLineDisplay(uint32_t lineNumber);
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
int32_t Display(ewol::TEXT_DISPLAY_TYPE& OOText,
ewol::OObject2DColored& OOColored,
int32_t offsetX, int32_t offsetY,
int32_t sizeX, int32_t sizeY);
#else
int32_t Display(ewol::TEXT_DISPLAY_TYPE& OOTextNormal,
ewol::TEXT_DISPLAY_TYPE& OOTextBold,
ewol::TEXT_DISPLAY_TYPE& OOTextItalic,
ewol::TEXT_DISPLAY_TYPE& OOTextBoldItalic,
ewol::OObject2DColored& OOColored,
int32_t offsetX, int32_t offsetY,
int32_t sizeX, int32_t sizeY);
#endif
void AddChar(uniChar_t unicodeData);
void cursorMove(ewol::eventKbMoveType_te moveTypeEvent);
void MouseSelectFromCursorTo(etk::Vector2D<float> pos);
void MouseEvent(etk::Vector2D<float> pos);
void MouseEventDouble(void);
void MouseEventTriple(void);
void Copy(ewol::clipBoard::clipboardListe_te clipboardID);
void Cut(ewol::clipBoard::clipboardListe_te clipboardID);
void Paste(ewol::clipBoard::clipboardListe_te clipboardID);
void Search(etk::UString &data, bool back, bool caseSensitive, bool wrap, bool regExp);
void Replace(etk::UString &data);
int32_t FindLine(etk::UString &data);
void JumpAtLine(int32_t newLine);
int32_t GetCurrentLine(void);
void RemoveLine(void);
void SelectAll(void);
void SelectNone(void);
void Undo(void);
void Redo(void);
void SetCharset(unicode::charset_te newCharset);
int32_t GetNumberOfLine(void);
protected:
void NameChange(void);
private:
int32_t GetLineNumberNumberOfElement(void);
// Direct buffer IO
EdnBuf m_EdnBuf; //!< buffer associated on this displayer
etk::Vector2D<float> m_displaySize; //!< number of char displayable in the screan
// Cursor :
int32_t m_cursorPos; //!< position in the buffer of the cursor
int32_t m_cursorPreferredCol; //!< colomn of the last up and down ...
cursorDisplayMode_te m_cursorMode; //!< type of cursor Selected
etk::Vector<CharElement> m_elmentList; //!< Elemnt position for every char displayed
// internal function
void BasicInit(void);
private:
bool m_centerRequested;
public:
virtual etk::Vector2D<float> GetPosition(int32_t fontId, bool& centerRequested);
private:
bool TextDMoveUp(int32_t offset);
bool TextDMoveDown(int32_t offset);
void SetInsertPosition(int32_t newPosition, bool insertChar = false);
int32_t GetMousePosition(etk::Vector2D<float> pos);
void DrawLineNumber(ewol::TEXT_DISPLAY_TYPE* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY, int32_t nbColomn, int32_t lineNumber, int32_t positionY);
void DrawCursor(ewol::OObject2DColored* OOColored, int32_t x, int32_t y, int32_t letterHeight, int32_t letterWidth, clipping_ts &clip);
};
#endif

View File

@@ -23,9 +23,11 @@
*******************************************************************************
*/
#include "tools_debug.h"
#include "tools_globals.h"
#include "EdnBuf.h"
#include <etk/Types.h>
#include <etk/unicode.h>
#include <appl/Debug.h>
#include <appl/global.h>
#include <EdnBuf.h>
#undef __class__
@@ -54,22 +56,14 @@ EdnBuf::EdnBuf(void)
m_useTabs = true;
// Current selection
m_selectionList[SELECTION_PRIMARY].selected = false;
m_selectionList[SELECTION_PRIMARY].zeroWidth = false;
m_selectionList[SELECTION_PRIMARY].rectangular = false;
m_selectionList[SELECTION_PRIMARY].start = m_selectionList[SELECTION_PRIMARY].end = 0;
m_selectionList[SELECTION_SECONDARY].selected = false;
m_selectionList[SELECTION_SECONDARY].zeroWidth = false;
m_selectionList[SELECTION_SECONDARY].rectangular = false;
m_selectionList[SELECTION_SECONDARY].start = m_selectionList[SELECTION_SECONDARY].end = 0;
m_selectionList[SELECTION_HIGHTLIGHT].selected = false;
m_selectionList[SELECTION_HIGHTLIGHT].zeroWidth = false;
m_selectionList[SELECTION_HIGHTLIGHT].rectangular = false;
m_selectionList[SELECTION_HIGHTLIGHT].start = m_selectionList[SELECTION_HIGHTLIGHT].end = 0;
m_selectionList.selected = false;
m_selectionList.zeroWidth = false;
m_selectionList.rectangular = false;
m_selectionList.start = m_selectionList.end = 0;
// charset :
m_isUtf8 = false;
m_charsetType = EDN_CHARSET_ISO_8859_15;
m_charsetType = unicode::EDN_CHARSET_ISO_8859_15;
m_isUndoProcessing = false;
m_isRedoProcessing = false;
@@ -77,7 +71,6 @@ EdnBuf::EdnBuf(void)
// basicly no HL system ...
m_Highlight = NULL;
m_nbLine = 1;
m_HLDataSequence = 0;
}
/**
@@ -96,10 +89,10 @@ EdnBuf::~EdnBuf(void)
* @return true if OK / false if an error occured
*
*/
bool EdnBuf::DumpIn(FILE *myFile)
bool EdnBuf::DumpIn(etk::FSNode &file)
{
// write Data
return m_data.DumpIn(myFile);
return m_data.DumpIn(file);
}
@@ -111,11 +104,11 @@ bool EdnBuf::DumpIn(FILE *myFile)
* @return true if OK / false if an error occured
*
*/
bool EdnBuf::DumpFrom(FILE *myFile)
bool EdnBuf::DumpFrom(etk::FSNode &file)
{
if (true == m_data.DumpFrom(myFile) ) {
if (true == m_data.DumpFrom(file) ) {
// set no selection
UpdateSelections(0, 0, m_data.Size() );
UpdateSelection(0, 0, m_data.Size() );
// generate HighLight
CleanHighLight();
GenerateHighLightAt(0, m_data.Size());
@@ -126,7 +119,7 @@ bool EdnBuf::DumpFrom(FILE *myFile)
}
void EdnBuf::GetAll(Edn::VectorType<int8_t> &text)
void EdnBuf::GetAll(etk::Vector<int8_t> &text)
{
// Clean output vector
text.Clear();
@@ -135,9 +128,9 @@ void EdnBuf::GetAll(Edn::VectorType<int8_t> &text)
}
void EdnBuf::SetAll(Edn::VectorType<int8_t> &text)
void EdnBuf::SetAll(etk::Vector<int8_t> &text)
{
Edn::VectorType<int8_t> deletedText;
etk::Vector<int8_t> deletedText;
// extract all data of the buffer :
GetAll(deletedText);
@@ -149,19 +142,39 @@ void EdnBuf::SetAll(Edn::VectorType<int8_t> &text)
m_data.Insert(0, text);
// Zero all of the existing selections
UpdateSelections(0, deletedText.Size(), 0);
UpdateSelection(0, deletedText.Size(), 0);
// Call the modification Event Manager
eventModification(0, m_data.Size(), deletedText);
}
void EdnBuf::GetRange(int32_t start, int32_t end, Edn::VectorType<int8_t> &output)
void EdnBuf::GetRange(int32_t start, int32_t end, etk::Vector<int8_t> &output)
{
// Remove all data ...
output.Clear();
// import data :
m_data.Get(start, end-start, output);
//EDN_DEBUG("request start=" << start << " end="<< end << " size="<< end-start << " result size=" << output.Size() );
//APPL_DEBUG("request start=" << start << " end="<< end << " size="<< end-start << " result size=" << output.Size() );
}
void EdnBuf::GetRange(int32_t start, int32_t end, etk::UString &output)
{
// Remove all data ...
output = "";
// import data :
etk::Vector<int8_t> localOutput;
m_data.Get(start, end-start, localOutput);
// transcript in UNICODE ...
if (true == m_isUtf8) {
localOutput.PushBack('\0');
output = (char*)&localOutput[0];
} else {
etk::Vector<uniChar_t> tmpUnicodeData;
// transform in unicode :
convertIsoToUnicode(m_charsetType, localOutput, tmpUnicodeData);
output = tmpUnicodeData;
}
//APPL_DEBUG("request start=" << start << " end="<< end << " size="<< end-start << " result size=" << output.Size() );
}
@@ -189,18 +202,30 @@ int8_t EdnBuf::operator[] (int32_t pos)
* @return ---
*
*/
void EdnBuf::Insert(int32_t pos, Edn::VectorType<int8_t> &insertText)
int32_t EdnBuf::Insert(int32_t pos, etk::Vector<int8_t> &insertText)
{
// if pos is not contiguous to existing text, make it
pos = edn_average(0, pos, m_data.Size() );
pos = etk_avg(0, pos, m_data.Size() );
// insert Data
insert(pos, insertText);
int32_t sizeInsert=LocalInsert(pos, insertText);
// Call the redisplay ...
Edn::VectorType<int8_t> deletedText;
etk::Vector<int8_t> deletedText;
eventModification(pos, insertText.Size(), deletedText);
return sizeInsert;
}
int32_t EdnBuf::Insert(int32_t pos, etk::UString &insertText)
{
// if pos is not contiguous to existing text, make it
pos = etk_avg(0, pos, m_data.Size() );
// insert Data
int32_t sizeInsert=LocalInsert(pos, insertText);
// Call the redisplay ...
etk::Vector<int8_t> deletedText;
eventModification(pos, insertText.Size(), deletedText);
return sizeInsert;
}
/**
* @brief Replace data in the buffer
@@ -209,16 +234,53 @@ void EdnBuf::Insert(int32_t pos, Edn::VectorType<int8_t> &insertText)
* @param[in] end Position ended in the buffer
* @param[in] insertText Test to set in the range [start..end]
*
* @return ---
* @return nb Octet inserted
*
*/
void EdnBuf::Replace(int32_t start, int32_t end, Edn::VectorType<int8_t> &insertText)
int32_t EdnBuf::Replace(int32_t start, int32_t end, etk::Vector<int8_t> &insertText)
{
Edn::VectorType<int8_t> deletedText;
if (end-start == 0) {
return 0;
}
etk::Vector<int8_t> deletedText;
GetRange(start, end, deletedText);
m_data.Replace(start, end-start, insertText);
// update internal elements
eventModification(start, insertText.Size(), deletedText);
return insertText.Size();
}
int32_t EdnBuf::Replace(int32_t start, int32_t end, etk::UString &insertText)
{
if (end-start == 0) {
return 0;
}
etk::Vector<int8_t> deletedText;
GetRange(start, end, deletedText);
etk::Vector<int8_t> tmpInsertText;
if (true == m_isUtf8) {
char * tmpPointer = insertText.c_str();
while (*tmpPointer != '\0') {
tmpInsertText.PushBack(*tmpPointer++);
}
} else {
etk::Vector<unsigned int> tmppp = insertText.GetVector();
convertUnicodeToIso(m_charsetType, tmppp, tmpInsertText);
}
if (tmpInsertText.Size()>0) {
if (tmpInsertText[tmpInsertText.Size()-1] == '\0') {
tmpInsertText.PopBack();
}
}
if (tmpInsertText.Size()>0) {
if (tmpInsertText[tmpInsertText.Size()-1] == '\0') {
tmpInsertText.PopBack();
}
}
m_data.Replace(start, end-start, tmpInsertText);
// update internal elements
eventModification(start, tmpInsertText.Size(), deletedText);
return tmpInsertText.Size();
}
@@ -234,15 +296,15 @@ void EdnBuf::Replace(int32_t start, int32_t end, Edn::VectorType<int8_t> &insert
void EdnBuf::Remove(int32_t start, int32_t end)
{
Edn::VectorType<int8_t> deletedText;
etk::Vector<int8_t> deletedText;
// Make sure the arguments make sense
if (start > end) {
int32_t temp = start;
start = end;
end = temp;
}
start = edn_average(0 , start, m_data.Size());
end = edn_average(0 , end, m_data.Size());
start = etk_avg(0 , start, m_data.Size());
end = etk_avg(0 , end, m_data.Size());
// Remove and redisplay
GetRange(start, end, deletedText);
@@ -251,21 +313,21 @@ void EdnBuf::Remove(int32_t start, int32_t end)
}
int32_t EdnBuf::Indent(selectionType_te select)
int32_t EdnBuf::Indent(void)
{
int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
bool SelectionIsRect;
bool haveSelectionActive = GetSelectionPos(select, SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
bool haveSelectionActive = GetSelectionPos(SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
if (false == haveSelectionActive) {
return SelectionEnd;
}
// Disable selection:
Unselect(select);
Unselect();
// Get Range :
int32_t l_start = StartOfLine(SelectionStart);
int32_t l_end = EndOfLine(SelectionEnd);
Edn::VectorType<int8_t> l_tmpData;
etk::Vector<int8_t> l_tmpData;
GetRange(l_start, l_end, l_tmpData);
l_tmpData.Insert(0, '\n');
@@ -285,26 +347,26 @@ int32_t EdnBuf::Indent(selectionType_te select)
Replace(l_start, l_end, l_tmpData);
// Set the new selection :
l_end = l_start + l_tmpData.Size();
Select(select, l_start, l_end);
Select(l_start, l_end);
// Return the position of the cursor
return l_end;
}
int32_t EdnBuf::UnIndent(selectionType_te select)
int32_t EdnBuf::UnIndent(void)
{
int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
bool SelectionIsRect;
bool haveSelectionActive = GetSelectionPos(select, SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
bool haveSelectionActive = GetSelectionPos(SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd);
if (false == haveSelectionActive) {
return SelectionEnd;
}
// Disable selection:
Unselect(select);
Unselect();
// Get Range :
int32_t l_start = StartOfLine(SelectionStart);
int32_t l_end = EndOfLine(SelectionEnd);
Edn::VectorType<int8_t> l_tmpData;
etk::Vector<int8_t> l_tmpData;
GetRange(l_start, l_end, l_tmpData);
l_tmpData.Insert(0, '\n');
@@ -331,7 +393,7 @@ int32_t EdnBuf::UnIndent(selectionType_te select)
Replace(l_start, l_end, l_tmpData);
// Set the new selection :
l_end = l_start + l_tmpData.Size();
Select(select, l_start, l_end);
Select(l_start, l_end);
// Return the position of the cursor
return l_end;
}
@@ -346,7 +408,7 @@ int32_t EdnBuf::UnIndent(selectionType_te select)
* @return ---
*
*/
void EdnBuf::GetLineText(int32_t pos, Edn::VectorType<int8_t> &text)
void EdnBuf::GetLineText(int32_t pos, etk::Vector<int8_t> &text)
{
GetRange( StartOfLine(pos), EndOfLine(pos), text);
}
@@ -468,7 +530,7 @@ int32_t EdnBuf::GetExpandedChar(int32_t &pos, int32_t indent, char outUTF8[MAX_E
tmpString[6] = '\0';
uint8_t size;
bool baseValid;
Utf8_SizeElement(tmpString, 6 , size, baseValid);
unicode::Utf8_SizeElement(tmpString, 6 , size, baseValid);
currentChar = 0; // TODO : Set UNICODE char ...
if (true == baseValid) {
char *tmp = outUTF8;
@@ -480,7 +542,7 @@ int32_t EdnBuf::GetExpandedChar(int32_t &pos, int32_t indent, char outUTF8[MAX_E
sprintf(outUTF8, "<? ? ? ?>");
}
if (0 == size) {
EDN_ERROR("plop");
APPL_ERROR("plop");
}
pos+=size;
return strlen(outUTF8);
@@ -488,6 +550,119 @@ int32_t EdnBuf::GetExpandedChar(int32_t &pos, int32_t indent, char outUTF8[MAX_E
return 1;
}
/**
* @brief Transform the current caracter in the buffer in a displayable vector of char
*
* @param[in,out] pos position of the char that might be converted (incremented to the next char (in case of UTF8)
* @param[in] indent Curent indentation befor the curent char
* @param[out] outUTF8 string of the displayed element
* @param[out] currentChar curent unicode output char
*
* @return number of displayable char (display char width)
*
*/
int32_t EdnBuf::GetExpandedChar(int32_t &pos, int32_t indent, uniChar_t outUnicode[MAX_EXP_CHAR_LEN], uint32_t &currentChar)
{
int32_t i, nSpaces;
char c = m_data.Get(pos);
currentChar = (uint32_t)c & 0xFF;
/* Convert tabs to spaces */
if (c == '\t') {
nSpaces = m_tabDist - (indent % m_tabDist);
for (i=0; i<nSpaces; i++) {
outUnicode[i] = ' ';
}
outUnicode[i] = '\0';
pos++;
return nSpaces;
}
// Convert ASCII control codes to readable character sequences
if (c == '\0') {
outUnicode[0] = '<';
outUnicode[1] = 'n';
outUnicode[2] = 'u';
outUnicode[3] = 'l';
outUnicode[4] = '>';
outUnicode[5] = '\0';
pos++;
return 5;
}
if (((unsigned char)c) == '\n') {
outUnicode[0] = (unsigned char)c;
outUnicode[1] = '\0';
pos++;
return 1;
}
if (((unsigned char)c) <= 31) {
const char * tmp = ControlCodeTable[(unsigned char)c];
int32_t nbElem = 2;
*outUnicode++ = '<';
while (*tmp!='\0') {
*outUnicode++ = *tmp;
tmp++;
nbElem++;
}
*outUnicode++ = '>';
*outUnicode++ = '\0';
pos++;
return nbElem;
} else if (c == 127) {
outUnicode[0] = '<';
outUnicode[1] = 'd';
outUnicode[2] = 'e';
outUnicode[3] = 'l';
outUnicode[4] = '>';
outUnicode[5] = '\0';
pos++;
return 5;
}
// clear all the data ...
memset(outUnicode, 0, sizeof(uniChar_t)*MAX_EXP_CHAR_LEN);
// Otherwise, just return the character
if (false ==m_isUtf8) {
unicode::convertIsoToUnicode(m_charsetType, c, outUnicode[0]);
pos++;
} else {
char tmpString[8];
for (int32_t k=0; k<6 && k< m_data.Size() - pos; k++) {
tmpString[k] = m_data.Get(pos+k);
}
tmpString[6] = '\0';
uint8_t size;
bool baseValid;
unicode::Utf8_SizeElement(tmpString, 6 , size, baseValid);
currentChar = 0;
if (true == baseValid) {
char tmp[20];
for (int32_t kkk=0; kkk<size; kkk++) {
tmp[kkk] = tmpString[kkk];
tmp[kkk+1] = '\0';
}
unicode::convertUtf8ToUnicode(tmp, outUnicode[0]);
outUnicode[1] = 0;
} else {
outUnicode[0] = '<';
outUnicode[1] = '?';
outUnicode[2] = '?';
outUnicode[3] = '?';
outUnicode[4] = '>';
outUnicode[5] = 0;
}
if (0 == size) {
APPL_ERROR("plop");
}
pos+=size;
int32_t outSize = 0;
while (outUnicode[outSize]!=0) {
outSize++;
}
return outSize;
}
return 1;
}
/**
* @brief generate the real display of character of the output (ex : \t ==> 4 spaces or less ...)
@@ -545,7 +720,7 @@ int32_t EdnBuf::ExpandCharacter(char c, int32_t indent, char outUTF8[MAX_EXP_CHA
// Otherwise, just return the character
//*outStr = c; // deprecated
convertIsoToUtf8(EDN_CHARSET_ISO_8859_15, c, outUTF8);
convertIsoToUtf8(unicode::EDN_CHARSET_ISO_8859_15, c, outUTF8);
return 1;
}
@@ -592,14 +767,14 @@ int32_t EdnBuf::CountDispChars(int32_t lineStartPos, int32_t targetPos)
int32_t charCount = 0;
char expandedChar[MAX_EXP_CHAR_LEN];
//EDN_DEBUG("lineStartPos="<< lineStartPos << " targetPos=" << targetPos);
//APPL_DEBUG("lineStartPos="<< lineStartPos << " targetPos=" << targetPos);
while( myPosIt
&& myPosIt.Position() < targetPos )
{
charCount += ExpandCharacter(*myPosIt, charCount, expandedChar);
myPosIt++;
}
//EDN_DEBUG(" result=" << charCount);
//APPL_DEBUG(" result=" << charCount);
return charCount;
}
@@ -666,9 +841,9 @@ int32_t EdnBuf::CountLines(int32_t startPos, int32_t endPos)
* @return number of line found
*
*/
int32_t EdnBuf::CountLines(Edn::VectorType<int8_t> &data)
int32_t EdnBuf::CountLines(etk::Vector<int8_t> &data)
{
Edn::VectorType<int8_t>::Iterator myPosIt = data.Begin();
etk::Vector<int8_t>::Iterator myPosIt = data.Begin();
int32_t lineCount = 0;
while(myPosIt) {
@@ -727,19 +902,19 @@ int32_t EdnBuf::CountForwardNLines(int32_t startPos, int32_t nLines)
}
EdnVectorBuf::Iterator myPosIt = m_data.Position(startPos);
int32_t lineCount = 0;
//EDN_INFO("startPos=" << startPos << " nLines=" << nLines);
//APPL_INFO("startPos=" << startPos << " nLines=" << nLines);
while(myPosIt)
{
if ('\n' == *myPosIt) {
lineCount++;
if (lineCount == nLines) {
//EDN_INFO(" ==> (1) at position=" << myPosIt.Position()+1 );
//APPL_INFO(" ==> (1) at position=" << myPosIt.Position()+1 );
return myPosIt.Position()+1;
}
}
myPosIt++;
}
//EDN_INFO(" ==> (2) at position=" << myPosIt.Position() );
//APPL_INFO(" ==> (2) at position=" << myPosIt.Position() );
return myPosIt.Position();
}
@@ -760,7 +935,7 @@ int32_t EdnBuf::CountBackwardNLines(int32_t startPos, int32_t nLines)
} else if (startPos > m_data.Size() ) {
startPos = m_data.Size();
}
//EDN_INFO("startPos=" << startPos << " nLines=" << nLines);
//APPL_INFO("startPos=" << startPos << " nLines=" << nLines);
EdnVectorBuf::Iterator myPosIt = m_data.Position(startPos-1);
int32_t lineCount = -1;
@@ -769,13 +944,13 @@ int32_t EdnBuf::CountBackwardNLines(int32_t startPos, int32_t nLines)
if ('\n' == *myPosIt) {
lineCount++;
if (lineCount >= nLines) {
//EDN_INFO(" ==> (1) at position=" << myPosIt.Position()+1 );
//APPL_INFO(" ==> (1) at position=" << myPosIt.Position()+1 );
return myPosIt.Position()+1;
}
}
myPosIt--;
}
//EDN_INFO(" ==> (2) at position=0");
//APPL_INFO(" ==> (2) at position=0");
return 0;
}
@@ -791,10 +966,10 @@ bool EdnBuf::charMatch(char first, char second, bool caseSensitive)
}
}
if(first == second) {
//EDN_DEBUG("charMatch(" << first << ", " << second << ", " << caseSensitive << ") ==> true");
//APPL_DEBUG("charMatch(" << first << ", " << second << ", " << caseSensitive << ") ==> true");
return true;
} else {
//EDN_DEBUG("charMatch(" << first << ", " << second << ", " << caseSensitive << ") ==> false");
//APPL_DEBUG("charMatch(" << first << ", " << second << ", " << caseSensitive << ") ==> false");
return false;
}
}
@@ -810,13 +985,25 @@ bool EdnBuf::charMatch(char first, char second, bool caseSensitive)
* @return false ==> not found data
*
*/
bool EdnBuf::SearchForward(int32_t startPos, Edn::VectorType<int8_t> &searchVect, int32_t *foundPos, bool caseSensitive)
bool EdnBuf::SearchForward(int32_t startPos, etk::UString &search, int32_t *foundPos, int32_t *foundPosEnd, bool caseSensitive)
{
etk::Vector<int8_t> searchVect;
if (true == m_isUtf8) {
char * tmpPointer = search.c_str();
while (*tmpPointer != '\0') {
searchVect.PushBack(*tmpPointer++);
}
} else {
etk::Vector<unsigned int> tmppp = search.GetVector();
convertUnicodeToIso(m_charsetType, tmppp, searchVect);
}
// remove the '\0' at the end of the string ...
searchVect.PopBack();
int32_t position;
int32_t searchLen = searchVect.Size();
int32_t dataLen = m_data.Size();
char currentChar = '\0';
//EDN_INFO(" startPos=" << startPos << " searchLen=" << searchLen);
APPL_INFO(" startPos=" << startPos << " searchLen=" << searchLen);
for (position=startPos; position<dataLen - (searchLen-1); position++) {
currentChar = m_data[position];
if (true == charMatch(currentChar, searchVect[0], caseSensitive)) {
@@ -831,11 +1018,13 @@ bool EdnBuf::SearchForward(int32_t startPos, Edn::VectorType<int8_t> &searchVect
}
if (true == found) {
*foundPos = position;
*foundPosEnd = position + searchVect.Size();
return true;
}
}
}
*foundPos = m_data.Size();
*foundPosEnd = m_data.Size();
return false;
}
@@ -851,12 +1040,25 @@ bool EdnBuf::SearchForward(int32_t startPos, Edn::VectorType<int8_t> &searchVect
* @return false ==> not found data
*
*/
bool EdnBuf::SearchBackward(int32_t startPos, Edn::VectorType<int8_t> &searchVect, int32_t *foundPos, bool caseSensitive)
bool EdnBuf::SearchBackward(int32_t startPos, etk::UString &search, int32_t *foundPos, int32_t *foundPosEnd, bool caseSensitive)
{
etk::Vector<int8_t> searchVect;
if (true == m_isUtf8) {
char * tmpPointer = search.c_str();
while (*tmpPointer != '\0') {
searchVect.PushBack(*tmpPointer++);
}
} else {
etk::Vector<unsigned int> tmppp = search.GetVector();
convertUnicodeToIso(m_charsetType, tmppp, searchVect);
}
// remove the '\0' at the end of the string ...
searchVect.PopBack();
int32_t position;
int32_t searchLen = searchVect.Size();
char currentChar = '\0';
//EDN_INFO(" startPos=" << startPos << " searchLen=" << searchLen);
//APPL_INFO(" startPos=" << startPos << " searchLen=" << searchLen);
for (position=startPos; position>=searchLen-1; position--) {
currentChar = m_data[position];
if (true == charMatch(currentChar, searchVect[searchLen-1], caseSensitive)) {
@@ -871,11 +1073,13 @@ bool EdnBuf::SearchBackward(int32_t startPos, Edn::VectorType<int8_t> &searchVec
}
if (true == found) {
*foundPos = position - (searchLen-1);
*foundPosEnd = position + searchVect.Size();
return true;
}
}
}
*foundPos = m_data.Size();
*foundPosEnd = m_data.Size();
return false;
}
@@ -887,10 +1091,10 @@ static bool isChar(char value)
|| '_' == value
|| '~' == value)
{
//EDN_DEBUG(" is a char \"" << value << "\"");
//APPL_DEBUG(" is a char \"" << value << "\"");
return true;
}
//EDN_DEBUG(" is NOT a char \"" << value << "\"");
//APPL_DEBUG(" is NOT a char \"" << value << "\"");
return false;
}
@@ -901,7 +1105,7 @@ bool EdnBuf::SelectAround(int32_t startPos, int32_t &beginPos, int32_t &endPos)
if( '\t' == currentChar
|| ' ' == currentChar)
{
EDN_DEBUG("select spacer");
APPL_DEBUG("select spacer");
// special case we are looking for separation
for (beginPos=startPos; beginPos>=0; beginPos--) {
currentChar = m_data[beginPos];
@@ -923,7 +1127,7 @@ bool EdnBuf::SelectAround(int32_t startPos, int32_t &beginPos, int32_t &endPos)
}
return true;
} else if( true == isChar(currentChar)){
EDN_DEBUG("select normal Char");
APPL_DEBUG("select normal Char");
// Search back
for (beginPos=startPos; beginPos>=0; beginPos--) {
currentChar = m_data[beginPos];
@@ -942,7 +1146,7 @@ bool EdnBuf::SelectAround(int32_t startPos, int32_t &beginPos, int32_t &endPos)
return true;
} else {
char comparechar = currentChar;
EDN_DEBUG("select same char");
APPL_DEBUG("select same char");
// Search back
for (beginPos=startPos; beginPos>=0; beginPos--) {
currentChar = m_data[beginPos];
@@ -977,15 +1181,34 @@ bool EdnBuf::SelectAround(int32_t startPos, int32_t &beginPos, int32_t &endPos)
* @return number of element inserted.
*
*/
int32_t EdnBuf::insert(int32_t pos, Edn::VectorType<int8_t> &insertText)
int32_t EdnBuf::LocalInsert(int32_t pos, etk::Vector<int8_t> &insertText)
{
// Insert data in buffer
m_data.Insert(pos, insertText);
// update the current selected area
UpdateSelections(pos, 0, insertText.Size() );
UpdateSelection(pos, 0, insertText.Size() );
// return the number of element inserted ...
return insertText.Size();
}
int32_t EdnBuf::LocalInsert(int32_t pos, etk::UString &insertText)
{
etk::Vector<int8_t> tmpInsertText;
if (true == m_isUtf8) {
char * tmpPointer = insertText.c_str();
while (*tmpPointer != '\0') {
tmpInsertText.PushBack(*tmpPointer++);
}
} else {
etk::Vector<unsigned int> tmppp = insertText.GetVector();
convertUnicodeToIso(m_charsetType, tmppp, tmpInsertText);
}
if (tmpInsertText.Size()>0) {
if (tmpInsertText[tmpInsertText.Size()-1] == '\0') {
tmpInsertText.PopBack();
}
}
return LocalInsert(pos, tmpInsertText);
}
/**
@@ -998,19 +1221,19 @@ int32_t EdnBuf::insert(int32_t pos, Edn::VectorType<int8_t> &insertText)
* @return ---
*
*/
void EdnBuf::eventModification(int32_t pos, int32_t nInserted, Edn::VectorType<int8_t> &deletedText)
void EdnBuf::eventModification(int32_t pos, int32_t nInserted, etk::Vector<int8_t> &deletedText)
{
if( 0 == deletedText.Size()
&& 0 == nInserted)
{
// we do nothing ...
//EDN_INFO("EdnBuf::eventModification(pos="<<pos<<", ... , nRestyled=" << nRestyled << ", deletedText=\"" << textDisplay << "\");");
//APPL_INFO("EdnBuf::eventModification(pos="<<pos<<", ... , nRestyled=" << nRestyled << ", deletedText=\"" << textDisplay << "\");");
} else {
EDN_INFO("(pos="<<pos<<", nDeleted="<<deletedText.Size()<<", nInserted=" << nInserted << ", deletedText=\"xx???xx\");");
APPL_INFO("(pos="<<pos<<", nDeleted="<<deletedText.Size()<<", nInserted=" << nInserted << ", deletedText=\"xx???xx\");");
// update the number of lines :
//CountNumberOfLines(); //==> not efficent methode ...
// ==> better methode : just update the number of line added and removed ...
//EDN_INFO(" add=" << CountLines(pos, pos+nInserted) << " lines | remove="<< CountLines(deletedText) << " lines");
//APPL_INFO(" add=" << CountLines(pos, pos+nInserted) << " lines | remove="<< CountLines(deletedText) << " lines");
m_nbLine += CountLines(pos, pos+nInserted) - CountLines(deletedText);
// Update histories
if (false == m_isUndoProcessing) {

View File

@@ -0,0 +1,209 @@
/**
*******************************************************************************
* @file EdnBuf.h
* @brief Editeur De N'ours : Buffer for internal Data (header)
* @author Edouard DUPIN
* @date 23/03/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_BUF_H__
#define __EDN_BUF_H__
/* Maximum length in characters of a tab or control character expansion
of a single buffer character */
#define MAX_EXP_CHAR_LEN 20*4
class EdnBuf;
#include <EdnVectorBuf.h>
#include <EdnBufHistory.h>
#include <HighlightManager.h>
#include <etk/unicode.h>
/*
rectStart rectStart
start ************* *************
********** * xxxx*xxxxxx *
* ******** xxxx*xxxxxxxxxxx*xxxxx
end *************** *************
rectEnd rectEnd
*/
typedef struct {
bool selected; //!< True if the selection is active
bool rectangular; //!< True if the selection is rectangular
bool zeroWidth; //!< Width 0 selections aren't "real" selections, but they can be useful when creating rectangular selections from the keyboard.
int32_t start; //!< Pos. of start of selection, or if rectangular start of line containing it.
int32_t end; //!< Pos. of end of selection, or if rectangular end of line containing it.
int32_t rectStart; //!< Indent of left edge of rect. selection
int32_t rectEnd; //!< Indent of right edge of rect. selection
} selection;
typedef struct {
etk::Vector<colorInformation_ts> HLData;
int32_t posHLPass1;
int32_t posHLPass2;
}displayHLData_ts;
class EdnBuf {
// TODO : Set an iterator to acces at every data without knowin the system ...
public:
// constructer
EdnBuf(void);
// destructer
~EdnBuf(void);
// public function :
void GetAll( etk::Vector<int8_t> &text);
void SetAll( etk::Vector<int8_t> &text);
void GetRange( int32_t start, int32_t end, etk::Vector<int8_t> &output);
void GetRange( int32_t start, int32_t end, etk::UString &output);
bool DumpIn( etk::FSNode &file);
bool DumpFrom( etk::FSNode &file);
// replace with operator [] ...
int8_t operator[] (int32_t);
int32_t Insert( int32_t pos, etk::Vector<int8_t> &insertText);
int32_t Insert( int32_t pos, etk::UString &insertText);
int32_t Replace( int32_t start, int32_t end, etk::Vector<int8_t> &insertText);
int32_t Replace( int32_t start, int32_t end, etk::UString &insertText);
void Remove( int32_t start, int32_t end);
int32_t Indent( void);
int32_t UnIndent( void);
void GetLineText( int32_t pos, etk::Vector<int8_t> &text);
int32_t StartOfLine( int32_t pos);
int32_t EndOfLine( int32_t pos);
int32_t GetExpandedChar( int32_t &pos, int32_t indent, uniChar_t outUnicode[MAX_EXP_CHAR_LEN], uint32_t &currentChar);
int32_t GetExpandedChar( int32_t &pos, int32_t indent, char outUTF8[MAX_EXP_CHAR_LEN], uint32_t &currentChar);
int32_t ExpandCharacter( char c, int32_t indent, char outUTF8[MAX_EXP_CHAR_LEN]); // TODO : Remove
int32_t CharWidth( char c, int32_t indent); // TODO : rework this
int32_t CountDispChars( int32_t lineStartPos, int32_t targetPos);
int32_t CountForwardDispChars( int32_t lineStartPos, int32_t nChars);
int32_t CountLines( int32_t startPos, int32_t endPos);
int32_t CountLines( void);
int32_t CountLines( etk::Vector<int8_t> &data);
int32_t CountForwardNLines( int32_t startPos, int32_t nLines);
int32_t CountBackwardNLines( int32_t startPos, int32_t nLines);
bool SearchForward( int32_t startPos, etk::UString &search, int32_t *foundPos, int32_t *foundPosEnd, bool caseSensitive = true);
bool SearchBackward( int32_t startPos, etk::UString &search, int32_t *foundPos, int32_t *foundPosEnd, bool caseSensitive = true);
bool SearchForward( int32_t startPos, char searchChar, int32_t *foundPos);
bool SearchBackward( int32_t startPos, char searchChar, int32_t *foundPos);
bool SelectAround( int32_t startPos, int32_t &beginPos, int32_t &endPos);
// Buffer Size system :
int32_t Size(void) { return m_data.Size(); };
int32_t NumberOfLines(void) { return m_nbLine; };
// -----------------------------------------
// selection remember...
// -----------------------------------------
public:
bool SelectHasSelection(void);
void Select( int32_t start, int32_t end);
void Unselect( void);
void RectSelect( int32_t start, int32_t end, int32_t rectStart, int32_t rectEnd);
bool GetSelectionPos( int32_t &start, int32_t &end, bool &isRect, int32_t &rectStart, int32_t &rectEnd);
void GetSelectionText( etk::Vector<int8_t> &text);
void GetSelectionText( etk::UString &text);
void RemoveSelected( void);
int32_t ReplaceSelected( etk::Vector<int8_t> &text);
int32_t ReplaceSelected( etk::UString &text);
private:
// current selection of the buffer
selection m_selectionList; //!< Selection area of the buffer
void UpdateSelection( int32_t pos, int32_t nDeleted, int32_t nInserted);
// -----------------------------------------
// History section :
// -----------------------------------------
public:
int32_t Undo(void);
int32_t Redo(void);
private:
bool m_isUndoProcessing;
bool m_isRedoProcessing;
etk::Vector<EdnBufHistory*> m_historyUndo;
etk::Vector<EdnBufHistory*> m_historyRedo;
// -----------------------------------------
// hightlight section :
// -----------------------------------------
private:
Highlight * m_Highlight; //!< internal link with the Highlight system
etk::Vector<colorInformation_ts> m_HLDataPass1; //!< colorisation position in the current buffer pass 1
void RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdded);
void GenerateHighLightAt(int32_t pos, int32_t endPos, int32_t addinPos=0);
void CleanHighLight(void);
void FindMainHighLightPosition(int32_t startPos, int32_t endPos, int32_t &startId, int32_t &stopId, bool backPreviousNotEnded);
public:
void SetHLSystem( Highlight * newHLSystem);
void HightlightGenerateLines(displayHLData_ts & MData, int32_t startPos, int32_t nbLines);
colorInformation_ts * GetElementColorAtPosition(displayHLData_ts & MData, int32_t pos);
private:
colorInformation_ts * GetElementColorAtPosition(int32_t pos, int32_t &starPos);
private:
EdnVectorBuf m_data; //!< buffer of the data in the mode int8_t
void CountNumberOfLines(void);
int32_t m_nbLine; //!< Number of line in the biffer
// -----------------------------------------
// Display property and charset ...
// -----------------------------------------
public:
int32_t GetTabDistance(void) { return m_tabDist; } ;
void SetTabDistance(int32_t tabDist) { m_tabDist = tabDist; };
unicode::charset_te GetCharsetType(void) { return m_charsetType; };
void SetCharsetType(unicode::charset_te newOne) { m_charsetType = newOne; if (unicode::EDN_CHARSET_UTF8==newOne){m_isUtf8=true;} else {m_isUtf8=false;} };
bool GetUTF8Mode(void) { return m_isUtf8; };
void SetUTF8Mode(bool newOne) { m_isUtf8 = newOne; m_charsetType=unicode::EDN_CHARSET_UTF8; };
private:
// Special mode of the buffer :
bool m_isUtf8; //!< true if we are in UTF8 mode ==> if true the size of a char is 0, otherwise .. 1->4 ( TODO : not now)
unicode::charset_te m_charsetType; //!< if UTF8 mode is at false : the charset type of the buffer
// Local Tabulation policies
int32_t m_tabDist; //!< equiv. number of characters in a tab
bool m_useTabs; //!< True if buffer routines are allowed to use tabs for padding in rectangular operations
// -----------------------------------------
// Local function :
// -----------------------------------------
private:
void findRectSelBoundariesForCopy( int32_t lineStartPos, int32_t rectStart, int32_t rectEnd, int32_t *selStart, int32_t *selEnd);
char * getSelectionText( selection &sel);
void removeSelected( selection &sel);
void replaceSelected( selection &sel, const char *text);
void eventModification( int32_t pos, int32_t nInserted, etk::Vector<int8_t> &deletedText);
int32_t LocalInsert( int32_t pos, etk::Vector<int8_t> &insertText);
int32_t LocalInsert( int32_t pos, etk::UString &insertText);
bool charMatch( char first, char second, bool caseSensitive = true);
};
#endif

View File

@@ -24,9 +24,9 @@
*/
#include "tools_debug.h"
#include "tools_globals.h"
#include "EdnBufHistory.h"
#include <appl/Debug.h>
#include <appl/global.h>
#include <EdnBufHistory.h>
#undef __class__
@@ -34,22 +34,22 @@
EdnBufHistory::EdnBufHistory(void)
{
//EDN_INFO("EdnBufHistory new");
//APPL_INFO("EdnBufHistory new");
m_pos = 0;
m_nInserted = 0;
}
EdnBufHistory::EdnBufHistory(int32_t pos, int32_t nInserted, Edn::VectorType<int8_t> &deletedText)
EdnBufHistory::EdnBufHistory(int32_t pos, int32_t nInserted, etk::Vector<int8_t> &deletedText)
{
//EDN_INFO("EdnBufHistory new + data");
//APPL_INFO("EdnBufHistory new + data");
m_pos = pos;
m_nInserted = nInserted;
m_deletedText = deletedText;
}
void EdnBufHistory::Set(int32_t pos, int32_t nInserted, Edn::VectorType<int8_t> &deletedText)
void EdnBufHistory::Set(int32_t pos, int32_t nInserted, etk::Vector<int8_t> &deletedText)
{
//EDN_INFO("EdnBufHistory new + data");
//APPL_INFO("EdnBufHistory new + data");
m_pos = pos;
m_nInserted = nInserted;
m_deletedText = deletedText;
@@ -75,7 +75,7 @@ int32_t EdnBufHistory::getnbInserted(void)
return m_nInserted;
}
void EdnBufHistory::getData(Edn::VectorType<int8_t> &deletedText)
void EdnBufHistory::getData(etk::Vector<int8_t> &deletedText)
{
deletedText = m_deletedText;
}

View File

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

View File

@@ -23,9 +23,9 @@
*******************************************************************************
*/
#include "tools_debug.h"
#include "tools_globals.h"
#include "EdnBuf.h"
#include <appl/Debug.h>
#include <appl/global.h>
#include <EdnBuf.h>
#undef __class__
@@ -35,19 +35,16 @@ void EdnBuf::SetHLSystem(Highlight * newHLSystem)
{
if (m_Highlight != newHLSystem) {
m_Highlight = newHLSystem;
m_HLDataPass1.clear();
m_HLDataPass1.Clear();
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)
{
GTimeVal timeStart;
g_get_current_time(&timeStart);
// remove display HL...
m_HLDataSequence++;
//GTimeVal timeStart;
//g_get_current_time(&timeStart);
// prevent ERROR...
if (NULL == m_Highlight) {
@@ -60,14 +57,23 @@ void EdnBuf::RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdd
return;
}
// normal case
EDN_INFO("(pos="<<pos<<", nbDeleted="<<nbDeleted<<", nbAdded=" << nbAdded << "\");");
//APPL_INFO("(pos="<<pos<<", nbDeleted="<<nbDeleted<<", nbAdded=" << nbAdded << "\");");
int32_t i;
/*
for (i=0; i< (int32_t)m_HLDataPass1.Size(); i++) {
etk::UString ploppp;
if (NULL != m_HLDataPass1[i].patern ) {
ploppp = ((HighlightPattern*)m_HLDataPass1[i].patern)->GetName();
}
APPL_DEBUG("HighLight (previous) element id=" << i << " S=" << m_HLDataPass1[i].beginStart << " E=" << m_HLDataPass1[i].endStop << " patern name=" << ploppp );
}
*/
int32_t posEnd = pos + nbDeleted;
// search position of the old element to reparse IT...
int32_t startId;
int32_t stopId;
// clean data if needed
if (0 != m_HLDataPass1.size()) {
if (0 != m_HLDataPass1.Size()) {
// find element previous
FindMainHighLightPosition(pos, posEnd, startId, stopId, true);
@@ -75,19 +81,37 @@ void EdnBuf::RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdd
if( -1 == startId
&& -1 == stopId)
{
m_HLDataPass1.clear();
m_HLDataPass1.Clear();
} else if(-1 == startId) {
if (0 == stopId){
m_HLDataPass1.erase(m_HLDataPass1.begin());
m_HLDataPass1.Erase(0);
//APPL_DEBUG("1 * Erase 0");
} else {
m_HLDataPass1.erase(m_HLDataPass1.begin(),m_HLDataPass1.begin()+stopId);
m_HLDataPass1.EraseLen(0,stopId);
//APPL_DEBUG("2 * Erase 0->" << stopId);
}
} else if(-1 == stopId) {
m_HLDataPass1.erase(m_HLDataPass1.begin()+startId+1,m_HLDataPass1.end());
//APPL_DEBUG("3 * Erase " << startId+1 << "-> end");
m_HLDataPass1.EraseLen(startId+1, m_HLDataPass1.Size() - startId);
stopId = -1;
} else {
m_HLDataPass1.erase(m_HLDataPass1.begin()+startId+1,m_HLDataPass1.begin()+stopId);
int32_t currentSize = m_HLDataPass1.Size();
//APPL_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);
//APPL_DEBUG("new size=" << (int32_t)m_HLDataPass1.Size()-1);
/*
for (i=0; i< (int32_t)m_HLDataPass1.Size(); i++) {
etk::UString ploppp;
if (NULL != m_HLDataPass1[i].patern ) {
ploppp = ((HighlightPattern*)m_HLDataPass1[i].patern)->GetName();
}
APPL_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 :
int32_t elemStart;
if(-1 == startId) {
@@ -95,8 +119,8 @@ void EdnBuf::RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdd
} else {
elemStart = startId+1;
}
for (i=elemStart; i< (int32_t)m_HLDataPass1.size(); i++) {
//EDN_DEBUG("move element=" << i);
for (i=elemStart; i< (int32_t)m_HLDataPass1.Size(); i++) {
//APPL_DEBUG("move element=" << i);
m_HLDataPass1[i].beginStart += nbAdded - nbDeleted;
m_HLDataPass1[i].beginStop += nbAdded - nbDeleted;
m_HLDataPass1[i].endStart += nbAdded - nbDeleted;
@@ -106,33 +130,34 @@ void EdnBuf::RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdd
if( -1 == startId
&& -1 == stopId)
{
//EDN_DEBUG("******* Regenerate ALL");
//APPL_DEBUG("******* Regenerate ALL");
GenerateHighLightAt(0, m_data.Size());
} else if(-1 == startId) {
//EDN_DEBUG("******* Regenerate START");
//APPL_DEBUG("******* Regenerate START");
GenerateHighLightAt(0, m_HLDataPass1[0].beginStart, 0);
} else if(-1 == stopId) {
//EDN_DEBUG("******* Regenerate STOP");
GenerateHighLightAt(m_HLDataPass1[m_HLDataPass1.size() -1].endStop, m_data.Size(), m_HLDataPass1.size());
//APPL_DEBUG("******* Regenerate STOP");
GenerateHighLightAt(m_HLDataPass1[m_HLDataPass1.Size() -1].endStop, m_data.Size(), m_HLDataPass1.Size());
} else {
//EDN_DEBUG("******* Regenerate RANGE");
//APPL_DEBUG("******* Regenerate RANGE");
GenerateHighLightAt(m_HLDataPass1[startId].endStop, m_HLDataPass1[startId+1].beginStart, startId+1);
}
} else {
// Parse the new element ...
//GenerateHighLightAt(pos, nbAdded);
GenerateHighLightAt(0, m_data.Size());
}
for (i=0; i< (int32_t)m_HLDataPass1.size(); i++) {
Edn::String ploppp;
/*
for (i=0; i< (int32_t)m_HLDataPass1.Size(); i++) {
etk::UString ploppp;
if (NULL != m_HLDataPass1[i].patern ) {
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() );
APPL_DEBUG("HighLight (end) element id=" << i << " S=" << m_HLDataPass1[i].beginStart << " E=" << m_HLDataPass1[i].endStop << " patern name=" << ploppp );
}
GTimeVal timeStop;
g_get_current_time(&timeStop);
EDN_DEBUG("HL General = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s");
*/
//GTimeVal timeStop;
//g_get_current_time(&timeStop);
//APPL_DEBUG("HL General = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s");
}
void EdnBuf::FindMainHighLightPosition(int32_t startPos, int32_t endPos, int32_t &startId, int32_t &stopId, bool backPreviousNotEnded)
@@ -177,7 +202,7 @@ void EdnBuf::FindMainHighLightPosition(int32_t startPos, int32_t endPos, int32_t
S=-1 *************** E
*/
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) {
break;
}
@@ -198,7 +223,7 @@ void EdnBuf::FindMainHighLightPosition(int32_t startPos, int32_t endPos, int32_t
} else {
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)
{
stopId = i;
@@ -206,15 +231,15 @@ void EdnBuf::FindMainHighLightPosition(int32_t startPos, int32_t endPos, int32_t
}
}
/*
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);
if (-1 != startId && startId < (int32_t)m_HLDataPass1.Size()) {
APPL_DEBUG("==> BEGIN : start="<<m_HLDataPass1[startId].beginStart<<", stop="<<m_HLDataPass1[startId].endStop<<" id=" << startId << "/" << (int32_t)m_HLDataPass1.Size()-1);
} else {
EDN_DEBUG("==> BEGIN : start=???, stop=??? id=" << startId);
APPL_DEBUG("==> BEGIN : start=???, stop=??? id=" << startId);
}
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);
if (-1 != stopId && stopId < (int32_t)m_HLDataPass1.Size()) {
APPL_DEBUG("==> END : start="<<m_HLDataPass1[stopId].beginStart<<", stop="<<m_HLDataPass1[stopId].endStop<<" id=" << stopId<< "/" << (int32_t)m_HLDataPass1.Size()-1);
} else {
EDN_DEBUG("==> END : start=???, stop=??? id=" << stopId);
APPL_DEBUG("==> END : start=???, stop=??? id=" << stopId);
}
*/
}
@@ -227,7 +252,7 @@ void EdnBuf::GenerateHighLightAt(int32_t pos, int32_t endPos, int32_t addinPos)
if (NULL == m_Highlight) {
return;
}
//EDN_DEBUG("area : ("<<pos<<","<<endPos<<") insert at : " << addinPos);
//APPL_DEBUG("area : ("<<pos<<","<<endPos<<") insert at : " << addinPos);
m_Highlight->Parse(pos, endPos, m_HLDataPass1, addinPos, m_data);
}
@@ -236,15 +261,15 @@ void EdnBuf::GenerateHighLightAt(int32_t pos, int32_t endPos, int32_t addinPos)
void EdnBuf::CleanHighLight(void)
{
// Remove all element in the list...
m_HLDataPass1.clear();
m_HLDataPass1.Clear();
}
colorInformation_ts *EdnBuf::GetElementColorAtPosition(int32_t pos, int32_t &starPos)
{
int32_t i;
int32_t start = edn_max(0, starPos-1);
for (i=start; i<(int32_t)m_HLDataPass1.size(); i++) {
int32_t start = etk_max(0, starPos-1);
for (i=start; i<(int32_t)m_HLDataPass1.Size(); i++) {
starPos = i;
if( m_HLDataPass1[i].beginStart <= pos
&& m_HLDataPass1[i].endStop > pos)
@@ -259,7 +284,6 @@ colorInformation_ts *EdnBuf::GetElementColorAtPosition(int32_t pos, int32_t &sta
}
void EdnBuf::HightlightGenerateLines(displayHLData_ts & MData, int32_t HLStart, int32_t nbLines)
{
MData.posHLPass1 = 0;
@@ -267,65 +291,62 @@ void EdnBuf::HightlightGenerateLines(displayHLData_ts & MData, int32_t HLStart,
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);
//GTimeVal timeStart;
//g_get_current_time(&timeStart);
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,
int32_t k;
//APPL_DEBUG("List of section between : "<< startId << " & " << stopId);
int32_t endSearch = stopId+1;
if (-1 == stopId) {
endSearch = m_HLDataPass1.Size();
}
for (k=etk_max(startId, 0); k<endSearch; k++) {
// empty section :
if (0==k) {
if (HLStart < m_HLDataPass1[k].beginStart) {
//APPL_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);
}
// under section :
//EDN_DEBUG(" ==> (under section ) k="<<k<<" start="<<m_HLDataPass1[k].beginStart<<" stop="<<m_HLDataPass1[k].endStop << " subSectionOfID=" << 99999999);
// TODO : ...
} // else : nothing to do ...
} else {
//APPL_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);
}
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 );
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);
}
}
GTimeVal timeStop;
g_get_current_time(&timeStop);
EDN_DEBUG("Display reAnnalyse = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s");
// under section :
//APPL_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) {
//APPL_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 {
//APPL_DEBUG(" ==> (empty section 4 ) k="<<k<<" start=0 stop="<<HLStop );
m_Highlight->Parse2(0,
HLStop,
MData.HLData,
m_data);
}
}
//GTimeVal timeStop;
//g_get_current_time(&timeStop);
//APPL_DEBUG("Display reAnnalyse = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s");
}
@@ -333,8 +354,8 @@ void EdnBuf::HightlightGenerateLines(displayHLData_ts & MData, int32_t HLStart,
colorInformation_ts * EdnBuf::GetElementColorAtPosition(displayHLData_ts & MData, int32_t pos)
{
int32_t i;
int32_t start = edn_max(0, MData.posHLPass2-1);
for (i=start; i<(int32_t)MData.HLData.size(); i++) {
int32_t start = etk_max(0, MData.posHLPass2-1);
for (i=start; i<(int32_t)MData.HLData.Size(); i++) {
MData.posHLPass2 = i;
if( MData.HLData[i].beginStart <= pos
&& MData.HLData[i].endStop > pos)
@@ -346,4 +367,4 @@ colorInformation_ts * EdnBuf::GetElementColorAtPosition(displayHLData_ts & MData
}
}
return GetElementColorAtPosition(pos, MData.posHLPass1);
}
}

View File

@@ -23,9 +23,9 @@
*******************************************************************************
*/
#include "tools_debug.h"
#include "tools_globals.h"
#include "EdnBuf.h"
#include <appl/Debug.h>
#include <appl/global.h>
#include <EdnBuf.h>
#undef __class__
@@ -37,29 +37,29 @@
int32_t EdnBuf::Undo(void)
{
int32_t nbElement = m_historyUndo.Size();
//EDN_DEBUG("EdnBuf::Undo Request id="<<nbElement);
//APPL_DEBUG("EdnBuf::Undo Request id="<<nbElement);
int32_t posDest = -1;
if (0 == nbElement) {
// nothing to do ...
EDN_ERROR("EdnBuf::Undo No more History");
APPL_ERROR("EdnBuf::Undo No more History");
return -1;
}
nbElement--;
if (m_historyUndo[nbElement] == NULL) {
EDN_ERROR("EdnBuf::Undo Find empty history ==> remove it");
APPL_ERROR("EdnBuf::Undo Find empty history ==> remove it");
m_historyUndo.PopBack();
return -1;
}
int32_t pos = m_historyUndo[nbElement]->getPos();
int32_t nbDeleted = m_historyUndo[nbElement]->getnbDeleted();
int32_t nbInserted = m_historyUndo[nbElement]->getnbInserted();
Edn::VectorType<int8_t> deletedText;
etk::Vector<int8_t> deletedText;
m_historyUndo[nbElement]->getData(deletedText);
m_isUndoProcessing = true;
if (0 == nbInserted) {
// just add data at position ...
if (0 == nbDeleted) {
EDN_ERROR("EdnBuf::Undo nothing to do in UNDO");
APPL_DEBUG("EdnBuf::Undo nothing to do in UNDO");
} else {
Insert(pos, deletedText);
posDest = pos + nbDeleted;
@@ -85,29 +85,29 @@ int32_t EdnBuf::Undo(void)
int32_t EdnBuf::Redo(void)
{
int32_t nbElement = m_historyRedo.Size();
//EDN_DEBUG("EdnBuf::Redo Request id="<<nbElement);
//APPL_DEBUG("EdnBuf::Redo Request id="<<nbElement);
int32_t posDest = -1;
if (0 == nbElement) {
// nothing to do ...
EDN_ERROR("EdnBuf::Redo No more History");
APPL_DEBUG("EdnBuf::Redo No more History");
return -1;
}
nbElement--;
if (m_historyRedo[nbElement] == NULL) {
EDN_ERROR("EdnBuf::Redo Find empty history ==> remove it");
APPL_ERROR("EdnBuf::Redo Find empty history ==> remove it");
m_historyRedo.PopBack();
return -1;
}
int32_t pos = m_historyRedo[nbElement]->getPos();
int32_t nbDeleted = m_historyRedo[nbElement]->getnbDeleted();
int32_t nbInserted = m_historyRedo[nbElement]->getnbInserted();
Edn::VectorType<int8_t> deletedText;
etk::Vector<int8_t> deletedText;
m_historyRedo[nbElement]->getData(deletedText);
m_isRedoProcessing = true;
if (0 == nbInserted) {
// just add data at position ...
if (0 == nbDeleted) {
EDN_ERROR("EdnBuf::Redo nothing to do in REDO");
APPL_ERROR("EdnBuf::Redo nothing to do in REDO");
} else {
Insert(pos, deletedText);
posDest = pos + nbDeleted;

View File

@@ -0,0 +1,310 @@
/**
*******************************************************************************
* @file EdnBuf_Selection.cpp
* @brief Editeur De N'ours : Buffer for internal Data - section selection (Sources)
* @author Edouard DUPIN
* @date 23/03/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 <appl/Debug.h>
#include <appl/global.h>
#include <EdnBuf.h>
#undef __class__
#define __class__ "EdnBuf{Selection}"
/**
* @brief
*
* @param[in,out] ---
* @param[in,out] ---
*
* @return ---
*
*/
bool EdnBuf::SelectHasSelection(void)
{
return m_selectionList.selected;
}
/**
* @brief
*
* @param[in,out] ---
* @param[in,out] ---
*
* @return ---
*
*/
void EdnBuf::Select(int32_t start, int32_t end)
{
//selection oldSelection = m_selectionList[select];
m_selectionList.selected = start != end;
m_selectionList.zeroWidth = (start == end) ? true : false;
m_selectionList.rectangular = false;
m_selectionList.start = etk_min(start, end);
m_selectionList.end = etk_max(start, end);
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void EdnBuf::Unselect(void)
{
//selection oldSelection = m_selectionList[select];
m_selectionList.selected = false;
m_selectionList.zeroWidth = false;
}
/**
* @brief
*
* @param[in,out] ---
* @param[in,out] ---
* @param[in,out] ---
* @param[in,out] ---
*
* @return ---
*
*/
void EdnBuf::RectSelect(int32_t start, int32_t end, int32_t rectStart, int32_t rectEnd)
{
m_selectionList.selected = rectStart < rectEnd;
m_selectionList.zeroWidth = (rectStart == rectEnd) ? false : true;
m_selectionList.rectangular = true;
m_selectionList.start = start;
m_selectionList.end = end;
m_selectionList.rectStart = rectStart;
m_selectionList.rectEnd = rectEnd;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
bool EdnBuf::GetSelectionPos(int32_t &start, int32_t &end, bool &isRect, int32_t &rectStart, int32_t &rectEnd)
{
/* Always fill in the parameters (zero-width can be requested too). */
isRect = m_selectionList.rectangular;
start = m_selectionList.start;
end = m_selectionList.end;
if (m_selectionList.rectangular) {
rectStart = m_selectionList.rectStart;
rectEnd = m_selectionList.rectEnd;
}
return m_selectionList.selected;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void EdnBuf::GetSelectionText(etk::Vector<int8_t> &text)
{
int32_t start, end, rectStart, rectEnd;
bool isRect;
// remove output data
text.Clear();
bool isSelected = GetSelectionPos(start, end, isRect, rectStart, rectEnd);
// No data selected ...
if (false == isSelected) {
return;
}
// Rectangular selection
if (true == isRect) {
//GetTextInRect(start, end, rectStart, rectEnd, text);
// TODO : ...
} else {
GetRange(start, end, text);
}
}
void EdnBuf::GetSelectionText(etk::UString &text)
{
int32_t start, end, rectStart, rectEnd;
bool isRect;
// remove output data
text = "";
bool isSelected = GetSelectionPos(start, end, isRect, rectStart, rectEnd);
// No data selected ...
if (false == isSelected) {
return;
}
// Rectangular selection
if (true == isRect) {
//GetTextInRect(start, end, rectStart, rectEnd, text);
// TODO : ...
} else {
GetRange(start, end, text);
}
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void EdnBuf::RemoveSelected(void)
{
int32_t start, end;
int32_t rectStart, rectEnd;
bool isRect;
bool isSelected = GetSelectionPos(start, end, isRect, rectStart, rectEnd);
// No data selected ...
if (false == isSelected) {
return;
}
// Rectangular selection
if (true == isRect) {
//RemoveRect(start, end, rectStart, rectEnd);
// TODO : ...
} else {
Remove(start, end);
}
Unselect();
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
int32_t EdnBuf::ReplaceSelected(etk::Vector<int8_t> &text)
{
int32_t start, end, rectStart, rectEnd;
bool isRect;
bool isSelected = GetSelectionPos(start, end, isRect, rectStart, rectEnd);
// No data selected ...
if (false == isSelected) {
return 0;
}
int32_t returnSize = 0;
// Rectangular selection
if (true == isRect) {
//ReplaceRect(start, end, rectStart, rectEnd, text);
// TODO : ...
} else {
returnSize = Replace(start, end, text);
}
// Clean selection
m_selectionList.selected = false;
return returnSize;
}
int32_t EdnBuf::ReplaceSelected(etk::UString &text)
{
int32_t start, end, rectStart, rectEnd;
bool isRect;
bool isSelected = GetSelectionPos(start, end, isRect, rectStart, rectEnd);
// No data selected ...
if (false == isSelected) {
return 0;
}
int32_t returnSize = 0;
// Rectangular selection
if (true == isRect) {
//ReplaceRect(start, end, rectStart, rectEnd, text);
// TODO : ...
} else {
returnSize = Replace(start, end, text);
}
// Clean selection
m_selectionList.selected = false;
return returnSize;
}
/*
** Update an individual selection for changes in the corresponding text
*/
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void EdnBuf::UpdateSelection(int32_t pos, int32_t nDeleted, int32_t nInserted)
{
if( ( false == m_selectionList.selected
&& false == m_selectionList.zeroWidth)
|| pos > m_selectionList.end )
{
return;
}
if (pos+nDeleted <= m_selectionList.start) {
m_selectionList.start += nInserted - nDeleted;
m_selectionList.end += nInserted - nDeleted;
} else if( pos <= m_selectionList.start
&& pos+nDeleted >= m_selectionList.end)
{
m_selectionList.start = pos;
m_selectionList.end = pos;
m_selectionList.selected = false;
m_selectionList.zeroWidth = false;
} else if( pos <= m_selectionList.start
&& pos+nDeleted < m_selectionList.end)
{
m_selectionList.start = pos;
m_selectionList.end = nInserted + m_selectionList.end - nDeleted;
} else if(pos < m_selectionList.end) {
m_selectionList.end += nInserted - nDeleted;
if (m_selectionList.end <= m_selectionList.start) {
m_selectionList.selected = false;
}
}
}

View File

@@ -23,11 +23,9 @@
*******************************************************************************
*/
#include "tools_debug.h"
#include "tools_globals.h"
#include "toolsMemory.h"
#include "EdnVectorBuf.h"
#include <appl/Debug.h>
#include <appl/global.h>
#include <EdnVectorBuf.h>
#undef __class__
#define __class__ "EdnEdnVectorBuf"
@@ -67,8 +65,8 @@ EdnVectorBuf::EdnVectorBuf(const EdnVectorBuf & Evb)
m_gapEnd = Evb.m_gapEnd;
// allocate all same data
EDN_MALLOC(m_data, m_allocated, int8_t);
EDN_ASSERT(NULL!=m_data, "Error in data allocation");
m_data = (int8_t *)malloc( m_allocated * sizeof(int8_t) );
APPL_ASSERT(NULL!=m_data, "Error in data allocation");
// Copy all data ...
memcpy(m_data, Evb.m_data, m_allocated * sizeof(int8_t) );
}
@@ -85,7 +83,7 @@ EdnVectorBuf::EdnVectorBuf(const EdnVectorBuf & Evb)
EdnVectorBuf::~EdnVectorBuf()
{
if (NULL!=m_data) {
EDN_FREE(m_data);
free(m_data);
m_data = NULL;
m_allocated = 0;
m_gapStart = 0;
@@ -116,12 +114,12 @@ static int32_t getFileSize(FILE *myFile)
* @return true if OK / false if an error occured
*
*/
bool EdnVectorBuf::DumpIn(FILE *myFile)
bool EdnVectorBuf::DumpIn(etk::FSNode &file)
{
bool ret = true;
// write Data
(void)fwrite(m_data, sizeof(int8_t), m_gapStart, myFile);
(void)fwrite(&m_data[m_gapEnd], sizeof(int8_t), m_allocated - m_gapEnd, myFile);
(void)file.FileWrite(m_data, sizeof(int8_t), m_gapStart);
(void)file.FileWrite(&m_data[m_gapEnd], sizeof(int8_t), m_allocated - m_gapEnd);
return ret;
}
@@ -134,23 +132,23 @@ bool EdnVectorBuf::DumpIn(FILE *myFile)
* @return true if OK / false if an error occured
*
*/
bool EdnVectorBuf::DumpFrom(FILE *myFile)
bool EdnVectorBuf::DumpFrom(etk::FSNode &file)
{
bool ret = true;
int32_t length = getFileSize(myFile);
uint32_t length = file.FileSize();
// error case ...
if (length < 0) {
length = 0;
if (length > 2000000000) {
return false;
}
// allocate the current buffer :
ChangeAllocation(length + GAP_SIZE_MIN);
// insert Data
int32_t nbReadData = fread(&m_data[GAP_SIZE_MIN], sizeof(int8_t), length, myFile);
EDN_INFO("load data : filesize=" << length << ", readData=" << nbReadData);
int32_t nbReadData = file.FileRead(&m_data[GAP_SIZE_MIN], sizeof(int8_t), length);
APPL_INFO("load data : filesize=" << length << ", readData=" << nbReadData);
// check ERROR
if (nbReadData != length) {
EDN_ERROR("load data pb : filesize=" << length << ", readData=" << nbReadData);
APPL_ERROR("load data pb : filesize=" << length << ", readData=" << nbReadData);
ret = false;
}
// set the gapsize at the end ...
@@ -174,7 +172,7 @@ EdnVectorBuf& EdnVectorBuf::operator=(const EdnVectorBuf & Evb)
if( this != &Evb ) // avoid copy to itself
{
if (NULL!=m_data) {
EDN_FREE(m_data);
free(m_data);
m_data = NULL;
}
// Set the new value
@@ -182,8 +180,8 @@ EdnVectorBuf& EdnVectorBuf::operator=(const EdnVectorBuf & Evb)
m_gapStart = Evb.m_gapStart;
m_gapEnd = Evb.m_gapEnd;
// allocate all same data
EDN_MALLOC(m_data, m_allocated, int8_t);
EDN_ASSERT(NULL!=m_data, "Error in data allocation");
m_data = (int8_t *)malloc( m_allocated * sizeof(int8_t) );
APPL_ASSERT(NULL!=m_data, "Error in data allocation");
// Copy all data ...
memcpy(m_data, Evb.m_data, m_allocated * sizeof(int8_t) );
}
@@ -193,7 +191,7 @@ EdnVectorBuf& EdnVectorBuf::operator=(const EdnVectorBuf & Evb)
int8_t EdnVectorBuf::operator[] (int32_t pos)
{
EDN_ASSERT(0 <= pos || pos < Size(), "try to read an element non existing");
APPL_ASSERT(0 <= pos || pos < Size(), "try to read an element non existing");
if (pos < m_gapStart) {
return m_data[pos];
}
@@ -211,7 +209,7 @@ int8_t EdnVectorBuf::operator[] (int32_t pos)
*/
int8_t& EdnVectorBuf::Get(int32_t pos)
{
EDN_ASSERT(0 <= pos || pos < Size(), "try to read an element non existing");
APPL_ASSERT(0 <= pos || pos < Size(), "try to read an element non existing");
if (pos < m_gapStart) {
return m_data[pos];
}
@@ -227,7 +225,7 @@ int8_t& EdnVectorBuf::Get(int32_t pos)
* @return ---
*
*/
void EdnVectorBuf::Get(int32_t pos, int32_t nbElement, Edn::VectorType<int8_t> &tmpBuffer)
void EdnVectorBuf::Get(int32_t pos, int32_t nbElement, etk::Vector<int8_t> &tmpBuffer)
{
tmpBuffer.Clear();
if (pos < m_gapStart) {
@@ -284,11 +282,11 @@ void EdnVectorBuf::Remove(int32_t pos, int32_t nbRemoveElement)
{
if( pos > Size()
|| pos < 0 ) {
EDN_ERROR("Request higher than buffer size : pos="<<pos<< " bufferSize="<<Size());
APPL_ERROR("Request higher than buffer size : pos="<<pos<< " bufferSize="<<Size());
return;
}
if( pos+nbRemoveElement > Size() ) {
EDN_ERROR("Request remove more element than expected in the buffer pos+nbRemoveElement="<<pos+nbRemoveElement<< " bufferSize="<<Size());
APPL_ERROR("Request remove more element than expected in the buffer pos+nbRemoveElement="<<pos+nbRemoveElement<< " bufferSize="<<Size());
return;
}
if (false == GapMove(pos) ) {
@@ -337,17 +335,17 @@ void EdnVectorBuf::ChangeAllocation(int32_t newSize)
if (newSize == m_allocated) {
return;
}
EDN_DEBUG("Change Allocation : " << m_allocated << " ==> " << newSize);
APPL_DEBUG("Change Allocation : " << m_allocated << " ==> " << newSize);
// check if something is allocated :
if (NULL == m_data) {
// no data allocated ==> request an allocation (might be the first)
EDN_MALLOC(m_data, newSize, int8_t);
m_data = (int8_t *)malloc( newSize * sizeof(int8_t) );
} else {
// move datas
EDN_REALLOC(m_data, newSize, int8_t);
m_data = (int8_t *)realloc( m_data, newSize* sizeof(int8_t) );
}
// Check result with assert :
EDN_ASSERT(NULL!=m_data, "Error in data allocation");
APPL_ASSERT(NULL!=m_data, "Error in data allocation");
// set the new allocation size
m_allocated = newSize;
}
@@ -365,7 +363,7 @@ void EdnVectorBuf::Insert(int32_t pos, const int8_t& item)
{
if( pos > Size()
|| pos < 0 ) {
EDN_ERROR("Request higher than buffer size : pos="<<pos<< " bufferSize="<<Size());
APPL_ERROR("Request higher than buffer size : pos="<<pos<< " bufferSize="<<Size());
return;
}
if( 0 == GapSize() ) {
@@ -399,11 +397,11 @@ void EdnVectorBuf::Insert(int32_t pos, const int8_t& item)
* @return ---
*
*/
void EdnVectorBuf::Insert(int32_t pos, Edn::VectorType<int8_t>& items)
void EdnVectorBuf::Insert(int32_t pos, etk::Vector<int8_t>& items)
{
if( pos > Size()
|| pos < 0 ) {
EDN_ERROR("Request higher than buffer size : pos="<<pos<< " bufferSize="<<Size());
APPL_ERROR("Request higher than buffer size : pos="<<pos<< " bufferSize="<<Size());
return;
}
if( items.Size() > GapSize() ) {
@@ -435,7 +433,7 @@ void EdnVectorBuf::Replace(int32_t pos, const int8_t& item)
{
if( pos > Size()
|| pos < 0 ) {
EDN_ERROR("Request higher than buffer size : pos="<<pos<< " bufferSize="<<Size());
APPL_ERROR("Request higher than buffer size : pos="<<pos<< " bufferSize="<<Size());
return;
}
// just replace the element, not update Gap position
@@ -455,15 +453,15 @@ void EdnVectorBuf::Replace(int32_t pos, const int8_t& item)
* @return ---
*
*/
void EdnVectorBuf::Replace(int32_t pos, int32_t nbRemoveElement, Edn::VectorType<int8_t>& items)
void EdnVectorBuf::Replace(int32_t pos, int32_t nbRemoveElement, etk::Vector<int8_t>& items)
{
if( pos > Size()
|| pos < 0 ) {
EDN_ERROR("Request higher than buffer size : pos="<<pos<< " bufferSize="<<Size());
APPL_ERROR("Request higher than buffer size : pos="<<pos<< " bufferSize="<<Size());
return;
}
if( pos+nbRemoveElement > Size() ) {
EDN_ERROR("Request remove more element than expected in the buffer pos+nbRemoveElement="<<pos+nbRemoveElement<< " bufferSize="<<Size());
APPL_ERROR("Request remove more element than expected in the buffer pos+nbRemoveElement="<<pos+nbRemoveElement<< " bufferSize="<<Size());
return;
}
if (false == GapMove(pos)) {
@@ -491,7 +489,7 @@ bool EdnVectorBuf::GapMove(int32_t pos)
{
if( pos > Size()
|| pos < 0 ) {
EDN_ERROR("Request higher than buffer size : pos="<<pos<< " bufferSize="<<Size());
APPL_ERROR("Request higher than buffer size : pos="<<pos<< " bufferSize="<<Size());
return false;
}
int32_t gapLen = m_gapEnd - m_gapStart;
@@ -518,7 +516,7 @@ bool EdnVectorBuf::GapResize(int32_t pos, int32_t newGapLen)
{
if( pos > Size()
|| pos < 0 ) {
EDN_ERROR("Request higher than buffer size : pos="<<pos<< " bufferSize="<<Size());
APPL_ERROR("Request higher than buffer size : pos="<<pos<< " bufferSize="<<Size());
return false;
}
int32_t previousSize = Size();
@@ -591,12 +589,12 @@ void EdnVectorBuf::GapCheckMaxSize(void)
*/
void EdnVectorBuf::Display(void)
{
EDN_INFO(" Display Buffer : Size="<<Size()<<" m_allocated="<<m_allocated<<" m_gapStart="<<m_gapStart<<" m_gapEnd="<<m_gapEnd);
APPL_INFO(" Display Buffer : Size="<<Size()<<" m_allocated="<<m_allocated<<" m_gapStart="<<m_gapStart<<" m_gapEnd="<<m_gapEnd);
for(int32_t i=0; i<m_allocated; i++) {
if (i>= m_gapStart && i< m_gapEnd) {
EDN_INFO( "Element " << i << " : GAP");
APPL_INFO( "Element " << i << " : GAP");
} else {
EDN_INFO( "Element " << i << " : " << m_data[i]);
APPL_INFO( "Element " << i << " : " << m_data[i]);
}
}
}
@@ -652,7 +650,7 @@ void TestEdnVectorBuf(void)
myBufferTmp.Display();
plop='m';
Edn::VectorType<int8_t> items;
etk::Vector<int8_t> items;
items.PushBack('i');
items.PushBack('j');
items.PushBack('k');

View File

@@ -26,8 +26,8 @@
#ifndef __EDN_VECTOR_BUF_H__
#define __EDN_VECTOR_BUF_H__
#include "toolsMemory.h"
#include "VectorType.h"
#include <etk/Vector.h>
#include <etk/os/FSNode.h>
#undef __class__
#define __class__ "EdnVectorBuf"
@@ -226,7 +226,7 @@ class EdnVectorBuf
*/
int8_t & operator-> () const
{
EDN_CHECK_INOUT(m_current >= 0 && m_current < m_EdnVectorBuf->Size());
APPL_CHECK_INOUT(m_current >= 0 && m_current < m_EdnVectorBuf->Size());
return m_EdnVectorBuf->Get(m_current);
}
/**
@@ -235,7 +235,7 @@ class EdnVectorBuf
*/
int8_t & operator* () const
{
EDN_CHECK_INOUT(m_current >= 0 && m_current < m_EdnVectorBuf->Size());
APPL_CHECK_INOUT(m_current >= 0 && m_current < m_EdnVectorBuf->Size());
return m_EdnVectorBuf->Get(m_current);
}
private:
@@ -266,20 +266,20 @@ class EdnVectorBuf
EdnVectorBuf(const EdnVectorBuf & Evb);
~EdnVectorBuf();
bool DumpIn( FILE *myFile);
bool DumpFrom( FILE *myFile);
bool DumpIn( etk::FSNode &file);
bool DumpFrom( etk::FSNode &file);
EdnVectorBuf & operator=( const EdnVectorBuf & Evb);
int8_t operator[] (int32_t pos);
int8_t & Get( int32_t pos);
void Get( int32_t pos, int32_t nbElement, Edn::VectorType<int8_t> &tmpBuffer);
void Get( int32_t pos, int32_t nbElement, etk::Vector<int8_t> &tmpBuffer);
// insert functions
void PushBack( const int8_t& item);
void Insert( int32_t pos, const int8_t& item);
void Insert( int32_t pos, Edn::VectorType<int8_t>& items);
void Insert( int32_t pos, etk::Vector<int8_t>& items);
// Remove and insert functions
void Replace( int32_t pos, const int8_t& item);
void Replace( int32_t pos, int32_t nbRemoveElement, Edn::VectorType<int8_t>& items);
void Replace( int32_t pos, int32_t nbRemoveElement, etk::Vector<int8_t>& items);
// Revove fonctions
void Remove( int32_t pos, int32_t nbRemoveElement = 1);
void PopBack( void);

View File

@@ -23,51 +23,42 @@
*******************************************************************************
*/
#include "tools_debug.h"
#include "tools_globals.h"
#include "Colorize.h"
#include "Edn.h"
#include <appl/Debug.h>
#include <appl/global.h>
#include <Colorize.h>
#undef __class__
#define __class__ "Colorize"
Colorize::Colorize( Edn::String &newColorName)
Colorize::Colorize( etk::UString &newColorName)
{
m_colorFG.red=0;
m_colorFG.green=0;
m_colorFG.blue=0;
m_colorBG.red=0;
m_colorBG.green=0;
m_colorBG.blue=0;
m_colorFG = draw::color::black;
m_colorBG = draw::color::black;
italic = false;
bold = false;
haveFG = false;
haveBG = false;
SetName(newColorName);
//EDN_INFO("New(Colorise)");
APPL_VERBOSE("New(Colorise)");
}
Colorize::Colorize(void)
{
ColorName = "no_name";
m_colorFG.red=0;
m_colorFG.green=0;
m_colorFG.blue=0;
m_colorBG.red=0;
m_colorBG.green=0;
m_colorBG.blue=0;
m_colorFG = draw::color::black;
m_colorBG = draw::color::black;
italic = false;
bold = false;
haveFG = false;
haveBG = false;
//EDN_INFO("New(Colorise)");
APPL_VERBOSE("New(Colorise)");
}
Colorize::~Colorize(void)
@@ -78,18 +69,18 @@ Colorize::~Colorize(void)
void Colorize::SetName(const char *newColorName)
{
//EDN_INFO("color change name : \"%s\" ==> \"%s\"",ColorName.c_str(), newColorName);
APPL_VERBOSE("color change name : \"" << ColorName << "\" ==> \"" << newColorName << "\"");
ColorName = newColorName;
}
void Colorize::SetName(Edn::String &newColorName)
void Colorize::SetName(etk::UString &newColorName)
{
//EDN_INFO("color change name : \"%s\" ==> \"%s\"",ColorName.c_str(), newColorName.c_str());
APPL_VERBOSE("color change name : \"" << ColorName << "\" ==> \"" << newColorName << "\"");
ColorName = newColorName;
}
Edn::String Colorize::GetName(void)
etk::UString Colorize::GetName(void)
{
return ColorName;
}
@@ -98,24 +89,15 @@ Edn::String Colorize::GetName(void)
void Colorize::SetFgColor(const char *myColor)
{
haveFG = true;
unsigned int r=0;
unsigned int v=0;
unsigned int b=0;
sscanf(myColor, "#%02x%02x%02x", &r,&v,&b);
m_colorFG.red = (float)r/255.0;
m_colorFG.green = (float)v/255.0;
m_colorFG.blue = (float)b/255.0;
//EDN_INFO(myColor << " ==> r="<< r <<" v="<< v <<" b="<< b );
m_colorFG = myColor;
APPL_VERBOSE(myColor << " ==> "<< m_colorFG );
}
void Colorize::SetBgColor(const char *myColor)
{
haveBG = true;
unsigned int r,v,b;
sscanf(myColor, "#%02x%02x%02x", &r,&v,&b);
m_colorBG.red = (float)r/255.0;
m_colorBG.green = (float)v/255.0;
m_colorBG.blue = (float)b/255.0;
m_colorBG = myColor;
APPL_VERBOSE(myColor << " ==> "<< m_colorBG );
}
bool Colorize::HaveBg(void)
@@ -127,13 +109,11 @@ bool Colorize::HaveBg(void)
void Colorize::SetItalic(bool enable)
{
italic = enable;
/*
if (true == enable) {
EDN_INFO("color : \"%s\" enable italic", ColorName.c_str());
APPL_VERBOSE("color : \"" << ColorName << "\" enable italic");
} else {
EDN_INFO("color : \"%s\" disable italic", ColorName.c_str());
APPL_VERBOSE("color : \"" << ColorName << "\" disable italic");
}
*/
}
bool Colorize::GetItalic(void)
@@ -145,13 +125,11 @@ bool Colorize::GetItalic(void)
void Colorize::SetBold(bool enable)
{
bold = enable;
/*
if (true == enable) {
EDN_INFO("color : \"%s\" enable bold", ColorName.c_str());
APPL_VERBOSE("color : \"" << ColorName << "\" enable bold");
} else {
EDN_INFO("color : \"%s\" disable bold", ColorName.c_str());
APPL_VERBOSE("color : \"" << ColorName << "\" disable bold");
}
*/
}
bool Colorize::GetBold(void)

View File

@@ -25,35 +25,23 @@
#ifndef __COLORIZE_H__
#define __COLORIZE_H__
#include "Edn.h"
extern "C" {
typedef struct {
float red;
float green;
float blue;
} color_ts;
}
#include <etk/UString.h>
class Colorize {
public:
// Constructeur
Colorize(void);
Colorize(Edn::String &newColorName);
Colorize(etk::UString &newColorName);
~Colorize(void);
void SetName(Edn::String &newColorName);
void SetName(etk::UString &newColorName);
void SetName(const char *newColorName);
Edn::String GetName(void);
etk::UString GetName(void);
void SetFgColor(const char *myColor);
void SetBgColor(const char *myColor);
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_rgba(cr, m_colorBG.red, m_colorBG.green, m_colorBG.blue, 1); };
color_ts & GetFG(void) { return m_colorFG; };
color_ts & GetBG(void) { return m_colorBG; };
draw::Color & GetFG(void) { return m_colorFG; };
draw::Color & GetBG(void) { return m_colorBG; };
bool HaveBg(void);
@@ -62,12 +50,12 @@ class Colorize {
bool GetItalic(void);
bool GetBold(void);
void Display(int32_t i) { EDN_INFO(" " << i << " : \"" << ColorName.c_str() << "\"" /*<< " fg="<< m_colorFG.red <<","<< m_colorFG.green <<","<< m_colorFG.blue <<" bg="<< m_colorBG.red <<","<< m_colorBG.green <<","<< m_colorBG.blue*/ ); };
void Display(int32_t i) { APPL_INFO(" " << i << " : \"" << ColorName << "\"" << " fg="<< m_colorFG); };
private:
Edn::String ColorName; //!< curent color Name
color_ts m_colorFG;
color_ts m_colorBG;
etk::UString ColorName; //!< curent color Name
draw::Color m_colorFG;
draw::Color m_colorBG;
bool italic;
bool bold;

View File

@@ -0,0 +1,455 @@
/**
*******************************************************************************
* @file ColorizeManager.cpp
* @brief Editeur De N'ours : Colorising Manager
* @author Edouard DUPIN
* @date 14/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 <appl/Debug.h>
#include <appl/global.h>
#include <ColorizeManager.h>
#include <tinyXML/tinyxml.h>
#include <ewol/eObject/EObject.h>
#include <ewol/eObject/EObjectManager.h>
#include <etk/os/FSNode.h>
#define PFX "ColorizeManager "
class classColorManager: public ewol::EObject
{
public:
// Constructeur
classColorManager(void);
~classColorManager(void);
/**
* @brief Get the current Object type of the EObject
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
* @param[in] objectType type description
* @return true if the object is compatible, otherwise false
*/
const char * const GetObjectType(void)
{
return "ApplColorManager";
}
/**
* @brief Receive a message from an other EObject with a specific eventId and data
* @param[in] CallerObject Pointer on the EObject that information came from
* @param[in] eventId Message registered by this class
* @param[in] data Data registered by this class
* @return ---
*/
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
public:
void LoadFile(etk::UString &xmlFilename);
void LoadFile(const char * xmlFilename);
Colorize * Get(const char *colorName);
Colorize * Get(etk::UString &colorName);
draw::Color& Get(basicColor_te myColor);
bool Exist(etk::UString &colorName);
bool Exist(const char *colorName);
void DisplayListOfColor(void);
private:
etk::UString m_fileColor;
etk::Vector<Colorize*> listMyColor; //!< List of ALL Color
Colorize * errorColor;
draw::Color basicColors[COLOR_NUMBER_MAX];
};
classColorManager::classColorManager(void)
{
//ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgGuiChangeColor);
}
classColorManager::~classColorManager(void)
{
delete(errorColor);
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 classColorManager::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
{
/*
switch (id)
{
case APPL_MSG__RELOAD_COLOR_FILE:
{
// Reaload File
// TODO : Check this : Pb in the recopy etk::UString element
etk::UString plop = m_fileColor;
LoadFile(plop);
}
break;
}
*/
}
void classColorManager::LoadFile(etk::UString &xmlFilename)
{
// TODO : Remove this
LoadFile(xmlFilename.c_str());
}
// TODO : Remove this ...
void classColorManager::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;
APPL_DEBUG("open file (COLOR) \"" << xmlFilename << "\" ? = \"" << m_fileColor << "\"");
errorColor = new Colorize();
errorColor->SetBgColor("#00FF00FF");
errorColor->SetFgColor("#FF00FFFF");
// allocate the document in the stack
TiXmlDocument XmlDocument;
// open the curent File
etk::FSNode fileName(etk::UString("DATA:") + xmlFilename);
if (false == fileName.Exist()) {
APPL_ERROR("File Does not exist : " << fileName);
return;
}
int32_t fileSize = fileName.FileSize();
if (0==fileSize) {
APPL_ERROR("This file is empty : " << fileName);
return;
}
if (false == fileName.FileOpenRead()) {
APPL_ERROR("Can not open the file : " << fileName);
return;
}
// allocate data
char * fileBuffer = new char[fileSize+5];
if (NULL == fileBuffer) {
APPL_ERROR("Error Memory allocation size=" << fileSize);
return;
}
memset(fileBuffer, 0, (fileSize+5)*sizeof(char));
// load data from the file :
fileName.FileRead(fileBuffer, 1, fileSize);
// close the file:
fileName.FileClose();
// load the XML from the memory
XmlDocument.Parse((const char*)fileBuffer, 0, TIXML_ENCODING_UTF8);
TiXmlElement* root = XmlDocument.FirstChildElement( "EdnColor" );
if (NULL == root ) {
APPL_ERROR(PFX"(l ?) main node not find: \"EdnColor\" in \"" << xmlFilename << "\"");
return;
} else {
TiXmlNode * pNode = root->FirstChild();
while(NULL != pNode) {
if (pNode->Type()==TiXmlNode::TINYXML_COMMENT) {
// nothing to do, just proceed to next step
} else if (!strcmp(pNode->Value(), "gui")) {
TiXmlNode * pGuiNode = pNode->FirstChild();
while(NULL != pGuiNode) {
if (pGuiNode->Type()==TiXmlNode::TINYXML_COMMENT) {
// nothing to do, just proceed to next step
} else if (!strcmp(pGuiNode->Value(), "color")) {
//--------------------------------------------------------------------------------------------
//<color name="basicBackground" val="#000000"/>
//--------------------------------------------------------------------------------------------
const char *colorName = pGuiNode->ToElement()->Attribute("name");
int32_t id = 0;
if (NULL == colorName) {
APPL_ERROR("(l "<< pGuiNode->Row() <<") node with no name");
// get next node element
pGuiNode = pGuiNode->NextSibling();
continue;
}
if (!strcmp(colorName, "CODE_space")) {
id = COLOR_CODE_SPACE;
} else if (!strcmp(colorName, "CODE_tabulation")) {
id = COLOR_CODE_TAB;
} else if (!strcmp(colorName, "CODE_basicBackgroung")) {
id = COLOR_CODE_BASIC_BG;
} else if (!strcmp(colorName, "CODE_cursor")) {
id = COLOR_CODE_CURSOR;
} else if (!strcmp(colorName, "CODE_lineNumber")) {
id = COLOR_CODE_LINE_NUMBER;
} else if (!strcmp(colorName, "LIST_backgroung1")) {
id = COLOR_LIST_BG_1;
} else if (!strcmp(colorName, "LIST_backgroung2")) {
id = COLOR_LIST_BG_2;
} else if (!strcmp(colorName, "LIST_backgroungSelected")) {
id = COLOR_LIST_BG_SELECTED;
} else if (!strcmp(colorName, "LIST_textNormal")) {
id = COLOR_LIST_TEXT_NORMAL;
} else if (!strcmp(colorName, "LIST_textModify")) {
id = COLOR_LIST_TEXT_MODIFY;
} else {
APPL_ERROR("(l "<<pGuiNode->Row()<<") Unknown basic gui color : \"" << colorName << "\"" );
// get next node element
pGuiNode = pGuiNode->NextSibling();
continue;
}
const char *color = pGuiNode->ToElement()->Attribute("val");
if (NULL != color) {
basicColors[id] = color;
}
} else {
APPL_ERROR("(l "<<pGuiNode->Row()<<") node not suported : \""<<pGuiNode->Value()<<"\" must be [color]");
}
// get next node element
pGuiNode = pGuiNode->NextSibling();
}
} else if (!strcmp(pNode->Value(), "syntax")) {
TiXmlNode * pGuiNode = pNode->FirstChild();
while(NULL != pGuiNode)
{
if (pGuiNode->Type()==TiXmlNode::TINYXML_COMMENT) {
// nothing to do, just proceed to next step
} else if (!strcmp(pGuiNode->Value(), "color")) {
Colorize *myNewColor = new Colorize();
//--------------------------------------------------------------------------------------------
//<color name="basicBackground" FG="#000000" BG="#000000" bold="no" italic="no"/>
//--------------------------------------------------------------------------------------------
// get the name of the Chaine
const char *colorName = pGuiNode->ToElement()->Attribute("name");
if (NULL == colorName) {
APPL_ERROR(PFX"(l "<< pGuiNode->Row() <<") node with no name");
// get next node element
pGuiNode = pGuiNode->NextSibling();
continue;
} else {
myNewColor->SetName(colorName);
//APPL_INFO(PFX"Add a new color in the panel : \"%s\"", colorName);
}
const char *colorBG = pGuiNode->ToElement()->Attribute("BG");
if (NULL != colorBG) {
myNewColor->SetBgColor(colorBG);
}
const char *colorFG = pGuiNode->ToElement()->Attribute("FG");
if (NULL != colorFG) {
myNewColor->SetFgColor(colorFG);
}
const char *bold = pGuiNode->ToElement()->Attribute("bold");
if (NULL != bold) {
if(0 == strcmp(bold, "yes") ) {
myNewColor->SetBold(true);
}
}
const char *italic = pGuiNode->ToElement()->Attribute("italic");
if (NULL != italic) {
if(0 == strcmp(italic, "yes") ) {
myNewColor->SetItalic(true);
}
}
listMyColor.PushBack(myNewColor);
} else {
APPL_ERROR(PFX"(l "<<pNode->Row()<<") node not suported : \""<<pNode->Value()<<"\" must be [color]");
}
pGuiNode = pGuiNode->NextSibling();
}
} else {
APPL_ERROR(PFX"(l "<<pNode->Row()<<") node not suported : \""<<pNode->Value()<<"\" must be [gui,syntax]");
}
// get next node element
pNode = pNode->NextSibling();
}
}
if (NULL != fileBuffer) {
delete[] fileBuffer;
}
//SendMessage(APPL_MSG__COLOR_HAS_CHANGE);
//SendMessage(APPL_MSG__USER_DISPLAY_CHANGE);
}
// TODO : Remove this ...
Colorize *classColorManager::Get(const char *colorName)
{
int32_t i;
for (i=0; i<listMyColor.Size(); i++) {
etk::UString elementName = listMyColor[i]->GetName();
if (elementName == colorName) {
return listMyColor[i];
}
}
APPL_ERROR(PFX"Color does not Existed ["<< colorName<<"]" );
// an error
return errorColor;
}
Colorize *classColorManager::Get(etk::UString &colorName)
{
// TODO : Remove this
return Get(colorName.c_str());
}
draw::Color & classColorManager::Get(basicColor_te myColor)
{
if (myColor < COLOR_NUMBER_MAX) {
return basicColors[myColor];
} else {
return basicColors[0];
}
}
// TODO : Remove this ...
bool classColorManager::Exist(const char *colorName)
{
int32_t i;
for (i=0; i<listMyColor.Size(); i++) {
etk::UString elementName = listMyColor[i]->GetName();
if (elementName == colorName) {
return true;
}
}
return false;
}
bool classColorManager::Exist(etk::UString &colorName)
{
// TODO : Remove this
return Exist(colorName.c_str());
}
void classColorManager::DisplayListOfColor(void)
{
int32_t i;
APPL_INFO(PFX"List of ALL COLOR : ");
for (i=0; i<listMyColor.Size(); i++) {
//etk::UString elementName = listMyColor[i]->GetName();
//APPL_INFO(i << " : \"" << elementName.c_str() << "\"" );
listMyColor[i]->Display(i);
}
}
static classColorManager * localManager = NULL;
void ColorizeManager::Init(void)
{
if (NULL != localManager) {
EWOL_ERROR("ColorizeManager ==> already exist, just unlink the previous ...");
localManager = NULL;
}
localManager = new classColorManager();
if (NULL == localManager) {
EWOL_CRITICAL("Allocation of HighlightManager not done ...");
}
}
void ColorizeManager::UnInit(void)
{
if (NULL == localManager) {
EWOL_ERROR("ColorizeManager ==> request UnInit, but does not exist ...");
return;
}
delete(localManager);
localManager = NULL;
}
void ColorizeManager::LoadFile(etk::UString &xmlFilename)
{
if (NULL == localManager) {
return;
}
localManager->LoadFile(xmlFilename);
}
void ColorizeManager::LoadFile(const char * xmlFilename)
{
if (NULL == localManager) {
return;
}
localManager->LoadFile(xmlFilename);
}
Colorize* ColorizeManager::Get(const char *colorName)
{
if (NULL == localManager) {
return NULL;
}
return localManager->Get(colorName);
}
Colorize* ColorizeManager::Get(etk::UString &colorName)
{
if (NULL == localManager) {
return NULL;
}
return localManager->Get(colorName);
}
draw::Color errorColor;
draw::Color& ColorizeManager::Get(basicColor_te myColor)
{
if (NULL == localManager) {
return errorColor;
}
return localManager->Get(myColor);
}
bool ColorizeManager::Exist(etk::UString &colorName)
{
if (NULL == localManager) {
return false;
}
return localManager->Exist(colorName);
}
bool ColorizeManager::Exist(const char *colorName)
{
if (NULL == localManager) {
return false;
}
return localManager->Exist(colorName);
}
void ColorizeManager::DisplayListOfColor(void)
{
if (NULL == localManager) {
return;
}
localManager->DisplayListOfColor();
}

View File

@@ -1,6 +1,6 @@
/**
*******************************************************************************
* @file ColoriseManager.h
* @file ColorizeManager.h
* @brief Editeur De N'ours : Colorising Manager (header)
* @author Edouard DUPIN
* @date 14/12/2010
@@ -26,10 +26,9 @@
#ifndef __COLORIZE_MANAGER_H__
#define __COLORIZE_MANAGER_H__
#include "Singleton.h"
#include <vector>
#include <string>
#include "Colorize.h"
#include <Colorize.h>
#include <appl/globalMsg.h>
#include <ewol/widget/Widget.h>
typedef enum {
// BASIC color for codeViewer
@@ -50,28 +49,18 @@ typedef enum {
class ColorizeManager: public Singleton<ColorizeManager>
namespace ColorizeManager
{
friend class Singleton<ColorizeManager>;
// specific for sigleton system...
private:
// Constructeur
ColorizeManager(void);
~ColorizeManager(void);
public:
void LoadFile(Edn::String &xmlFilename);
void LoadFile(const char * xmlFilename);
Colorize * Get(const char *colorName);
Colorize * Get(Edn::String &colorName);
color_ts & Get(basicColor_te myColor);
bool Exist(Edn::String &colorName);
bool Exist(const char *colorName);
void DisplayListOfColor(void);
private:
std::vector<Colorize*> listMyColor; //!< List of ALL Color
Colorize* errorColor;
color_ts basicColors[COLOR_NUMBER_MAX];
void Init(void);
void UnInit(void);
void LoadFile(etk::UString &xmlFilename);
void LoadFile(const char * xmlFilename);
Colorize * Get(const char *colorName);
Colorize * Get(etk::UString &colorName);
draw::Color& Get(basicColor_te myColor);
bool Exist(etk::UString &colorName);
bool Exist(const char *colorName);
void DisplayListOfColor(void);
};
#endif

View File

@@ -1,9 +1,9 @@
/**
*******************************************************************************
* @file Edn.h
* @brief Editeur De N'ours : Basic namespace for Edn (header)
* @file Debug.h
* @brief Editeur De N'ours : log implementation
* @author Edouard DUPIN
* @date 16/07/2011
* @date 08/06/2010
* @par Project
* Edn
*
@@ -24,13 +24,4 @@
*/
#include "tools_debug.h"
#include "toolsMemory.h"
//#include "Vector.h" // TODO : Set the vector of edn enable
#include "VectorType.h"
#include "String.h"
#include "File.h"
const char * applLog = "edn ";

View File

@@ -1,9 +1,9 @@
/**
*******************************************************************************
* @file WindowsManager.h
* @brief Editeur De N'ours : Windows creation, pop up, destruction ... (header)
* @file Debug.h
* @brief Application log implementation
* @author Edouard DUPIN
* @date 20/06/2011
* @date 10/04/2012
* @par Project
* Edn
*
@@ -23,28 +23,22 @@
*******************************************************************************
*/
#ifndef __WINDOWS_MANAGER_H__
#define __WINDOWS_MANAGER_H__
#ifndef __DEBUG_H__
#define __DEBUG_H__
#include "Singleton.h"
#include "MsgBroadcast.h"
#include "MainWindows.h"
#include <etk/Types.h>
#include <etk/Debug.h>
class WindowsManager: public Singleton<WindowsManager>, public MsgBroadcast
{
friend class Singleton<WindowsManager>;
// specific for sigleton system...
private:
// Constructeur
WindowsManager(void);
~WindowsManager(void);
extern const char * applLog;
public:
void OnMessage(int32_t id, int32_t dataID);
private:
MainWindows * m_mainWindow;
int32_t m_currentBufferID;
};
#define APPL_CRITICAL(data) ETK_CRITICAL(applLog, data)
#define APPL_WARNING(data) ETK_WARNING(applLog, data)
#define APPL_ERROR(data) ETK_ERROR(applLog, data)
#define APPL_INFO(data) ETK_INFO(applLog, data)
#define APPL_DEBUG(data) ETK_DEBUG(applLog, data)
#define APPL_VERBOSE(data) ETK_VERBOSE(applLog, data)
#define APPL_ASSERT(cond, data) ETK_ASSERT(applLog, cond, data)
#define APPL_CHECK_INOUT(cond) ETK_CHECK_INOUT(applLog, cond)
#define APPL_TODO(cond) ETK_TODO(applLog, cond)
#endif

View File

@@ -0,0 +1,211 @@
/**
*******************************************************************************
* @file BufferViewer.cpp
* @brief Editeur De N'ours : main textViewer diplayer
* @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 <appl/Debug.h>
#include <appl/global.h>
#include <BufferView.h>
#include <BufferManager.h>
#include <ColorizeManager.h>
#include <MainWindows.h>
#include <ewol/eObject/EObject.h>
#undef __class__
#define __class__ "BufferView"
static void SortElementList(etk::Vector<appl::dataBufferStruct *> &list)
{
etk::Vector<appl::dataBufferStruct *> tmpList = list;
list.Clear();
for(int32_t iii=0; iii<tmpList.Size(); iii++) {
if (NULL != tmpList[iii]) {
int32_t findPos = 0;
for(int32_t jjj=0; jjj<list.Size(); jjj++) {
//EWOL_DEBUG("compare : \""<<*tmpList[iii] << "\" and \"" << *m_listDirectory[jjj] << "\"");
if (list[jjj]!=NULL) {
if (tmpList[iii]->m_bufferName.GetNameFile() > list[jjj]->m_bufferName.GetNameFile()) {
findPos = jjj+1;
}
}
}
//EWOL_DEBUG("position="<<findPos);
list.Insert(findPos, tmpList[iii]);
}
}
}
BufferView::BufferView(void)
{
SetCanHaveFocus(true);
RegisterMultiCast(ednMsgBufferListChange);
RegisterMultiCast(ednMsgBufferState);
RegisterMultiCast(ednMsgBufferId);
m_selectedID = -1;
m_selectedIdRequested = -1;
}
BufferView::~BufferView(void)
{
RemoveAllElement();
}
void BufferView::RemoveAllElement(void)
{
for(int32_t iii=0; iii<m_list.Size(); iii++) {
if (NULL!=m_list[iii]) {
delete(m_list[iii]);
m_list[iii] = NULL;
}
}
m_list.Clear();
}
/**
* @brief Receive a message from an other EObject with a specific eventId and data
* @param[in] CallerObject Pointer on the EObject that information came from
* @param[in] eventId Message registered by this class
* @param[in] data Data registered by this class
* @return ---
*/
void BufferView::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
{
ewol::List::OnReceiveMessage(CallerObject, eventId, data);
if (eventId == ednMsgBufferListChange) {
// clean The list
RemoveAllElement();
// Get all the buffer name and properties:
int32_t nbBufferOpen = BufferManager::Size();
for (int32_t iii=0; iii<nbBufferOpen; iii++) {
if (BufferManager::Exist(iii)) {
bool isModify = BufferManager::Get(iii)->IsModify();
etk::FSNode name = BufferManager::Get(iii)->GetFileName();
appl::dataBufferStruct* tmpElement = new appl::dataBufferStruct(name, iii, isModify);
if (NULL != tmpElement) {
m_list.PushBack(tmpElement);
} else {
APPL_ERROR("Allocation error of the tmp buffer list element");
}
}
}
if (true == globals::OrderTheBufferList() ) {
SortElementList(m_list);
}
MarkToRedraw();
}else if (eventId == ednMsgBufferId) {
m_selectedIdRequested = BufferManager::GetSelected();
MarkToRedraw();
}else if (eventId == ednMsgBufferState) {
// Update list of modify section ...
for (int32_t iii=0; iii<m_list.Size(); iii++) {
if (NULL!=m_list[iii]) {
m_list[iii]->m_isModify = BufferManager::Get(m_list[iii]->m_bufferID)->IsModify();
}
}
MarkToRedraw();
}
}
draw::Color BufferView::GetBasicBG(void)
{
return ColorizeManager::Get(COLOR_LIST_BG_1);
}
uint32_t BufferView::GetNuberOfColomn(void)
{
return 1;
}
bool BufferView::GetTitle(int32_t colomn, etk::UString &myTitle, draw::Color &fg, draw::Color &bg)
{
myTitle = "Buffers : ";
return true;
}
uint32_t BufferView::GetNuberOfRaw(void)
{
return m_list.Size();
}
bool BufferView::GetElement(int32_t colomn, int32_t raw, etk::UString &myTextToWrite, draw::Color &fg, draw::Color &bg)
{
bool isModify;
basicColor_te selectFG = COLOR_LIST_TEXT_NORMAL;
basicColor_te selectBG = COLOR_LIST_BG_1;
// when requested a new display selection ==> reset the previous one ...
if (m_selectedIdRequested != -1) {
m_selectedID = -1;
}
if( raw>=0
&& raw<m_list.Size()
&& NULL != m_list[raw]) {
myTextToWrite = m_list[raw]->m_bufferName.GetNameFile();
if (true == m_list[raw]->m_isModify) {
selectFG = COLOR_LIST_TEXT_MODIFY;
} else {
selectFG = COLOR_LIST_TEXT_NORMAL;
}
if (raw%2==0) {
selectBG = COLOR_LIST_BG_1;
} else {
selectBG = COLOR_LIST_BG_2;
}
// the buffer change of selection ...
if (m_selectedIdRequested == m_list[raw]->m_bufferID) {
m_selectedID = raw;
// stop searching
m_selectedIdRequested = -1;
}
if (m_selectedID == raw) {
selectBG = COLOR_LIST_BG_SELECTED;
}
} else {
myTextToWrite = "ERROR";
}
fg = ColorizeManager::Get(selectFG);
bg = ColorizeManager::Get(selectBG);
return true;
}
bool BufferView::OnItemEvent(int32_t IdInput, ewol::eventInputType_te typeEvent, int32_t colomn, int32_t raw, float x, float y)
{
if (1 == IdInput && typeEvent == ewol::EVENT_INPUT_TYPE_SINGLE) {
APPL_INFO("Event on List : IdInput=" << IdInput << " colomn=" << colomn << " raw=" << raw );
if( raw>=0
&& raw<m_list.Size()
&& NULL != m_list[raw]) {
m_selectedID = raw;
SendMultiCast(ednMsgBufferId, m_list[raw]->m_bufferID);
}
}
MarkToRedraw();
return false;
}

View File

@@ -0,0 +1,92 @@
/**
*******************************************************************************
* @file BufferView.h
* @brief Editeur De N'ours : main List Buffer Viewer (header)
* @author Edouard DUPIN
* @date 09/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.
*
*******************************************************************************
*/
#ifndef __BUFFER_VIEW_H__
#define __BUFFER_VIEW_H__
#include <appl/Debug.h>
#include <CodeView.h>
#include <BufferManager.h>
#include <appl/globalMsg.h>
#include <ewol/widget/List.h>
namespace appl
{
class dataBufferStruct
{
public:
etk::FSNode m_bufferName;
uint32_t m_bufferID;
bool m_isModify;
dataBufferStruct(etk::FSNode& bufferName, int32_t bufferID, bool isModify) :
m_bufferName(bufferName),
m_bufferID(bufferID),
m_isModify(isModify)
{
};
~dataBufferStruct(void) { };
};
};
class BufferView : public ewol::List
{
private:
int32_t m_selectedIdRequested;
int32_t m_selectedID;
etk::Vector<appl::dataBufferStruct*> m_list;
public:
// Constructeur
BufferView(void);
~BufferView(void);
/**
* @brief Get the current Object type of the EObject
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
* @param[in] objectType type description
* @return true if the object is compatible, otherwise false
*/
const char * const GetObjectType(void) { return "ApplBufferView"; };
/**
* @brief Receive a message from an other EObject with a specific eventId and data
* @param[in] CallerObject Pointer on the EObject that information came from
* @param[in] eventId Message registered by this class
* @param[in] data Data registered by this class
* @return ---
*/
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
protected:
// function call to display the list :
virtual draw::Color GetBasicBG(void);
virtual uint32_t GetNuberOfColomn(void);
virtual bool GetTitle(int32_t colomn, etk::UString &myTitle, draw::Color &fg, draw::Color &bg);
virtual uint32_t GetNuberOfRaw(void);
virtual bool GetElement(int32_t colomn, int32_t raw, etk::UString &myTextToWrite, draw::Color &fg, draw::Color &bg);
virtual bool OnItemEvent(int32_t IdInput, ewol::eventInputType_te typeEvent, int32_t colomn, int32_t raw, float x, float y);
void RemoveAllElement(void);
};
#endif

View File

@@ -0,0 +1,475 @@
/**
*******************************************************************************
* @file CodeView.cpp
* @brief Editeur De N'ours : Code Viewer Widget
* This is an abstraction
* @author Edouard DUPIN
* @date 05/01/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 <CodeView.h>
#include <appl/Debug.h>
#include <appl/global.h>
#include <CodeView.h>
#include <BufferManager.h>
#include <ColorizeManager.h>
#include <ewol/ClipBoard.h>
#include <SearchData.h>
#include <ewol/widget/WidgetManager.h>
#include <ewol/eObject/EObject.h>
#undef __class__
#define __class__ "CodeView"
void CodeView::Init(void)
{
m_label = "CodeView is disable ...";
m_bufferID = -1;
m_buttunOneSelected = false;
m_lineNumberList.Clear();
m_textColorFg = draw::color::black;
m_textColorBg = draw::color::black;
m_textColorBg.a = 0x40;
SetCanHaveFocus(true);
RegisterMultiCast(ednMsgBufferId);
RegisterMultiCast(ednMsgGuiCopy);
RegisterMultiCast(ednMsgGuiPaste);
RegisterMultiCast(ednMsgGuiCut);
RegisterMultiCast(ednMsgGuiRedo);
RegisterMultiCast(ednMsgGuiUndo);
RegisterMultiCast(ednMsgGuiRm);
RegisterMultiCast(ednMsgGuiSelect);
RegisterMultiCast(ednMsgGuiChangeCharset);
RegisterMultiCast(ednMsgGuiFind);
RegisterMultiCast(ednMsgGuiReplace);
RegisterMultiCast(ednMsgGuiGotoLine);
SetLimitScrolling(0.2);
ShortCutAdd("ctrl+w", ednMsgGuiRm, "Line");
ShortCutAdd("ctrl+shift+w", ednMsgGuiRm, "Paragraph");
ShortCutAdd("ctrl+x", ednMsgGuiCut, "STD");
ShortCutAdd("ctrl+c", ednMsgGuiCopy, "STD");
ShortCutAdd("ctrl+v", ednMsgGuiPaste, "STD");
ShortCutAdd("ctrl+a", ednMsgGuiSelect, "ALL");
ShortCutAdd("ctrl+shift+a", ednMsgGuiSelect, "NONE");
}
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
CodeView::CodeView(etk::UString fontName, int32_t fontSize) :
m_OObjectText(fontName, fontSize)
{
Init();
}
#endif
CodeView::CodeView(void)
{
Init();
}
CodeView::~CodeView(void)
{
}
/**
* @brief Check if the number of reference buffer is good or not ...
* @param[in] bufferID id of the current Buffer that needed to have a reference
* @return ---
*/
void CodeView::UpdateNumberOfLineReference(int32_t bufferID)
{
etk::Vector2D<float> tmpCoord;
tmpCoord.x = 0;
tmpCoord.y = 0;
if (m_lineNumberList.Size()<=bufferID) {
// update the number of elements :
for (int32_t iii=m_lineNumberList.Size(); iii <= bufferID; iii++) {
// add start line at 0 :
m_lineNumberList.PushBack(tmpCoord);
}
}
}
bool CodeView::CalculateMinSize(void)
{
m_minSize.x = 50;
m_minSize.y = 50;
return true;
}
void CodeView::CalculateMaxSize(void)
{
m_maxSize.x = 2048;
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
int32_t letterHeight = m_OObjectText.GetHeight();
#else
int32_t letterHeight = m_OObjectTextNormal.GetHeight();
#endif
m_maxSize.y = BufferManager::Get(m_bufferID)->GetNumberOfLine() * letterHeight;
}
void CodeView::OnDraw(ewol::DrawProperty& displayProp)
{
m_OObjectsColored.Draw();
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
m_OObjectText.Draw();
#else
m_OObjectTextNormal.Draw();
m_OObjectTextBold.Draw();
m_OObjectTextItalic.Draw();
m_OObjectTextBoldItalic.Draw();
#endif
WidgetScrooled::OnDraw(displayProp);
}
void CodeView::OnRegenerateDisplay(void)
{
if (true == NeedRedraw()) {
int64_t startTime = ewol::GetTime();
// For the scrooling windows
CalculateMaxSize();
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
m_OObjectText.Clear();
#else
m_OObjectTextNormal.Clear();
m_OObjectTextBold.Clear();
m_OObjectTextItalic.Clear();
m_OObjectTextBoldItalic.Clear();
#endif
m_OObjectsColored.Clear();
if(true == BufferManager::Get(m_bufferID)->NeedToUpdateDisplayPosition() ) {
etk::Vector2D<float> borderWidth = BufferManager::Get(m_bufferID)->GetBorderSize();
bool centerRequested = false;
// TODO : set it back ...
etk::Vector2D<float> currentPosition = BufferManager::Get(m_bufferID)->GetPosition(999/*m_OObjectTextNormal.GetFontID()*/, centerRequested);
SetScrollingPositionDynamic(borderWidth, currentPosition, centerRequested);
} // else : nothing to do ...
// generate the objects :
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
BufferManager::Get(m_bufferID)->Display(m_OObjectText,
m_OObjectsColored,
m_originScrooled.x, m_originScrooled.y, m_size.x, m_size.y);
#else
BufferManager::Get(m_bufferID)->Display(m_OObjectTextNormal,
m_OObjectTextBold,
m_OObjectTextItalic,
m_OObjectTextBoldItalic,
m_OObjectsColored,
m_originScrooled.x, m_originScrooled.y, m_size.x, m_size.y);
#endif
// set the current size of the windows
SetMaxSize(BufferManager::Get(m_bufferID)->GetMaxSize());
int64_t stopTime = ewol::GetTime();
APPL_DEBUG("Display Code Generation = " << stopTime - startTime << " micro-s");
// call the herited class...
WidgetScrooled::OnRegenerateDisplay();
}
}
bool CodeView::OnEventKb(ewol::eventKbType_te typeEvent, uniChar_t unicodeData)
{
//APPL_DEBUG("KB EVENT : \"" << UTF8_data << "\" size=" << strlen(UTF8_data) << "type=" << (int32_t)typeEvent);
if (typeEvent == ewol::EVENT_KB_TYPE_DOWN) {
BufferManager::Get(m_bufferID)->AddChar(unicodeData);
MarkToRedraw();
}
return true;
}
bool CodeView::OnEventKbMove(ewol::eventKbType_te typeEvent, ewol::eventKbMoveType_te moveTypeEvent)
{
if (typeEvent == ewol::EVENT_KB_TYPE_DOWN) {
BufferManager::Get(m_bufferID)->cursorMove(moveTypeEvent);
MarkToRedraw();
}
return true;
}
/**
* @brief Event on a past event ==> this event is asynchronous due to all system does not support direct getting datas
* @note : need to have focus ...
* @param[in] mode Mode of data requested
* @return ---
*/
void CodeView::OnEventClipboard(ewol::clipBoard::clipboardListe_te clipboardID)
{
BufferManager::Get(m_bufferID)->Paste(clipboardID);
MarkToRedraw();
}
/**
* @brief Event on an input of this Widget
* @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...)
* @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger))
* @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/...
* @param[in] pos Absolute position of the event
* @return true the event is used
* @return false the event is not used
*/
bool CodeView::OnEventInput(ewol::inputType_te type, int32_t IdInput, ewol::eventInputType_te typeEvent, etk::Vector2D<float> pos)
{
etk::Vector2D<float> relativePos = RelativePosition(pos);
// corection for the openGl abstraction
//relativePos.y = m_size.y - relativePos.y;
etk::Vector2D<float> limitedPos = relativePos;
limitedPos.x = etk_avg(1, limitedPos.x, m_size.x-1);
limitedPos.y = etk_avg(1, limitedPos.y, m_size.y-1);
if (m_bufferID < 0) {
return false;
}
if (true == WidgetScrooled::OnEventInput(type, IdInput, typeEvent, pos)) {
ewol::widgetManager::FocusKeep(this);
// nothing to do ... done on upper widget ...
return true;
}
if (1 == IdInput) {
#ifndef __MODE__Touch
if (ewol::EVENT_INPUT_TYPE_DOWN == typeEvent) {
m_buttunOneSelected = true;
ewol::widgetManager::FocusKeep(this);
// TODO : Set something good
BufferManager::Get(m_bufferID)->MouseEvent(limitedPos);
MarkToRedraw();
} else if (ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
m_buttunOneSelected = false;
BufferManager::Get(m_bufferID)->Copy(ewol::clipBoard::CLIPBOARD_SELECTION);
MarkToRedraw();
} else
#endif
if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) {
#ifdef __MODE__Touch
ewol::widgetManager::FocusKeep(this);
BufferManager::Get(m_bufferID)->MouseEvent(limitedPos);
MarkToRedraw();
#else
// nothing to do ...
#endif
} else if (ewol::EVENT_INPUT_TYPE_DOUBLE == typeEvent) {
BufferManager::Get(m_bufferID)->MouseEventDouble();
MarkToRedraw();
} else if (ewol::EVENT_INPUT_TYPE_TRIPLE == typeEvent) {
BufferManager::Get(m_bufferID)->MouseEventTriple();
MarkToRedraw();
} else if (ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) {
if (true == m_buttunOneSelected) {
int xxx, yyy;
xxx = relativePos.x;
yyy = relativePos.y;
if (xxx<0) {
xxx = 0;
}
if (yyy<0) {
yyy = 0;
}
//APPL_INFO("mouse-motion BT1 %d, %d", xxx, yyy);
// TODO : Set something good
BufferManager::Get(m_bufferID)->MouseSelectFromCursorTo(limitedPos);
MarkToRedraw();
}
}
} else if (2 == IdInput) {
if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) {
// TODO : Set something good
BufferManager::Get(m_bufferID)->MouseEvent(limitedPos);
ewol::clipBoard::Request(ewol::clipBoard::CLIPBOARD_SELECTION);
ewol::widgetManager::FocusKeep(this);
}
}
return true;
}
/**
* @brief Receive a message from an other EObject with a specific eventId and data
* @param[in] CallerObject Pointer on the EObject that information came from
* @param[in] eventId Message registered by this class
* @param[in] data Data registered by this class
* @return ---
*/
void CodeView::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
{
ewol::WidgetScrooled::OnReceiveMessage(CallerObject, eventId, data);
APPL_DEBUG("Extern Event : " << CallerObject << " type : " << eventId << " data=\"" << data << "\"");
if(eventId == ednMsgBufferId) {
//keep the reference of the display offset :
if( m_bufferID >=0
&& m_bufferID < m_lineNumberList.Size()) {
m_lineNumberList[m_bufferID] = m_originScrooled;
}
int32_t bufferID = 0;
sscanf(data.c_str(), "%d", &bufferID);
APPL_INFO("Select a new Buffer ... " << bufferID);
// set the new buffer ID
m_bufferID = bufferID;
// update the start display position...
UpdateNumberOfLineReference(m_bufferID);
// set back if needed the display position ...
if( m_bufferID >=0
&& m_bufferID < m_lineNumberList.Size()) {
m_originScrooled = m_lineNumberList[m_bufferID];
}
} else if (eventId == ednMsgGuiCopy) {
BufferManager::Get(m_bufferID)->Copy(ewol::clipBoard::CLIPBOARD_STD);
} else if (eventId == ednMsgGuiCut) {
BufferManager::Get(m_bufferID)->Cut(ewol::clipBoard::CLIPBOARD_STD);
} else if (eventId == ednMsgGuiPaste) {
ewol::clipBoard::Request(ewol::clipBoard::CLIPBOARD_STD);
} else if (eventId == ednMsgGuiUndo) {
BufferManager::Get(m_bufferID)->Undo();
} else if (eventId == ednMsgGuiRedo) {
BufferManager::Get(m_bufferID)->Redo();
} else if (eventId == ednMsgGuiRm) {
// data : "Word" "Line" "Paragraph"
if (data == "Word") {
APPL_WARNING(" on event " << eventId << " data=\"" << data << "\" ==> not coded" );
} else if (data == "Line") {
BufferManager::Get(m_bufferID)->RemoveLine();
} else if (data == "Paragraph") {
APPL_WARNING(" on event " << eventId << " data=\"" << data << "\" ==> not coded" );
} else {
APPL_ERROR(" on event " << eventId << " unknow data=\"" << data << "\"" );
}
} else if (eventId == ednMsgGuiSelect) {
// data : "ALL" "NONE"
if (data == "ALL") {
BufferManager::Get(m_bufferID)->SelectAll();
} else if (data == "NONE") {
BufferManager::Get(m_bufferID)->SelectNone();
} else {
APPL_ERROR(" on event " << eventId << " unknow data=\"" << data << "\"" );
}
} else if (eventId == ednMsgGuiChangeCharset) {
// data : "UTF-8" "ISO-8859-1" "ISO-8859-15"
if (data == "UTF-8") {
BufferManager::Get(m_bufferID)->SetCharset(unicode::EDN_CHARSET_UTF8);
} else if (data == "ISO-8859-1") {
BufferManager::Get(m_bufferID)->SetCharset(unicode::EDN_CHARSET_ISO_8859_1);
} else if (data == "ISO-8859-15") {
BufferManager::Get(m_bufferID)->SetCharset(unicode::EDN_CHARSET_ISO_8859_15);
} else {
APPL_ERROR(" on event " << eventId << " unknow data=\"" << data << "\"" );
}
} else if (eventId == ednMsgGuiFind) {
etk::UString myDataString;
SearchData::GetSearch(myDataString);
if (data == "Next") {
BufferManager::Get(m_bufferID)->Search(myDataString, false, SearchData::GetCase(), SearchData::GetWrap(), SearchData::GetRegExp() );
} else if (data == "Previous") {
BufferManager::Get(m_bufferID)->Search(myDataString, true, SearchData::GetCase(), SearchData::GetWrap(), SearchData::GetRegExp() );
}
} else if (eventId == ednMsgGuiReplace) {
etk::UString myDataString;
SearchData::GetReplace(myDataString);
if (data == "Normal") {
BufferManager::Get(m_bufferID)->Replace(myDataString);
} else if (data == "All") {
}
} else if (eventId == ednMsgGuiGotoLine) {
int32_t lineID = 0;
sscanf(data.c_str(), "%d", &lineID);
APPL_INFO("Goto line : " << lineID);
BufferManager::Get(m_bufferID)->JumpAtLine(lineID);
}
// Force redraw of the widget
MarkToRedraw();
}
void CodeView::OnGetFocus(void)
{
/*
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferId, m_bufferID);
*/
ewol::KeyboardShow();
APPL_INFO("Focus - In");
}
void CodeView::OnLostFocus(void)
{
ewol::KeyboardHide();
APPL_INFO("Focus - out");
}
void CodeView::SetFontSize(int32_t size)
{
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
m_OObjectText.SetSize(size);
#else
m_OObjectTextNormal.SetSize(size);
m_OObjectTextBold.SetSize(size);
m_OObjectTextItalic.SetSize(size);
m_OObjectTextBoldItalic.SetSize(size);
#endif
SetScrollingSize(size*3.0*1.46); // 1.46 is a magic nmber ...
}
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
void CodeView::SetFontName(etk::UString fontName)
{
m_OObjectText.SetFont(fontName);
}
#else
void CodeView::SetFontNameNormal(etk::UString fontName)
{
m_OObjectTextNormal.SetFont(fontName);
}
void CodeView::SetFontNameBold(etk::UString fontName)
{
m_OObjectTextBold.SetFont(fontName);
}
void CodeView::SetFontNameItalic(etk::UString fontName)
{
m_OObjectTextItalic.SetFont(fontName);
}
void CodeView::SetFontNameBoldItalic(etk::UString fontName)
{
m_OObjectTextBoldItalic.SetFont(fontName);
}
#endif

124
Sources/appl/Gui/CodeView.h Normal file
View File

@@ -0,0 +1,124 @@
/**
*******************************************************************************
* @file CodeView.h
* @brief Editeur De N'ours : Code Viewer Widget (header)
* @author Edouard DUPIN
* @date 05/01/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 __CODE_VIEW_H__
#define __CODE_VIEW_H__
#include <appl/Debug.h>
#include <CodeView.h>
#include <BufferManager.h>
#include <appl/globalMsg.h>
#include <etk/Types.h>
#include <ewol/widget/WidgetScrolled.h>
#include <ewol/ResourceManager.h>
class CodeView :public ewol::WidgetScrooled
{
public:
void Init(void);
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
CodeView(etk::UString fontName, int32_t fontSize);
#endif
CodeView(void);
virtual ~CodeView(void);
/**
* @brief Get the current Object type of the EObject
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
* @param[in] objectType type description
* @return true if the object is compatible, otherwise false
*/
const char * const GetObjectType(void) { return "ApplCodeView"; };
virtual bool CalculateMinSize(void);
private:
etk::UString m_label;
draw::Color m_textColorFg; //!< Text color
draw::Color m_textColorBg; //!< Background color
int32_t m_bufferID;
bool m_buttunOneSelected;
etk::Vector<etk::Vector2D<float> > m_lineNumberList;
void UpdateNumberOfLineReference(int32_t bufferID);
// drawing elements :
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
ewol::TEXT_DISPLAY_TYPE m_OObjectText;
#else
ewol::TEXT_DISPLAY_TYPE m_OObjectTextNormal;
ewol::TEXT_DISPLAY_TYPE m_OObjectTextBold;
ewol::TEXT_DISPLAY_TYPE m_OObjectTextItalic;
ewol::TEXT_DISPLAY_TYPE m_OObjectTextBoldItalic;
#endif
ewol::OObject2DColored m_OObjectsColored;
public:
virtual void OnRegenerateDisplay(void);
/**
* @brief Receive a message from an other EObject with a specific eventId and data
* @param[in] CallerObject Pointer on the EObject that information came from
* @param[in] eventId Message registered by this class
* @param[in] data Data registered by this class
* @return ---
*/
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
public:
/**
* @brief Event on an input of this Widget
* @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...)
* @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger))
* @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/...
* @param[in] pos Absolute position of the event
* @return true the event is used
* @return false the event is not used
*/
virtual bool OnEventInput(ewol::inputType_te type, int32_t IdInput, ewol::eventInputType_te typeEvent, etk::Vector2D<float> pos);
virtual bool OnEventKb(ewol::eventKbType_te typeEvent, uniChar_t unicodeData);
virtual bool OnEventKbMove(ewol::eventKbType_te typeEvent, ewol::eventKbMoveType_te moveTypeEvent);
/**
* @brief Event on a past event ==> this event is asynchronous due to all system does not support direct getting datas
* @note : need to have focus ...
* @param[in] mode Mode of data requested
* @return ---
*/
virtual void OnEventClipboard(ewol::clipBoard::clipboardListe_te clipboardID);
virtual void OnGetFocus(void);
virtual void OnLostFocus(void);
public:
void SetFontSize(int32_t size);
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
void SetFontName(etk::UString fontName);
#else
void SetFontNameNormal(etk::UString fontName);
void SetFontNameBold(etk::UString fontName);
void SetFontNameItalic(etk::UString fontName);
void SetFontNameBoldItalic(etk::UString fontName);
#endif
private:
void CalculateMaxSize(void);
protected:
virtual void OnDraw(ewol::DrawProperty& displayProp);
};
#endif

View File

@@ -0,0 +1,442 @@
/**
*******************************************************************************
* @file MainWindows.cpp
* @brief Editeur De N'ours : main Windows diplayer (Sources)
* @author Edouard DUPIN
* @date 04/01/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 <appl/Debug.h>
#include <appl/global.h>
#include <MainWindows.h>
#include <CodeView.h>
#include <BufferView.h>
#include <Search.h>
#include <ewol/widget/Button.h>
#include <ewol/widget/CheckBox.h>
#include <ewol/widget/SizerHori.h>
#include <ewol/widget/SizerVert.h>
#include <ewol/widget/Label.h>
#include <ewol/widget/Entry.h>
#include <ewol/widget/List.h>
#include <ewol/widget/ContextMenu.h>
#include <ewol/widget/PopUp.h>
#include <ewol/widget/Spacer.h>
#include <ewol/widget/Slider.h>
#include <ewol/widget/Menu.h>
#include <ewol/widget/meta/FileChooser.h>
#include <ewol/widget/meta/Parameter.h>
#include <ewol/widget/WidgetManager.h>
#include <ewol/ResourceManager.h>
#include <ewol/eObject/EObject.h>
#undef __class__
#define __class__ "AboutGui"
#include <ewol/widget/Label.h>
#include <ewol/widget/Spacer.h>
class ParameterAboutGui : public ewol::SizerVert
{
public :
ParameterAboutGui(void)
{
ewol::Spacer* mySpacer = NULL;
mySpacer = new ewol::Spacer();
if (NULL == mySpacer) {
APPL_ERROR("Can not allocate widget ==> display might be in error");
} else {
mySpacer->SetExpendX(true);
mySpacer->SetExpendY(true);
SubWidgetAdd(mySpacer);
}
AddElement(" libPng");
AddElement(" ogg-tremor");
AddElement(" portaudio");
AddElement(" libZip");
AddElement(" tinyXml");
AddElement(" freetype");
AddElement(" agg2.4");
AddElement(" etk (BSD)");
AddElement(" ewol is based on");
AddElement(" Website : https://github.com/HeeroYui/ewol");
AddElement(" Licence : BSD like");
AddElement(" Copyright 2010 Edouard DUPIN, all right reserved");
AddElement(" Supported OS : Linux, Windows, Android" );
AddElement(etk::UString(" OpenGl librairy : v") + ewol::GetVersion() );
AddElement("Ewol", true);
AddElement("");
AddElement(" Website : https://github.com/HeeroYui/edn");
AddElement(" Licence : GPL");
AddElement(" Copyright 2010 Edouard DUPIN, all right reserved");
AddElement(etk::UString(" Build Time : ") + etk::UString(BUILD_TIME));
AddElement(" Source Code Editor");
AddElement(etk::UString(" Editeur De N'ours : v") + etk::UString(APPL_VERSION_TAG_NAME));
AddElement("Edn", true);
};
~ParameterAboutGui(void) { };
void AddElement(etk::UString label, bool bold=false, bool italic=false)
{
ewol::Label* myLabel = new ewol::Label(label);
if (NULL == myLabel) {
APPL_ERROR("Can not allocate widget ==> display might be in error");
} else {
myLabel->SetExpendX(true);
SubWidgetAdd(myLabel);
}
};
};
const char * l_smoothChick = "tmpEvent_smooth";
const char * l_smoothMin = "tmpEvent_minChange";
const char * l_smoothMax = "tmpEvent_maxChange";
extern float DF_SoftEdge_min;
extern float DF_SoftEdge_max;
extern int32_t DF_SoftEdge;
ewol::Slider* tmpSliderMin = NULL;
ewol::Slider* tmpSliderMax = NULL;
#undef __class__
#define __class__ "MainWindows"
MainWindows::MainWindows(void)
{
APPL_DEBUG("CREATE WINDOWS ... ");
ewol::SizerVert * mySizerVert = NULL;
ewol::SizerVert * mySizerVert2 = NULL;
ewol::SizerHori * mySizerHori = NULL;
//ewol::Button * myButton = NULL;
CodeView * myCodeView = NULL;
BufferView * myBufferView = NULL;
ewol::Menu * myMenu = NULL;
mySizerVert = new ewol::SizerVert();
SetSubWidget(mySizerVert);
mySizerHori = new ewol::SizerHori();
mySizerVert->SubWidgetAdd(mySizerHori);
myBufferView = new BufferView();
myBufferView->SetExpendX(false);
myBufferView->SetExpendY(true);
myBufferView->SetFillX(true);
myBufferView->SetFillY(true);
mySizerHori->SubWidgetAdd(myBufferView);
mySizerVert2 = new ewol::SizerVert();
mySizerHori->SubWidgetAdd(mySizerVert2);
// main buffer Area :
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
myCodeView = new CodeView("Font/freefont/FreeMono.ttf", 24);
#else
myCodeView = new CodeView();
#endif
myCodeView->SetExpendX(true);
myCodeView->SetExpendY(true);
myCodeView->SetFillX(true);
myCodeView->SetFillY(true);
#ifndef APPL_BUFFER_FONT_DISTANCE_FIELD
myCodeView->SetFontSize(11);
myCodeView->SetFontNameNormal( "Font/freefont/FreeMono.ttf");
myCodeView->SetFontNameBold( "Font/freefont/FreeMonoBold.ttf");
myCodeView->SetFontNameItalic( "Font/freefont/FreeMonoOblique.ttf");
myCodeView->SetFontNameBoldItalic("Font/freefont/FreeMonoBoldOblique.ttf");
#endif
mySizerVert2->SubWidgetAdd(myCodeView);
// search area :
Search * mySearch = new Search();
mySizerVert2->SubWidgetAdd(mySearch);
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
{
ewol::SizerHori * mySizerHori2 = new ewol::SizerHori();
mySizerVert2->SubWidgetAdd(mySizerHori2);
ewol::CheckBox* tmpCheck = new ewol::CheckBox("smooth");
mySizerHori2->SubWidgetAdd(tmpCheck);
tmpCheck->RegisterOnEvent(this, ewolEventCheckBoxClicked, l_smoothChick);
ewol::Slider* tmpSlider = new ewol::Slider();
mySizerHori2->SubWidgetAdd(tmpSlider);
tmpSlider->RegisterOnEvent(this, ewolEventSliderChange, l_smoothMin);
tmpSlider->SetExpendX(true);
tmpSlider->SetMin(0);
tmpSlider->SetMax(1000);
tmpSlider->SetValue(0450);
tmpSliderMin = tmpSlider;
tmpSlider = new ewol::Slider();
mySizerHori2->SubWidgetAdd(tmpSlider);
tmpSlider->RegisterOnEvent(this, ewolEventSliderChange, l_smoothMax);
tmpSlider->SetExpendX(true);
tmpSlider->SetMin(0);
tmpSlider->SetMax(1000);
tmpSlider->SetValue(0550);
tmpSliderMax = tmpSlider;
}
#endif
mySizerHori = new ewol::SizerHori();
mySizerVert->SubWidgetAdd(mySizerHori);
myMenu = new ewol::Menu();
mySizerHori->SubWidgetAdd(myMenu);
int32_t idMenuFile = myMenu->AddTitle("File");
(void)myMenu->Add(idMenuFile, "New", "", ednMsgGuiNew);
(void)myMenu->AddSpacer();
(void)myMenu->Add(idMenuFile, "Open", "icon/Load.svg", ednMsgGuiOpen);
(void)myMenu->Add(idMenuFile, "Close", "icon/Close.svg", ednMsgGuiClose, "current");
(void)myMenu->Add(idMenuFile, "Close (all)", "", ednMsgGuiClose, "All");
(void)myMenu->Add(idMenuFile, "Save", "icon/Save.svg", ednMsgGuiSave, "current");
(void)myMenu->Add(idMenuFile, "Save As ...", "", ednMsgGuiSaveAs);
(void)myMenu->AddSpacer();
//(void)myMenu->Add(idMenuFile, "Exit", "", ednMsgGuiExit);
(void)myMenu->AddSpacer();
(void)myMenu->Add(idMenuFile, "Properties", "icon/Parameter.svg", ednMsgProperties);
int32_t idMenuEdit = myMenu->AddTitle("Edit");
(void)myMenu->Add(idMenuEdit, "Undo", "icon/Undo.svg", ednMsgGuiUndo);
(void)myMenu->Add(idMenuEdit, "Redo", "icon/Redo.svg", ednMsgGuiRedo);
(void)myMenu->AddSpacer();
(void)myMenu->Add(idMenuEdit, "Copy", "", ednMsgGuiCopy, "STD");
(void)myMenu->Add(idMenuEdit, "Cut", "", ednMsgGuiCut, "STD");
(void)myMenu->Add(idMenuEdit, "Paste", "", ednMsgGuiPaste, "STD");
(void)myMenu->Add(idMenuEdit, "Remove", "", ednMsgGuiRm);
(void)myMenu->AddSpacer();
(void)myMenu->Add(idMenuEdit, "Select All","", ednMsgGuiSelect, "ALL");
(void)myMenu->Add(idMenuEdit, "Un-Select","", ednMsgGuiSelect, "NONE");
(void)myMenu->Add(idMenuEdit, "Goto line ...","", ednMsgGuiGotoLine, "???");
int32_t idMenuSearch = myMenu->AddTitle("Search");
(void)myMenu->Add(idMenuSearch, "Search", "icon/Search.svg", ednMsgGuiSearch);
(void)myMenu->Add(idMenuSearch, "Replace", "icon/Replace.svg", ednMsgGuiReplace);
(void)myMenu->AddSpacer();
(void)myMenu->Add(idMenuSearch, "Find (previous)","", ednMsgGuiFind, "Previous");
(void)myMenu->Add(idMenuSearch, "Find (next)", "", ednMsgGuiFind, "Next");
(void)myMenu->Add(idMenuSearch, "Find (all)", "", ednMsgGuiFind, "All");
(void)myMenu->Add(idMenuSearch, "Un-Select", "", ednMsgGuiFind, "None");
int32_t idMenuCTags = myMenu->AddTitle("C-tags");
(void)myMenu->Add(idMenuCTags, "Load", "", ednMsgGuiCtags, "Load");
(void)myMenu->Add(idMenuCTags, "ReLoad", "", ednMsgGuiCtags, "ReLoad");
(void)myMenu->Add(idMenuCTags, "Jump", "", ednMsgGuiCtags, "Jump");
(void)myMenu->Add(idMenuCTags, "Back", "", ednMsgGuiCtags, "Back");
int32_t idMenugDisplay = myMenu->AddTitle("Display");
(void)myMenu->Add(idMenugDisplay, "Charset UTF-8", "", ednMsgGuiChangeCharset, "UTF-8");
(void)myMenu->Add(idMenugDisplay, "Charset ISO-8859-1", "", ednMsgGuiChangeCharset, "ISO-8859-1");
(void)myMenu->Add(idMenugDisplay, "Charset ISO-8859-15", "", ednMsgGuiChangeCharset, "ISO-8859-15");
(void)myMenu->AddSpacer();
(void)myMenu->Add(idMenugDisplay, "Color Black", "", ednMsgGuiChangeColor, "Black");
(void)myMenu->Add(idMenugDisplay, "Color White", "", ednMsgGuiChangeColor, "White");
(void)myMenu->AddSpacer();
(void)myMenu->Add(idMenugDisplay, "Reload OpenGl Shader", "", ednMsgGuiReloadShader);
m_widgetLabelFileName = new ewol::Label("FileName");
m_widgetLabelFileName->SetExpendX(true);
m_widgetLabelFileName->SetFillY(true);
mySizerHori->SubWidgetAdd(m_widgetLabelFileName);
// Generic event ...
RegisterMultiCast(ednMsgGuiSaveAs);
RegisterMultiCast(ednMsgProperties);
RegisterMultiCast(ednMsgGuiOpen);
// to update the title ...
RegisterMultiCast(ednMsgBufferState);
RegisterMultiCast(ednMsgBufferId);
RegisterMultiCast(ednMsgGuiReloadShader);
}
MainWindows::~MainWindows(void)
{
}
const char *const ednEventPopUpFileSelected = "edn-mainWindows-openSelected";
const char *const ednEventPopUpFileSaveAs = "edn-mainWindows-saveAsSelected";
/**
* @brief Receive a message from an other EObject with a specific eventId and data
* @param[in] CallerObject Pointer on the EObject that information came from
* @param[in] eventId Message registered by this class
* @param[in] data Data registered by this class
* @return ---
*/
void MainWindows::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
{
ewol::Windows::OnReceiveMessage(CallerObject, eventId, data);
//APPL_INFO("Receive Event from the main windows ... : \"" << eventId << "\" ==> data=\"" << data << "\"" );
// Open file Section ...
if (eventId == ednMsgGuiOpen) {
ewol::FileChooser* tmpWidget = new ewol::FileChooser();
tmpWidget->SetTitle("Open Files ...");
tmpWidget->SetValidateLabel("Open");
if (BufferManager::GetSelected()!=-1) {
Buffer * myBuffer = BufferManager::Get(BufferManager::GetSelected());
if (NULL!=myBuffer) {
etk::FSNode tmpFile = myBuffer->GetFileName();
tmpWidget->SetFolder(tmpFile.GetNameFolder());
}
}
PopUpWidgetPush(tmpWidget);
tmpWidget->RegisterOnEvent(this, ewolEventFileChooserValidate, ednEventPopUpFileSelected);
} else if (eventId == ednEventPopUpFileSelected) {
APPL_DEBUG("Request opening the file : " << data);
SendMultiCast(ednMsgOpenFile, data);
} else if (eventId == ednMsgGuiSaveAs) {
if (data == "") {
APPL_ERROR("Null data for Save As file ... ");
} else {
m_currentSavingAsIdBuffer = -1;
if (data == "current") {
m_currentSavingAsIdBuffer = BufferManager::GetSelected();
} else {
sscanf(data.c_str(), "%d", &m_currentSavingAsIdBuffer);
}
if (false == BufferManager::Exist(m_currentSavingAsIdBuffer)) {
APPL_ERROR("Request saveAs on non existant Buffer ID=" << m_currentSavingAsIdBuffer);
} else {
Buffer * myBuffer = BufferManager::Get(m_currentSavingAsIdBuffer);
ewol::FileChooser* tmpWidget = new ewol::FileChooser();
if (NULL == tmpWidget) {
APPL_ERROR("Can not allocate widget ==> display might be in error");
} else {
tmpWidget->SetTitle("Save Files As...");
tmpWidget->SetValidateLabel("Save");
etk::UString folder = "/home/";
etk::UString fileName = "";
if (true == myBuffer->HaveName()) {
etk::FSNode tmpName = myBuffer->GetFileName();
folder = tmpName.GetNameFolder();
fileName = tmpName.GetNameFile();
}
tmpWidget->SetFolder(folder);
tmpWidget->SetFileName(fileName);
PopUpWidgetPush(tmpWidget);
tmpWidget->RegisterOnEvent(this, ewolEventFileChooserValidate, ednEventPopUpFileSaveAs);
}
}
}
} else if (eventId == ednEventPopUpFileSaveAs) {
// get the filename :
etk::UString tmpData = data;
APPL_DEBUG("Request Saving As file : " << tmpData);
BufferManager::Get(m_currentSavingAsIdBuffer)->SetFileName(tmpData);
SendMultiCast(ednMsgGuiSave, m_currentSavingAsIdBuffer);
} else if( eventId == ednMsgBufferState
|| eventId == ednMsgBufferId) {
// the buffer change we need to update the widget string
Buffer* tmpBuffer = BufferManager::Get(BufferManager::GetSelected());
if (NULL != tmpBuffer) {
etk::FSNode compleateName = tmpBuffer->GetFileName();
bool isModify = tmpBuffer->IsModify();
etk::UString directName = compleateName.GetName();
if (true == isModify) {
directName += " *";
}
if (NULL == m_widgetLabelFileName) {
return;
}
m_widgetLabelFileName->SetLabel(directName);
etk::UString windowsTitle = "edn - ";
windowsTitle += directName;
ewol::SetTitle(windowsTitle);
return;
} else {
m_widgetLabelFileName->SetLabel("");
ewol::SetTitle("edn");
}
return;
// TODO : Set the Title ....
} else if (eventId == ednMsgProperties) {
// Request the parameter GUI
ewol::Parameter* tmpWidget = new ewol::Parameter();
if (NULL == tmpWidget) {
APPL_ERROR("Can not allocate widget ==> display might be in error");
} else {
tmpWidget->SetTitle("Properties");
PopUpWidgetPush(tmpWidget);
tmpWidget->MenuAddGroup("Editor");
ewol::Widget* tmpSubWidget = new globals::ParameterGlobalsGui();
tmpWidget->MenuAdd("Editor", "", tmpSubWidget);
tmpWidget->MenuAdd("Polices & Color", "", NULL);
tmpWidget->MenuAdd("Highlight", "", NULL);
tmpWidget->MenuAddGroup("Genral");
tmpWidget->MenuAdd("Affichage", "", NULL);
tmpSubWidget = new ParameterAboutGui();
tmpWidget->MenuAdd("About", "", tmpSubWidget);
}
} else if (eventId == l_smoothChick) {
if (data == "true") {
DF_SoftEdge = 1;
} else {
DF_SoftEdge = 0;
}
} else if (eventId == l_smoothMin) {
int32_t newVal = 0;
sscanf(data.c_str(), "%d", &newVal);
DF_SoftEdge_min = (float)newVal / 1000.0;
if (DF_SoftEdge_min>DF_SoftEdge_max) {
DF_SoftEdge_max = DF_SoftEdge_min;
tmpSliderMax->SetValue(DF_SoftEdge_max*1000.0);
}
} else if (eventId == l_smoothMax) {
int32_t newVal = 0;
sscanf(data.c_str(), "%d", &newVal);
DF_SoftEdge_max = (float)newVal / 1000.0;
if (DF_SoftEdge_min>DF_SoftEdge_max) {
DF_SoftEdge_min = DF_SoftEdge_max;
tmpSliderMin->SetValue(DF_SoftEdge_min*1000.0);
}
} else if (eventId == ednMsgGuiReloadShader) {
ewol::resource::ReLoadResources();
ewol::ForceRedrawAll();
}
return;
}
/**
* @brief Inform object that an other object is removed ...
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
* @note : Sub classes must call this class
* @return ---
*/
void MainWindows::OnObjectRemove(ewol::EObject * removeObject)
{
ewol::Windows::OnObjectRemove(removeObject);
if (m_widgetLabelFileName == removeObject) {
m_widgetLabelFileName = NULL;
}
}

View File

@@ -0,0 +1,73 @@
/**
*******************************************************************************
* @file MainWindows.h
* @brief Editeur De N'ours : main Windows diplayer (header)
* @author Edouard DUPIN
* @date 04/01/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 __MAIN_WINDOWS_H__
#define __MAIN_WINDOWS_H__
#include <appl/Debug.h>
#include <appl/globalMsg.h>
#include <CodeView.h>
#include <BufferView.h>
#include <BufferManager.h>
#include <ewol/widget/Label.h>
class MainWindows : public ewol::Windows
{
private:
int32_t m_currentSavingAsIdBuffer;
ewol::Label* m_widgetLabelFileName;
public:
// Constructeur
MainWindows(void);
~MainWindows(void);
/**
* @brief Get the current Object type of the EObject
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
* @param[in] objectType type description
* @return true if the object is compatible, otherwise false
*/
const char * const GetObjectType(void) { return "MainWindows"; };
/**
* @brief Receive a message from an other EObject with a specific eventId and data
* @param[in] CallerObject Pointer on the EObject that information came from
* @param[in] eventId Message registered by this class
* @param[in] data Data registered by this class
* @return ---
*/
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
/**
* @brief Inform object that an other object is removed ...
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
* @note : Sub classes must call this class
* @return ---
*/
virtual void OnObjectRemove(ewol::EObject * removeObject);
};
#define EDN_CAST_MAIN_WINDOWS(curentPointer) EWOL_CAST(TYPE_EOBJECT_EDN_MAIN_WINDOWS,MainWindows,curentPointer)
#endif

253
Sources/appl/Gui/Search.cpp Normal file
View File

@@ -0,0 +1,253 @@
/**
*******************************************************************************
* @file Search.cpp
* @brief Editeur De N'ours : Search system
* @author Edouard DUPIN
* @date 03/01/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 "appl/global.h"
#include "Search.h"
#include "SearchData.h"
#include "BufferManager.h"
#include "MainWindows.h"
#include "appl/globalMsg.h"
#include <ewol/widget/ButtonImage.h>
#undef __class__
#define __class__ "Search"
const char* const l_eventSearchEntry = "appl-search-entry";
const char* const l_eventSearchEntryEnter = "appl-search-entry-enter";
const char* const l_eventReplaceEntry = "appl-replace-entry";
const char* const l_eventReplaceEntryEnter = "appl-replace-entry-enter";
const char* const l_eventSearchBt = "appl-search-button";
const char* const l_eventReplaceBt = "appl-replace-button";
const char* const l_eventCaseCb = "appl-case-sensitive-CheckBox";
const char* const l_eventWrapCb = "appl-wrap-CheckBox";
const char* const l_eventForwardCb = "appl-forward-CheckBox";
const char* const l_eventHideBt = "appl-hide-button";
Search::Search(void) :
m_searchEntry(NULL),
m_replaceEntry(NULL)
{
m_forward = false;
ewol::ButtonImage * myButtonImage = NULL;
myButtonImage = new ewol::ButtonImage("icon/Remove.svg");
if (NULL == myButtonImage) {
APPL_ERROR("Widget allocation error ==> it will missing in the display");
} else {
myButtonImage->SetMinSize(32,32);
myButtonImage->RegisterOnEvent(this, ewolEventButtonPressed, l_eventHideBt);
SubWidgetAdd(myButtonImage);
}
m_searchEntry = new ewol::Entry();
if (NULL == m_searchEntry) {
APPL_ERROR("Widget allocation error ==> it will missing in the display");
} else {
m_searchEntry->RegisterOnEvent(this, ewolEventEntryModify, l_eventSearchEntry);
m_searchEntry->RegisterOnEvent(this, ewolEventEntryEnter, l_eventSearchEntryEnter);
m_searchEntry->SetExpendX(true);
m_searchEntry->SetFillX(true);
SubWidgetAdd(m_searchEntry);
}
myButtonImage = new ewol::ButtonImage("icon/Search.svg");
if (NULL == myButtonImage) {
APPL_ERROR("Widget allocation error ==> it will missing in the display");
} else {
myButtonImage->SetMinSize(32,32);
myButtonImage->RegisterOnEvent(this, ewolEventButtonPressed, l_eventSearchBt);
SubWidgetAdd(myButtonImage);
}
m_replaceEntry = new ewol::Entry();
if (NULL == m_replaceEntry) {
APPL_ERROR("Widget allocation error ==> it will missing in the display");
} else {
m_replaceEntry->RegisterOnEvent(this, ewolEventEntryModify, l_eventReplaceEntry);
m_replaceEntry->RegisterOnEvent(this, ewolEventEntryEnter, l_eventReplaceEntryEnter);
m_replaceEntry->SetExpendX(true);
m_replaceEntry->SetFillX(true);
SubWidgetAdd(m_replaceEntry);
}
myButtonImage = new ewol::ButtonImage("icon/Replace.svg");
if (NULL == myButtonImage) {
APPL_ERROR("Widget allocation error ==> it will missing in the display");
} else {
myButtonImage->SetMinSize(32,32);
myButtonImage->RegisterOnEvent(this, ewolEventButtonPressed, l_eventReplaceBt);
SubWidgetAdd(myButtonImage);
}
myButtonImage = new ewol::ButtonImage("icon/CaseSensitive.svg");
if (NULL == myButtonImage) {
APPL_ERROR("Widget allocation error ==> it will missing in the display");
} else {
myButtonImage->SetImageSelected("icon/CaseSensitive.svg", 0xFFFFFF5F);
myButtonImage->SetMinSize(32,32);
myButtonImage->SetToggleMode(true);
myButtonImage->SetValue(SearchData::GetCase());
myButtonImage->RegisterOnEvent(this, ewolEventButtonPressed, l_eventCaseCb);
SubWidgetAdd(myButtonImage);
}
myButtonImage = new ewol::ButtonImage("icon/WrapAround.svg");
if (NULL == myButtonImage) {
APPL_ERROR("Widget allocation error ==> it will missing in the display");
} else {
myButtonImage->SetImageSelected("icon/WrapAround.svg", 0xFFFFFF5F);
myButtonImage->SetMinSize(32,32);
myButtonImage->SetToggleMode(true);
myButtonImage->SetValue(SearchData::GetWrap());
myButtonImage->RegisterOnEvent(this, ewolEventButtonPressed, l_eventWrapCb);
SubWidgetAdd(myButtonImage);
}
myButtonImage = new ewol::ButtonImage("icon/Up.svg");
if (NULL == myButtonImage) {
APPL_ERROR("Widget allocation error ==> it will missing in the display");
} else {
myButtonImage->SetImageSelected("icon/Down.svg");
myButtonImage->SetMinSize(32,32);
myButtonImage->SetToggleMode(true);
myButtonImage->SetValue(m_forward);
myButtonImage->RegisterOnEvent(this, ewolEventButtonPressed, l_eventForwardCb);
SubWidgetAdd(myButtonImage);
}
RegisterMultiCast(ednMsgGuiSearch);
// basicly hiden ...
Hide();
}
Search::~Search(void)
{
}
/**
* @brief Receive a message from an other EObject with a specific eventId and data
* @param[in] CallerObject Pointer on the EObject that information came from
* @param[in] eventId Message registered by this class
* @param[in] data Data registered by this class
* @return ---
*/
void Search::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
{
ewol::SizerHori::OnReceiveMessage(CallerObject, eventId, data);
//APPL_INFO("Search receive message : \"" << eventId << "\" data=\"" << data << "\"");
if ( eventId == l_eventSearchEntry) {
SearchData::SetSearch(data);
} else if ( eventId == l_eventSearchEntryEnter) {
SearchData::SetSearch(data);
if (true==m_forward) {
SendMultiCast(ednMsgGuiFind, "Previous");
} else {
SendMultiCast(ednMsgGuiFind, "Next");
}
} else if ( eventId == l_eventReplaceEntry) {
SearchData::SetReplace(data);
} else if ( eventId == l_eventReplaceEntryEnter) {
SearchData::SetReplace(data);
SendMultiCast(ednMsgGuiReplace, "Normal");
if (true==m_forward) {
SendMultiCast(ednMsgGuiFind, "Previous");
} else {
SendMultiCast(ednMsgGuiFind, "Next");
}
} else if ( eventId == l_eventSearchBt) {
if (true==m_forward) {
SendMultiCast(ednMsgGuiFind, "Previous");
} else {
SendMultiCast(ednMsgGuiFind, "Next");
}
} else if ( eventId == l_eventReplaceBt) {
SendMultiCast(ednMsgGuiReplace, "Normal");
if (true==m_forward) {
SendMultiCast(ednMsgGuiFind, "Previous");
} else {
SendMultiCast(ednMsgGuiFind, "Next");
}
} else if ( eventId == l_eventCaseCb) {
if (data == "true") {
SearchData::SetCase(true);
} else {
SearchData::SetCase(false);
}
} else if ( eventId == l_eventWrapCb) {
if (data == "true") {
SearchData::SetWrap(true);
} else {
SearchData::SetWrap(false);
}
} else if ( eventId == l_eventForwardCb) {
if (data == "true") {
m_forward = true;
} else {
m_forward = false;
}
} else if ( eventId == l_eventHideBt) {
Hide();
} else if ( eventId == ednMsgGuiSearch) {
if (true == IsHide()) {
Show();
if (m_searchEntry!= NULL) {
m_searchEntry->KeepFocus();
}
} else {
if( (m_searchEntry!=NULL && true==m_searchEntry->GetFocus())
|| (m_replaceEntry!=NULL && true==m_replaceEntry->GetFocus()) ) {
Hide();
} else if (m_searchEntry!= NULL) {
m_searchEntry->KeepFocus();
} else {
Hide();
}
}
}
}
/**
* @brief Inform object that an other object is removed ...
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
* @note : Sub classes must call this class
* @return ---
*/
void Search::OnObjectRemove(ewol::EObject * removeObject)
{
ewol::SizerHori::OnObjectRemove(removeObject);
if (removeObject == m_searchEntry) {
m_searchEntry = NULL;
}
if (removeObject == m_replaceEntry) {
m_replaceEntry = NULL;
}
}

69
Sources/appl/Gui/Search.h Normal file
View File

@@ -0,0 +1,69 @@
/**
*******************************************************************************
* @file Search.h
* @brief Editeur De N'ours : Search system (header)
* @author Edouard DUPIN
* @date 03/01/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 __SEARCH_H__
#define __SEARCH_H__
#include <appl/Debug.h>
#include <ewol/widget/SizerHori.h>
#include <ewol/widget/Entry.h>
class Search : public ewol::SizerHori
{
public:
// Constructeur
Search(void);
~Search(void);
/**
* @brief Get the current Object type of the EObject
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
* @param[in] objectType type description
* @return true if the object is compatible, otherwise false
*/
const char * const GetObjectType(void) { return "ApplSearch"; };
/**
* @brief Receive a message from an other EObject with a specific eventId and data
* @param[in] CallerObject Pointer on the EObject that information came from
* @param[in] eventId Message registered by this class
* @param[in] data Data registered by this class
* @return ---
*/
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
/**
* @brief Inform object that an other object is removed ...
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
* @note : Sub classes must call this class
* @return ---
*/
virtual void OnObjectRemove(ewol::EObject * removeObject);
private:
bool m_forward;
ewol::Entry * m_searchEntry;
ewol::Entry * m_replaceEntry;
};
#endif

View File

@@ -23,22 +23,21 @@
*******************************************************************************
*/
#include "tools_globals.h"
#include "SearchData.h"
#include "Edn.h"
#include <appl/global.h>
#include <SearchData.h>
#undef __class__
#define __class__ "SearchData"
static Edn::String m_findRequest = "";
static etk::UString m_findRequest = "";
void SearchData::SetSearch(Edn::String &myData)
void SearchData::SetSearch(etk::UString &myData)
{
m_findRequest = myData;
}
void SearchData::GetSearch(Edn::String &myData)
void SearchData::GetSearch(etk::UString &myData)
{
myData = m_findRequest;
}
@@ -50,12 +49,12 @@ bool SearchData::IsSearchEmpty(void)
return true;
}
static Edn::String m_replaceRequest = "";
void SearchData::SetReplace(Edn::String &myData)
static etk::UString m_replaceRequest = "";
void SearchData::SetReplace(etk::UString &myData)
{
m_replaceRequest = myData;
}
void SearchData::GetReplace(Edn::String &myData)
void SearchData::GetReplace(etk::UString &myData)
{
myData = m_replaceRequest;
}

View File

@@ -26,16 +26,16 @@
#ifndef __SEARCH_DATA_H__
#define __SEARCH_DATA_H__
#include "tools_debug.h"
#include "Edn.h"
#include <etk/UString.h>
#include <appl/Debug.h>
namespace SearchData
{
void SetSearch(Edn::String &myData);
void GetSearch(Edn::String &myData);
void SetSearch(etk::UString &myData);
void GetSearch(etk::UString &myData);
bool IsSearchEmpty(void);
void SetReplace(Edn::String &myData);
void GetReplace(Edn::String &myData);
void SetReplace(etk::UString &myData);
void GetReplace(etk::UString &myData);
bool IsReplaceEmpty(void);
void SetCase(bool value);
bool GetCase(void);

View File

@@ -0,0 +1,155 @@
/**
*******************************************************************************
* @file TagFileList.cpp
* @brief Editeur De N'ours : Tags list display to jump (sources)
* @author Edouard DUPIN
* @date 16/10/2012
* @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 <etk/tool.h>
#include <appl/Gui/TagFileList.h>
#undef __class__
#define __class__ "TagFileList"
extern const char * const applEventCtagsListSelect = "appl-event-ctags-list-select";
extern const char * const applEventCtagsListUnSelect = "appl-event-ctags-list-un-select";
extern const char * const applEventCtagsListValidate = "appl-event-ctags-list-validate";
appl::TagFileList::TagFileList(void)
{
m_selectedLine = -1;
AddEventId(applEventCtagsListSelect);
AddEventId(applEventCtagsListValidate);
SetMouseLimit(1);
}
appl::TagFileList::~TagFileList(void)
{
for (int32_t iii=0; iii<m_list.Size(); iii++) {
if (NULL != m_list[iii]) {
delete(m_list[iii]);
m_list[iii] = NULL;
}
}
}
draw::Color appl::TagFileList::GetBasicBG(void) {
draw::Color bg(0x00000010);
return bg;
}
uint32_t appl::TagFileList::GetNuberOfColomn(void) {
return 2;
}
bool appl::TagFileList::GetTitle(int32_t colomn, etk::UString &myTitle, draw::Color &fg, draw::Color &bg) {
myTitle = "title";
return true;
}
uint32_t appl::TagFileList::GetNuberOfRaw(void) {
return m_list.Size();
}
bool appl::TagFileList::GetElement(int32_t colomn, int32_t raw, etk::UString &myTextToWrite, draw::Color &fg, draw::Color &bg) {
if (raw >= 0 && raw < m_list.Size() && NULL != m_list[raw]) {
if (0==colomn) {
myTextToWrite = etk::UString(m_list[raw]->fileLine);
} else {
myTextToWrite = m_list[raw]->filename;
}
} else {
myTextToWrite = "ERROR";
}
fg = draw::color::black;
if (raw % 2) {
if (colomn%2==0) {
bg = 0xFFFFFF00;
} else {
bg = 0xFFFFFF10;
}
} else {
if (colomn%2==0) {
bg = 0xBFBFBFFF;
} else {
bg = 0xCFCFCFFF;
}
}
if (m_selectedLine == raw) {
if (colomn%2==0) {
bg = 0x8F8FFFFF;
} else {
bg = 0x7F7FFFFF;
}
}
return true;
};
bool appl::TagFileList::OnItemEvent(int32_t IdInput, ewol::eventInputType_te typeEvent, int32_t colomn, int32_t raw, float x, float y)
{
if (typeEvent == ewol::EVENT_INPUT_TYPE_SINGLE) {
EWOL_INFO("Event on List : IdInput=" << IdInput << " colomn=" << colomn << " raw=" << raw );
if (1 == IdInput) {
int32_t previousRaw = m_selectedLine;
if (raw > m_list.Size() ) {
m_selectedLine = -1;
} else {
m_selectedLine = raw;
}
const char * event = applEventCtagsListValidate;
if (previousRaw != m_selectedLine) {
event = applEventCtagsListSelect;
}
if( m_selectedLine >=0
&& m_selectedLine < m_list.Size()
&& NULL != m_list[m_selectedLine] ) {
GenerateEventId(event, etk::UString(m_list[raw]->fileLine)+":"+m_list[m_selectedLine]->filename);
} else {
GenerateEventId(applEventCtagsListUnSelect);
}
// need to regenerate the display of the list :
MarkToRedraw();
return true;
}
}
return false;
}
/**
* @brief Add a Ctags item on the curent list
* @param[in] file Compleate file name
* @param[in] jump line id
* @return ---
*/
void appl::TagFileList::Add(etk::UString& file, int32_t line)
{
appl::TagListElement *tmpFile = new appl::TagListElement(file, line);
if (NULL != tmpFile) {
m_list.PushBack(tmpFile);
}
MarkToRedraw();
}

View File

@@ -0,0 +1,84 @@
/**
*******************************************************************************
* @file TagFileList.h
* @brief Editeur De N'ours : Tags list display to jump (header)
* @author Edouard DUPIN
* @date 16/10/2012
* @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 __APPL_CTAGS_LIST_H__
#define __APPL_CTAGS_LIST_H__
#include <etk/Types.h>
#include <appl/Debug.h>
#include <ewol/widget/List.h>
extern const char * const applEventCtagsListSelect;
extern const char * const applEventCtagsListValidate;
extern const char * const applEventCtagsListUnSelect;
namespace appl {
class TagListElement {
public:
etk::UString filename;
int32_t fileLine;
TagListElement(etk::UString& file, int32_t line) : filename(file), fileLine(line) {};
~TagListElement(void) {};
};
class TagFileList : public ewol::List
{
private:
int32_t m_selectedLine;
etk::Vector<appl::TagListElement*> m_list;
public:
TagFileList(void);
~TagFileList(void);
// display API :
virtual draw::Color GetBasicBG(void);
uint32_t GetNuberOfColomn(void);
bool GetTitle(int32_t colomn, etk::UString &myTitle, draw::Color &fg, draw::Color &bg);
uint32_t GetNuberOfRaw(void);
bool GetElement(int32_t colomn, int32_t raw, etk::UString &myTextToWrite, draw::Color &fg, draw::Color &bg);
bool OnItemEvent(int32_t IdInput, ewol::eventInputType_te typeEvent, int32_t colomn, int32_t raw, float x, float y);
/**
* @brief Get the current Object type of the EObject
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
* @param[in] objectType type description
* @return true if the object is compatible, otherwise false
*/
const char * const GetObjectType(void) { return "TagFileList"; };
public:
/**
* @brief Add a Ctags item on the curent list
* @param[in] file Compleate file name
* @param[in] jump line id
* @return ---
*/
void Add(etk::UString& file, int32_t line);
};
};
#endif

View File

@@ -0,0 +1,229 @@
/**
*******************************************************************************
* @file TagFileSelection.cpp
* @brief Editeur De N'ours : Tags list selection to jump (sources)
* @author Edouard DUPIN
* @date 16/10/2012
* @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.
*
*******************************************************************************
*/
/**
*******************************************************************************
* @file ewol/widget/meta/FileChooser.cpp
* @brief ewol File chooser meta widget system (Sources)
* @author Edouard DUPIN
* @date 29/12/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 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
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <appl/Gui/TagFileSelection.h>
#include <ewol/widget/SizerHori.h>
#include <ewol/widget/SizerVert.h>
#include <ewol/widget/List.h>
#include <ewol/widget/Spacer.h>
#include <ewol/widget/Image.h>
#include <ewol/widget/WidgetManager.h>
#include <etk/Vector.h>
#include <etk/tool.h>
#include <ewol/widget/Button.h>
#include <ewol/widget/Label.h>
#include <ewol/ewol.h>
#undef __class__
#define __class__ "TagFileSelection"
extern const char * const applEventctagsSelection = "appl-event-ctags-validate";
extern const char * const applEventctagsCancel = "appl-event-ctags-cancel";
appl::TagFileSelection::TagFileSelection(void)
{
AddEventId(applEventctagsSelection);
AddEventId(applEventctagsCancel);
ewol::Label* myWidgetTitle = NULL;
ewol::Button* myWidgetValidate = NULL;
ewol::Button* myWidgetCancel = NULL;
ewol::SizerVert * mySizerVert = NULL;
ewol::SizerHori * mySizerHori = NULL;
ewol::Spacer * mySpacer = NULL;
#if defined(__TARGET_OS__Android)
SetDisplayRatio(0.90);
#elif defined(__TARGET_OS__Windows)
SetDisplayRatio(0.80);
#else
SetDisplayRatio(0.80);
#endif
mySizerVert = new ewol::SizerVert();
if (NULL == mySizerVert) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else {
mySizerVert->LockExpendContamination(true);
// set it in the pop-up-system :
SubWidgetSet(mySizerVert);
mySizerHori = new ewol::SizerHori();
if (NULL == mySizerHori) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else {
mySizerVert->SubWidgetAdd(mySizerHori);
mySpacer = new ewol::Spacer();
if (NULL == mySpacer) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else {
mySpacer->SetExpendX(true);
mySizerHori->SubWidgetAdd(mySpacer);
}
myWidgetValidate = new ewol::Button("Jump");
if (NULL == myWidgetValidate) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else {
myWidgetValidate->SetImage("icon/Load.svg");
myWidgetValidate->RegisterOnEvent(this, ewolEventButtonPressed, applEventctagsSelection);
mySizerHori->SubWidgetAdd(myWidgetValidate);
}
myWidgetCancel = new ewol::Button("Cancel");
if (NULL == myWidgetCancel) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else {
myWidgetCancel->SetImage("icon/Remove.svg");
myWidgetCancel->RegisterOnEvent(this, ewolEventButtonPressed, applEventctagsCancel);
mySizerHori->SubWidgetAdd(myWidgetCancel);
}
}
m_listTag = new appl::TagFileList();
if (NULL == m_listTag) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else {
m_listTag->RegisterOnEvent(this, applEventCtagsListValidate);
m_listTag->RegisterOnEvent(this, applEventCtagsListSelect);
m_listTag->RegisterOnEvent(this, applEventCtagsListUnSelect);
m_listTag->SetExpendX(true);
m_listTag->SetExpendY(true);
m_listTag->SetFillX(true);
m_listTag->SetFillY(true);
mySizerVert->SubWidgetAdd(m_listTag);
}
myWidgetTitle = new ewol::Label("Ctags Jump Selection ...");
if (NULL == myWidgetTitle) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else {
mySizerVert->SubWidgetAdd(myWidgetTitle);
}
}
}
appl::TagFileSelection::~TagFileSelection(void)
{
}
/**
* @brief Receive a message from an other EObject with a specific eventId and data
* @param[in] CallerObject Pointer on the EObject that information came from
* @param[in] eventId Message registered by this class
* @param[in] data Data registered by this class
* @return ---
*/
void appl::TagFileSelection::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
{
EWOL_INFO("ctags LIST ... : \"" << eventId << "\" ==> data=\"" << data << "\"" );
if (eventId == applEventctagsSelection) {
if (m_eventNamed!="") {
GenerateEventId(applEventctagsSelection, m_eventNamed);
//==> Auto remove ...
AutoDestroy();
}
} else if (eventId == applEventCtagsListSelect) {
m_eventNamed = data;
} else if (eventId == applEventCtagsListUnSelect) {
m_eventNamed = "";
} else if (eventId == applEventCtagsListValidate) {
GenerateEventId(applEventctagsSelection, data);
//==> Auto remove ...
AutoDestroy();
} else if (eventId == applEventctagsCancel) {
GenerateEventId(applEventctagsCancel, "");
//==> Auto remove ...
AutoDestroy();
}
return;
};
/**
* @brief Add a Ctags item on the curent list
* @param[in] file Compleate file name
* @param[in] jump line id
* @return ---
*/
void appl::TagFileSelection::AddCtagsNewItem(etk::UString file, int32_t line)
{
if (NULL != m_listTag) {
m_listTag->Add(file, line);
}
}
/**
* @brief Inform object that an other object is removed ...
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
* @note : Sub classes must call this class
* @return ---
*/
void appl::TagFileSelection::OnObjectRemove(ewol::EObject * removeObject)
{
// First step call parrent :
ewol::PopUp::OnObjectRemove(m_listTag);
// second step find if in all the elements ...
if(removeObject == m_listTag) {
m_listTag = NULL;
}
}

View File

@@ -0,0 +1,81 @@
/**
*******************************************************************************
* @file TagFileSelection.h
* @brief Editeur De N'ours : Tags list selection to jump (header)
* @author Edouard DUPIN
* @date 16/10/2012
* @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 __APPL_CTAGS_SELECTION_H__
#define __APPL_CTAGS_SELECTION_H__
#include <etk/Types.h>
#include <appl/Debug.h>
#include <ewol/widget/PopUp.h>
#include <appl/Gui/TagFileList.h>
extern const char * const applEventctagsSelection;
extern const char * const applEventctagsCancel;
namespace appl {
class TagFileSelection : public ewol::PopUp
{
private:
appl::TagFileList* m_listTag;
etk::UString m_eventNamed;
public:
TagFileSelection(void);
virtual ~TagFileSelection(void);
/**
* @brief Get the current Object type of the EObject
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
* @param[in] objectType type description
* @return true if the object is compatible, otherwise false
*/
const char * const GetObjectType(void) { return "EwolFileChooser"; };
/**
* @brief Receive a message from an other EObject with a specific eventId and data
* @param[in] CallerObject Pointer on the EObject that information came from
* @param[in] eventId Message registered by this class
* @param[in] data Data registered by this class
* @return ---
*/
void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
/**
* @brief Inform object that an other object is removed ...
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
* @note : Sub classes must call this class
* @return ---
*/
void OnObjectRemove(ewol::EObject * removeObject);
/**
* @brief Add a Ctags item on the curent list
* @param[in] file Compleate file name
* @param[in] jump line id
* @return ---
*/
void AddCtagsNewItem(etk::UString file, int32_t line);
};
};
#endif

View File

@@ -0,0 +1,332 @@
/**
*******************************************************************************
* @file Highlight.c
* @brief Editeur De N'ours : Hightlightning Specific
* @author Edouard DUPIN
* @date 14/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 <appl/Debug.h>
#include <appl/global.h>
#include <Highlight.h>
#include <tinyXML/tinyxml.h>
#undef __class__
#define __class__ "Highlight"
void Highlight::ParseRules(TiXmlNode *child, etk::Vector<HighlightPattern*> &mListPatern, int32_t level)
{
// Create the patern ...
HighlightPattern *myPattern = new HighlightPattern();
// parse under Element
myPattern->ParseRules(child, level);
// add element in the list
mListPatern.PushBack(myPattern);
}
Highlight::Highlight(etk::UString &xmlFilename)
{
TiXmlDocument XmlDocument;
etk::FSNode fileName(etk::UString("DATA:") + xmlFilename);
if (false == fileName.Exist()) {
APPL_ERROR("File Does not exist : " << fileName);
return;
}
int32_t fileSize = fileName.FileSize();
if (0==fileSize) {
APPL_ERROR("This file is empty : " << fileName);
return;
}
if (false == fileName.FileOpenRead()) {
APPL_ERROR("Can not open the file : " << fileName);
return;
}
// allocate data
char * fileBuffer = new char[fileSize+5];
if (NULL == fileBuffer) {
APPL_ERROR("Error Memory allocation size=" << fileSize);
return;
}
memset(fileBuffer, 0, (fileSize+5)*sizeof(char));
// load data from the file :
fileName.FileRead(fileBuffer, 1, fileSize);
// close the file:
fileName.FileClose();
// load the XML from the memory
bool loadError = XmlDocument.Parse((const char*)fileBuffer, 0, TIXML_ENCODING_UTF8);
if (false == loadError) {
APPL_ERROR( "can not load Hightlight XML: PARSING error: \"" << xmlFilename << "\"");
return;
}
TiXmlElement* root = XmlDocument.FirstChildElement( "EdnLang" );
if (NULL == root) {
APPL_ERROR( "can not load Hightlight XML: main node not find: \"EdnLang\"");
return;
}
int32_t level1 = 0;
int32_t level2 = 0;
TiXmlNode * child = root->FirstChild();
while(NULL != child)
{
if (child->Type()==TiXmlNode::TINYXML_COMMENT) {
// nothing to do ...
} else if (!strcmp(child->Value(), "ext")) {
const char *myData = child->ToElement()->GetText();
if (NULL != myData) {
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", child->Row(), child->Value() , myData);
etk::UString * myEdnData = new etk::UString(myData);
m_listExtentions.PushBack(myEdnData);
}
} else if (!strcmp(child->Value(), "pass1")) {
// Get sub Nodes ...
TiXmlNode *passChild = child->FirstChild();
while (NULL != passChild) {
if (passChild->Type()==TiXmlNode::TINYXML_COMMENT) {
// nothing to do ...
} else if (!strcmp(passChild->Value(), "rule")) {
ParseRules(passChild, m_listHighlightPass1, level1++);
} else {
APPL_ERROR("(l "<< passChild->Row() << ") node not suported : \""<< passChild->Value() << "\" must be [rule]" );
}
// get the next node element :
passChild = passChild->NextSibling();
}
} else if (!strcmp(child->Value(), "pass2")) {
// Get sub Nodes ...
TiXmlNode *passChild = child->FirstChild();
while (NULL != passChild) {
if (passChild->Type()==TiXmlNode::TINYXML_COMMENT) {
// nothing to do ...
} else if (!strcmp(passChild->Value(), "rule")) {
ParseRules(passChild, m_listHighlightPass2, level2++);
} else {
APPL_ERROR("(l "<< passChild->Row() << ") node not suported : \""<< passChild->Value() << "\" must be [rule]" );
}
// get the next node element :
passChild = passChild->NextSibling();
}
} else {
APPL_ERROR("(l "<< child->Row() << ") node not suported : \""<< child->Value() << "\" must be [ext,pass1,pass2]" );
}
// get the next node element :
child = child->NextSibling();
}
if (NULL != fileBuffer) {
delete[] fileBuffer;
}
}
Highlight::~Highlight(void)
{
int32_t i;
// clean all Element
for (i=0; i< m_listHighlightPass1.Size(); i++) {
if (NULL != m_listHighlightPass1[i]) {
delete(m_listHighlightPass1[i]);
m_listHighlightPass1[i] = NULL;
}
}
// clear the compleate list
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(etk::UString &ext)
{
int32_t i;
for (i=0; i<m_listExtentions.Size(); i++) {
if (ext == *m_listExtentions[i] ) {
return true;
}
}
return false;
}
bool Highlight::FileNameCompatible(etk::FSNode &fileName)
{
int32_t i;
etk::UString extention;
if (true == fileName.FileHasExtention() ) {
extention = "*.";
extention += fileName.FileGetExtention();
} else {
extention = fileName.GetNameFile();
}
APPL_DEBUG(" try to find : in \"" << fileName << "\" extention:\"" << extention << "\" ");
for (i=0; i<m_listExtentions.Size(); i++) {
if (extention == *m_listExtentions[i] ) {
return true;
}
}
return false;
}
void Highlight::Display(void)
{
int32_t i;
APPL_INFO("List of ALL Highlight : ");
for (i=0; i< m_listExtentions.Size(); i++) {
APPL_INFO(" Extention : " << i << " : " << *m_listExtentions[i] );
}
// Display all elements
for (i=0; i< m_listHighlightPass1.Size(); i++) {
APPL_INFO(" " << i << " Pass 1 : " << m_listHighlightPass1[i]->GetName() );
//m_listHighlightPass1[i]->Display();
}
// Display all elements
for (i=0; i< m_listHighlightPass2.Size(); i++) {
APPL_INFO(" " << i << " Pass 2 : " << m_listHighlightPass2[i]->GetName() );
//m_listHighlightPass2[i]->Display();
}
}
// 13h 46min 22s | (l= 214) Highlight::Parse | [II] Find Pattern in the Buffer : (2457,2479)
// 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,
etk::Vector<colorInformation_ts> &metaData,
int32_t addingPos,
EdnVectorBuf &buffer)
{
if (0 > addingPos) {
addingPos = 0;
}
//APPL_DEBUG("Parse element 0 => " << m_listHighlightPass1.Size() << " ==> position search: (" << start << "," << stop << ")" );
int32_t elementStart = start;
int32_t elementStop = stop;
colorInformation_ts resultat;
while (elementStart<elementStop) {
//APPL_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;
//APPL_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) {
//APPL_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
//APPL_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 ...
metaData.Insert(addingPos, resultat);
//APPL_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
elementStart = resultat.endStop-1;
// increment the position of insertion:
addingPos++;
// We find a pattern ==> Stop search for the current element
break;
}
}
// Go to the next element (and search again ...).
elementStart++;
}
}
/**
* @brief second pass of the hightlight
*
*/
void Highlight::Parse2(int32_t start,
int32_t stop,
etk::Vector<colorInformation_ts> &metaData,
EdnVectorBuf &buffer)
{
//APPL_DEBUG("Parse element 0 => " << m_listHighlightPass2.size() << " ==> position search: (" << start << "," << stop << ")" );
int32_t elementStart = start;
int32_t elementStop = stop;
colorInformation_ts resultat;
while (elementStart<elementStop) {
//APPL_DEBUG("Parse element in the buffer id=" << elementStart);
//try to fond the HL in ALL of we have
int32_t jjj;
for (jjj=0; jjj<m_listHighlightPass2.Size(); jjj++){
resultFind_te ret = HLP_FIND_OK;
//APPL_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) {
//APPL_INFO("Find Pattern in the Buffer : (" << resultat.beginStart << "," << resultat.endStop << ")" );
// Add curent element in the list ...
metaData.PushBack(resultat);
elementStart = resultat.endStop-1;
// Exit current cycle
break;
}
}
// Go to the next element (and search again ...).
elementStart++;
}
}

View File

@@ -38,34 +38,40 @@ extern "C" {
int32_t endStart;
int32_t endStop;
bool notEnded;
HighlightPattern * patern; // pointer on class :
HighlightPattern * patern; // pointer on class :
} colorInformation_ts;
}
#include <vector>
#include "HighlightPattern.h"
#include "Colorize.h"
#include "Edn.h"
#include "EdnVectorBuf.h"
#include "tinyxml.h"
#include <etk/os/FSNode.h>
#include <HighlightPattern.h>
#include <Colorize.h>
#include <EdnVectorBuf.h>
#include <tinyXML/tinyxml.h>
class Highlight {
public:
// Constructeur
Highlight(Edn::String &xmlFilename);
Highlight(etk::UString &xmlFilename);
~Highlight(void);
bool HasExtention(Edn::String &ext);
bool FileNameCompatible(Edn::String &fileName);
bool HasExtention(etk::UString &ext);
bool FileNameCompatible(etk::FSNode &fileName);
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 Parse2(int32_t start, int32_t stop, std::vector<colorInformation_ts> &metaData, EdnVectorBuf &buffer, int32_t elementID=0);
void ReloadColor(void);
void Parse(int32_t start,
int32_t stop,
etk::Vector<colorInformation_ts> &metaData,
int32_t addingPos,
EdnVectorBuf &buffer);
void Parse2(int32_t start,
int32_t stop,
etk::Vector<colorInformation_ts> &metaData,
EdnVectorBuf &buffer);
private:
void ParseRules(TiXmlNode *child, std::vector<HighlightPattern*> &mListPatern, int32_t level);
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"
std::vector<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)) )
void ParseRules(TiXmlNode *child, etk::Vector<HighlightPattern*> &mListPatern, int32_t level);
etk::UString m_styleName; //!< curent style name (like "c++" or "c" or "script Bash")
etk::Vector<etk::UString*> m_listExtentions; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h"
etk::Vector<HighlightPattern*> m_listHighlightPass1; //!< List of ALL hightlight modules (pass 1 ==> when we load and wride data on the buffer)
etk::Vector<HighlightPattern*> m_listHighlightPass2; //!< List of ALL hightlight modules (pass 2 ==> When we display the buffer( only the display area (100 lines)) )
};

View File

@@ -0,0 +1,221 @@
/**
*******************************************************************************
* @file HighlightManager.cpp
* @brief Editeur De N'ours : Hightlining Manager
* @author Edouard DUPIN
* @date 16/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 <appl/Debug.h>
#include <appl/global.h>
#include <HighlightManager.h>
#include <ewol/eObject/EObject.h>
#include <ewol/eObject/EObjectManager.h>
#undef __class__
#define __class__ "HighlightManager"
class localClassHighlightManager: public ewol::EObject
{
private:
etk::Vector<Highlight*> listHighlight; //!< List of ALL hightlight modules
public:
// Constructeur
localClassHighlightManager(void) {
//ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferColor);
};
~localClassHighlightManager(void) {
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();
};
/**
* @brief Get the current Object type of the EObject
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
* @param[in] objectType type description
* @return true if the object is compatible, otherwise false
*/
const char * const GetObjectType(void)
{
return "ApplHighlightManager";
}
/**
* @brief Receive a message from an other EObject with a specific eventId and data
* @param[in] CallerObject Pointer on the EObject that information came from
* @param[in] eventId Message registered by this class
* @param[in] data Data registered by this class
* @return ---
*/
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
{
/*
switch (id)
{
case APPL_MSG__COLOR_HAS_CHANGE:
APPL_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* Get(etk::FSNode &fileName)
{
int32_t i;
for (i=0; i<listHighlight.Size(); i++) {
if (true == listHighlight[i]->FileNameCompatible(fileName) ) {
return listHighlight[i];
}
}
return NULL;
}
bool Exist(etk::FSNode &fileName)
{
if (NULL != Get(fileName) ) {
return true;
}
return false;
}
void loadLanguages(void)
{
etk::UString xmlFilename = "lang_c.xml";
Highlight *myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "lang_boo.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "lang_Makefile.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "lang_asm.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "lang_xml.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "lang_php.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "lang_bash.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "lang_matlab.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "lang_java.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "lang_lua.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "lang_in.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "lang_glsl.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
//myHightline->Display();
}
};
#define EDN_CAST_HIGHLIGHT_MANAGER(curentPointer) EWOL_CAST(TYPE_EOBJECT_EDN_HIGHLIGHT_MANAGER,localClassHighlightManager,curentPointer)
static localClassHighlightManager * localManager = NULL;
void HighlightManager::Init(void)
{
if (NULL != localManager) {
APPL_ERROR("HighlightManager ==> already exist, just unlink the previous ...");
localManager = NULL;
}
localManager = new localClassHighlightManager();
if (NULL == localManager) {
APPL_CRITICAL("Allocation of HighlightManager not done ...");
}
}
void HighlightManager::UnInit(void)
{
if (NULL == localManager) {
APPL_ERROR("HighlightManager ==> request UnInit, but does not exist ...");
return;
}
delete(localManager);
localManager = NULL;
}
void HighlightManager::loadLanguages(void)
{
if (NULL == localManager) {
return;
}
localManager->loadLanguages();
}
Highlight* HighlightManager::Get(etk::FSNode &fileName)
{
if (NULL == localManager) {
return NULL;
}
return localManager->Get(fileName);
}
bool HighlightManager::Exist(etk::FSNode &fileName)
{
if (NULL == localManager) {
return false;
}
return localManager->Exist(fileName);
}

View File

@@ -26,31 +26,20 @@
#ifndef __HIGHLIGHT_MANAGER_H__
#define __HIGHLIGHT_MANAGER_H__
class HighlightManager;
#include "Singleton.h"
#include <vector>
#include <string>
#include "Highlight.h"
#include <etk/UString.h>
#include <appl/globalMsg.h>
#include <Highlight.h>
#include <ewol/widget/Widget.h>
class HighlightManager: public Singleton<HighlightManager>
{
friend class Singleton<HighlightManager>;
// specific for sigleton system...
private:
// Constructeur
HighlightManager(void);
~HighlightManager(void);
public:
void loadLanguages(void);
Highlight * Get(Edn::String &fileName);
bool Exist(Edn::String &fileName);
private:
std::vector<Highlight*> listHighlight; //!< List of ALL hightlight modules
namespace HighlightManager{
void Init(void);
void UnInit(void);
void loadLanguages(void);
Highlight* Get(etk::FSNode &fileName);
bool Exist(etk::FSNode &fileName);
};
#endif

View File

@@ -22,10 +22,10 @@
*
*******************************************************************************
*/
#include "tools_debug.h"
#include "tools_globals.h"
#include "HighlightPattern.h"
#include "ColorizeManager.h"
#include <appl/Debug.h>
#include <appl/global.h>
#include <HighlightPattern.h>
#include <ColorizeManager.h>
#undef __class__
@@ -37,10 +37,9 @@ HighlightPattern::HighlightPattern(void)
{
m_haveStopPatern = false;
m_multiline = false;
ColorizeManager *myColorManager = ColorizeManager::getInstance();
m_color = myColorManager->Get("normal");
m_regExpStart = new EdnRegExp<EdnVectorBuf>();
m_regExpStop = new EdnRegExp<EdnVectorBuf>();
m_color = ColorizeManager::Get("normal");
m_regExpStart = new etk::RegExp<EdnVectorBuf>();
m_regExpStop = new etk::RegExp<EdnVectorBuf>();
m_escapeChar = 0;
}
@@ -50,12 +49,12 @@ HighlightPattern::~HighlightPattern(void)
delete(m_regExpStop);
}
void HighlightPattern::SetPaternStart(Edn::String &regExp)
void HighlightPattern::SetPaternStart(etk::UString &regExp)
{
m_regExpStart->SetRegExp(regExp);
}
void HighlightPattern::SetPaternStop(Edn::String &regExp)
void HighlightPattern::SetPaternStop(etk::UString &regExp)
{
if (regExp.Size() != 0) {
m_regExpStop->SetRegExp(regExp);
@@ -65,21 +64,20 @@ void HighlightPattern::SetPaternStop(Edn::String &regExp)
}
}
void HighlightPattern::SetEscapeChar(Edn::String &EscapeChar)
void HighlightPattern::SetEscapeChar(etk::UString &EscapeChar)
{
if (EscapeChar.Size()>0) {
m_escapeChar = EscapeChar.c_str()[0];
m_escapeChar = EscapeChar[0];
} else {
m_escapeChar = 0;
}
}
void HighlightPattern::SetColor(Edn::String &colorName)
void HighlightPattern::SetColor(etk::UString &colorName)
{
m_colorName = colorName;
ColorizeManager *myColorManager = ColorizeManager::getInstance();
m_color = myColorManager->Get(m_colorName);
m_color = ColorizeManager::Get(m_colorName);
}
bool HighlightPattern::IsEnable(void)
@@ -87,6 +85,12 @@ bool HighlightPattern::IsEnable(void)
return true;
}
void HighlightPattern::ReloadColor(void)
{
m_color = ColorizeManager::Get(m_colorName);
}
/**
* @brief
*
@@ -98,24 +102,24 @@ bool HighlightPattern::IsEnable(void)
void HighlightPattern::Display(void)
{
/*
EDN_INFO("patern : \"" << m_paternName.c_str() << "\" level=" << m_level );
EDN_INFO(" ==> colorName \"" << m_colorName.c_str() << "\"");
EDN_INFO(" ==> regExpStart \"" << m_regExpStart->GetRegExp().c_str() << "\"");
EDN_INFO(" ==> regExpStop \"" << m_regExpStop->GetRegExp().c_str() << "\"");
APPL_INFO("patern : \"" << m_paternName << "\" level=" << m_level );
APPL_INFO(" ==> colorName \"" << m_colorName << "\"");
APPL_INFO(" ==> regExpStart \"" << m_regExpStart->GetRegExp() << "\"");
APPL_INFO(" ==> regExpStop \"" << m_regExpStop->GetRegExp() << "\"");
if (true == m_haveStopPatern) {
EDN_INFO(" ==> stop pattern: YES");
APPL_INFO(" ==> stop pattern: YES");
} else {
EDN_INFO(" ==> stop pattern: NO");
APPL_INFO(" ==> stop pattern: NO");
}
if (true == m_multiline) {
EDN_INFO(" ==> multiline pattern: YES");
APPL_INFO(" ==> multiline pattern: YES");
} else {
EDN_INFO(" ==> multiline pattern: NO");
APPL_INFO(" ==> multiline pattern: NO");
}
*/
// Display all elements
for (int32_t i=0; i< m_subPatern.Size(); i++) {
EDN_INFO(" " << i << " SubPattern : " << m_subPatern[i]->GetName().c_str() );
APPL_INFO(" " << i << " SubPattern : " << m_subPatern[i]->GetName() );
m_subPatern[i]->Display();
}
}
@@ -133,7 +137,7 @@ void HighlightPattern::ParseRules(TiXmlNode *child, int32_t level)
//--------------------------------------------------------------------------------------------
// process attribute
const char *highLightName = child->ToElement()->Attribute("name");
Edn::String myEdnDataTmp = "???";
etk::UString myEdnDataTmp = "???";
if (NULL != highLightName) {
myEdnDataTmp = highLightName;
}
@@ -144,8 +148,8 @@ void HighlightPattern::ParseRules(TiXmlNode *child, int32_t level)
if (NULL != xChild) {
const char *myData = xChild->GetText();
if (myData) {
//EDN_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
Edn::String myEdnData = myData;
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
etk::UString myEdnData = myData;
SetColor(myEdnData);
}
}
@@ -153,8 +157,8 @@ void HighlightPattern::ParseRules(TiXmlNode *child, int32_t level)
if (NULL != xChild) {
const char *myData = xChild->GetText();
if (myData) {
//EDN_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
Edn::String myEdnData = myData;
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
etk::UString myEdnData = myData;
SetPaternStart(myEdnData);
}
}
@@ -162,8 +166,8 @@ void HighlightPattern::ParseRules(TiXmlNode *child, int32_t level)
if (NULL != xChild) {
const char *myData = xChild->GetText();
if (myData) {
//EDN_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
Edn::String myEdnData = myData;
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
etk::UString myEdnData = myData;
SetPaternStop(myEdnData);
}
}
@@ -171,8 +175,8 @@ void HighlightPattern::ParseRules(TiXmlNode *child, int32_t level)
if (NULL != xChild) {
const char *myData = xChild->GetText();
if (myData) {
//EDN_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
Edn::String myEdnData = myData;
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
etk::UString myEdnData = myData;
SetEscapeChar(myEdnData);
}
}
@@ -190,9 +194,22 @@ 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)
{
//EDN_DEBUG(" try to find the element");
//APPL_DEBUG(" try to find the element");
resultat.beginStart = -1;
resultat.beginStop = -1;
resultat.endStart = -1;
@@ -202,17 +219,17 @@ resultFind_te HighlightPattern::Find(int32_t start, int32_t stop, colorInformati
// when we have only one element :
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.beginStop = m_regExpStart->Stop();
resultat.endStart = m_regExpStart->Start();
resultat.endStop = m_regExpStart->Stop();
return HLP_FIND_OK;
}
//EDN_DEBUG("NOT find hightlightpatern ...");
//APPL_DEBUG("NOT find hightlightpatern ...");
} else {
// 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.beginStop = m_regExpStart->Stop();
if (true == m_regExpStop->Process(buffer, resultat.beginStop, stop, m_escapeChar)) {
@@ -226,7 +243,7 @@ resultFind_te HighlightPattern::Find(int32_t start, int32_t stop, colorInformati
return HLP_FIND_OK_NO_END;
}
}
//EDN_DEBUG("NOT find start hightlightpatern ...");
//APPL_DEBUG("NOT find start hightlightpatern ...");
}
return HLP_FIND_ERROR;
}

View File

@@ -23,19 +23,19 @@
*******************************************************************************
*/
#include "Highlight.h"
#include <Highlight.h>
#ifndef __HIGHLIGHT_PATTERN_H__
#define __HIGHLIGHT_PATTERN_H__
class HighlightPattern;
#include "Edn.h"
#include "RegExp.h"
#include "Colorize.h"
#include "VectorType.h"
#include "tinyxml.h"
#include "EdnVectorBuf.h"
#include <etk/RegExp.h>
#include <Colorize.h>
#include <etk/Vector.h>
#include <tinyXML/tinyxml.h>
#include <EdnVectorBuf.h>
typedef enum {
HLP_FIND_ERROR,
@@ -51,36 +51,38 @@ class HighlightPattern {
HighlightPattern(void);
~HighlightPattern(void);
void SetName(Edn::String &name) { m_paternName = name;};
Edn::String GetName(void) { return m_paternName;};
void SetName(etk::UString &name) { m_paternName = name;};
etk::UString GetName(void) { return m_paternName;};
void SetPaternStart(Edn::String &regExp);
void SetPaternStop(Edn::String &regExp);
void SetColor(Edn::String &colorName);
void SetEscapeChar(Edn::String &EscapeChar);
void SetMultiline(bool enable) { m_multiline = enable; };
void SetPaternStart(etk::UString &regExp);
void SetPaternStop(etk::UString &regExp);
void SetColor(etk::UString &colorName);
void SetEscapeChar(etk::UString &EscapeChar);
void SetMultiline(bool enable) { m_multiline = enable; };
void SetLevel(int32_t newLevel) { m_level = newLevel; };
int32_t GetLevel(void) { return m_level; };
void SetLevel(int32_t newLevel) { m_level = newLevel; };
int32_t GetLevel(void) { return m_level; };
bool IsEnable(void);
void Display(void);
resultFind_te Find(int32_t start, int32_t stop, colorInformation_ts &resultat, EdnVectorBuf &buffer);
Colorize * GetColor(void) { return m_color; };
void ParseRules(TiXmlNode *child, int32_t level);
bool IsEnable(void);
void Display(void);
resultFind_te Find(int32_t start, int32_t stop, colorInformation_ts &resultat, EdnVectorBuf &buffer);
Colorize * GetColor(void) { return m_color; };
void ParseRules(TiXmlNode *child, int32_t level);
void ReloadColor(void);
private:
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_colorName; //!< Current color name
etk::UString m_paternName; //!< Current style name (like "c++" or "c" or "script Bash")
etk::UString m_colorName; //!< Current color name
Colorize * m_color; //!< Link to the color manager
EdnRegExp<EdnVectorBuf> * m_regExpStart; //!< Start of Regular expression
EdnRegExp<EdnVectorBuf> * m_regExpStop; //!< Stop of Regular Expression
etk::RegExp<EdnVectorBuf> * m_regExpStart; //!< Start of Regular expression
etk::RegExp<EdnVectorBuf> * m_regExpStop; //!< Stop of Regular Expression
bool m_haveStopPatern; //!< Stop patern presence
bool m_multiline; //!< The patern is multiline
char m_escapeChar; //!< Escape char to prevent exeit of patern ....
Edn::VectorType<HighlightPattern *> m_subPatern; //!< Under patern of this one
// Edn::VectorType<HighlightPattern *> m_subColor; //!< Under Color in the start RegExp ...
uniChar_t m_escapeChar; //!< Escape char to prevent exeit of patern ....
etk::Vector<HighlightPattern *> m_subPatern; //!< Under patern of this one
// etk::Vector<HighlightPattern *> m_subColor; //!< Under Color in the start RegExp ...
};
#endif

View File

@@ -0,0 +1,313 @@
/**
*******************************************************************************
* @file CTagsManager.cpp
* @brief Editeur De N'ours : Ctags manager : acces to the ctags file (Sources)
* @author Edouard DUPIN
* @date 15/07/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 <appl/Debug.h>
#include <appl/global.h>
#include <CTagsManager.h>
#include <BufferManager.h>
#include <ewol/eObject/EObject.h>
#include <ewol/widget/meta/FileChooser.h>
#include <appl/Gui/TagFileSelection.h>
// TODO : The line ID is no more stored in the file system (FSNode) ...
#undef __class__
#define __class__ "CTagsManager"
class CTagsManager: public ewol::EObject
{
public:
// Constructeur
CTagsManager(void);
~CTagsManager(void);
/**
* @brief Get the current Object type of the EObject
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
* @param[in] objectType type description
* @return true if the object is compatible, otherwise false
*/
const char * const GetObjectType(void)
{
return "CTagsManager";
};
/**
* @brief Receive a message from an other EObject with a specific eventId and data
* @param[in] CallerObject Pointer on the EObject that information came from
* @param[in] eventId Message registered by this class
* @param[in] data Data registered by this class
* @return ---
*/
void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
int32_t m_currentSelectedID;
void LoadTagFile(void);
int32_t MultipleJump(void);
void JumpTo(void);
void PrintTag(const tagEntry *entry);
etk::UString GetFolder(etk::UString &inputString);
etk::UString m_tagFolderBase;
etk::UString m_tagFilename;
tagFile * m_ctagFile;
// history system
int32_t m_historyPos;
etk::Vector<etk::FSNode*> m_historyList;
void RegisterHistory(void);
};
static CTagsManager* s_elementPointer = NULL;
void cTagsManager::Init(void)
{
if (NULL != s_elementPointer) {
s_elementPointer = NULL;
EWOL_WARNING("Ctags manager already instanciate ... ==> restart IT (can have memory leek ...)");
}
s_elementPointer = new CTagsManager();
if (NULL == s_elementPointer) {
EWOL_ERROR("Ctags manager error to instanciate ...");
}
}
void cTagsManager::UnInit(void)
{
if (NULL != s_elementPointer) {
delete(s_elementPointer);
s_elementPointer = NULL;
} else {
EWOL_ERROR("Ctags manager not instanciate ... ==> can not remove it ...");
}
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
CTagsManager::CTagsManager(void)
{
m_tagFilename = "";
m_tagFolderBase = "";
m_ctagFile = NULL;
m_historyPos = 0;
RegisterMultiCast(ednMsgGuiCtags);
RegisterMultiCast(ednMsgBufferId);
RegisterMultiCast(ednMsgCtagsLoadFile);
EWOL_INFO("Ctags manager (INIT)");
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
CTagsManager::~CTagsManager(void)
{
EWOL_INFO("Ctags manager (Un-INIT)");
if(0 != m_historyList.Size()) {
for (int32_t iii=0; iii< m_historyList.Size(); iii++) {
delete(m_historyList[iii]);
}
m_historyList.Clear();
}
}
const char * ednEventPopUpCtagsLoadFile = "edn-event-load-ctags";
void CTagsManager::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
{
//EWOL_INFO("ctags manager event ... : \"" << eventId << "\" ==> data=\"" << data << "\"" );
if (eventId == ednMsgBufferId) {
//m_currentSelectedID = dataID;
} else if( eventId == ednEventPopUpCtagsLoadFile
|| eventId == ednMsgCtagsLoadFile) {
// open the new one :
etk::FSNode tmpFilename = data;
m_tagFilename = tmpFilename.GetNameFile();
m_tagFolderBase = tmpFilename.GetNameFolder();
APPL_DEBUG("Receive load Ctags file : " << m_tagFolderBase << "/" << m_tagFilename << " ");
LoadTagFile();
} else if (eventId == ednMsgGuiCtags) {
if (data == "Load") {
APPL_INFO("Request opening ctag file");
ewol::FileChooser* tmpWidget = new ewol::FileChooser();
if (NULL == tmpWidget) {
APPL_ERROR("Can not allocate widget ==> display might be in error");
} else {
tmpWidget->SetTitle("Open Exuberant Ctags File");
tmpWidget->SetValidateLabel("Open");
PopUpWidgetPush(tmpWidget);
tmpWidget->RegisterOnEvent(this, ewolEventFileChooserValidate, ednEventPopUpCtagsLoadFile);
}
} else if (data == "ReLoad") {
APPL_INFO("Request re-load ctag file");
LoadTagFile();
} else if (data == "Jump") {
JumpTo();
} else if (data == "Back") {
if (m_historyList.Size() > 0) {
int32_t id = m_historyList.Size()-1;
SendMultiCast(ednMsgOpenFile, m_historyList[id]->GetName() );
SendMultiCast(ednMsgGuiGotoLine, 0);// TODO : m_historyList[id]->GetLineNumber());
// Remove element ....
delete(m_historyList[id]);
m_historyList[id]=NULL;
m_historyList.PopBack();
}
} else {
}
} else if (eventId == applEventctagsSelection) {
// save the current file in the history
RegisterHistory();
// parse the input data
char tmp[4096];
int32_t lineID;
sscanf(data.c_str(), "%d:%s", &lineID, tmp);
// generate envents
SendMultiCast(ednMsgOpenFile, tmp);
SendMultiCast(ednMsgGuiGotoLine, lineID - 1);
}
}
void CTagsManager::LoadTagFile(void)
{
tagFileInfo info;
// close previous tag file
if (NULL != m_ctagFile) {
tagsClose(m_ctagFile);
m_ctagFile = NULL;
}
if (m_tagFilename == "") {
return;
}
// load (open) the tag file :
APPL_INFO("try to open tag file : " << m_tagFilename);
m_ctagFile = tagsOpen(m_tagFilename.c_str(), &info);
if (NULL != m_ctagFile) {
APPL_INFO("open exuberant Ctags file is OK ...");
} else {
APPL_INFO("Error to open ctags file ...");
}
}
void CTagsManager::RegisterHistory(void)
{
APPL_INFO("save curent filename and position : ");
int32_t currentSelected = BufferManager::GetSelected();
Buffer* tmpBuf = BufferManager::Get(currentSelected);
if (NULL != tmpBuf) {
etk::FSNode * bufferFilename = new etk::FSNode();
*bufferFilename = tmpBuf->GetFileName();
// TODO : bufferFilename->SetLineNumber(tmpBuf->GetCurrentLine());
m_historyList.PushBack(bufferFilename);
}
}
void CTagsManager::JumpTo(void)
{
if (NULL != m_ctagFile) {
// get the middle button of the clipboard ==> represent the current selection ...
etk::UString data = ewol::clipBoard::Get(ewol::clipBoard::CLIPBOARD_SELECTION);
APPL_DEBUG("clipboard data : \"" << data << "\"");
if (data.Size() == 0) {
APPL_INFO("No current selection");
}
tagEntry entry;
APPL_INFO("try to find the tag : " << data);
if (tagsFind (m_ctagFile, &entry, data.c_str(), 0) == TagSuccess) {
tagEntry entrySave = entry;
int32_t numberOfTags = 0;
// For all tags : Save in an internal Structure :
etk::UString tmpFile(m_tagFolderBase + "/" + entry.file);
etk::FSNode myfile(tmpFile);
int32_t lineID = entry.address.lineNumber;
PrintTag(&entry);
if (tagsFindNext (m_ctagFile, &entry) == TagSuccess) {
APPL_INFO("Multiple file destination ...");
appl::TagFileSelection* tmpWidget = new appl::TagFileSelection();
if (NULL == tmpWidget) {
APPL_ERROR("Can not allocate widget ==> display might be in error");
} else {
tmpWidget->AddCtagsNewItem(myfile.GetName(), lineID);
do {
tmpFile = m_tagFolderBase + "/" + entry.file;
myfile = tmpFile;
lineID = entry.address.lineNumber;
PrintTag(&entry);
tmpWidget->AddCtagsNewItem(myfile.GetName(), lineID);
} while (tagsFindNext (m_ctagFile, &entry) == TagSuccess);
PopUpWidgetPush(tmpWidget);
tmpWidget->RegisterOnEvent(this, applEventctagsSelection);
}
} else {
RegisterHistory();
APPL_INFO(" OPEN the TAG file Destination : " << tmpFile );
SendMultiCast(ednMsgOpenFile, myfile.GetName());
SendMultiCast(ednMsgGuiGotoLine, lineID - 1);
}
} else {
APPL_INFO("no tag find ...");
}
}
}
void CTagsManager::PrintTag(const tagEntry *entry)
{
#if 1
APPL_INFO("find Tag file : name=\"" << entry->name << "\" in file=\"" << entry->file
<< "\" at line="<< (int32_t)entry->address.lineNumber);
#else
int i;
APPL_INFO("find Tag file : name=\"" << entry->name << "\" in file=\"" << entry->file
<< "\" pattern=\"" << entry->address.pattern
<< "\" at line="<< (int32_t)entry->address.lineNumber);
APPL_INFO("Extention field : ");
if (entry->kind != NULL && entry->kind [0] != '\0') {
APPL_INFO(" kind : " << entry->kind);
}
if (entry->fileScope) {
APPL_INFO(" file : ");
}
for (i = 0 ; i < entry->fields.count ; ++i) {
APPL_INFO(" " << entry->fields.list[i].key << ":" << entry->fields.list[i].value );
}
#endif
}

View File

@@ -1,9 +1,9 @@
/**
*******************************************************************************
* @file BufferEmpty.h
* @brief Editeur De N'ours : Text Buffer (edit For No buffer Display) (header)
* @file CTagsManager.h
* @brief Editeur De N'ours : Ctags manager : acces to the ctags file (header)
* @author Edouard DUPIN
* @date 19/01/2011
* @date 15/07/2011
* @par Project
* Edn
*
@@ -23,20 +23,21 @@
*******************************************************************************
*/
#ifndef __BUFFER_EMPTY_H__
#define __BUFFER_EMPTY_H__
#ifndef __C_TAGS_MANAGER_H__
#define __C_TAGS_MANAGER_H__
#include "Buffer.h"
class BufferEmpty : public Buffer {
public:
BufferEmpty(void);
virtual ~BufferEmpty(void);
virtual int32_t Display(DrawerManager &drawer);
#include <ewol/widget/Widget.h>
#include "appl/globalMsg.h"
#include "readtags.h"
#define MAX_REG_EXP_SEARCH (1024)
namespace cTagsManager
{
void Init(void);
void UnInit(void);
};
#endif

245
Sources/appl/global.cpp Normal file
View File

@@ -0,0 +1,245 @@
/**
*******************************************************************************
* @file tools_Globals.cpp
* @brief Editeur De N'ours : Globals Values
* @author Edouard DUPIN
* @date 05/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 <appl/global.h>
#include <ColorizeManager.h>
#include <appl/globalMsg.h>
#include <ewol/eObject/EObject.h>
#include <ewol/ResourceManager.h>
#include <etk/os/FSNode.h>
#undef __class__
#define __class__ "globals"
erreurCode_te globals::init(void)
{
erreurCode_te ret = ERR_NONE;
return ret;
}
// -----------------------------------------------------------
static bool displayEOL = false;
bool globals::IsSetDisplayEndOfLine(void)
{
return displayEOL;
}
void globals::SetDisplayEndOfLine(bool newVal)
{
APPL_INFO("Set EndOfLine " << newVal);
displayEOL = newVal;
//ewol::widgetMessageMultiCast::Send(-1, ednMsgUserDisplayChange);
}
// -----------------------------------------------------------
static bool displaySpaceChar = true;
bool globals::IsSetDisplaySpaceChar(void)
{
return displaySpaceChar;
}
void globals::SetDisplaySpaceChar(bool newVal)
{
APPL_INFO("Set SpaceChar " << newVal);
displaySpaceChar = newVal;
//ewol::widgetMessageMultiCast::Send(-1, ednMsgUserDisplayChange);
}
// -----------------------------------------------------------
static bool displayTabChar = true;
bool globals::IsSetDisplayTabChar(void)
{
return displayTabChar;
}
void globals::SetDisplayTabChar(bool newVal)
{
APPL_INFO("Set SpaceChar " << newVal);
displayTabChar = newVal;
//ewol::widgetMessageMultiCast::Send(-1, ednMsgUserDisplayChange);
}
// -----------------------------------------------------------
static bool AutoIndent = true;
bool globals::IsSetAutoIndent(void)
{
return AutoIndent;
}
void globals::SetAutoIndent(bool newVal)
{
APPL_INFO("Set AutoIndent " << newVal);
AutoIndent = newVal;
}
// -----------------------------------------------------------
bool globals::OrderTheBufferList(void)
{
return true;
}
// -----------------------------------------------------------
int32_t globals::getNbColoneBorder(void)
{
return 6;
}
int32_t globals::getNbLineBorder(void)
{
return 3;
}
#include <ewol/widget/CheckBox.h>
#include <ewol/widget/Spacer.h>
static const char * const l_changeIndentation = "edn-event-change-indentation";
static const char * const l_changeSpace = "edn-event-change-spaces";
static const char * const l_changeTabulation = "edn-event-change-tabulation";
static const char * const l_changeEndOfLine = "edn-event-change-endOfLine";
static const char * const l_changeRounded = "edn-event-change-rounded";
globals::ParameterGlobalsGui::ParameterGlobalsGui(void)
{
ewol::CheckBox* myCheckbox = NULL;
ewol::Spacer* mySpacer = NULL;
mySpacer = new ewol::Spacer();
if (NULL == mySpacer) {
APPL_ERROR("Can not allocate widget ==> display might be in error");
} else {
mySpacer->SetExpendX(true);
mySpacer->SetExpendY(true);
SubWidgetAdd(mySpacer);
}
myCheckbox = new ewol::CheckBox("Automatic Indentation");
if (NULL == myCheckbox) {
APPL_ERROR("Can not allocate widget ==> display might be in error");
} else {
myCheckbox->SetExpendX(true);
myCheckbox->SetValue(IsSetAutoIndent());
myCheckbox->RegisterOnEvent(this, ewolEventCheckBoxClicked, l_changeIndentation);
SubWidgetAdd(myCheckbox);
}
myCheckbox = new ewol::CheckBox("Display space char (' ')");
if (NULL == myCheckbox) {
APPL_ERROR("Can not allocate widget ==> display might be in error");
} else {
myCheckbox->SetExpendX(true);
myCheckbox->SetValue(IsSetDisplaySpaceChar());
myCheckbox->RegisterOnEvent(this, ewolEventCheckBoxClicked, l_changeSpace);
SubWidgetAdd(myCheckbox);
}
myCheckbox = new ewol::CheckBox("Display tabulation char ('\\t')");
if (NULL == myCheckbox) {
APPL_ERROR("Can not allocate widget ==> display might be in error");
} else {
myCheckbox->SetExpendX(true);
myCheckbox->SetValue(IsSetDisplayTabChar());
myCheckbox->RegisterOnEvent(this, ewolEventCheckBoxClicked, l_changeTabulation);
SubWidgetAdd(myCheckbox);
}
myCheckbox = new ewol::CheckBox("Display end of line ('\\n')");
if (NULL == myCheckbox) {
APPL_ERROR("Can not allocate widget ==> display might be in error");
} else {
myCheckbox->SetExpendX(true);
myCheckbox->SetValue(IsSetDisplayEndOfLine());
myCheckbox->RegisterOnEvent(this, ewolEventCheckBoxClicked, l_changeEndOfLine);
SubWidgetAdd(myCheckbox);
}
myCheckbox = new ewol::CheckBox("switch Rounded/default");
if (NULL == myCheckbox) {
APPL_ERROR("Can not allocate widget ==> display might be in error");
} else {
myCheckbox->SetExpendX(true);
myCheckbox->SetValue(IsSetDisplayEndOfLine());
myCheckbox->RegisterOnEvent(this, ewolEventCheckBoxClicked, l_changeRounded);
SubWidgetAdd(myCheckbox);
}
}
globals::ParameterGlobalsGui::~ParameterGlobalsGui(void)
{
}
/**
* @brief Receive a message from an other EObject with a specific eventId and data
* @param[in] CallerObject Pointer on the EObject that information came from
* @param[in] eventId Message registered by this class
* @param[in] data Data registered by this class
* @return ---
*/
void globals::ParameterGlobalsGui::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
{
ewol::SizerVert::OnReceiveMessage(CallerObject, eventId, data);
if (eventId == l_changeEndOfLine) {
if (data == "true") {
SetDisplayEndOfLine(true);
} else {
SetDisplayEndOfLine(false);
}
} else if (eventId == l_changeIndentation) {
if (data == "true") {
SetAutoIndent(true);
} else {
SetAutoIndent(false);
}
} else if (eventId == l_changeSpace) {
if (data == "true") {
SetDisplaySpaceChar(true);
} else {
SetDisplaySpaceChar(false);
}
} else if (eventId == l_changeTabulation) {
if (data == "true") {
SetDisplayTabChar(true);
} else {
SetDisplayTabChar(false);
}
} else if (eventId == l_changeRounded) {
if (data == "true") {
etk::theme::SetName("GUI", "rounded");;
} else {
etk::theme::SetName("GUI", "default");;
}
// Reload shaders and graphic system ...
ewol::resource::ReLoadResources();
}
}

View File

@@ -1,6 +1,6 @@
/**
*******************************************************************************
* @file tools_globals.h
* @file appl/global.h
* @brief Editeur De N'ours : Globals Values (header)
* @author Edouard DUPIN
* @date 05/12/2010
@@ -26,15 +26,16 @@
#ifndef __TOOLS_GLOBALS_H__
#define __TOOLS_GLOBALS_H__
#include "tools_debug.h"
#include <string>
#include <vector>
#include <appl/Debug.h>
#include <etk/Types.h>
#include <ewol/widget/SizerVert.h>
namespace globals
{
erreurCode_te init(void);
int32_t getNbColoneBorder(void);
int32_t getNbLineBorder(void);
erreurCode_te init(void);
int32_t getNbColoneBorder(void);
int32_t getNbLineBorder(void);
bool IsSetDisplayEndOfLine(void);
void SetDisplayEndOfLine(bool newVal);
@@ -42,28 +43,31 @@ namespace globals
bool IsSetDisplaySpaceChar(void);
void SetDisplaySpaceChar(bool newVal);
bool IsSetDisplayTabChar(void);
void SetDisplayTabChar(bool newVal);
bool IsSetAutoIndent(void);
void SetAutoIndent(bool newVal);
void init2(void);
void init2(void);
bool OrderTheBufferList(void);
class ParameterGlobalsGui : public ewol::SizerVert
{
public :
ParameterGlobalsGui(void);
~ParameterGlobalsGui(void);
/**
* @brief Receive a message from an other EObject with a specific eventId and data
* @param[in] CallerObject Pointer on the EObject that information came from
* @param[in] eventId Message registered by this class
* @param[in] data Data registered by this class
* @return ---
*/
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
};
void SetShift(void);
void UnSetShift(void);
bool IsSetShift(void);
void SetAlt(void);
void UnSetAlt(void);
bool IsSetAlt(void);
void SetCtrl(void);
void UnSetCtrl(void);
bool IsSetCtrl(void);
void SetPomme(void);
void UnSetPomme(void);
bool IsSetPomme(void);
void SetInsert(void);
void UnSetInsert(void);
void ToggleInsert(void);
bool IsSetInsert(void);
void DisplaySystemString(std::vector<int32_t> &data);
}
#endif

View File

@@ -0,0 +1,76 @@
/**
*******************************************************************************
* @file MsgBroadcast.cpp
* @brief Editeur De N'ours : message beetween thread and GUI elements ... (Souces)
* @author Edouard DUPIN
* @date 04/02/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 <appl/globalMsg.h>
////////////////////////////////////////////////////////////////////////
// Event of the gui request something :
////////////////////////////////////////////////////////////////////////
extern const char* const ednMsgGuiNew = "edn-Msg-Gui-New";
extern const char* const ednMsgGuiOpen = "edn-Msg-Gui-Open";
extern const char* const ednMsgGuiClose = "edn-Msg-Gui-Close";
extern const char* const ednMsgGuiSave = "edn-Msg-Gui-Save";
extern const char* const ednMsgGuiSaveAs = "edn-Msg-Gui-SaveAs";
extern const char* const ednMsgProperties = "edn-Msg-Gui-Properties";
extern const char* const ednMsgGuiUndo = "edn-Msg-Gui-Undo";
extern const char* const ednMsgGuiRedo = "edn-Msg-Gui-Redo";
extern const char* const ednMsgGuiCopy = "edn-Msg-Gui-Copy";
extern const char* const ednMsgGuiCut = "edn-Msg-Gui-Cut";
extern const char* const ednMsgGuiPaste = "edn-Msg-Gui-Paste";
extern const char* const ednMsgGuiRm = "edn-Msg-Gui-Rm";
extern const char* const ednMsgGuiSelect = "edn-Msg-Gui-Select";
extern const char* const ednMsgGuiGotoLine = "edn-Msg-Gui-GotoLine";
extern const char* const ednMsgGuiSearch = "edn-Msg-Gui-Search";
extern const char* const ednMsgGuiReplace = "edn-Msg-Gui-Replace";
extern const char* const ednMsgGuiFind = "edn-Msg-Gui-Find";
extern const char* const ednMsgGuiChangeColor = "edn-Msg-Gui-ChangeColor";
extern const char* const ednMsgGuiChangeCharset = "edn-Msg-Gui-ChangeCharset";
extern const char* const ednMsgGuiShowSpaces = "edn-Msg-Gui-ShowSpaces";
extern const char* const ednMsgGuiShowEndOfLine = "edn-Msg-Gui-ShowEndOfLine";
extern const char* const ednMsgGuiCtags = "edn-Msg-Gui-CTags";
extern const char* const ednMsgCtagsLoadFile = "edn-Msg-CTags-direct-load";
extern const char* const ednMsgGuiReloadShader = "edn-Msg-Gui-ReloadOpenGlShader";
////////////////////////////////////////////////////////////////////////
// Event internal :
////////////////////////////////////////////////////////////////////////
extern const char* const ednMsgBufferState = "edn-Msg-Buffer-State";
extern const char* const ednMsgBufferName = "edn-Msg-Buffer-Name";
extern const char* const ednMsgBufferId = "edn-Msg-Buffer-Id";
extern const char* const ednMsgCodeViewSelectedId = "edn-Msg-CodeView-Select-Id";
extern const char* const ednMsgOpenFile = "edn-Msg-OpenFile";
extern const char* const ednMsgBufferListChange = "edn-Msg-BufferListChange";
extern const char* const ednMsgBufferColor = "edn-Msg-Buffer-Color";

78
Sources/appl/globalMsg.h Normal file
View File

@@ -0,0 +1,78 @@
/**
*******************************************************************************
* @file appl/globalMsg.h
* @brief Editeur De N'ours : message beetween thread and GUI elements ... (header)
* @author Edouard DUPIN
* @date 04/02/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 __MSG_BROADCAST_H__
#define __MSG_BROADCAST_H__
////////////////////////////////////////////////////////////////////////
// Event of the gui request something :
////////////////////////////////////////////////////////////////////////
extern const char* const ednMsgGuiNew; // data : ""
extern const char* const ednMsgGuiOpen; // data : ""
extern const char* const ednMsgGuiClose; // data : "current" "All"
extern const char* const ednMsgGuiSave; // data : ""
extern const char* const ednMsgGuiSaveAs; // data : ""
extern const char* const ednMsgProperties; // data : ""
extern const char* const ednMsgGuiUndo; // data : ""
extern const char* const ednMsgGuiRedo; // data : ""
extern const char* const ednMsgGuiCopy; // data : "STD" "Middle" "1" ... "9"
extern const char* const ednMsgGuiCut; // data : "STD" "Middle" "1" ... "9"
extern const char* const ednMsgGuiPaste; // data : "STD" "Middle" "1" ... "9"
extern const char* const ednMsgGuiRm; // data : "Word" "Line" "Paragraph"
extern const char* const ednMsgGuiSelect; // data : "ALL" "NONE"
extern const char* const ednMsgGuiGotoLine; // data : "???" / "1" ... "999999999999"
extern const char* const ednMsgGuiSearch; // data : ""
extern const char* const ednMsgGuiReplace; // data : "Normal" "All"
extern const char* const ednMsgGuiFind; // data : "Next" "Previous" "All" "None"
extern const char* const ednMsgGuiChangeColor; // data : "Black" "White"
extern const char* const ednMsgGuiChangeCharset; // data : "UTF-8" "ISO-8859-1" "ISO-8859-15"
extern const char* const ednMsgGuiShowSpaces; // data : "enable" "disable"
extern const char* const ednMsgGuiShowEndOfLine; // data : "enable" "disable"
extern const char* const ednMsgGuiCtags; // data : "Load" "ReLoad" "Jump" "Back"
extern const char* const ednMsgCtagsLoadFile; // data : "filename of the ctags file"
extern const char* const ednMsgGuiReloadShader; // data : ""
////////////////////////////////////////////////////////////////////////
// Event internal :
////////////////////////////////////////////////////////////////////////
extern const char* const ednMsgBufferState; // data : "Saved" "Modify" "HasHistory" "HasNotHistory" "HasFutureHistory" "HasNotFutureHistory"
extern const char* const ednMsgBufferName; // data : "filename"
extern const char* const ednMsgBufferId; // data : "0" ... "99999999999"
extern const char* const ednMsgCodeViewSelectedId; // data : "0" ... "99999999999"
extern const char* const ednMsgOpenFile; // data : "/Compleate/file/name.xx"
extern const char* const ednMsgBufferListChange; // data : ""
extern const char* const ednMsgBufferColor; // data : "new"
#endif

192
Sources/appl/init.cpp Normal file
View File

@@ -0,0 +1,192 @@
/**
*******************************************************************************
* @file init.cpp
* @brief Editeur De N'ours : main fonction
* @author Edouard DUPIN
* @date 26/01/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 <etk/Types.h>
#include <etk/UString.h>
#include <ewol/ewol.h>
#include <ewol/eObject/EObject.h>
#include <ewol/widget/WidgetManager.h>
#include <appl/Debug.h>
#include <appl/global.h>
#include <etk/os/FSNode.h>
#include <etk/tool.h>
#include <Gui/MainWindows.h>
#include <BufferManager.h>
#include <ColorizeManager.h>
#include <HighlightManager.h>
#include <Gui/Search.h>
#include <unistd.h>
#include <readtags.h>
#include <CTagsManager.h>
#include <globalMsg.h>
#include <ewol/font/FontManager.h>
MainWindows * basicWindows = NULL;
/**
* @brief main application function Initialisation
*/
void APP_Init(void)
{
#ifdef __TARGET_OS__Linux
#ifdef MODE_RELEASE
APPL_INFO("==> Init "PROJECT_NAME" (START) (Linux) (Release)");
#else
APPL_INFO("==> Init "PROJECT_NAME" (START) (Linux) (Debug)");
#endif
#else
#ifdef MODE_RELEASE
APPL_INFO("==> Init "PROJECT_NAME" (START) (Android) (Release)");
#else
APPL_INFO("==> Init "PROJECT_NAME" (START) (Android) (Debug)");
#endif
#endif
ewol::ChangeSize(etk::Vector2D<int32_t>(800, 600));
etk::InitDefaultFolder(PROJECT_NAME);
ewol::font::SetDefaultFont("Font/freefont/FreeSerif.ttf");
//ewol::font::SetDefaultFont("Font/ACharmingFont.ttf");
#ifdef __TARGET_OS__Android
ewol::font::SetDefaultSize(19);
#else
ewol::font::SetDefaultSize(14);
#endif
// init internal global value
globals::init();
// init ALL Singleton :
//(void)CTagsManager::getInstance();
BufferManager::Init();
// set color and other trucs...
ColorizeManager::Init();
etk::UString corlorFile = "color_white.xml";
ColorizeManager::LoadFile( corlorFile.c_str() );
ColorizeManager::DisplayListOfColor();
HighlightManager::Init();
HighlightManager::loadLanguages();
cTagsManager::Init();
char cCurrentPath[FILENAME_MAX];
// get the curent program folder
if (!getcwd(cCurrentPath, FILENAME_MAX)) {
return ;
}
cCurrentPath[FILENAME_MAX - 1] = '\0';
//APPL_INFO("The current working directory is " << cCurrentPath);
basicWindows = new MainWindows();
if (NULL == basicWindows) {
APPL_ERROR("Can not allocate the basic windows");
ewol::Stop();
return;
}
// create the specific windows
ewol::DisplayWindows(basicWindows);
// add generic shortcut ...
// (shift, control, alt, meta, uniChar_t unicodeValue, const char * generateEventId, etk::UString& data)
ewol::shortCut::Add("ctrl+o", ednMsgGuiOpen, "");
ewol::shortCut::Add("ctrl+n", ednMsgGuiNew, "");
ewol::shortCut::Add("ctrl+s", ednMsgGuiSave, "current");
ewol::shortCut::Add("ctrl+shift+s", ednMsgGuiSave, "All");
ewol::shortCut::Add("ctrl+q", ednMsgGuiClose, "current");
ewol::shortCut::Add("ctrl+shift+q", ednMsgGuiClose, "All");
ewol::shortCut::Add("ctrl+z", ednMsgGuiUndo, "");
ewol::shortCut::Add("ctrl+shift+z", ednMsgGuiRedo, "");
ewol::shortCut::Add("ctrl+l", ednMsgGuiGotoLine, "???");
ewol::shortCut::Add("ctrl+f", ednMsgGuiSearch, "");
ewol::shortCut::Add("F12", ednMsgGuiReloadShader, "");
ewol::shortCut::Add("ctrl+d", ednMsgGuiCtags, "Jump");
// add files
APPL_INFO("show list of files : ");
bool ctagDetected = false;
for( int32_t iii=0 ; iii<ewol::CmdLine::Nb(); iii++) {
etk::UString tmpppp = ewol::CmdLine::Get(iii);
if (tmpppp == "-t") {
ctagDetected = true;
} else if (true == ctagDetected) {
APPL_INFO("Load ctag file : \"" << tmpppp << "\"" );
ctagDetected = false;
ewol::EObjectMessageMultiCast::AnonymousSend(ednMsgCtagsLoadFile, tmpppp);
} else {
APPL_INFO("need load file : \"" << tmpppp << "\"" );
ewol::EObjectMessageMultiCast::AnonymousSend(ednMsgOpenFile, tmpppp);
}
}
APPL_INFO("==> Init Edn (END)");
}
etk::FSNode APP_Icon(void)
{
etk::FSNode bitmapFile("DATA:iconEdn.bmp");
return bitmapFile;
}
/**
* @brief main application function Un-Initialisation
*/
void APP_UnInit(void)
{
APPL_INFO("==> Un-Init Edn (START)");
// Remove windows :
ewol::DisplayWindows(NULL);
cTagsManager::UnInit();
APPL_INFO("Stop Hightlight");
HighlightManager::UnInit();
//Kill all singleton
APPL_INFO("Stop BufferManager");
BufferManager::UnInit();
APPL_INFO("Stop ColorizeManager");
ColorizeManager::UnInit();
APPL_INFO("Stop Search");
//Search::Kill();
//APPL_INFO("Stop Accel key");
//AccelKey::Kill();
if (NULL != basicWindows) {
delete(basicWindows);
basicWindows = NULL;
}
APPL_INFO("==> Un-Init Edn (END)");
}

View File

@@ -1,332 +0,0 @@
/**
*******************************************************************************
* @file CTagsManager.cpp
* @brief Editeur De N'ours : Ctags manager : acces to the ctags file (Sources)
* @author Edouard DUPIN
* @date 15/07/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 "Edn.h"
#include "CTagsManager.h"
#include "ClipBoard.h"
#include "BufferManager.h"
#undef __class__
#define __class__ "CTagsManager"
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
CTagsManager::CTagsManager(void) : MsgBroadcast("C-Tags Manager", EDN_CAT_CTAGS)
{
m_tagFilename = "";
m_tagFolderBase = "";
m_ctagFile = NULL;
m_historyPos = 0;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
CTagsManager::~CTagsManager(void)
{
if(0 != m_historyList.Size()) {
for (int32_t iii=0; iii< m_historyList.Size(); iii++) {
delete(m_historyList[iii]);
}
m_historyList.Clear();
}
}
Edn::String CTagsManager::GetFolder(Edn::String &inputString)
{
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;
}
void CTagsManager::OnMessage(int32_t id, int32_t dataID)
{
switch (id)
{
case EDN_MSG__BUFFER_CHANGE_CURRENT:
m_currentSelectedID = dataID;
break;
case EDN_MSG__OPEN_CTAGS:
EDN_INFO("Request opening ctag file");
{
GtkWidget *dialog = gtk_file_chooser_dialog_new( "Open Exuberant Ctags File", NULL,
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
NULL); // end button/response list
if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
{
// open the new one :
m_tagFilename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog));
m_tagFolderBase = GetFolder(m_tagFilename);
LoadTagFile();
}
gtk_widget_destroy(dialog);
}
break;
case EDN_MSG__RELOAD_CTAGS:
LoadTagFile();
break;
case EDN_MSG__JUMP_TO_CURRENT_SELECTION:
JumpTo();
break;
case EDN_MSG__JUMP_BACK:
EDN_INFO("TODO .... jump back");
break;
}
}
void CTagsManager::LoadTagFile(void)
{
tagFileInfo info;
// close previous tag file
if (NULL != m_ctagFile) {
tagsClose(m_ctagFile);
m_ctagFile = NULL;
}
if (m_tagFilename == "") {
return;
}
// load (open) the tag file :
EDN_INFO("try to open tag file : " << m_tagFilename.c_str());
m_ctagFile = tagsOpen(m_tagFilename.c_str(), &info);
if (NULL != m_ctagFile) {
EDN_INFO("open exuberant Ctags file is OK ...");
} else {
EDN_INFO("Error to open ctags file ...");
}
}
void CTagsManager::AddToHistory(int32_t bufferID)
{
// check tho history position : remove if needed
if (m_historyPos < edn_max(m_historyList.Size()-1, 0) ) {
for(int32_t iii= m_historyPos; iii < m_historyList.Size(); iii++) {
delete(m_historyList[iii]);
}
m_historyList.Erase(m_historyPos, m_historyList.Size() - m_historyPos);
}
// add the current element
BufferManager *myBufferManager = BufferManager::getInstance();
Edn::String currentFilename = myBufferManager->Get(bufferID)->GetName();
int32_t currentLineId = 0;
Edn::File * currentFile = new Edn::File(currentFilename);
}
enum
{
CTAGS_COL_FILE = 0,
CTAGS_COL_REGEXP,
CTAGS_NUM_COLS
};
static GtkTreeModel * create_and_fill_model(void)
{
GtkListStore * store;
GtkTreeIter iter;
store = gtk_list_store_new(CTAGS_NUM_COLS, G_TYPE_STRING, G_TYPE_STRING);
// Append a row and fill in some data
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter,
CTAGS_COL_FILE, "file1.c",
CTAGS_COL_REGEXP, "void function1(void);",
-1);
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter,
CTAGS_COL_FILE, "file2.c",
CTAGS_COL_REGEXP, "void function2(void);",
-1);
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter,
CTAGS_COL_FILE, "file3.c",
CTAGS_COL_REGEXP, "void function3(void);",
-1);
return GTK_TREE_MODEL(store);
}
static GtkWidget * create_view_and_model(void)
{
GtkCellRenderer * renderer;
GtkTreeModel * model;
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,
"Regular Expression",
renderer,
"text", CTAGS_COL_REGEXP,
NULL);
model = create_and_fill_model();
gtk_tree_view_set_model(GTK_TREE_VIEW (view), model);
g_object_unref(model);
return view;
}
void CTagsManager::MultipleJump(void)
{
// dlg to confirm the quit event :
GtkWidget *myDialog = 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(myDialog));
GtkWidget *listView = create_view_and_model ();
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 (myDialog));
// Get data from the gtk entry
// Remove dialogue
gtk_widget_destroy(myDialog);
}
void CTagsManager::JumpTo(void)
{
MultipleJump();
if (NULL != m_ctagFile) {
Edn::VectorType<int8_t> data;
// get the middle button of the clipboard ==> represent the current selection ...
ClipBoard::Get(COPY_MIDDLE_BUTTON, data);
if (data.Size() == 0) {
EDN_INFO("No current S<>lection");
}
tagEntry entry;
data.PushBack('\0');
EDN_INFO("try to find the tag : " << (const char *)&data[0]);
if (tagsFind (m_ctagFile, &entry, (const char *)&data[0], 0) == TagSuccess) {
//EDN_INFO("find the tag");
BufferManager *myBufferManager = BufferManager::getInstance();
Edn::String destinationFilename = m_tagFolderBase;
destinationFilename += entry.file;
EDN_INFO(" OPEN the TAG file Destination : " << destinationFilename.c_str() );
if (false == myBufferManager->Exist(destinationFilename) ) {
// need to open the file :
int32_t openID = myBufferManager->Open(destinationFilename);
SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, openID);
} else {
SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, myBufferManager->GetId(destinationFilename));
}
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);
/*
do {
PrintTag (&entry);
} while (tagsFindNext (m_ctagFile, &entry) == TagSuccess);
*/
} else {
EDN_INFO("no tag find ...");
}
}
}
void CTagsManager::PrintTag (const tagEntry *entry)
{
int i;
EDN_INFO("find Tag file : name=\"" << entry->name << "\" in file=\"" << entry->file
<< "\" pattern=\"" <<entry->address.pattern
<< "\" at line="<<entry->address.lineNumber);
EDN_INFO("Extention field : ");
if (entry->kind != NULL && entry->kind [0] != '\0') {
EDN_INFO(" kind : " << entry->kind);
}
if (entry->fileScope) {
EDN_INFO(" file : ");
}
for (i = 0 ; i < entry->fields.count ; ++i) {
EDN_INFO(" " << entry->fields.list[i].key << ":" << entry->fields.list[i].value );
}
}

View File

@@ -1,63 +0,0 @@
/**
*******************************************************************************
* @file CTagsManager.h
* @brief Editeur De N'ours : Ctags manager : acces to the ctags file (header)
* @author Edouard DUPIN
* @date 15/07/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 __C_TAGS_MANAGER_H__
#define __C_TAGS_MANAGER_H__
#include "Singleton.h"
#include "MsgBroadcast.h"
#include "readtags.h"
#include "Edn.h"
class CTagsManager: public Singleton<CTagsManager>, public MsgBroadcast
{
friend class Singleton<CTagsManager>;
// specific for sigleton system...
private:
// Constructeur
CTagsManager(void);
~CTagsManager(void);
public:
void OnMessage(int32_t id, int32_t dataID);
private:
int32_t m_currentSelectedID;
void LoadTagFile(void);
void MultipleJump(void);
void JumpTo(void);
void PrintTag(const tagEntry *entry);
Edn::String GetFolder(Edn::String &inputString);
Edn::String m_tagFolderBase;
Edn::String m_tagFilename;
tagFile * m_ctagFile;
// history system
void AddToHistory(int32_t bufferID);
int32_t m_historyPos;
Edn::VectorType<Edn::File*> m_historyList;
};
#endif

58
Sources/file.mk Normal file
View File

@@ -0,0 +1,58 @@
###############################################################################
### Files Listes ###
###############################################################################
# ExuberantCtags reading file tools (extern OPEN Sources) :
FILE_LIST+= appl/ctags/readtags.cpp \
appl/ctags/CTagsManager.cpp
# Globals debug tool:
FILE_LIST+= appl/Debug.cpp \
appl/global.cpp \
appl/globalMsg.cpp
# Gui:
FILE_LIST+= appl/Gui/BufferView.cpp \
appl/Gui/CodeView.cpp \
appl/Gui/MainWindows.cpp \
appl/Gui/Search.cpp \
appl/Gui/SearchData.cpp \
appl/Gui/TagFileSelection.cpp \
appl/Gui/TagFileList.cpp
# All needed for the buffer management :
FILE_LIST+= appl/Buffer/EdnVectorBuf.cpp \
appl/Buffer/EdnBuf/EdnBuf.cpp \
appl/Buffer/EdnBuf/EdnBuf_HighLight.cpp \
appl/Buffer/EdnBuf/EdnBuf_History.cpp \
appl/Buffer/EdnBuf/EdnBuf_Selection.cpp \
appl/Buffer/EdnBuf/EdnBufHistory.cpp \
appl/Buffer/Buffer.cpp \
appl/Buffer/BufferText.cpp \
appl/Buffer/BufferEmpty.cpp \
appl/Buffer/BufferManager.cpp
# Generic color management for the text editor :
FILE_LIST+= appl/Colorize/Colorize.cpp \
appl/Colorize/ColorizeManager.cpp
# syntax coloration for the text editor
FILE_LIST+= appl/Highlight/HighlightPattern.cpp \
appl/Highlight/Highlight.cpp \
appl/Highlight/HighlightManager.cpp
# Main entry file :
FILE_LIST+= appl/init.cpp
LOCAL_COPY_FILES := \
../share/Font/freefont/FreeSerif.ttf:Font/freefont/FreeSerif.ttf
LOCAL_COPY_FOLDERS := \
../share/*.xml: \
../share/icon/*.svg:icon \
../share/Font/freefont/FreeMon*.ttf:Font/freefont

View File

@@ -1,150 +0,0 @@
/**
*******************************************************************************
* @file init.cpp
* @brief Editeur De N'ours : main fonction
* @author Edouard DUPIN
* @date 26/01/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 "Display.h"
#include "BufferManager.h"
#include "ColorizeManager.h"
#include "HighlightManager.h"
#include "ClipBoard.h"
#include <string>
#include "WindowsManager.h"
#include "Search.h"
#include <unistd.h>
#include "readtags.h"
#include "CTagsManager.h"
#include "Edn.h"
/**
* @brief Main start function of the system
*
* @param[in] argc number of argument when called
* @param[in] argv sus nomer arguments
*
* @return EXIT_SUCCESS, all time
*
*/
int main (int argc, char *argv[])
{
EDN_INFO("Start Edn");
//Edn::TestUntaire_String();
//return 0;
// Use and remove GTK arguments from the application argument list.
gtk_init (&argc, &argv);
// init internal global value
globals::init();
ClipBoard::Init();
Display::Init();
//MainWindows *window = MainWindows::getInstance();
// init ALL Singleton :
(void)MsgBroadcastCore::getInstance();
(void)AccelKey::getInstance();
(void)WindowsManager::getInstance();
(void)CTagsManager::getInstance();
BufferManager *myBufferManager = BufferManager::getInstance();
// set color and other trucs...
ColorizeManager *myColorManager = NULL;
myColorManager = ColorizeManager::getInstance();
Edn::String homedir;
//homedir = getenv("HOME");
#ifdef NDEBUG
homedir = "/usr/share/edn/";
#else
homedir = "./data/";
#endif
homedir += "color_black.xml";
myColorManager->LoadFile( homedir.c_str() );
myColorManager->DisplayListOfColor();
HighlightManager *myHighlightManager = NULL;
myHighlightManager = HighlightManager::getInstance();
myHighlightManager->loadLanguages();
// open display
MsgBroadcastCore::getInstance()->SendMessage(NULL, EDN_MSG__GUI_SHOW_MAIN_WINDOWS);
// get the curent program folder
char cCurrentPath[FILENAME_MAX];
if (!getcwd(cCurrentPath, FILENAME_MAX)) {
return -1;
}
cCurrentPath[FILENAME_MAX - 1] = '\0';
//EDN_INFO("The current working directory is " << cCurrentPath);
// add files
EDN_INFO("show list of files : ");
for( int32_t i=1 ; i<argc; i++) {
EDN_INFO("need load file : \"" << argv[i] << "\"" );
Edn::String myfile = "";
// Special case for the root file origin
if ('/' != argv[i][0]) {
myfile+=cCurrentPath;
myfile+="/";
}
myfile+=(char *)argv[i];
if (false == myBufferManager->Exist(myfile) ) {
int32_t idBuffOpened = myBufferManager->Open(myfile);
if (1==i) {
MsgBroadcastCore::getInstance()->SendMessage(NULL, EDN_MSG__CURRENT_CHANGE_BUFFER_ID, idBuffOpened);
}
}
}
EDN_INFO("Start gtk main");
gtk_main();
EDN_INFO("Stop gtk main");
//Kill all singleton
EDN_INFO("Stop BufferManager");
BufferManager::kill();
EDN_INFO("Stop ColorizeManager");
ColorizeManager::kill();
EDN_INFO("Stop Search");
Search::kill();
EDN_INFO("Stop Accel key");
AccelKey::kill();
EDN_INFO("Stop Display");
Display::UnInit();
EDN_INFO("Stop Edn");
return EXIT_SUCCESS;
}

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

@@ -1,45 +0,0 @@
/**
*******************************************************************************
* @file AL_Mutex.h
* @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.
*
*******************************************************************************
*/
#ifndef __AL_MUTEX_H__
#define __AL_MUTEX_H__
//basic mutex with pthread system
#include <pthread.h>
#include <errno.h>
typedef pthread_mutex_t AL_MUTEX;
erreurCode_te AL_mutex_init(AL_MUTEX * pointerMutex,bool recursive);
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

@@ -1,95 +0,0 @@
/**
*******************************************************************************
* @file ClipBoard.cpp
* @brief Editeur De N'ours : copy / past main system
* @author Edouard DUPIN
* @date 05/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_globals.h"
#include "ClipBoard.h"
#undef __class__
#define __class__ "ClipBoard"
/*
note: la copy dans le :
0 : copy standard
[1..9] : copy interne
10 : bouton du milieux
*/
static Edn::VectorType<int8_t> mesCopy[TOTAL_OF_CLICKBOARD];
void ClipBoard::Init(void)
{
EDN_INFO("Initialyse ClipBoards");
for(int32_t i=0; i<TOTAL_OF_CLICKBOARD; i++) {
mesCopy[i].Clear();
}
}
void ClipBoard::Set(uint8_t clipboardID, Edn::VectorType<int8_t> &data)
{
// check if ID is correct
if(clipboardID >= TOTAL_OF_CLICKBOARD) {
EDN_WARNING("request ClickBoard id error");
} else if(0 == data.Size()) {
EDN_INFO("request a copy of nothing");
} else if (COPY_STD == clipboardID) {
GtkClipboard * clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
gtk_clipboard_set_text(clipboard, (const gchar*)&data[0], data.Size() );
} else if (COPY_MIDDLE_BUTTON == clipboardID) {
GtkClipboard * clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
gtk_clipboard_set_text(clipboard, (const gchar*)&data[0], data.Size() );
}
// Copy datas ...
mesCopy[clipboardID] = data;
}
void ClipBoard::Get(uint8_t clipboardID, Edn::VectorType<int8_t> &data)
{
if(clipboardID >= TOTAL_OF_CLICKBOARD) {
EDN_WARNING("request ClickBoard id error");
} else if (COPY_STD == clipboardID) {
GtkClipboard * clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD );
gchar *text = gtk_clipboard_wait_for_text(clipboard);
if (text != NULL) {
mesCopy[COPY_STD].Clear();
mesCopy[COPY_STD].PushBack((int8_t*)text, strlen(text) );
}
} else if (COPY_MIDDLE_BUTTON == clipboardID) {
GtkClipboard * clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY );
gchar *text = gtk_clipboard_wait_for_text(clipboard);
if (text != NULL) {
mesCopy[COPY_MIDDLE_BUTTON].Clear();
mesCopy[COPY_MIDDLE_BUTTON].PushBack((int8_t*)text, strlen(text) );
}
}
// Copy datas ...
data = mesCopy[clipboardID];
}

View File

@@ -1,45 +0,0 @@
/**
*******************************************************************************
* @file ClipBoard.h
* @brief Editeur De N'ours : copy / past main system (header)
* @author Edouard DUPIN
* @date 30/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.
*
*******************************************************************************
*/
#ifndef __CLIP_BOARD_H__
#define __CLIP_BOARD_H__
#include "tools_debug.h"
#include "VectorType.h"
#define TOTAL_OF_CLICKBOARD (11)
#define COPY_MIDDLE_BUTTON (10)
#define COPY_STD (0)
namespace ClipBoard
{
void Init(void);
void Set(uint8_t clipboardID, Edn::VectorType<int8_t> &data);
void Get(uint8_t clipboardID, Edn::VectorType<int8_t> &data);
}
#endif

View File

@@ -1,634 +0,0 @@
/**
*******************************************************************************
* @file Display.cpp
* @brief Editeur De N'ours : Basic Pixbuf display function
* @author Edouard DUPIN
* @date 21/01/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 "tools_globals.h"
#include "Display.h"
#include "ColorizeManager.h"
#include "charset.h"
#include <string>
#undef __class__
#define __class__ "Display"
#define FONT_BOLD_NO (0)
#define FONT_BOLD_YES (1)
#define FONT_ITALIC_NO (0)
#define FONT_ITALIC_YES (1)
// Variables privé du namespace
#define POLICE_NAME "Monospace"
#ifdef USE_GTK_VERSION_3_0
#define POLICE_SIZE 15
static int32_t m_pangoFontWidth = 9;
static int32_t m_pangoFontHeight = 19;
#elif USE_GTK_VERSION_2_0
#define POLICE_SIZE 12
static int32_t m_pangoFontWidth = 7;
static int32_t m_pangoFontHeight = 15;
#endif
/*
#define POLICE_SIZE 11
static int32_t m_pangoFontWidth = 7;
static int32_t m_pangoFontHeight = 11;
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)
{
/*
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_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_YES][FONT_BOLD_YES] = cairo_toy_font_face_create(POLICE_NAME, CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_BOLD);
if ( NULL == m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_NO]) {
EDN_ASSERT(FALSE, "basic font ERROR");
}
if ( NULL == m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_NO]) {
EDN_ERROR("Italic font error ... link with basic font");
m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_NO] = m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_NO];
}
if ( NULL == m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_YES]) {
EDN_ERROR("Bold font error ... link with basic font");
m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_YES] = m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_NO];
}
if ( NULL == m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_YES]) {
EDN_ERROR("Italic & Bold font error ... link with basic font");
m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_YES] = m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_NO];
}
}
void Display::UnInit(void)
{
// clean the builder...
free(m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_NO]);
free(m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_NO]);
free(m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_YES]);
free(m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_YES]);
}
int32_t Display::GetFontHeight(void)
{
return m_pangoFontHeight;
}
int32_t Display::GetFontWidth(void)
{
return m_pangoFontWidth;
}
cairo_font_face_t * Display::GetFont(bool bold, bool italic)
{
if( false == bold
&& false == italic) {
return m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_NO];
} else if( true == bold
&& false == italic) {
return m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_YES];
} else if ( false == bold
&& true == italic) {
return m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_NO];
}
return m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_YES];
}
#undef __class__
#define __class__ "DrawerManager"
/**
* @brief DrawerManager constructor : generate a memoryDC where we can draw everything...
*
* @param [in] window Current windows where the memoryDC must be paint
* @param [in] x Current width of the Display
* @param [in] y Current Height of the Display
*
* @note : No exeption
*
* @return ---
*
*/
DrawerManager::DrawerManager(GtkWidget * widget, int32_t x, int32_t y)
{
m_size.x = x;
m_size.y = y;
m_haveWork = false;
// Create the Cairo Element
# if USE_GTK_VERSION_3_0
m_cairo = gdk_cairo_create(gtk_widget_get_window(widget));
# elif USE_GTK_VERSION_2_0
m_cairo = gdk_cairo_create(widget->window);
# endif
//cairo_translate(m_cairo, 0, 7);
cairo_set_source_rgb(m_cairo, 0, 0, 0);
cairo_paint(m_cairo);
cairo_set_font_size(m_cairo, POLICE_SIZE);
m_dataToDisplay[0] = '\0';
cairo_scale(m_cairo, 1.0, 1.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);
}
/**
* @brief main DrawerManager destructor : Copy data on the curent screen
*
* @param ---
*
* @note : No exeption
*
* @return ---
*
*/
DrawerManager::~DrawerManager()
{
cairo_destroy(m_cairo);
}
/**
* @brief Draw Text with the specify color
*
* This function does not display the text directly, it save it while a flush appare or the y position differ, or the color differ.
* This is for the char by char writing ==> more efficient when we write multiple char.
*
* @param [in] SelectColor Color that is used to display data
* @param [in] x Horizontal position to display data
* @param [in] y Vertical position to display data
* @param [in] myText Text to write in UTF8 ...
* @param [in] displayBG unused
*
* @return ---
*
*/
void DrawerManager::Text(Colorize *SelectColor, int32_t x, int32_t y,const char *myUTF8Text, int32_t len)
{
EDN_CHECK_INOUT(NULL!=SelectColor);
// check if flush is needed :
if (true == m_haveWork) {
if( m_pos.y != y
|| m_selectColor != SelectColor)
{
Flush();
}
}
// check change
if (false == m_haveWork) {
m_pos.x = x;
m_pos.y = y;
m_selectColor = SelectColor;
}
//EDN_WARNING("add data : \"" << myText << "\" x=" << x << " y=" << y );
// process :
m_haveWork = true;
strcat(m_dataToDisplay, myUTF8Text);
if (len != -1 ) {
m_nbElement+=len;
} else {
m_nbElement+=strUtf8Len(myUTF8Text);
}
}
void DrawerManager::Text(color_ts & SelectColorFg, color_ts & SelectColorBg, int32_t x, int32_t y,const char *myText)
{
Flush();
cairo_set_font_face(m_cairo, Display::GetFont(false, false));
int32_t letterHeight = Display::GetFontHeight();
int32_t letterWidth = Display::GetFontWidth();
int32_t stringLen = strUtf8Len(myText);
DirectRectangle(SelectColorBg, x, y, letterWidth*strlen(myText), letterHeight);
cairo_fill(m_cairo);
cairo_move_to(m_cairo, x, y+letterHeight-4);
cairo_set_source_rgb(m_cairo, SelectColorFg.red, SelectColorFg.green, SelectColorFg.blue);
cairo_show_text(m_cairo, myText);
cairo_fill(m_cairo);
}
void DrawerManager::Text(color_ts & SelectColorFg, int32_t x, int32_t y,const char *myText)
{
Flush();
cairo_set_font_face(m_cairo, Display::GetFont(false, false));
int32_t letterHeight = Display::GetFontHeight();
cairo_move_to(m_cairo, x, y+letterHeight-4);
cairo_set_source_rgb(m_cairo, SelectColorFg.red, SelectColorFg.green, SelectColorFg.blue);
cairo_show_text(m_cairo, myText);
cairo_fill(m_cairo);
}
void DrawerManager::SpaceText(color_ts & SelectColor, int32_t x, int32_t y,int32_t nbChar)
{
Flush();
int32_t letterHeight = Display::GetFontHeight();
int32_t letterWidth = Display::GetFontWidth();
DirectRectangle(SelectColor, x, y, letterWidth*nbChar, letterHeight);
cairo_fill(m_cairo);
}
/**
* @brief Force de display of the curent Text
*
* The flush is to be more performent with the Pango display methode...
*
* @param ---
*
* @return ---
*
*/
void DrawerManager::Flush(void)
{
if (true == m_haveWork) {
//EDN_WARNING("flush : \"" << m_dataToDisplay << "\"");
m_haveWork = false;
cairo_set_font_face(m_cairo, Display::GetFont(m_selectColor->GetBold(), m_selectColor->GetItalic()));
int32_t letterHeight = Display::GetFontHeight();
if (true == m_selectColor->HaveBg() ) {
int32_t letterWidth = Display::GetFontWidth();
int32_t stringLen = m_nbElement;
// generate Clean BG:
DirectRectangle(m_selectColor, m_pos.x, m_pos.y, letterWidth*stringLen, letterHeight);
}
cairo_move_to(m_cairo, m_pos.x, m_pos.y+letterHeight-4);
m_selectColor->ApplyFG(m_cairo);
cairo_show_text(m_cairo, m_dataToDisplay);
cairo_fill(m_cairo);
m_dataToDisplay[0] = '\0';
m_nbElement = 0;
}
}
/**
* @brief display a rectangle with the curent bgColor and no border
*
* This function in the open API to drow the rectangle, it flush the curent Text in the buffer
*
* @param [in] SelectColor Color that is used to display rectangle
* @param [in] x Horizontal position to display rectangle
* @param [in] y Vertical position to display rectangle
* @param [in] width Width of the rectangle
* @param [in] height Height of the rectangle
*
* @return ---
*
*/
void DrawerManager::Rectangle(Colorize *SelectColor, int32_t x, int32_t y, int32_t width, int32_t height)
{
Flush();
DirectRectangle(SelectColor, x, y, width, height);
}
/**
* @brief Real function to display the rectangle (no flush done (expectially for the Background display)
*
* @param [in] SelectColor Color that is used to display rectangle
* @param [in] x Horizontal position to display rectangle
* @param [in] y Vertical position to display rectangle
* @param [in] width Width of the rectangle
* @param [in] height Height of the rectangle
*
* @return ---
*
*/
void DrawerManager::DirectRectangle(Colorize *SelectColor, int32_t x, int32_t y, int32_t width, int32_t height)
{
EDN_CHECK_INOUT(NULL!=SelectColor);
//EDN_INFO("x="<< x <<" y="<< y <<" width="<< width <<" height="<< height);
//gdk_draw_rectangle( p_pixmap, SelectColor->GetColorBG(), TRUE, x, y, width, height);
// set color
SelectColor->ApplyBG(m_cairo);
// set postion
cairo_rectangle(m_cairo, x, y, width, height);
//cairo_stroke(m_cairo);
// flush
cairo_fill(m_cairo);
}
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);
// set postion
cairo_rectangle(m_cairo, x, y, width, height);
//cairo_stroke(m_cairo);
// flush
cairo_fill(m_cairo);
}
/**
* @brief Clean the curent Windows with the curent color
*
* @param [in] SelectColor Color that is used to display background
*
* @return ---
*
*/
void DrawerManager::Clean(Colorize *SelectColor)
{
m_haveWork = false;
DirectRectangle(SelectColor, 0, 0, m_size.x, m_size.y);
}
/**
* @brief Clean the curent Windows with the curent color
*
* @param [in] SelectColor Color that is used to display background
*
* @return ---
*
*/
void DrawerManager::Clean(color_ts & SelectColor)
{
m_haveWork = false;
DirectRectangle(SelectColor, 0, 0, m_size.x, m_size.y);
}
/**
* @brief Display a cursor with the cortect form.
*
* Automatic selection of the XML color "cursorColor"
*
* @param [in] x Horizontal position to display cursor
* @param [in] y Vertical position to display cursor
*
* @return ---
*
*/
#define CURSOR_WIDTH (4)
void DrawerManager::Cursor(int32_t x, int32_t y)
{
Flush();
// get the cursor Color :
color_ts myColor = ColorizeManager::getInstance()->Get(COLOR_CODE_CURSOR);
cairo_set_source_rgb(m_cairo, myColor.red, myColor.green, myColor.blue);
// draw cursor
int32_t letterHeight = Display::GetFontHeight();
int32_t letterWidth = Display::GetFontWidth();
// depending on the inserting mode
if (false == globals::IsSetInsert()) {
cairo_set_line_width(m_cairo, 2);
cairo_move_to(m_cairo, x-CURSOR_WIDTH, y - letterHeight+1);
cairo_rel_line_to(m_cairo, CURSOR_WIDTH*2, 0);
cairo_rel_move_to(m_cairo, -CURSOR_WIDTH, 0);
cairo_rel_line_to(m_cairo, 0, letterHeight-2);
cairo_rel_move_to(m_cairo, -CURSOR_WIDTH, 0);
cairo_rel_line_to(m_cairo, CURSOR_WIDTH*2, 0);
} else {
cairo_set_line_width(m_cairo, 1);
cairo_move_to(m_cairo, x, y - letterHeight + 1);
cairo_rel_line_to(m_cairo, letterWidth, 0);
cairo_rel_line_to(m_cairo, 0, letterHeight);
cairo_rel_line_to(m_cairo, -letterWidth, 0);
cairo_rel_line_to(m_cairo, 0, -letterHeight);
}
cairo_stroke(m_cairo);
cairo_fill(m_cairo);
}
/**
* @brief Display a end of the curent line ...
*
* Automatic draw the end of line with the curent XML color "cursorColor"
*
* @param [in] x Horizontal position to display cursor
* @param [in] y Vertical position to display cursor
*
* @return ---
*
*/
void DrawerManager::EndOfLine(int32_t x, int32_t y)
{
if (true == globals::IsSetDisplayEndOfLine() ) {
Flush();
// get the cursor Color :
color_ts myColor = ColorizeManager::getInstance()->Get(COLOR_CODE_CURSOR);
cairo_set_source_rgb(m_cairo, myColor.red, myColor.green, myColor.blue);
// draw cursor
int32_t letterHeight = Display::GetFontHeight();
// depending on the inserting mode
/*
x1 x2
y1 | |-----
| |-----
| |
y2 | |
*/
cairo_set_line_width(m_cairo, 2);
cairo_move_to(m_cairo, x, y - letterHeight+1);
cairo_rel_line_to(m_cairo, 0, letterHeight);
cairo_move_to(m_cairo, x+2, y - letterHeight+1);
cairo_rel_line_to(m_cairo, 0, letterHeight);
cairo_arc(m_cairo, x+3, y - letterHeight/4*3, 3.0, -3.149/2, 3.149/2);
cairo_stroke(m_cairo);
cairo_fill(m_cairo);
}
}
/**
* @brief Display a Tabulation with the user form selection.
*
* @param [in] SelectColor Color that is used to display Tabulation
* @param [in] x Horizontal position to display cursor
* @param [in] y Vertical position to display cursor
* @param [in] mbColomn Width of the current Tabulation caracter (in number of Char)
*
* @return ---
*
*/
void DrawerManager::Tabulation(Colorize *SelectColor, int32_t x, int32_t y, int32_t mbColomn)
{
Flush();
int32_t letterWidth = Display::GetFontWidth();
int32_t letterHeight = Display::GetFontHeight();
// generate Clean BG:
DirectRectangle(SelectColor, x, y-letterHeight, letterWidth*mbColomn, letterHeight);
// set the pen for the display
SelectColor->ApplyFG(m_cairo);
uint32_t yCalc = y - (letterHeight+1)/2;
cairo_move_to(m_cairo, x + 3, yCalc);
cairo_line_to(m_cairo, x + letterWidth*mbColomn - 2 , yCalc);
cairo_rel_line_to(m_cairo, -6 , -2);
cairo_move_to(m_cairo, x + letterWidth*mbColomn - 2 , yCalc);
cairo_rel_line_to(m_cairo, -6 , +2);
cairo_stroke(m_cairo);
cairo_fill(m_cairo);
}
/**
* @brief Display an unknow UTF8 character (a special rectangle)
*
* @param [in] SelectColor Color that is used to display Tabulation
* @param [in] x Horizontal position to display cursor
* @param [in] y Vertical position to display cursor
* @param [in] utf8Size number of char used by the UTF8 character
* @param [in] ValidUtf8 true if the character UTF8 is well encoded
*
* @return ---
*
*/
void DrawerManager::UTF8UnknownElement(Colorize *SelectColor, int32_t x, int32_t y, int8_t utf8Size, bool ValidUtf8)
{
Flush();
int32_t letterWidth = Display::GetFontWidth();
int32_t letterHeight = Display::GetFontHeight();
// generate Clean BG:
DirectRectangle(SelectColor, x, y-letterHeight, letterWidth*2, letterHeight);
SelectColor->ApplyFG(m_cairo);
/*
y1 y2
x1 |-------|
| |
| |
x2 |-------|
*/
uint32_t x1 = x + 2;
uint32_t x2 = x + letterWidth*2 - 2;
uint32_t y1 = y - letterHeight + 2;
uint32_t y2 = y - 2;
// Box
cairo_move_to(m_cairo, x1 , y1);
cairo_line_to(m_cairo, x2 , y1);
cairo_line_to(m_cairo, x2 , y2);
cairo_line_to(m_cairo, x1 , y2);
cairo_line_to(m_cairo, x1 , y1);
// croix in the middle
switch(utf8Size)
{
case 1:
break;
case 2:
cairo_line_to(m_cairo, x2 , y2);
break;
case 3:
cairo_move_to(m_cairo, x1 , y2);
cairo_line_to(m_cairo, x2 , y1);
break;
default:
cairo_line_to(m_cairo, x2 , y2);
cairo_move_to(m_cairo, x1 , y2);
cairo_line_to(m_cairo, x2 , y1);
break;
}
if (false == ValidUtf8) {
cairo_move_to(m_cairo, x1 , y2-2);
cairo_line_to(m_cairo, x2 , y2-2);
}
cairo_stroke(m_cairo);
cairo_fill(m_cairo);
}
/* Basic axample with cairo and pango...
cairo_t *cr;
cr = gdk_cairo_create(widget->window);
cairo_translate(cr, 0, 7);
cairo_set_source_rgb(cr, 0, 0, 0);
cairo_paint(cr);
gint pos = 18;//GTK_CPU(widget)->sel;
gint rect = pos / 5;
cairo_set_source_rgb(cr, 0.2, 0.4, 0);
gint i;
for ( i = 1; i <= 20; i++) {
if (i > 20 - rect) {
cairo_set_source_rgb(cr, 0.6, 1.0, 0);
} else {
cairo_set_source_rgb(cr, 0.2, 0.4, 0);
}
cairo_rectangle(cr, 8, i*4, 30, 3);
cairo_rectangle(cr, 42, i*4, 30, 3);
cairo_fill(cr);
}
//----
PangoLayout *layout;
PangoFontDescription *desc;
cairo_translate(cr, 10, 20);
layout = pango_cairo_create_layout(cr);
pango_layout_set_text(layout, "Hello World!", -1);
desc = pango_font_description_from_string("Sans Bold 12");
pango_layout_set_font_description(layout, desc);
pango_font_description_free(desc);
cairo_set_source_rgb(cr, 0.0, 0.0, 1.0);
pango_cairo_update_layout(cr, layout);
pango_cairo_show_layout(cr, layout);
g_object_unref(layout);
//-----
cairo_destroy(cr);
*/

View File

@@ -1,95 +0,0 @@
/**
*******************************************************************************
* @file Display.h
* @brief Editeur De N'ours : Basic Pixbuf display function (header)
* @author Edouard DUPIN
* @date 21/01/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.
*
*******************************************************************************
*/
#ifndef __TOOLS_DISPLAY_H__
#define __TOOLS_DISPLAY_H__
#include "tools_debug.h"
#include "Colorize.h"
#include "ColorizeManager.h"
#include <string>
#include <vector>
/**
* Basic namespace for the font display system
*/
namespace Display
{
void Init(void);
void UnInit(void);
cairo_font_face_t * GetFont(bool bold, bool italic);
int32_t GetFontHeight(void);
int32_t GetFontWidth(void);
};
#define MAX_CARACTER_CYCLE (512)
/**
* class to abstrate the writing on the curent GUI (INTEFACE to be no dependent of the one chosen)
*/
class DrawerManager;
class DrawerManager {
public:
// Constructeur
DrawerManager(GtkWidget * widget, int32_t x, int32_t y);
~DrawerManager();
void Rectangle(Colorize *SelectColor, int32_t x, int32_t y, int32_t width, int32_t height);
void Rectangle(color_ts & SelectColor, int32_t x, int32_t y, int32_t width, int32_t height) {
DirectRectangle(SelectColor, x, y, width, height);
}
void Clean(Colorize *SelectColor);
void Clean(color_ts & SelectColor);
void Text(Colorize *SelectColor, int32_t x, int32_t y,const char *myUTF8Text, int32_t len = -1);
void Text(color_ts & SelectColorFg, color_ts & SelectColorBg, int32_t x, int32_t y,const char *myText);
void Text(color_ts & SelectColorFg, int32_t x, int32_t y,const char *myText);
void SpaceText(color_ts & SelectColor, int32_t x, int32_t y,int32_t nbChar);
void Cursor(int32_t x, int32_t y);
void EndOfLine(int32_t x, int32_t y);
void Tabulation(Colorize *SelectColor, int32_t x, int32_t y, int32_t mbColomn);
void UTF8UnknownElement(Colorize *SelectColor, int32_t x, int32_t y, int8_t utf8Size, bool ValidUtf8);
void Flush(void);
int32_t GetWidth(void) { return m_size.x; };
int32_t GetHeight(void) { return m_size.y; };
private:
void DirectRectangle(Colorize *SelectColor, int32_t x, int32_t y, int32_t width, int32_t height);
void DirectRectangle(color_ts & SelectColor, int32_t x, int32_t y, int32_t width, int32_t height);
bool m_haveWork; //!< if data might be print (true)
char m_dataToDisplay[MAX_CARACTER_CYCLE]; //!< curent string to display
uint32_t m_nbElement; //!< nb element in the string
position_ts m_pos; //!< position where start the string display (X,Y)
Colorize * m_selectColor; //!< curent color to display
position_ts m_size; //!< Total size
cairo_t * m_cairo; //!< Cairo Layout pointer
};
#endif

View File

@@ -1,212 +0,0 @@
/**
*******************************************************************************
* @file EdnBuf.h
* @brief Editeur De N'ours : Buffer for internal Data (header)
* @author Edouard DUPIN
* @date 23/03/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_BUF_H__
#define __EDN_BUF_H__
/* Maximum length in characters of a tab or control character expansion
of a single buffer character */
#define MAX_EXP_CHAR_LEN 20*4
class EdnBuf;
#include "EdnVectorBuf.h"
#include "EdnBufHistory.h"
#include "HighlightManager.h"
#include "charset.h"
/*
rectStart rectStart
start ************* *************
********** * xxxx*xxxxxx *
* ******** xxxx*xxxxxxxxxxx*xxxxx
end *************** *************
rectEnd rectEnd
*/
typedef struct {
bool selected; //!< True if the selection is active
bool rectangular; //!< True if the selection is rectangular
bool zeroWidth; //!< Width 0 selections aren't "real" selections, but they can be useful when creating rectangular selections from the keyboard.
int32_t start; //!< Pos. of start of selection, or if rectangular start of line containing it.
int32_t end; //!< Pos. of end of selection, or if rectangular end of line containing it.
int32_t rectStart; //!< Indent of left edge of rect. selection
int32_t rectEnd; //!< Indent of right edge of rect. selection
} selection;
typedef enum{
SELECTION_PRIMARY,
SELECTION_SECONDARY,
SELECTION_HIGHTLIGHT,
SELECTION_SIZE
}selectionType_te;
typedef struct {
std::vector<colorInformation_ts> HLData;
int32_t idSequence;
int32_t posHLPass1;
int32_t posHLPass2;
}displayHLData_ts;
class EdnBuf {
public:
// constructer
EdnBuf(void);
// destructer
~EdnBuf(void);
// public function :
void GetAll( Edn::VectorType<int8_t> &text);
void SetAll( Edn::VectorType<int8_t> &text);
void GetRange( int32_t start, int32_t end, Edn::VectorType<int8_t> &output);
bool DumpIn( FILE *myFile);
bool DumpFrom( FILE *myFile);
// replace with operator [] ...
int8_t operator[] (int32_t);
void Insert( int32_t pos, Edn::VectorType<int8_t> &insertText);
void Replace( int32_t start, int32_t end, Edn::VectorType<int8_t> &insertText);
void Remove( int32_t start, int32_t end);
int32_t Indent( selectionType_te select);
int32_t UnIndent( selectionType_te select);
void GetLineText( int32_t pos, Edn::VectorType<int8_t> &text);
int32_t StartOfLine( int32_t pos);
int32_t EndOfLine( int32_t pos);
int32_t GetExpandedChar( int32_t &pos, int32_t indent, char outUTF8[MAX_EXP_CHAR_LEN], uint32_t &currentChar);
int32_t ExpandCharacter( char c, int32_t indent, char outUTF8[MAX_EXP_CHAR_LEN]); // TODO : rework this
int32_t CharWidth( char c, int32_t indent); // TODO : rework this
int32_t CountDispChars( int32_t lineStartPos, int32_t targetPos);
int32_t CountForwardDispChars( int32_t lineStartPos, int32_t nChars);
int32_t CountLines( int32_t startPos, int32_t endPos);
int32_t CountLines( void);
int32_t CountLines( Edn::VectorType<int8_t> &data);
int32_t CountForwardNLines( int32_t startPos, int32_t nLines);
int32_t CountBackwardNLines( int32_t startPos, int32_t nLines);
bool SearchForward( int32_t startPos, Edn::VectorType<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 SearchBackward( int32_t startPos, char searchChar, int32_t *foundPos);
bool SelectAround( int32_t startPos, int32_t &beginPos, int32_t &endPos);
// Buffer Size system :
int32_t Size(void) { return m_data.Size(); };
int32_t NumberOfLines(void) {return m_nbLine;};
// -----------------------------------------
// selection remember...
// -----------------------------------------
public:
bool SelectHasSelection( selectionType_te select);
void Select( selectionType_te select, int32_t start, int32_t end);
void Unselect( selectionType_te select);
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);
void GetSelectionText( selectionType_te select, Edn::VectorType<int8_t> &text);
void RemoveSelected( selectionType_te select);
void ReplaceSelected( selectionType_te select, Edn::VectorType<int8_t> &text);
private:
// current selection of the buffer
selection m_selectionList[SELECTION_SIZE]; //!< Selection area of the buffer
void UpdateSelection( selectionType_te select, int32_t pos, int32_t nDeleted, int32_t nInserted);
void UpdateSelections( int32_t pos, int32_t nDeleted, int32_t nInserted);
// -----------------------------------------
// History section :
// -----------------------------------------
public:
int32_t Undo( void);
int32_t Redo( void);
private:
bool m_isUndoProcessing;
bool m_isRedoProcessing;
Edn::VectorType<EdnBufHistory*> m_historyUndo;
Edn::VectorType<EdnBufHistory*> m_historyRedo;
// -----------------------------------------
// hightlight section :
// -----------------------------------------
private:
Highlight * m_Highlight; //!< internal link with the Highlight system
std::vector<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
void RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdded);
void GenerateHighLightAt(int32_t pos, int32_t endPos, int32_t addinPos=0);
void CleanHighLight(void);
void FindMainHighLightPosition(int32_t startPos, int32_t endPos, int32_t &startId, int32_t &stopId, bool backPreviousNotEnded);
public:
void SetHLSystem( Highlight * newHLSystem);
void HightlightGenerateLines(displayHLData_ts & MData, int32_t startPos, int32_t nbLines);
colorInformation_ts * GetElementColorAtPosition(displayHLData_ts & MData, int32_t pos);
private:
colorInformation_ts * GetElementColorAtPosition(int32_t pos, int32_t &starPos);
private:
EdnVectorBuf m_data; //!< buffer of the data in the mode int8_t
void CountNumberOfLines(void);
int32_t m_nbLine; //!< Number of line in the biffer
// -----------------------------------------
// Display property and charset ...
// -----------------------------------------
public:
int32_t GetTabDistance(void) { return m_tabDist; } ;
void SetTabDistance(int32_t tabDist) { m_tabDist = tabDist; };
charset_te GetCharsetType(void) { return m_charsetType; };
void SetCharsetType(charset_te newOne) { m_charsetType = newOne; if (EDN_CHARSET_UTF8==newOne){m_isUtf8=true;} else {m_isUtf8=false;} };
bool GetUTF8Mode(void) { return m_isUtf8; };
void SetUTF8Mode(bool newOne) { m_isUtf8 = newOne; m_charsetType=EDN_CHARSET_UTF8; };
private:
// Special mode of the buffer :
bool m_isUtf8; //!< true if we are in UTF8 mode ==> if true the size of a char is 0, otherwise .. 1->4 ( TODO : not now)
charset_te m_charsetType; //!< if UTF8 mode is at false : the charset type of the buffer
// Local Tabulation policies
int32_t m_tabDist; //!< equiv. number of characters in a tab
bool m_useTabs; //!< True if buffer routines are allowed to use tabs for padding in rectangular operations
// -----------------------------------------
// Local function :
// -----------------------------------------
private:
void findRectSelBoundariesForCopy( int32_t lineStartPos, int32_t rectStart, int32_t rectEnd, int32_t *selStart, int32_t *selEnd);
char *getSelectionText( selection &sel);
void removeSelected( selection &sel);
void replaceSelected( selection &sel, const char *text);
void eventModification( int32_t pos, int32_t nInserted, Edn::VectorType<int8_t> &deletedText);
int32_t insert( int32_t pos, Edn::VectorType<int8_t> &insertText);
bool charMatch( char first, char second, bool caseSensitive = true);
};
#endif

View File

@@ -1,284 +0,0 @@
/**
*******************************************************************************
* @file EdnBuf_Selection.cpp
* @brief Editeur De N'ours : Buffer for internal Data - section selection (Sources)
* @author Edouard DUPIN
* @date 23/03/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 "EdnBuf.h"
#undef __class__
#define __class__ "EdnBuf{Selection}"
/**
* @brief
*
* @param[in,out] ---
* @param[in,out] ---
*
* @return ---
*
*/
bool EdnBuf::SelectHasSelection(selectionType_te select)
{
return m_selectionList[select].selected;
}
/**
* @brief
*
* @param[in,out] ---
* @param[in,out] ---
*
* @return ---
*
*/
void EdnBuf::Select(selectionType_te select, int32_t start, int32_t end)
{
selection oldSelection = m_selectionList[select];
m_selectionList[select].selected = start != end;
m_selectionList[select].zeroWidth = (start == end) ? true : false;
m_selectionList[select].rectangular = false;
m_selectionList[select].start = edn_min(start, end);
m_selectionList[select].end = edn_max(start, end);
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void EdnBuf::Unselect(selectionType_te select)
{
selection oldSelection = m_selectionList[select];
m_selectionList[select].selected = false;
m_selectionList[select].zeroWidth = false;
}
/**
* @brief
*
* @param[in,out] ---
* @param[in,out] ---
* @param[in,out] ---
* @param[in,out] ---
*
* @return ---
*
*/
void EdnBuf::RectSelect(selectionType_te select, int32_t start, int32_t end, int32_t rectStart, int32_t rectEnd)
{
m_selectionList[select].selected = rectStart < rectEnd;
m_selectionList[select].zeroWidth = (rectStart == rectEnd) ? false : true;
m_selectionList[select].rectangular = true;
m_selectionList[select].start = start;
m_selectionList[select].end = end;
m_selectionList[select].rectStart = rectStart;
m_selectionList[select].rectEnd = rectEnd;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
bool EdnBuf::GetSelectionPos(selectionType_te select, int32_t &start, int32_t &end, bool &isRect, int32_t &rectStart, int32_t &rectEnd)
{
/* Always fill in the parameters (zero-width can be requested too). */
isRect = m_selectionList[select].rectangular;
start = m_selectionList[select].start;
end = m_selectionList[select].end;
if (m_selectionList[select].rectangular) {
rectStart = m_selectionList[select].rectStart;
rectEnd = m_selectionList[select].rectEnd;
}
return m_selectionList[select].selected;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void EdnBuf::GetSelectionText(selectionType_te select, Edn::VectorType<int8_t> &text)
{
int32_t start, end, rectStart, rectEnd;
bool isRect;
// remove output data
text.Clear();
bool isSelected = GetSelectionPos(select, start, end, isRect, rectStart, rectEnd);
// No data selected ...
if (false == isSelected) {
return;
}
// Rectangular selection
if (true == isRect) {
//GetTextInRect(start, end, rectStart, rectEnd, text);
// TODO : ...
} else {
GetRange(start, end, text);
}
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void EdnBuf::RemoveSelected(selectionType_te select)
{
int32_t start, end;
int32_t rectStart, rectEnd;
bool isRect;
bool isSelected = GetSelectionPos(select, start, end, isRect, rectStart, rectEnd);
// No data selected ...
if (false == isSelected) {
return;
}
// Rectangular selection
if (true == isRect) {
//RemoveRect(start, end, rectStart, rectEnd);
// TODO : ...
} else {
Remove(start, end);
}
Unselect(select);
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void EdnBuf::ReplaceSelected(selectionType_te select, Edn::VectorType<int8_t> &text)
{
int32_t start, end, rectStart, rectEnd;
bool isRect;
bool isSelected = GetSelectionPos(select, start, end, isRect, rectStart, rectEnd);
// No data selected ...
if (false == isSelected) {
return;
}
// Rectangular selection
if (true == isRect) {
//ReplaceRect(start, end, rectStart, rectEnd, text);
// TODO : ...
} else {
Replace(start, end, text);
}
// Clean selection
m_selectionList[select].selected = false;
}
/*
** Update all of the selections in "buf" for changes in the buffer's text
*/
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void EdnBuf::UpdateSelections(int32_t pos, int32_t nDeleted, int32_t nInserted)
{
UpdateSelection(SELECTION_PRIMARY , pos, nDeleted, nInserted);
UpdateSelection(SELECTION_SECONDARY , pos, nDeleted, nInserted);
UpdateSelection(SELECTION_HIGHTLIGHT, pos, nDeleted, nInserted);
}
/*
** Update an individual selection for changes in the corresponding text
*/
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void EdnBuf::UpdateSelection(selectionType_te select, int32_t pos, int32_t nDeleted, int32_t nInserted)
{
if( ( false == m_selectionList[select].selected
&& false == m_selectionList[select].zeroWidth)
|| pos > m_selectionList[select].end )
{
return;
}
if (pos+nDeleted <= m_selectionList[select].start) {
m_selectionList[select].start += nInserted - nDeleted;
m_selectionList[select].end += nInserted - nDeleted;
} else if( pos <= m_selectionList[select].start
&& pos+nDeleted >= m_selectionList[select].end)
{
m_selectionList[select].start = pos;
m_selectionList[select].end = pos;
m_selectionList[select].selected = false;
m_selectionList[select].zeroWidth = false;
} else if( pos <= m_selectionList[select].start
&& pos+nDeleted < m_selectionList[select].end)
{
m_selectionList[select].start = pos;
m_selectionList[select].end = nInserted + m_selectionList[select].end - nDeleted;
} else if(pos < m_selectionList[select].end) {
m_selectionList[select].end += nInserted - nDeleted;
if (m_selectionList[select].end <= m_selectionList[select].start) {
m_selectionList[select].selected = false;
}
}
}

Some files were not shown because too many files have changed in this diff Show More