Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
karudu
/
C-editor
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Pipelines
Snippets
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4523c805
authored
Mar 31, 2022
by
Herman Ounas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lisatud search aknasse
parent
43e3d3dd
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
89 additions
and
2 deletions
ceditor.h
search.c
search.h
tab.c
tab.h
ui.c
ui.h
ceditor.h
View file @
4523c805
...
@@ -21,6 +21,8 @@ typedef struct
...
@@ -21,6 +21,8 @@ typedef struct
GtkSourceLanguageManager
*
LangManager
;
GtkSourceLanguageManager
*
LangManager
;
GtkSourceLanguage
*
Language
;
GtkSourceLanguage
*
Language
;
GtkWidget
*
search_entry
;
}
tab
;
}
tab
;
typedef
struct
typedef
struct
...
...
search.c
0 → 100644
View file @
4523c805
#include "search.h"
void
find
(
GtkTextView
*
text_view
,
const
gchar
*
text
,
GtkTextIter
*
iter
)
{
GtkTextIter
mstart
,
mend
;
GtkTextBuffer
*
buffer
;
gboolean
found
;
buffer
=
gtk_text_view_get_buffer
(
GTK_TEXT_VIEW
(
text_view
));
found
=
gtk_text_iter_forward_search
(
iter
,
text
,
0
,
&
mstart
,
&
mend
,
NULL
);
if
(
found
)
{
gtk_text_buffer_select_range
(
buffer
,
&
mstart
,
&
mend
);
gtk_text_buffer_create_mark
(
buffer
,
"last_pos"
,
&
mend
,
FALSE
);
}
}
// funktsioon selleks kui search nuppu vajutatakse
void
Otsi_nupp_vajutatud
(
GtkWidget
*
search_button
,
tab
*
Tab
)
{
const
gchar
*
text
;
GtkTextBuffer
*
buffer
;
GtkTextIter
iter
;
text
=
gtk_entry_get_text
(
GTK_ENTRY
(
Tab
->
search_entry
));
buffer
=
gtk_text_view_get_buffer
(
GTK_TEXT_VIEW
(
Tab
->
TextView
));
gtk_text_buffer_get_start_iter
(
buffer
,
&
iter
);
find
(
GTK_TEXT_VIEW
(
Tab
->
TextView
),
text
,
&
iter
);
}
// funktsioon selleks kui jargmine_nupp vajutatakse
void
Jargmine_nupp_vajutatud
(
GtkWidget
*
next_button
,
tab
*
Tab
)
{
const
gchar
*
text
;
GtkTextBuffer
*
buffer
;
GtkTextMark
*
last_pos
;
GtkTextIter
iter
;
text
=
gtk_entry_get_text
(
GTK_ENTRY
(
Tab
->
search_entry
));
buffer
=
gtk_text_view_get_buffer
(
GTK_TEXT_VIEW
(
Tab
->
TextView
));
last_pos
=
gtk_text_buffer_get_mark
(
buffer
,
"last_pos"
);
if
(
last_pos
==
NULL
)
return
;
gtk_text_buffer_get_iter_at_mark
(
buffer
,
&
iter
,
last_pos
);
find
(
GTK_TEXT_VIEW
(
Tab
->
TextView
),
text
,
&
iter
);
}
search.h
0 → 100644
View file @
4523c805
#ifndef SEARCH_H
#define SEARCH_H
#include "ceditor.h"
#ifdef SOURCEVIEW
#include <gtksourceview/gtksource.h>
#endif
//void search_aken(ui *UI, tab *Tab);
void
find
(
GtkTextView
*
text_view
,
const
gchar
*
text
,
GtkTextIter
*
iter
);
void
Otsi_nupp_vajutatud
(
GtkWidget
*
search_button
,
tab
*
app
);
void
Jargmine_nupp_vajutatud
(
GtkWidget
*
next_button
,
tab
*
app
);
#endif // SEARCH_H
tab.c
View file @
4523c805
...
@@ -22,7 +22,24 @@ void LisaTab(ui *UI)
...
@@ -22,7 +22,24 @@ void LisaTab(ui *UI)
// Tekstiaken
// Tekstiaken
Tab
->
TextView
=
gtk_source_view_new
();
// Loo tekstiaken
Tab
->
TextView
=
gtk_source_view_new
();
// Loo tekstiaken
Tab
->
Puhver
=
gtk_text_view_get_buffer
(
GTK_TEXT_VIEW
(
Tab
->
TextView
));
// Tekstiakna teksti puhver
Tab
->
Puhver
=
gtk_text_view_get_buffer
(
GTK_TEXT_VIEW
(
Tab
->
TextView
));
// Tekstiakna teksti puhver
Tab
->
OnMuudetud
=
0
;
//Tab->OnMuudetud = 0;
GtkWidget
*
hbox
=
gtk_box_new
(
FALSE
,
0
);
//search bar
Tab
->
search_entry
=
gtk_entry_new
();
gtk_box_pack_start
(
GTK_BOX
(
hbox
),
Tab
->
search_entry
,
TRUE
,
TRUE
,
0
);
GtkWidget
*
Otsi_nupp
=
gtk_button_new_with_label
(
"Otsi"
);
// Otsi nupp
gtk_box_pack_start
(
GTK_BOX
(
hbox
),
Otsi_nupp
,
FALSE
,
TRUE
,
3
);
g_signal_connect
(
G_OBJECT
(
Otsi_nupp
),
"clicked"
,
G_CALLBACK
(
Otsi_nupp_vajutatud
),
&
UI
->
Tabid
[
TabidN
]);
GtkWidget
*
Jargmine_nupp
=
gtk_button_new_with_label
(
"Järgmine"
);
// Järmine nupp
gtk_box_pack_start
(
GTK_BOX
(
hbox
),
Jargmine_nupp
,
FALSE
,
TRUE
,
3
);
g_signal_connect
(
G_OBJECT
(
Jargmine_nupp
),
"clicked"
,
G_CALLBACK
(
Jargmine_nupp_vajutatud
),
&
UI
->
Tabid
[
TabidN
]);
// Scroll window
// Scroll window
Tab
->
ScrollWindow
=
gtk_scrolled_window_new
(
NULL
,
NULL
);
// Loo scroll aken
Tab
->
ScrollWindow
=
gtk_scrolled_window_new
(
NULL
,
NULL
);
// Loo scroll aken
...
@@ -41,6 +58,7 @@ void LisaTab(ui *UI)
...
@@ -41,6 +58,7 @@ void LisaTab(ui *UI)
// Box
// Box
Tab
->
Box
=
gtk_box_new
(
GTK_ORIENTATION_VERTICAL
,
0
);
// Vertikaalne box, 0px vahe
Tab
->
Box
=
gtk_box_new
(
GTK_ORIENTATION_VERTICAL
,
0
);
// Vertikaalne box, 0px vahe
gtk_box_pack_start
(
GTK_BOX
(
Tab
->
Box
),
Tab
->
ScrollWindow
,
TRUE
,
TRUE
,
0
);
gtk_box_pack_start
(
GTK_BOX
(
Tab
->
Box
),
Tab
->
ScrollWindow
,
TRUE
,
TRUE
,
0
);
gtk_box_pack_start
(
GTK_BOX
(
Tab
->
Box
),
hbox
,
FALSE
,
TRUE
,
3
);
gtk_box_pack_start
(
GTK_BOX
(
Tab
->
Box
),
Tab
->
StatusBar
,
FALSE
,
FALSE
,
0
);
gtk_box_pack_start
(
GTK_BOX
(
Tab
->
Box
),
Tab
->
StatusBar
,
FALSE
,
FALSE
,
0
);
// Pealkiri
// Pealkiri
...
...
tab.h
View file @
4523c805
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#include "ceditor.h"
#include "ceditor.h"
#include "statusbar.h"
#include "statusbar.h"
#include "textview.h"
#include "textview.h"
#include "search.h"
void
LisaTab
(
ui
*
UI
);
void
LisaTab
(
ui
*
UI
);
void
KustutaTab
(
ui
*
UI
,
int
Indeks
);
void
KustutaTab
(
ui
*
UI
,
int
Indeks
);
...
...
ui.c
View file @
4523c805
...
@@ -123,9 +123,11 @@ ui *LooUI()
...
@@ -123,9 +123,11 @@ ui *LooUI()
UI
->
ToolBar
=
gtk_toolbar_new
();
UI
->
ToolBar
=
gtk_toolbar_new
();
gtk_toolbar_set_style
(
GTK_TOOLBAR
(
UI
->
ToolBar
),
GTK_TOOLBAR_ICONS
);
gtk_toolbar_set_style
(
GTK_TOOLBAR
(
UI
->
ToolBar
),
GTK_TOOLBAR_ICONS
);
GtkWidget
*
UndoIcon
=
gtk_image_new_from_icon_name
(
GTK_STOCK_UNDO
,
5
);
GtkWidget
*
UndoIcon
=
gtk_image_new_from_icon_name
(
GTK_STOCK_UNDO
,
5
);
UI
->
Undo
=
gtk_tool_button_new
(
UndoIcon
,
"undo"
);
GtkWidget
*
RedoIcon
=
gtk_image_new_from_icon_name
(
GTK_STOCK_REDO
,
5
);
GtkWidget
*
RedoIcon
=
gtk_image_new_from_icon_name
(
GTK_STOCK_REDO
,
5
);
GtkWidget
*
SearchIcon
=
gtk_image_new_from_icon_name
(
GTK_STOCK_FIND
,
5
);
UI
->
Undo
=
gtk_tool_button_new
(
UndoIcon
,
"undo"
);
UI
->
Redo
=
gtk_tool_button_new
(
RedoIcon
,
"redo"
);
UI
->
Redo
=
gtk_tool_button_new
(
RedoIcon
,
"redo"
);
//g_signal_connect(UI->Search, "clicked", G_CALLBACK(search_aken), UI);
//nupud toolbarile
//nupud toolbarile
gtk_toolbar_insert
(
GTK_TOOLBAR
(
UI
->
ToolBar
),
UI
->
Undo
,
-
1
);
gtk_toolbar_insert
(
GTK_TOOLBAR
(
UI
->
ToolBar
),
UI
->
Undo
,
-
1
);
gtk_toolbar_insert
(
GTK_TOOLBAR
(
UI
->
ToolBar
),
UI
->
Redo
,
-
1
);
gtk_toolbar_insert
(
GTK_TOOLBAR
(
UI
->
ToolBar
),
UI
->
Redo
,
-
1
);
...
...
ui.h
View file @
4523c805
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
#include "tab.h"
#include "tab.h"
#include "menubar.h"
#include "menubar.h"
#include "compiler.h"
#include "compiler.h"
#include "search.h"
#define PEALKIRI "CEditor"
#define PEALKIRI "CEditor"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment