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
0f32743c
authored
Mar 15, 2022
by
castro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete search.c
parent
44ed5103
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
122 deletions
search.c
search.c
deleted
100644 → 0
View file @
44ed5103
#include <gtk/gtk.h>
/* TODO
Failide avamine
Failide salvestamine
*/
#ifdef SOURCEVIEW
#include <gtksourceview/gtksource.h>
#endif
#ifdef SOURCEVIEW
#define PEALKIRI "CEditor SourceView"
#else
#define PEALKIRI "CEditor TextView"
#endif
// Uuenda nidatud rida ja veergu kursori asukoha jrgi
void
UuendaRidaVeerg
(
GtkTextBuffer
*
Puhver
,
GtkStatusbar
*
StatusBar
)
{
GtkTextIter
Iter
;
// Leia kursori asukoht
gtk_text_buffer_get_iter_at_mark
(
Puhver
,
&
Iter
,
gtk_text_buffer_get_insert
(
Puhver
));
// Vta selle rida ja veerg
gint
Rida
=
gtk_text_iter_get_line
(
&
Iter
);
gint
Veerg
=
gtk_text_iter_get_line_offset
(
&
Iter
);
gtk_statusbar_pop
(
StatusBar
,
0
);
// Vta eelmine tekst ra
gchar
*
Tekst
=
g_strdup_printf
(
"%d:%d"
,
Rida
+
1
,
Veerg
+
1
);
// Loo string rea ja veeruga
gtk_statusbar_push
(
StatusBar
,
0
,
Tekst
);
// Nita teksti
g_free
(
Tekst
);
}
// Kutsutakse copy/paste lohistamise korral, praegu lihtsalt uuendab rida/veergu
void
TekstMarkSet
(
GtkTextBuffer
*
Puhver
,
const
GtkTextIter
*
new_location
,
GtkTextMark
*
Mark
,
gpointer
Data
)
{
UuendaRidaVeerg
(
Puhver
,
GTK_STATUSBAR
(
Data
));
}
int
main
(
int
argc
,
char
**
argv
)
{
gtk_init
(
&
argc
,
&
argv
);
// Aken
GtkWidget
*
Aken
=
gtk_window_new
(
GTK_WINDOW_TOPLEVEL
);
// Loo aken
gtk_window_set_position
(
GTK_WINDOW
(
Aken
),
GTK_WIN_POS_CENTER
);
// Aken ekraani keskel
gtk_window_set_default_size
(
GTK_WINDOW
(
Aken
),
800
,
600
);
// Akna suurus
gtk_window_set_title
(
GTK_WINDOW
(
Aken
),
PEALKIRI
);
// Pealkiri
// Close nupu callback
g_signal_connect_swapped
(
G_OBJECT
(
Aken
),
"destroy"
,
G_CALLBACK
(
gtk_main_quit
),
NULL
);
// Box
GtkWidget
*
Box
=
gtk_box_new
(
GTK_ORIENTATION_VERTICAL
,
0
);
// Vertikaalne box, 0px vahe
gtk_container_add
(
GTK_CONTAINER
(
Aken
),
Box
);
// Pane box aknasse
// Menu bar
GtkWidget
*
MenuBar
=
gtk_menu_bar_new
();
// Loo menu bar
GtkWidget
*
FailMenuNupp
=
gtk_menu_item_new_with_label
(
"Fail"
);
// Fail
GtkWidget
*
AboutMenuNupp
=
gtk_menu_item_new_with_label
(
"About"
);
// About
GtkWidget
*
FailMenu
=
gtk_menu_new
();
// Fail men
GtkWidget
*
FailMenuUus
=
gtk_menu_item_new_with_label
(
"Uus"
);
// Fail->Uus
GtkWidget
*
FailMenuAva
=
gtk_menu_item_new_with_label
(
"Ava"
);
// Fail->Ava
GtkWidget
*
FailMenuSalvesta
=
gtk_menu_item_new_with_label
(
"Salvesta"
);
// Fail->Salvesta
GtkWidget
*
FailMenuSalvestaN
=
gtk_menu_item_new_with_label
(
"Salvesta nimega"
);
// Fail->Salvesta nimega
GtkWidget
*
FailMenuValju
=
gtk_menu_item_new_with_label
(
"Vlju"
);
// Fail->Vlju
// Search
GtkWidget
*
search_nupp
=
gtk_menu_item_new_with_label
(
"Otsi"
);
GtkWidget
*
search_aken
;
// Men nupud menu bar'i
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
MenuBar
),
FailMenuNupp
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
MenuBar
),
AboutMenuNupp
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
MenuBar
),
search_nupp
);
// Mend nuppudesse
gtk_menu_item_set_submenu
(
GTK_MENU_ITEM
(
FailMenuNupp
),
FailMenu
);
// Fail men
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
FailMenu
),
FailMenuUus
);
// Fail->Uus
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
FailMenu
),
FailMenuAva
);
// Fail->Ava
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
FailMenu
),
FailMenuSalvesta
);
// Fail->Salvesta
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
FailMenu
),
FailMenuSalvestaN
);
// Fail->Salvesta nimega
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
FailMenu
),
gtk_separator_menu_item_new
());
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
FailMenu
),
FailMenuValju
);
// Fail->Vlju
g_signal_connect
(
G_OBJECT
(
FailMenuValju
),
"activate"
,
G_CALLBACK
(
gtk_main_quit
),
NULL
);
// Search
//GtkWidget *search_nupp = gtk_button_new_with_label ("Otsi");
//GtkWidget *search_aken ;
//gtk_menu_shell_append(GTK_MENU_SHELL(MenuBar), search_nupp);
// Pane search nupp aknasse
//gtk_box_pack_start(GTK_BOX(Box), search_nupp, FALSE, FALSE, 0);
// Pane menubar box'i
gtk_box_pack_start
(
GTK_BOX
(
Box
),
MenuBar
,
FALSE
,
FALSE
,
0
);
// Tekstiaken
#ifdef SOURCEVIEW
GtkWidget
*
View
=
gtk_source_view_new
();
// Loo tekstiaken
#else
GtkWidget
*
View
=
gtk_text_view_new
();
// Loo tekstiaken
#endif
gtk_box_pack_start
(
GTK_BOX
(
Box
),
View
,
TRUE
,
TRUE
,
0
);
// Pane tekstiaken box'i
// Teksti puhver
GtkTextBuffer
*
Puhver
=
gtk_text_view_get_buffer
(
GTK_TEXT_VIEW
(
View
));
// Tekstiakna teksti puhver
// Status bar
GtkWidget
*
StatusBar
=
gtk_statusbar_new
();
// Loo status bar
gtk_box_pack_start
(
GTK_BOX
(
Box
),
StatusBar
,
FALSE
,
FALSE
,
0
);
// Pane statusbar box'i
// Teksti muutuse callback, uuendab rida/veergu
g_signal_connect
(
Puhver
,
"changed"
,
G_CALLBACK
(
UuendaRidaVeerg
),
StatusBar
);
// Copy/paste lohistamise callback, uuendab samuti
g_signal_connect_object
(
Puhver
,
"mark_set"
,
G_CALLBACK
(
TekstMarkSet
),
StatusBar
,
0
);
gtk_widget_show_all
(
Aken
);
// Nita akent
UuendaRidaVeerg
(
Puhver
,
GTK_STATUSBAR
(
StatusBar
));
// Esimene uuendus
gtk_main
();
return
0
;
}
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