First commit

This commit is contained in:
mollusk 2016-11-25 00:27:22 -07:00
commit 5106228da2
41 changed files with 40154 additions and 0 deletions

13
editor Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
if [ ! -f /usr/bin/eui ];then
sudo ./tools/euphoria-manager i
eui ./tools/WEE/wee.exw
else
if [ "${1}" = "-c" ];then
euc ./tools/WEE/wee.exw
fi
eui ./tools/WEE/wee.exw
fi

39
eugtk/GtkAboutDialog.e Normal file
View File

@ -0,0 +1,39 @@
-------------------
namespace about -- Generic About dialog
-------------------
export constant version = "4.12.0"
--# EXPORTS: about:Dialog -- use run(about:Dialog), not show()
include GtkEngine.e
public include euphoria/info.e
if not equal(version,gtk:version) then
Error(,,"GtkAboutDialog version mismatch","should be version " & gtk:version)
end if
export atom Dialog = create(GtkAboutDialog,{
{"name","about:dialog"},
{"logo","thumbnails/eugtk.png"},
{"program name",prg_name},
{"version","EuGTK version: " & gtk:version},
{"copyright",copyright},
{"comments","For information on the Euphoria\nprogramming language, click below"},
-- must specify custom as the license type if supplying license text;
{"license type",GTK_LICENSE_CUSTOM},
{"license",LGPL}, -- LGPL text is built into EuGTK
{"wrap license",0},
{"website","http://OpenEuphoria.org"},
{"website label","OpenEuphoria"},
{"authors",{"Irv Mullins"}},
--{"artists",0},
--{"documenters",0},
--{"translator credits",0},
--{"add credit section","Special Thanks to",{"\nBob's Burgers\nDuff's Beer"}},
$})

643
eugtk/GtkCairo.e Normal file
View File

@ -0,0 +1,643 @@
----------------------------
namespace cairo
----------------------------
export constant version = "4.12.0"
include GtkEngine.e
if not equal(version,gtk:version) then
Error(,,"GtkCairo version mismatch","should be version " & gtk:version)
end if
export constant pango_version = gtk_str_func("pango_version_string")
widget[GdkCairo_t] = {"gdk_cairo",
{Cairo_t},
{"new",{P},-routine_id("newGdkCairo")},
{"draw_from_gl",{P,P,I,I,I,I,I,I,I}}, -- 3.16
{"get_clip_rectangle",{P},-routine_id("getClipRect")},
{"set_source_pixbuf",{P,P,D,D}},
{"set_source_window",{P,P,D,D}},
{"region",{P,P}},
{"region_create_from_surface",{P},P},
{"surface_create_from_pixbuf",{P,I,P},P,0,CairoSurface_t},
{"set_source_rgba",{P,I,I,I,D},-routine_id("setCairoRGBA")},
{"set_color",{P,P},-routine_id("setCairoColor")},
"GdkCairo_t"}
function getClipRect(atom cr)
atom fn = define_func("gdk_cairo_get_clip_rectangle",{P,P},B)
atom rect = allocate(8,1)
if c_func(fn,{cr,rect}) then
return rect
else return -1
end if
end function
function newGdkCairo(atom win)
return gtk_func("gdk_cairo_create",{P},{win})
end function
----------------------------------------------------------------
-- to use the Cairo color specs, where colors are 0.0 => 1.0
----------------------------------------------------------------------
function setCairoRGBA(atom cr, atom r, atom g, atom b, atom a=1)
gtk_proc("cairo_set_source_rgba",{P,D,D,D,D},{cr,r,g,b,a})
return 1
end function
--------------------------------------------
-- it's easier to use named colors
--------------------------------------------
function setCairoColor(atom cr, object color)
if atom(color) then color = sprintf("#%06x",color) end if
color = to_rgba(color)
color = from_rgba(color,7)
setCairoRGBA(cr,color[1],color[2],color[3],color[4])
return 1
end function
widget[Cairo_t] = {"cairo",
{GObject},
{"create",{P},P},
{"reference",{P},P},
{"destroy",{P}},
{"status",{P},I},
{"save",{P}},
{"restore",{P}},
{"get_target",{P},P,0,CairoSurface_t},
{"push_group",{P}},
{"push_group_with_content",{P,P}},
{"pop_group",{P},P},
{"pop_group_to_source",{P}},
{"get_group_target",{P},P},
{"set_source_rgb",{P,D,D,D}},
{"set_source",{P,P}},
{"get_source",{P},P},
{"set_source_surface",{P,P,D,D}},
{"set_antialias",{P,I}},
{"get_antialias",{P},I},
{"set_dash",{P,P,I,D}},
{"get_dash_count",{P},I},
{"get_dash",{P,D,D}},
{"set_fill_rule",{P,I}},
{"get_fill_rule",{P},I},
{"set_line_cap",{P,I}},
{"get_line_cap",{P},I},
{"set_line_join",{P,I}},
{"get_line_join",{P},I},
{"set_line_width",{P,D}},
{"get_line_width",{P},D},
{"set_miter_limit",{P,I}},
{"get_miter_limit",{P},I},
{"set_operator",{P,I}},
{"get_operator",{P},I},
{"set_tolerance",{P,D}},
{"get_tolerance",{P},D},
{"clip",{P}},
{"clip_preserve",{P}},
{"clip_extents",{P,D,D,D,D}},
{"in_clip",{P,D,D},B},
{"reset_clip",{P}},
{"rectangle_list_destroy",{P}},
{"fill",{P}},
{"fill_preserve",{P}},
{"fill_extents",{P,D,D,D,D}},
{"in_fill",{P,D,D},B},
{"mask",{P,P}},
{"mask_surface",{P,P,D,D}},
{"paint",{P}},
{"paint_with_alpha",{P,D}},
{"stroke",{P}},
{"stroke_preserve",{P}},
{"stroke_extents",{P,D,D,D,D}},
{"in_stroke",{P,D,D},B},
{"copy_page",{P}},
{"show_page",{P}},
{"copy_path",{P},P},
{"copy_path_flat",{P},P},
{"path_destroy",{P}},
{"append_path",{P,P}},
{"has_current_point",{P},B},
{"get_current_point",{P,D,D}},
{"new_path",{P}},
{"new_sub_path",{P}},
{"close_path",{P}},
{"set_user_data",{P,S,P,P},I},
{"get_user_data",{P,S}},
{"arc",{P,D,D,D,D,D}},
{"arc_negative",{P,D,D,D,D,D}},
{"move_to",{P,D,D}},
{"rel_move_to",{P,D,D}},
{"line_to",{P,D,D}},
{"rel_line_to",{P,D,D}},
{"rectangle",{P,D,D,D,D}},
{"glyph_path",{P,I,I}},
{"text_path",{P,S}},
{"curve_to",{P,D,D,D,D,D,D}},
{"rel_curve_to",{P,D,D,D,D,D,D}},
{"path_extents",{P,D,D,D,D}},
{"set_font_face",{P,S}},
{"device_get_type",{P},I},
{"device_status",{P},I},
{"status_to_string",{I},S},
{"translate",{P,D,D}},
{"scale",{P,D,D}},
{"rotate",{P,D}},
{"transform",{P,P}},
{"translate",{P,D,D}},
{"scale",{P,D,D}},
{"rotate",{P,D}},
{"transform",{P,P}},
{"set_matrix",{P,P}},
{"get_matrix",{P,P}},
{"identity_matrix",{P}},
{"user_to_device",{P,D,D}},
{"user_to_device_distance",{P,D,D}},
{"device_to_user",{P,D,D}},
{"device_to_user_distance",{P,D,D}},
{"version",{},I},
{"version_string",{},S},
{"set_font_size",{P,D}},
{"set_font_matrix",{P,P}},
{"get_font_matrix",{P,P}},
{"set_font_options",{P,P}},
{"get_font_options",{P,P}},
{"select_font_face",{P,S,I,I}},
{"get_font_face",{P},P},
{"set_scaled_font",{P,P}},
{"get_scaled_font",{P},P},
{"show_glyphs",{P,P}},
{"show_text_glyphs",{P,S,I,P,I,P,I,I}},
{"font_extents",{P,P}},
{"text_extents",{P,S,P}},
{"glyph_extents",{P,P,I,P}},
{"toy_font_face_create",{S,I,I},P},
{"toy_font_face_get_slant",{P},I},
{"toy_font_face_get_weight",{P},I},
{"glyph_allocate",{I},P},
{"glyph_free",{P}},
{"text_cluster_allocate",{I},P},
{"text_cluster_free",{P}},
{"show_text",{P,S}},
{"set_source_rgba",{P,D,D,D,D},-routine_id("setCairoRGBA")},
{"set_color",{P,S},-routine_id("setCairoColor")},
{"should_draw_window",{P,P},-routine_id("CairoShouldDrawWin")},
{"transform_to_window",{P,P,P},-routine_id("CairoTransformToWin")},
"Cairo_t"}
function CairoShouldDrawWin(atom cr, atom win)
return gtk_func("gtk_cairo_should_draw_window",{P,P},{cr,win})
end function
function CairoTransformToWin(atom cr, atom win1, atom win2)
gtk_proc("gtk_cairo_transform_to_window",{P,P,P},{cr,win1,win2})
return 1
end function
widget[CairoPattern_t] = {0,
{Cairo_t},
"CairoPattern_t"}
widget[CairoFontOptions] = {"cairo_font_options",
{0},
"CairoFontOptions"}
widget[CairoContent_t] = {0,
{Cairo_t},
"CairoContent_t"}
widget[CairoStatus_t] = {0,
{0},
"CairoStatus_t"}
widget[CairoPattern] = {"cairo_pattern",
{CairoPattern_t},
{"new",{P},-routine_id("newCairoPattern")},
{"add_color_stop_rgb",{P,D,D,D,D}},
{"add_color_stop_rgba",{P,D,D,D,D,D}},
{"get_color_stop_count",{P,I},P,0,CairoStatus_t},
{"get_color_stop_rgba",{P,I,D,D,D,D,D},P,0,CairoStatus_t},
{"create_rgb",{D,D,D},P,0,CairoPattern_t},
{"create_rgba",{D,D,D,D},P,0,CairoPattern_t},
{"get_rgba",{P,D,D,D,D},P,0,CairoPattern_t},
{"create_for_surface",{P},P,0,CairoPattern_t},
{"reference",{P},P,0,CairoPattern_t},
{"destroy",{P}},
{"status",{P},P,0,CairoStatus_t},
{"set_extend",{P,I}},
{"get_extend",{P},I},
{"set_filter",{P,I}},
{"get_filter",{P},I},
{"set_matrix",{P,P}},
{"get_matrix",{P,P}},
{"get_type",{P},I},
{"get_reference_count",{P},I},
"CairoPattern"}
function newCairoPattern(atom surf)
return gtk_func("cairo_pattern_create_for_surface",{P},{surf})
end function
widget[CairoLinearGradient] = {"cairo_pattern",
{CairoPattern},
{"new",{D,D,D,D},-routine_id("newLinearGradient"),0,CairoPattern_t},
{"get_linear_points",{P,D,D,D,D},P,0,CairoStatus_t},
"CairoLinearGradient"}
function newLinearGradient(atom a, atom b, atom c, atom d)
return gtk_func("cairo_pattern_create_linear",{D,D,D,D},{a,b,c,d})
end function
widget[CairoRadialGradient] = {"cairo_pattern",
{CairoPattern},
{"new",{D,D,D,D,D,D},-routine_id("newRadialGradient"),0,CairoPattern_t},
{"get_radial_circles",{P,D,D,D,D,D,D},P,0,CairoStatus_t},
"CairoRadialGradient"}
function newRadialGradient(atom a, atom b, atom c, atom d, atom e, atom f)
return gtk_func("cairo_pattern_create_radial",{D,D,D,D,D,D},{a,b,c,d,e,f})
end function
widget[CairoRegion_t] = {"cairo_region_t", -- FIXME!
{Cairo_t},
"CairoRegion_t"}
widget[CairoSurface_t] = {"cairo_surface_t",
{Cairo_t},
{"get_write_to_png",{P,S},-routine_id("writetoPNG")},
{"create_similar",{P,P,I,I},P,0,CairoSurface_t},
{"create_for_rectangle",{P,D,D,D,D},P,0,CairoSurface_t},
{"reference",{P},P,0,CairoSurface_t},
{"destroy",{P}},
{"finish",{P}},
{"flush",{P}},
{"get_font_options",{P,P}},
{"mark_dirty",{P}},
{"mark_dirty_rectangle",{P,I,I,I,I}},
{"show_page",{P}},
"CairoSurface_t"}
function writetoPNG(atom surf, object name) -- note difference in call name;
return gtk_func("cairo_surface_write_to_png",{P,S},{surf,name})
end function
widget[CairoImageSurface] = {"cairo_image_surface",
{CairoSurface_t},
{"new",{P},-routine_id("newCairoImageSurface")},
{"get_format",{P},I},
{"get_width",{P},P},
{"get_height",{P},P},
{"get_stride",{P},I},
"CairoImageSurface"}
function newCairoImageSurface(object png)
if string(png) then
png = locate_file(png) if file_type(png) = 1 then
png = allocate_string(png)
end if
end if
return gtk_func("cairo_image_surface_create_from_png",{S},{png})
end function
widget[PangoCairoLayout] = {"pango_cairo",
{PangoLayout},
{"new",{P},-routine_id("newPangoCairoLayout")},
{"update_layout",{P,P},-routine_id("updateLayout")},
{"show_glyph_string",{P,P,P}},
{"show_glyph_item",{P,S,P}},
{"show_layout_line",{P,P}},
{"layout_line_path",{P,P}},
{"layout_path",{P,P}},
"PangoCairoLayout"}
function newPangoCairoLayout(atom cr)
atom pcl = gtk_func("pango_cairo_create_layout",{P},{cr})
register(pcl,PangoLayout)
return pcl
end function
function updateLayout(atom pl, atom cr) -- params swapped;
gtk_proc("pango_cairo_update_layout",{P,P},{cr,pl})
return 1
end function
widget[PangoFont] = {"pango_font",
{0},
{"describe",{P},P,0,PangoFontDescription},
{"describe_with_absolute_size",{P},P,0,PangoFontDescription},
{"get_coverage",{P,P},P},
{"get_metrics",{P,P},P},
{"get_font_map",{P},P,0,PangoFontMap},
"PangoFont"}
widget[PangoAttrList] = {"pango_attr_list",
{0},
"PangoAttrList"}
widget[PangoFontDescription] = {"pango_font_description",
{PangoFont},
{"new",{P},-routine_id("newPangoFontDescription")},
{"copy",{P},P,0,PangoFontDescription},
{"copy_static",{P},P,0,PangoFontDescription},
{"hash",{P},I},
{"equal",{P,P},B},
{"free",{P}},
{"set_family",{P,S}},
{"set_family_static",{P,S}},
{"get_family",{P},S},
{"set_style",{P,I}},
{"get_style",{P},I},
{"set_variant",{P,I}},
{"get_variant",{P},P},
{"set_weight",{P,I}},
{"get_weight",{P},I},
{"set_stretch",{P,I}},
{"get_stretch",{P},I},
{"set_size",{P,I}},
{"get_size",{P},I},
{"set_absolute_size",{P,D}},
{"get_size_is_absolute",{P},B},
{"set_gravity",{P,I}},
{"get_gravity",{P},I},
{"get_set_fields",{P},I},
{"unset_fields",{P,I}},
{"merge",{P,P,B}},
{"merge_static",{P,P,B}},
{"better_match",{P,P,P},B},
-- from_string, see new
{"to_string",{P},S},
{"to_filename",{P},S},
"PangoFontDescription"}
function newPangoFontDescription(object name=0)
if atom(name) then
return gtk_func("pango_font_description_new")
else
return gtk_func("pango_font_description_from_string",{P},{allocate_string(name,1)})
end if
end function
widget[PangoContext] = {"pango_context",
{GObject},
{"new",{},P},
{"load_font",{P,P},P},
{"load_fontset",{P,P,P},P},
{"get_metrics",{P,P,P},P},
{"list_families",{P,A,I}},
{"set_font_description",{P,P}},
{"get_font_description",{P},P,0,PangoFontDescription},
{"set_font_map",{P,P}},
{"get_font_map",{P},P},
{"set_base_gravity",{P,I}},
{"get_language",{P},P},
{"set_language",{P,P}},
{"get_layout",{P},P},
{"get_base_dir",{P},I},
{"set_base_dir",{P,I}},
{"get_base_gravity",{P},I},
{"set_base_gravity",{P,I}},
{"get_gravity",{P},I},
{"get_gravity_hint",{P},I},
{"set_gravity_hint",{P,I}},
{"get_matrix",{P},P},
{"set_matrix",{P,P}},
"PangoContext"}
widget[PangoFontsetSimple] = {"pango_fontset_simple",
{GObject},
{"new",{P},P},
{"append",{P,P}},
{"size",{P},I},
"PangoFontsetSimple"}
widget[PangoFontSet] = {"pango_fontset",
{PangoFontsetSimple},
{"get_font",{P,I},P,0,PangoFont},
{"get_metrics",{P},P},
{"foreach",{P,P,P}},
"PangoFontSet"}
widget[PangoFontMap] = {"pango_font_map",
{PangoFontSet},
{"create_context",{P},P},
{"load_font",{P,P,S},P},
{"load_fontset",{P,P,S,P},P},
{"list_families",{P,A,I}},
{"get_shape_engine_type",{P},S},
{"get_serial",{P},I},
{"changed",{P}},
"PangoFontMap"}
widget[PangoFontFace] = {"pango_font_face",
{PangoFontMap},
{"get_face_name",{P},S},
{"list_sizes",{P,P,I}},
{"describe",{P},P,0,PangoFontDescription},
{"is_synthesized",{P},B},
"PangoFontFace"}
widget[PangoFontFamily] = {"pango_font_family",
{PangoFontFace},
{"get_name",{P},S},
{"is_monospace",{P},B},
{"list_faces",{P,P,I}},
"PangoFontFamily"}
widget[PangoLayout] = {"pango_layout",
{GObject},
{"new",{P},-routine_id("newPangoLayout")},
{"set_text",{P,P},-routine_id("pl_set_text")},
{"get_text",{P},S},
{"get_character_count",{P},I},
{"set_markup",{P,S},-routine_id("pl_set_markup")},
{"set_markup_with_accel",{P,S,I,I},-routine_id("pl_set_markup_with_accel")},
{"set_font_description",{P,P}},
{"get_font_description",{P},P},
{"set_attributes",{P,P}},
{"get_attributes",{P},P,0,PangoAttrList},
{"set_width",{P,I}},
{"get_width",{P},I},
{"set_height",{P,I}},
{"get_height",{P},I},
{"get_size",{P,I,I}},
{"get_pixel_size",{P,I,I}},
{"set_wrap",{P,I}},
{"get_wrap",{P},I},
{"is_wrapped",{P},B},
{"set_ellipsize",{P,I}},
{"get_ellipsize",{P},I},
{"is_ellipsized",{P},B},
{"set_indent",{P,I}},
{"get_extents",{P,P,P}},
{"get_indent",{P},I},
{"get_pixel_size",{P,I,I}},
{"get_size",{P,I,I}},
{"set_spacing",{P,I}},
{"get_spacing",{P},I},
{"set_justify",{P,B}},
{"get_justify",{P},B},
{"set_auto_dir",{P,B}},
{"get_auto_dir",{P},B},
{"set_alignment",{P,P}},
{"get_alignment",{P},P},
{"set_tabs",{P,A}},
{"get_tabs",{P},A},
{"set_single_paragraph_mode",{P,B}},
{"get_single_paragraph_mode",{P},B},
{"get_unknown_glyphs_count",{P},I},
{"get_log_attrs",{P,P,I}},
{"get_log_attrs_readonly",{P,I},P},
{"index_to_pos",{P,I,P}},
{"index_to_line_x",{P,I,B,I,I}},
{"xy_to_line",{P,I,I,I,I},B},
{"get_cursor_pos",{P,I,P,P}},
{"move_cursor_visually",{P,B,I,I,I,I,I}},
{"get_pixel_extents",{P,P,P}},
{"get_baseline",{P},I},
{"get_line_count",{P},I},
{"get_line",{P,I},P,0,PangoLayoutLine},
{"get_line_readonly",{P,I},P,0,PangoLayoutLine},
{"get_lines",{P},A,0,GSList},
{"get_lines_readonly",{P},A,0,GSList},
{"get_iter",{P},P,0,PangoLayoutIter},
{"show_layout",{P,P},-routine_id("pl_show_layout")},
{"get_context",{P},P,0,PangoContext},
{"context_changed",{P}},
{"get_serial",{P},I},
{"get_extents",{P,P,P}},
"PangoLayout"}
function newPangoLayout(atom cr=0)
if cr=0 then
Error(,,"requires cairo_t as param!")
end if
return gtk_func("pango_cairo_create_layout",{P},{cr})
end function
function pl_set_text(atom layout, object txt)
if string(txt) then
txt = allocate_string(txt,1)
end if
gtk_proc("pango_layout_set_text",{P,P,I},{layout,txt,-1})
return 1
end function
function pl_set_markup(atom layout, object txt)
if string(txt) then
txt = allocate_string(txt,1)
end if
gtk_proc("pango_layout_set_markup",{P,P,I},{layout,txt,-1})
return 1
end function
function pl_set_markup_with_accel(atom layout, object txt,
integer marker, integer char)
if string(txt) then
txt = allocate_string(txt,1)
end if
gtk_proc("pango_layout_set_markup_with_accel",{P,P,I,I,I},
{layout,txt,-1,marker,char})
return 1
end function
function pl_show_layout(atom pcl, atom cr)
gtk_proc("pango_cairo_show_layout",{P,P},{cr,pcl})
return 1
end function
widget[PangoLayoutLine] = {"pango_layout_line",
{0},
{"ref",{P},P},
{"unref",{P}},
{"get_extents",{P,P,P}},
{"get_pixel_extents",{P,P,P}},
{"index_to_x",{P,I,B,I}},
{"x_to_index",{P,I,I,I},B},
{"get_x_ranges",{P,I,I,P,P}},
"PangoLayoutLine"}
widget[PangoLayoutIter] = {"pango_layout_iter",
{0},
{"copy",{P},P,0,PangoLayoutIter},
{"free",{P}},
{"next_run",{P},B},
{"next_char",{P},B},
{"next_cluster",{P},B},
{"next_line",{P},B},
{"at_last_line",{P},B},
{"get_index",{P},I},
{"get_baseline",{P},I},
{"get_run",{P},P,0,PangoLayoutRun},
{"get_run_readonly",{P},P,0,PangoLayoutRun},
{"get_line",{P},P,0,PangoLayoutLine},
{"get_line_readonly",{P},P,0,PangoLayoutLine},
{"get_layout",{P},P,0,PangoLayout},
{"get_char_extents",{P,P}},
{"get_cluster_extents",{P,P,P}},
{"get_run_extents",{P,P,P}},
{"get_line_yrange",{P,I,I}},
{"get_line_extents",{P,P,P}},
{"get_layout_extents",{P,P,P}},
"PangoLayoutIter"}
widget[PangoLayoutRun] = {"pango_layout_run",
{0},
"PangoLayoutRun"}
widget[PangoTabArray] = {"pango_tab_array",
{0},
{"new",{I,B},P},
{"get_size",{P},I},
{"resize",{P,I}},
{"set_tab",{P,I,I,I}},
{"get_tab",{P,I,P,P}},
{"get_tabs",{P,P,P}},
{"get_position_in_pixels",{P},B},
"PangoTabArray"}
widget[PangoLanguage] = {"pango_language",
{GObject},
{"new",{S},-routine_id("newPangoLanguage")},
{"get_default",{P},-routine_id("getDefaultLanguage")},
{"get_sample_string",{P},-routine_id("getSampleStr")},
{"to_string",{P},S},
{"matches",{P,S},B},
{"includes_script",{P,P},B},
"PangoLanguage"}
function newPangoLanguage(object s)
return gtk_func("pango_language_from_string",{S},{s})
end function
function getDefaultLanguage(object junk)
return gtk_str_func("pango_language_get_default")
end function
function getSampleStr(object x)
return gtk_str_func("pango_language_get_sample_string",{P},{x})
end function
export enum by * 2
PANGO_STRETCH_ULTRA_CONDENSED,
PANGO_STRETCH_EXTRA_CONDENSED,
PANGO_STRETCH_CONDENSED,
PANGO_STRETCH_SEMI_CONDENSED,
PANGO_STRETCH_NORMAL,
PANGO_STRETCH_SEMI_EXPANDED,
PANGO_STRETCH_EXPANDED = 64,
PANGO_STRETCH_EXTRA_EXPANDED,
PANGO_STRETCH_ULTRA_EXPANDED
export enum by * 2
PANGO_FONT_MASK_FAMILY,
PANGO_FONT_MASK_STYLE,
PANGO_FONT_MASK_VARIANT,
PANGO_FONT_MASK_WEIGHT,
PANGO_FONT_MASK_STRETCH,
PANGO_FONT_MASK_SIZE,
PANGO_FONT_MASK_GRAVITY

9648
eugtk/GtkEngine.e Normal file

File diff suppressed because it is too large Load Diff

1514
eugtk/GtkEnums.e Normal file

File diff suppressed because it is too large Load Diff

277
eugtk/GtkEvents.e Normal file
View File

@ -0,0 +1,277 @@
----------------
namespace events
----------------
export constant version = "4.12.0"
--Thanks to Pete Eberlein for helping with this!
include GtkEngine.e
include std/convert.e
if not equal(version,gtk:version) then
Error(,,"GtkEvents version mismatch","should be version " & gtk:version)
end if
-- Maps keys from keypad to match same keys on keyboard,
-- maps control/arrow keys to negative numbers, so they
-- can be differentiated from the same ascii character
-- values;
constant keyvalues = {
{8,-8}, -- bksp
{9,-9}, -- tab
{20,-20}, -- scroll lock
{27,27}, -- escape
{80,-80}, -- home 'P'
{81,-81}, -- left arrow 'Q'
{82,-82}, -- up arrow 'R'
{83,-83}, -- right arrow 'S'
{84,-84}, -- down arrow 'T'
{85,-85}, -- page up 'U'
{86,-86}, -- page dn 'V'
{87,-87}, -- end 'W'
{99,-99}, -- insert 'c'
{103,-103},
{127,-127}, -- num lock
{141,13}, -- keypad Enter, with or w/o numlock;
-- keypad keys w/o numlock;
{149,-149}, -- keypad home
{150,-150}, -- keypad left
{151,-151}, -- keypad up
{152,-152}, -- keypad right
{153,-153}, -- keypad down
{154,-154}, -- keypad pg up
{155,-155}, -- keypad pg dn
{156,-156}, -- keypad end
{157,-157}, -- keypad 5
{158,-158}, -- keypad ins
{159,-159}, -- keypad del
-- keypad keys with numlock - return ascii 0..9
{170,'*'},{171,'+'},{173,'-'},{175,'/'},
{176,48},{177,49},{178,50},{179,51},{180,52}, -- keypad numbers 0..4
{181,53},{182,54},{183,55},{184,56},{185,57}, -- keypad numbers 5..9
-- F keys;
{190,-190}, -- F1
{191,-191}, -- F2
{192,-192}, -- F3
{193,-193}, -- F4
{194,-194}, -- F5
{195,-195}, -- F6
{196,-196}, -- F7
{197,-197}, -- F8
{198,-198}, -- F9
{199,-199}, -- F10
{200,-200}, -- F11
{201,-201}, -- F12
{227,-227}, -- left ctl
{228,-228}, -- right ctl
{229,-229},
{225,-225}, -- left shift
{226,-226}, -- right shift
{228,-228},
{233,-233}, -- left alt
{234,-234}, -- right alt
{236,-236},
{255,-255}, -- delete
$}
constant shiftkeys = {
{32,-9}, -- shift tab
$}
constant event_names = {
{3,"focus-in"},
{11,"focus-out"}
}
----------------------------------------------------------------------
export function key(atom event) -- get key pressed;
----------------------------------------------------------------------
if event = 0 then return 0 end if
integer k = peek(event+16)
integer z = peek(event+17)
integer s = state(event)
ifdef BITS64 then
k = peek(event+28)
z = peek(event+29)
end ifdef
switch z do
case 0 then return k
case 255 then return vlookup(k,keyvalues,1,2,k)
case 254 then return vlookup(k,shiftkeys,1,2,k)
end switch
return 0
end function
--(32/64)struct GdkEventButton
-- 0 0 GdkEventType type a.k.a. id
-- 4 8 GtkWindow *window
-- 8 16 gint8 send_event
-- 12 20 guint32 time
-- 16 24 gdouble x
-- 24 32 gdouble y
-- 32 40 gdouble *axes
-- 36 48 guint state
-- 40 52 guint button
-- 44 56 GdkDevice *device
-- 48 64 gdouble x_root, y_root
---------------------------------------------------------------------
export function id(atom event)
---------------------------------------------------------------------
if event > 0 then return peek4u(event) else return event end if
end function
---------------------------------------------------------------------
export function name(atom event)
---------------------------------------------------------------------
event = id(event)
for i = 1 to length(event_names) do
if event = event_names[i][1] then
return event_names[i][2]
end if
end for
return -1
end function
---------------------------------------------------------------------
export function window(atom event) -- get event window
---------------------------------------------------------------------
ifdef BITS64 then
return peek8u(event + 8)
end ifdef
return peek4u(event + 4)
end function
---------------------------------------------------------------------
export function time(atom event) -- get event time
---------------------------------------------------------------------
ifdef BITS64 then
return peek4u(event + 20)
end ifdef
return peek4u(event + 12)
end function
---------------------------------------------------------------------
export function xy(atom event) -- get mouse button x y;
---------------------------------------------------------------------
ifdef BITS64 then
return floor({
float64_to_atom(peek({event + 24, 8})),
float64_to_atom(peek({event + 32, 8}))})
end ifdef
return floor({
float64_to_atom(peek({event + 16, 8})),
float64_to_atom(peek({event + 24, 8}))})
end function
---------------------------------------------------------------------
export function axes(atom event)
---------------------------------------------------------------------
ifdef BITS64 then
return float64_to_atom(peek({event + 40, 8}))
end ifdef
return float64_to_atom(peek({event + 32, 8}))
end function
---------------------------------------------------------------------
export function button(atom event) -- get mouse button clicked;
---------------------------------------------------------------------
ifdef BITS64 then
return peek(event+52)
end ifdef
return peek(event+40)
end function
----------------------------------------------------------------------
export function state(atom event)
----------------------------------------------------------------------
ifdef BITS64 then
return peek(event+48)
end ifdef
return peek(event+36)
end function
----------------------------------------------------------------------
export function device(atom event)
----------------------------------------------------------------------
ifdef BITS64 then
return peek(event+56)
end ifdef
return peek(event+44)
end function
---------------------------------------------------------------------
export function clicks(atom event)
---------------------------------------------------------------------
atom ct = allocate(64)
object result
if gtk_func("gdk_event_get_click_count",{P,I},{event,ct}) then
result = peek4u(ct)
else
result = -1
end if
free(ct)
return result
end function
---------------------------------------------------------------------
export function scroll_dir(atom event)
---------------------------------------------------------------------
atom dir = allocate(64)
object result
if gtk_func("gdk_event_get_scroll_direction",{P,I},{event,dir}) then
result = peek4u(dir)
else
result = -1
end if
free(dir)
return result
end function
---------------------------------------------------------------------------------
export function pending() -- used sometimes when using timeout or eu tasks
---------------------------------------------------------------------------------
return gtk_func("gtk_events_pending")
end function
------------------------------------------------------------------------
export procedure main_iteration()
------------------------------------------------------------------------
gtk_proc("gtk_main_iteration")
end procedure
-----------------------------------------------------------------------------------
export procedure main_iteration_do(integer i) -- used sometimes when multi-tasking;
-----------------------------------------------------------------------------------
gtk_proc("gtk_main_iteration_do",{I},i)
end procedure
------------------------------------------------------------------------
-- following routine traps the enter key when Entry is activated,
-- and uses it like the tab key - so it works like people expect.
-- When using Glade, connect each entry's 'activate' signal to
-- trap_enter_key
------------------------------------------------------------------------
constant gsig = define_proc("g_signal_emit_by_name",{P,P,P})
constant fsig = allocate_string("move-focus")
------------------------------------------------------------------------
global function trap_enter_key(atom ctl, atom event)
-----------------------------------------------------------------------
if class_id(ctl) = GtkEntry then
if event = 0 then
c_proc(gsig,{ctl,allocate_string("move-focus"),0})
return 1
end if
end if
return 0
end function

454
eugtk/GtkFileSelector.e Normal file
View File

@ -0,0 +1,454 @@
-------------------------
namespace fileselector -- Generic file selection dialog;
-------------------------
--# EXPORTS:
/*
-- functions:
fileselector:New()
fileselector:Open()
fileselector:Save()
fileselector:SaveAs()
fileselector:CreateFolder()
fileselector:SelectFolder()
-- returns:
full file path if successful, e.g. "/home/irv/demos/test99.ex"
or an atom:
MB_ABORT when dialog is closed
MB_CANCEL when cancel button is clicked.
*/
include GtkEngine.e
export constant version = "4.12.0"
if not equal(version,gtk:version) then
Error(,,"GtkFileSelector version mismatch","should be version " & gtk:version)
end if
-- default settings, change before calling the dialog if required;
export boolean
create_folders = TRUE,
local_only = TRUE,
select_multiple = FALSE,
show_hidden = FALSE,
do_overwrite_confirmation = TRUE,
show_preview = FALSE,
preview_widget_active = TRUE
export sequence preview_size = {200,200}
export atom preview_max = 150 -- default size
export object selected_filter=0, filters = {"euphoria","text"}
-- may change filters before calling the dialog
-- (or every 5,000 miles, whichever comes first)
-- IOW, to show only .css files, add the line:
-- fileselector:filters = {"css"}
-- before calling:
-- fileselector:Open("~/demos/*")
-- note that the syntax of the parameter to Open() is important:
-- ~/demos or ~/demos/ will only cause the dialog to highlight the ~/demos folder,
-- ~/demos/* will open the demos folder and display the [filtered] file types
-- ~/demos/*.css will show folders and all *.css files
-- combining filters with wildcards:
-- fileselector:filters = {"images"}
-- fileselector:Open("~/demos/glade/*")
-- the above will show all images in the specified directory,
-- whereas:
-- fileselector:Open("~/demos/glade/*.png")
-- will show only .png images in the specified directory,
-- regardless of how the filters are set.
-- below, only .png images will be shown, but drop-down options to show .html and .c files
-- will be available also:
-- fileselector:filters = {"html","c"}
-- fileselector:Open("~/demos/glade/*.png")
--------------------------------------
function generate_filter(object name)
--------------------------------------
object filter = 0
switch name do
case "images",".jpg",".gif",".png",".xpm" then filter = create(GtkFileFilter,{
{"name","Images"},{"add mime type","image/*"}})
case "euphoria",".eu",".e",".exw" then filter = create(GtkFileFilter,{
{"name","Euphoria files"},{"add pattern","*.e"},
{"add pattern","*.ex"},{"add pattern","*.cfg"}})
case "text",".text",".txt" then filter = create(GtkFileFilter,{
{"name","All text"},{"add mime type","text/plain"}})
case "c",".c",".h" then filter = create(GtkFileFilter,{
{"name","C source code"},{"add mime type","text/x-c"},
{"add pattern","*.c"},{"add pattern","*.h"}})
case "c++" then filter = create(GtkFileFilter,{
{"name","C++ source code"},{"add pattern","*.c++"}})
case "css",".css" then filter = create(GtkFileFilter,{
{"name","css markup"},{"add mime type","text/css"},
{"add pattern","*.css"}})
case "python",".python",".py" then filter = create(GtkFileFilter,{
{"name","Python"},{"add mime type","text/x-python"}})
case "html",".htm",".html" then filter = create(GtkFileFilter,{
{"name","html source"},{"add mime type","text/html"},
{"add pattern","*.html"}})
case "ini",".ini" then filter = create(GtkFileFilter,{
{"name","ini"},{"add pattern","*.ini"}})
case "all" then filter = create(GtkFileFilter,{
{"name","All files"},{"add pattern","*"}})
case "dir" then filter = create(GtkFileFilter,{
{"name","Directories"},{"add mime type","inode/directory"}})
end switch
return filter
end function
constant update_preview = call_back(routine_id("UpdatePreview"))
----------------------------------------------------------
export function New(object current=0)
----------------------------------------------------------
object result=0
atom dlg = create(GtkFileChooserDialog)
set(dlg,{
{"name","FileNew"},
{"title","Create a new file"},
{"action",GTK_FILE_CHOOSER_ACTION_SAVE},
{"preview widget active",preview_widget_active},
{"add button","gtk-cancel",MB_CANCEL},
{"add button","gtk-ok",MB_OK},
{"create folders",create_folders},
{"local only",local_only},
{"select multiple",select_multiple},
{"show hidden",show_hidden},
{"do overwrite confirmation",do_overwrite_confirmation}})
for i = 1 to length(filters) do
set(dlg,"add filter",generate_filter(filters[i]))
end for
if show_preview = TRUE then
atom preview = create(GtkImage)
set(dlg,"preview widget",preview)
connect(dlg,"update-preview",update_preview,preview)
end if
if atom(current) and current > 0 then
set(dlg,"current name",unpack(current))
end if
result = get(dlg,"run")
if result = MB_OK then
result = get(dlg,"filename")
end if
destroy(dlg)
return result
end function
export constant new = call_back(routine_id("New"))
----------------------------------------------------
export function Open(object data=0, atom x=0)
----------------------------------------------------
object result=0
object filter=0
if atom(data) and data > 0 then data = unpack(data) end if
if string(data) and equal("*",filename(data)) then filters &= {"all"} end if
atom dlg = create(GtkFileChooserDialog)
set(dlg,{
{"name","FileOpen"},
{"title","Open a file"},
{"action",GTK_FILE_CHOOSER_ACTION_OPEN},
{"preview widget active",preview_widget_active},
{"add button","gtk-cancel",MB_CANCEL},
{"add button","gtk-ok",MB_OK},
{"create folders",create_folders},
{"local only",local_only},
{"select multiple",select_multiple},
{"show hidden",show_hidden},
{"do overwrite confirmation",do_overwrite_confirmation}})
for i = 1 to length(filters) do
set(dlg,"add filter",generate_filter(filters[i]))
end for
if show_preview = TRUE then
atom preview = create(GtkImage)
set(dlg,"preview widget",preview)
connect(dlg,"update-preview",update_preview,preview)
end if
if atom(data) and data > 0 then
data = unpack(data)
end if
if string(data) then
if file_exists(canonical_path(data)) then
set(dlg,"filename",canonical_path(data))
else
if not equal("*",filename(data)) then
filter = create(GtkFileFilter,{ -- build a custom filter;
{"name",filename(data) & " files"},
{"add pattern",filename(data)}})
set(dlg,"add filter",filter)
set(dlg,"filter",filter)
end if
set(dlg,"filename",canonical_path(data)) -- change to desired folder;
end if
end if
result = get(dlg,"run")
if result = MB_OK then
result = get(dlg,"filename")
end if
destroy(dlg)
return result
end function
export constant open = call_back(routine_id("Open"))
----------------------------------------------------
export function Save(object data, object x=0)
----------------------------------------------------
object result=0
atom dlg = create(GtkFileChooserDialog)
atom f
set(dlg,{
{"name","FileSave"},
{"title","Save this file"},
{"action",GTK_FILE_CHOOSER_ACTION_SAVE},
{"add button","gtk-cancel",MB_CANCEL},
{"add button","gtk-ok",MB_OK},
{"create folders",create_folders},
{"local only",local_only},
{"select multiple",select_multiple},
{"show hidden",show_hidden},
{"do overwrite confirmation",do_overwrite_confirmation}})
for i = 1 to length(filters) do
set(dlg,"add filter",generate_filter(filters[i]))
end for
if show_preview = TRUE then
atom preview = create(GtkImage)
set(dlg,"preview widget",preview)
connect(dlg,"update-preview",update_preview,preview)
end if
if atom(data) and data > 0 then
set(dlg,"current name",unpack(data))
end if
if string(data) then
set(dlg,"current name",data)
end if
result = get(dlg,"run")
if result = MB_OK then
result = get(dlg,"filename")
end if
destroy(dlg)
return result
end function
export constant save = call_back(routine_id("Save"))
-----------------------------------------------------------
export function SaveAs(object data=0, object x=0)
-----------------------------------------------------------
object result=0
atom dlg = create(GtkFileChooserDialog)
set(dlg,{
{"name=FileSaveAs"},
{"title","Save this file with a new name"},
{"action",GTK_FILE_CHOOSER_ACTION_SAVE},
{"add button","gtk-cancel",MB_CANCEL},
{"add button","gtk-ok",MB_OK},
{"create folders",create_folders},
{"local only",local_only},
{"select multiple",select_multiple},
{"show hidden",show_hidden},
{"do overwrite confirmation",do_overwrite_confirmation}})
for i = 1 to length(filters) do
set(dlg,"add filter",generate_filter(filters[i]))
end for
if show_preview = TRUE then
atom preview = create(GtkImage)
set(dlg,"preview widget",preview)
connect(dlg,"update-preview",update_preview,preview)
end if
if atom(data) and data > 0 then
set(dlg,"current name",unpack(data))
elsif string(data) then
set(dlg,"current name",data)
end if
result = get(dlg,"run")
if result = MB_OK then
result = get(dlg,"filename")
end if
destroy(dlg)
return result
end function
export constant save_as = call_back(routine_id("SaveAs"))
---------------------------------------------------------------
export function CreateFolder(object data=0, object x=0)
---------------------------------------------------------------
object result=0
atom dlg = create(GtkFileChooserDialog)
set(dlg,{
{"name=NewFolder"},
{"title","Create a new folder"},
{"action",GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER},
{"add button","gtk-cancel",MB_CANCEL},
{"add button","gtk-ok",MB_OK},
{"create folders",create_folders},
{"local only",local_only},
{"select multiple",select_multiple},
{"show hidden",show_hidden},
{"do overwrite confirmation",do_overwrite_confirmation}})
for i = 1 to length(filters) do
set(dlg,"add filter",generate_filter(filters[i]))
end for
if show_preview = TRUE then
atom preview = create(GtkImage)
set(dlg,"preview widget",preview)
connect(dlg,"update-preview",update_preview,preview)
end if
if atom(data) and data > 0 then
set(dlg,"current name",unpack(data))
end if
result = get(dlg,"run")
if result = MB_OK then
result = get(dlg,"filename")
end if
destroy(dlg)
return result
end function
export constant create_folder = call_back(routine_id("CreateFolder"))
---------------------------------------------------------------
export function SelectFolder(object data=0, object x=0)
---------------------------------------------------------------
object result=0
atom dlg = create(GtkFileChooserDialog)
set(dlg,{
{"name","SelectFolder"},
{"title","Select a folder"},
{"action",GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER},
{"add button","gtk-cancel",MB_CANCEL},
{"add button","gtk-ok",MB_OK},
{"create folders",create_folders},
{"local only",local_only},
{"select multiple",select_multiple},
{"show hidden",show_hidden},
{"do overwrite confirmation",do_overwrite_confirmation}})
for i = 1 to length(filters) do
set(dlg,"add filter",generate_filter(filters[i]))
end for
if show_preview = TRUE then
atom preview = create(GtkImage)
set(dlg,"preview widget",preview)
connect(dlg,"update-preview",update_preview,preview)
end if
if atom(data) and data > 0 then
data = unpack(data)
if string(data) then
if file_exists(canonical_path(data)) then
set(dlg,"filename",canonical_path(data))
else
set(dlg,"filename",data)
end if
end if
end if
result = get(dlg,"run")
if result = MB_OK then
result = get(dlg,"filename")
end if
destroy(dlg)
return result
end function
export constant select_folder = call_back(routine_id("SelectFolder"))
------------------------------------------------------------------------------
function UpdatePreview(atom dlg, atom preview) -- local: follow focus changes;
------------------------------------------------------------------------------
object pix
atom ratio
object dimensions
object fn = get(dlg,"filename")
if string(fn) then -- avoid trying to preview a directory!
pix = create(GdkPixbuf,fn)
if pix > 0 then
dimensions = get(pix,"size")
ratio = preview_max / dimensions[1]
dimensions *= {ratio,ratio}
pix = get(pix,"scale simple",dimensions[1],dimensions[2],1)
set(preview,"from pixbuf",pix)
end if
end if
return 0
end function

154
eugtk/GtkFontSelector.e Normal file
View File

@ -0,0 +1,154 @@
----------------------
namespace fontselector -- Generic font selector dialog
----------------------
--# EXPORTS
/*
-- functions -- callbacks
fontselector:Select() fontselector:select
fontselector:FilterFonts() fontselector:filter
-- fontlist
*/
include GtkEngine.e
include GtkCairo.e
include std/wildcard.e
include std/hash.e
export constant version = "4.12.0"
if not equal(version,gtk:version) then
Error(,,"GtkFontSelector version mismatch","should be version " & gtk:version)
end if
-- Optional parameter is preferred (default) font, the one to be
-- returned if the font dialog ok button is clicked without choosing
-- a different font. You can just specify a size here: "8" and that
-- will set only the dialog's size selector.
--
-- You can specify a full font name and size: e.g. Purisa bold 16,
-- and that font will be the one highlighted for selection.
-- If you specify a font that doesn't exist: e.g. Bogus italic 18,
-- and then use the returned font, GTK will do the best it can,
-- which will be to set the existing font to italic in 18pt.
-- Fairly fail-safe, in other words.
--
-- Setting this does not filter the list of fonts shown by the dialog.
-- to do this, you need to set the pattern. See below.
--
-- To exclude unwanted (and unreadable) fonts, such as symbols and
-- dingbats, add them to the exclude sequence. See below.
--
-- pattern can be set prior to the select() call
-- pattern can be an array of font names, wildcards are ok
-- e.g. {"Courier*","purisa"}
-- if you use, for example, just {"Courier"}, without the wildcard,
-- no fonts will be found.
--
-- {"sans"}, {"*sans"}, or {"*sans*"} will each return a different
-- set of matching font names! trial and error may be required.
--
-- if pattern is left unset, ALL fonts will be shown!
export atom dlg = create(GtkFontChooserDialog,"name=FontSelector")
export object
name = 0, -- font name
title = "Choose a font", -- dialog title
preview_text = "This is an EuGTK font selector",
description = 0, -- a PangoFontDescription
family = 0, -- font family
style = 0, -- normal, oblique, italic
variant = 0,
weight = PANGO_WEIGHT_NORMAL,
mono_filter = 0,
font_list = {}
export atom size = 12*1024
export integer points = 12
export sequence pattern = {"*"}
export sequence exclude = {"*symbol*","*dingbat*","*webdings","*wingdings*"}
-- above list filters out unusable fonts;
------------------------------------------------------------------------
export function Select(object curr_fnt=0)
------------------------------------------------------------------------
set(dlg,"title","Select a font")
set(dlg,"preview text",preview_text)
if string(curr_fnt) then
set(dlg,"font",curr_fnt)
end if
pattern = lower(pattern)
exclude = lower(exclude)
set(dlg,"filter func",filter)
if get(dlg,"run") then
name = get(dlg,"font")
description = create(PangoFontDescription,name)
family = get(description,"family")
size = get(description,"size")
points = math:round(size/PANGO_UNIT)
variant = get(description,"variant")
style = get(description,"style")
weight = get(description,"weight")
end if
hide(dlg) -- we keep it around, since it's likely to be used again :p
return name
end function
export constant select = call_back(routine_id("Select"))
------------------------------------------------------------------------
export function FilterFonts(object family, object face, object data)
------------------------------------------------------------------------
integer result = 0
if mono_filter then
if gtk_func("pango_font_family_is_monospace",{P},{family}) = FALSE then
return 0
end if
end if
object name = lower(gtk_str_func("pango_font_family_get_name",{P},{family}))
for i = 1 to length(pattern) do
result = is_match(pattern[i],name) > 0
if result = 1 then
for x = 1 to length(exclude) do
if is_match(exclude[x],name) then
return 0
end if
end for
end if
return result
end for
return result
end function
export constant filter = call_back(routine_id("FilterFonts"))
sequence weight_names =
{"thin","ultralight","light","book","normal","medium",
"semibold","bold","ultrabold","heavy","ultraheavy"}
/* -- reference;
PANGO_WEIGHT_THIN = 100,
PANGO_WEIGHT_ULTRALIGHT = 200,
PANGO_WEIGHT_LIGHT = 300,
PANGO_WEIGHT_BOOK = 380,
PANGO_WEIGHT_NORMAL = 400,
PANGO_WEIGHT_MEDIUM = 500,
PANGO_WEIGHT_SEMIBOLD = 600,
PANGO_WEIGHT_BOLD = 700,
PANGO_WEIGHT_ULTRABOLD = 800,
PANGO_WEIGHT_HEAVY = 900,
PANGO_WEIGHT_ULTRAHEAVY = 1000,
PANGO_UNIT = 1024
PANGO_STYLE_NORMAL = 0,
PANGO_STYLE_OBLIQUE = 1,
PANGO_STYLE_ITALIC = 2
*/

567
eugtk/GtkPrinter.e Normal file
View File

@ -0,0 +1,567 @@
--------------------
namespace printer -- Utility to make printing easier
--------------------
export constant version = "4.12.0"
-- EXPORTS:
-- functions callbacks
-- printer:PrintFile() printer:print_file
-- printer:PrintText() printer:print_text
-- This version handles most common printing needs, but it will not yet respect
-- 'marked up' a.k.a. 'rich' text, i.e. text with colors and styles as produced
-- by GTK3's TextView widget. It just prints them as plain text.
--
-- However, it DOES print text marked up with GTK's HTML subset, so you can use
-- <b>, <i>, <u>, <span>, <font> ... etc. in your printouts! This includes various
-- imbedded font styles and colors.
--
-- More documentation is found in ~/documentation/printing.html
include GtkEngine.e
include GtkCairo.e
include std/datetime.e
if not equal(version,gtk:version) then
Error(,,"GtkPrinter version mismatch","should be version " & gtk:version)
end if
-- The following exported variables can be modified before calling the
-- print routine:
public object header = "[1]\n" -- default is just the page title
public object subheader = "[1] page [5]\n\n" -- format for headers on pg.2 ... n
-- default subheader (above) prints page title and pg #;
public object footer = "<small>\n<i>Printed by EuGTK [8] on [9]'s computer</i></small>"
-- default footer (above) prints date and user name;
-- Info ID's for use in header and footer;
-- 1 = page title (for first page)
-- 2 = sub title (for subsequent pages - leave null to use page title (1) on all pgs)
-- 3 = file name
-- 4 = short name (file name w/o path)
-- 5 = current page number
-- 6 = n_pages printed e.g. pg 1 of n
-- 7 = n_copies requested
-- 8 = today's date in date_format
-- 9 = user name
--10 = user's real name
--11 = font name used for this print job
--12 = file length in bytes
--13 = file timestamp
--14 = exported filename, if any
export integer
n_pages = 0, -- number of pages to print (0=all)
n_copies = 1,
collate = FALSE,
duplex = 0,
number_up = 1,
number_up_layout = 1,
units = GTK_UNIT_INCH,
use_line_numbers = TRUE,
use_color = TRUE, -- print eu comments in red if true
lines_per_page = 60,
wrap_at = 0,
track_status = TRUE,
show_progress = TRUE, -- enable the built-in progressbar
embed_page_setup = TRUE,
orientation = 0,
order = 0,
confirm = FALSE,
sourcecode = TRUE,
plaintext = FALSE,
use_full_page = FALSE, -- ignore margins
has_selection = FALSE,
support_selection = FALSE,
quality = GTK_PRINT_QUALITY_DRAFT,
action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
auto_lpp = TRUE
export atom
scale = 100,
top_margin = 0.25, -- in inch units
left_margin = 0.25,
right_margin = 0.25,
bottom_margin = 0.25,
parent = 0,
signal_status_changed = call_back(routine_id("show_status")),
signal_begin_print = call_back(routine_id("begin_print")),
signal_draw_page = call_back(routine_id("draw_page")),
signal_end_print = call_back(routine_id("end_print")),
signal_request_page_setup = 0,
signal_done = 0,
signal_ready = 0,
signal_got_page_size = 0
export object
name = 0,
font = "Ubuntu Mono 8",
jobname = 0,
settings_file = 0,
setup_file = 0,
export_file = 0,
page_ranges = 0,
page_set = GTK_PAGE_SET_ALL,
custom_tab_hook = 0,
custom_tab_label = 0,
custom_tab_func = 0
ifdef WINDOWS then font = "Courier New 16" end ifdef
export object
line_number_format = "[:4] []\n", -- controls line # format AND code line!
paper_name = "na_letter", -- 8.5x11.0"
tabs = " ", -- replace tab chars with 8 spaces
file_name = 0,
short_name = 0,
page_title = 0,
sub_title = 0
export atom
progress = create(GtkProgressBar),
settings = create(GtkPrintSettings)
-- use date and time formats in std/datetime.e;
export sequence date_format = "%A, %B %d %Y %l:%M %p"
sequence user
ifdef WINDOWS then
user = "User"
elsedef
user = proper(getenv("USER"))
end ifdef
-- for local use;
atom fontdesc
integer filesize = 0
object timestamp = 0
sequence text
sequence today = datetime:format(datetime:now(),date_format)
export procedure reset()
n_pages = 0
n_copies = 1
collate = FALSE
duplex = 0
number_up = 1
number_up_layout = 1
units = GTK_UNIT_INCH
use_line_numbers = TRUE
use_color = TRUE
lines_per_page = 60
wrap_at = 0
track_status = TRUE
show_progress = TRUE
embed_page_setup = TRUE
orientation = 0
order = 0
confirm = FALSE
sourcecode = TRUE
plaintext = FALSE
use_full_page = FALSE
has_selection = FALSE
support_selection = FALSE
quality = GTK_PRINT_QUALITY_DRAFT
action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG
auto_lpp = TRUE
scale = 100
top_margin = 0.25
left_margin = 0.25
right_margin = 0.25
bottom_margin = 0.25
parent = 0
name = 0
paper_name = "na_letter"
font = "Ubuntu Mono 8"
jobname = 0
settings_file = 0
setup_file = 0
export_file = 0
page_ranges = 0
page_set = GTK_PAGE_SET_ALL
custom_tab_hook = 0
custom_tab_label = 0
custom_tab_func = 0
end procedure
------------------------------------------------------------------------
export function PrintFile(object f=0, object x=0)
------------------------------------------------------------------------
if string(f) and string(x) then
page_title = f
file_name = canonical_path(x)
timestamp = file_timestamp(file_name)
filesize = file_length(file_name)
short_name = filebase(file_name)
text = read_file(file_name)
setup_printer()
return 1
end if
if string(f) and atom(x) and x = 0 then
f = canonical_path(f)
file_name = f
timestamp = file_timestamp(f)
filesize = file_length(f)
short_name = filebase(f)
page_title = filename(f)
text = read_file(f)
setup_printer()
return 1
end if
if string(f) and atom(x) and x < 100 then
page_title = f
short_name = f
file_name = f
text = read_file(x)
setup_printer()
return 1
end if
if atom(f) and atom(x) and x < 101 then
if atom(file_name) then
file_name = ""
end if
if atom(short_name) then
short_name = ""
end if
if atom(page_title) then
page_title = ""
end if
text = read_file(x)
setup_printer()
return 1
end if
if atom(f) and atom(x) then
x = unpack(x)
x = canonical_path(x)
file_name = x
short_name = filebase(x)
page_title = filename(x)
text = read_file(x)
setup_printer()
return 1
end if
return 1
end function
export constant print_file = call_back(routine_id("PrintFile"))
------------------------------------------------------------------------
export function PrintText(object f=0, object x=0)
------------------------------------------------------------------------
if string(f) and string(x) then
page_title = f
text = x
setup_printer()
return 1
end if
if atom(f) and string(x) then
setup_printer()
text = x
return 1
end if
if atom(f) and atom(x) then
if atom(page_title) and page_title = 0 then
page_title = ""
end if
text = unpack(x)
setup_printer()
return 1
end if
return 0
end function
export constant print_text = call_back(routine_id("PrintText"))
integer status_code
sequence status_string
-----------------------------------------------
export function show_status(atom op)
-----------------------------------------------
atom
fn1 = define_func("gtk_print_operation_get_status",{P},I),
fn2 = define_func("gtk_print_operation_get_status_string",{P},S)
status_code = c_func(fn1,{op})
status_string = peek_string(c_func(fn2,{op}))
ifdef PRINT then display("Status [] []",{status_code,status_string}) end ifdef
if show_progress then
set(progress,"text",status_string)
end if
ifdef DELAY then sleep(0.15) end ifdef
return 1
end function
------------------------------------------------------
export function begin_print(atom op, atom context)
------------------------------------------------------
ifdef PRINT then display("Begin printing [] pages ",length(text)) end ifdef
fontdesc = create(PangoFontDescription,font)
if auto_lpp then
atom setup = get(op,"default page setup")
atom pght = get(setup,"page height",GTK_UNIT_POINTS)
--display("Page height [] pt.",pght)
pght -= length(header)
pght -= length(footer)
atom fs = get(fontdesc,"size") / 1024
--display("Font size []",fs)
fs = fs * (96/72)
integer lpp = 1
while ((fs*lpp)) < pght do
lpp += 1
--display("Text height [] lpp []",{(fs*lpp),lpp})
end while
--display("New LPP []",lpp-1)
lines_per_page = lpp
end if
text = process_text(text)
set(op,"n pages",n_pages)
-- important, as a new value for n_pages is computed
-- based on the length of the file being read, unless a set number
-- has been provided from the calling program.
if show_progress then -- turn on the progress dialog in the calling program
show_all(progress)
end if
return 1
end function
----------------------------------------------------------------------------
export function draw_page(atom op, atom context, integer pg, atom data)
----------------------------------------------------------------------------
atom fn6 = define_func("gtk_print_context_get_cairo_context",{P},P)
atom cr = c_func(fn6,{context})
atom pl = create(PangoCairoLayout,cr)
set(pl,"font description",fontdesc)
pg += 1
if pg > length(text) then
set(progress,"text","Printing complete")
return 0
end if
if show_progress then
set(progress,"text",sprintf("Printing page %d",pg))
set(progress,"fraction",pg/n_pages)
end if
ifdef DELAY then sleep(0.25) end ifdef
object details = {
page_title,sub_title,file_name,short_name,
pg,n_pages,n_copies,
today,user,real_name,font,filesize,timestamp,export_file
}
object page
if atom(header) then header = "<b><u>[1]</u> page [5] of [6]</b>\n\n" end if
if pg = 1 or atom(subheader) then
page = text:format(header,details)
& flatten(text[pg])
& text:format(footer,details)
else
page = text:format(subheader,details)
& flatten(text[pg])
& text:format(footer,details)
end if
if plaintext then
set(pl,"text",page,length(page))
else
set(pl,"markup",page,length(page))
end if
set(pl,"update layout",cr)
set(pl,"show layout",cr)
ifdef PRINT then printf(1,"Page %d\n",pg) end ifdef
return 1
end function
------------------------------------------------------------------------
function process_text(object txt)
------------------------------------------------------------------------
txt = split(txt,'\n')
integer comment, n
object a,b
object test
for i = 1 to length(txt) do -- replace chars which will confuse markup
txt[i] = join(split(txt[i],'&'),"&amp;")
txt[i] = join(split(txt[i],"&amp;amp;"),"&amp;")
if sourcecode then
txt[i] = join(split(txt[i],'<'),"&lt;")
txt[i] = join(split(txt[i],'>'),"&gt;")
end if
if use_color then
if match("--",txt[i]) then -- a comment;
txt[i] = split(txt[i],"--")
txt[i] = txt[i][1] & "<span color='red'>-- " & txt[i][2] & "</span>"
end if
end if
if use_line_numbers then
txt[i] = text:format(line_number_format,{i,txt[i]})
else
txt[i] &= '\n'
end if
end for
txt = breakup(txt,lines_per_page)
if n_pages = 0 then -- no selection
n_pages = length(txt)
end if
return txt
end function
------------------------------------------------------------------------
export function end_print()
------------------------------------------------------------------------
status_string = "Printing complete"
ifdef PRINT then display(status_string) end ifdef
return 1
end function
---------------------------------------------------------------
export function setup_printer()
---------------------------------------------------------------
atom _size = create(GtkPaperSize,paper_name)
atom err = allocate(16) err = 0
object results = 0
atom fn7 = define_func("gtk_print_operation_run",{P,I,P,P},I)
atom fn8 = define_func("gtk_print_run_page_setup_dialog",{P,P,P},P)
set(settings,"paper size",_size,units)
set(settings,"n copies",n_copies)
set(settings,"collate",collate)
set(settings,"duplex",duplex)
set(settings,"reverse",order)
set(settings,"scale",scale)
set(settings,"quality",quality)
set(settings,"number up",number_up)
set(settings,"number up layout",number_up_layout)
if string(name) then
set(settings,"printer",name)
end if
atom setup = create(GtkPageSetup)
set(setup,"paper size",_size)
set(setup,"orientation",orientation)
set(setup,"left margin",left_margin,units)
set(setup,"right margin",right_margin,units)
set(setup,"top margin",top_margin,units)
set(setup,"bottom margin",bottom_margin,units)
atom printop = create(GtkPrintOperation)
set(printop,"print settings",settings)
set(printop,"default page setup",setup)
set(printop,"show progress",show_progress)
set(printop,"track print status",track_status)
set(printop,"embed page setup",embed_page_setup)
set(printop,"support selection",support_selection)
set(printop,"has selection",has_selection)
set(printop,"use full page",use_full_page)
if action = GTK_PRINT_OPERATION_ACTION_EXPORT then
export_file = canonical_path(export_file)
set(printop,"export filename",export_file)
end if
if string(jobname) then
set(printop,"job name",jobname)
end if
if custom_tab_hook != 0 then
set(printop,"custom tab label",custom_tab_label)
connect(printop,"create-custom-widget",custom_tab_func,printop)
connect(printop,"custom-widget-apply",custom_tab_hook)
end if
connect(printop,"status-changed",signal_status_changed)
connect(printop,"begin-print",signal_begin_print)
connect(printop,"draw-page",signal_draw_page)
connect(printop,"end-print",signal_end_print)
connect(printop,"request-page-setup",signal_request_page_setup)
connect(printop,"done",signal_done)
connect(printop,"ready",signal_ready)
connect(printop,"got-page-size",signal_got_page_size)
display(get(settings,"printer lpi"))
c_func(fn7,{printop,action,parent,err}) -- start the print process;
if string(setup_file) and file_exists(canonical_path(setup_file)) then
get(setup,"to file",canonical_path(setup_file))
end if
object jobname = get(printop,"job name")
if confirm then
if action = GTK_PRINT_OPERATION_ACTION_EXPORT then
if Question(0,"PDF Written",
sprintf("%s\n<small>Folder: %s</small>",
{filename(export_file),pathname(export_file)}),
sprintf("%s\nStatus: %d\n%s\nClick Yes to view",{jobname,status_code,status_string})
,,,"printer") then
show_uri(export_file)
end if
else
Info(0,"Print Job",jobname,
sprintf("Status: %d %s",{status_code,status_string})
,,"printer")
end if
end if
page_title = 0
n_pages = 0
n_copies = 1
action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG
return 1
end function
header = "<b><u>[1]</u></b>\n\n"
-----------------------------
-- copyright 2015 Irv Mullins
-----------------------------

305
eugtk/GtkSettings.e Normal file
View File

@ -0,0 +1,305 @@
---------------------
namespace settings -- functions to read and write config files (*.ini);
---------------------
export constant version = "4.12.0"
--# EXPORTS
/*
--functions:
settings:Save()
settings:Load()
settings:Add()
-- debug:
-d SETTINGS
*/
include GtkEngine.e
if not equal(version,gtk:version) then
Error(,,"GtkSettings version mismatch","should be version " & gtk:version)
end if
constant fmt = """[].[]=[]"""
------------------------------------------------------------------------
export function Save(sequence inifile, object ctl_list, integer debug=0)
------------------------------------------------------------------------
-- writes an 'ini' type file (file name and extension are up to you)
-- with an entry for each control on ctl_list. The controls MUST have
-- been named, otherwise there's no way to save and retrieve the
-- value/setting for that control.
------------------------------------------------------------------------
object comments = {}
object txt,line
if file_exists(inifile) then
txt = read_lines(inifile)
for i = 1 to length(txt) do -- extract the comments;
line = txt[i]
if match("--",line) = 1
or match("!",line) = 1
or match("+",line) = 1
or equal("\n",line)
or equal({},line) then
comments = append(comments,line)
end if
end for
write_lines(inifile,comments) -- removing everything but the comments;
end if -- file exists
object setting, tmp = 0, pos = {0,0}
object t1, name, prop
atom handle
integer class
atom fn = open(inifile,"a")
for x = 1 to length(ctl_list) do
if string(ctl_list[x]) then
handle = pointer(ctl_list[x])
else
handle = ctl_list[x]
end if
name = get(handle,"name")
class = class_id(handle)
if class=GtkWindow then -- special handling for multiple properties;
printf(fn,"%s\n",{get_setting(handle,"size")})
pos = get(handle,"position")
printf(fn,"%s.position={%d,%d}\n",{name,pos[1],pos[2]})
else
setting = get_setting(handle) -- others have 1 obvious 'saveable' property
if length(setting) < 1 then
continue
end if
if sequence(setting) then
printf(fn,"%s\n",{setting})
end if
end if
end for
flush(fn)
close(fn)
-- if ! exists for this control:property, then ignore the updated setting;
tmp = read_lines(inifile)
for i = 1 to length(tmp) do
if match("--!",tmp[i]) = 1 then
t1 = split(tmp[i],"=")
t1 = t1[1][2..$]
end if
end for
write_lines(inifile,tmp)
return 1
end function
------------------------------------------------------------------------
export function Load(sequence inifile, integer debug=0)
------------------------------------------------------------------------
-- used to restore settings from the specified ini file.
-- this should be called after the controls are 'realized'
object txt, line, obj, prop, val1=0, val2=0, val3=0, val4=0
if not(file_exists(inifile)) then
write_file(inifile,sprintf("--%s\n\n",{inifile}),TEXT_MODE)
display("Creating ini file: []",{inifile})
else
if debug then display("Reading []",{inifile}) end if
end if
txt = read_lines(inifile)
integer err=0
object a,b
for i = 1 to length(txt) do
line = txt[i]
if match("--",line) > 2 then -- strip trailing comments;
line = line[1..match("--",line)-2]
end if
if match("--!",line) = 1 then
line = line[4..$] -- keep it
end if
if match("+",line) = 1 or match("!",line) then
line = line[2..$] -- dito
end if
if match("--",line) or match(";",line)
or match("/*",line) then
continue -- a comment, do nothing with it
end if
if length(line) > 0 then
line = split(line,'=')
a = line[1] b = line[2]
a = split(a,'.')
line = a & {b}
if debug > 1 then display(line) end if
if vlookup(line[1],registry,4,1,-1) = -1 then
err = i
Error(,"Ini Load Error",
sprintf("Invalid object name: %s",{line[1]}),
sprintf("Line #%d of %s",{i,filename(inifile)}))
else
if equal("data",line[2]) then
set(line[1],"data",line[3],line[4])
else
set(line[1],line[2],line[3])
end if
end if
end if
end for
if debug = 1 then
for i = 1 to length(txt) do
if i = err then
display("ERROR:[:3]:[]",{i,txt[i]})
else
display("[:3]:[]",{i,txt[i]})
end if
end for
end if
write_lines(inifile,txt)
return 1
end function
-------------------------------------------------------------------------------------------
export function Add(object ini,object ctl, sequence prop, object v1=0, object v2=0)
-------------------------------------------------------------------------------------------
if atom(ctl) then ctl = get(ctl,"name") end if
Delete(ini,ctl,prop)
if equal("position",prop) or equal("size",prop) then
if string(v1) then v2 = v1[2] v1 = v1[1] end if
end if
if atom(v2) and v2=0 then
writefln("+[].[]=[]",{ctl,prop,v1},{ini,"a"})
else
writefln("+[].[]={[],[]}",{ctl,prop,v1,v2},{ini,"a"})
end if
return 1
end function
--------------------------------------------------------------------
export function Delete(object ini,object ctl, sequence prop)
--------------------------------------------------------------------
if atom(ctl) then ctl = get(ctl,"name") end if
object tmp = read_lines(ini)
object out = {}
object s1 = text:format("[].[]",{ctl,prop})
for i = 1 to length(tmp) do
if match(s1,tmp[i]) then -- skip
else out &= {tmp[i]}
end if
end for
write_lines(ini,out)
return 1
end function
---------------------------------------------------------------------------------
function get_setting(object self, object property = 0)
-- returns the 'important' value from a control
---------------------------------------------------------------------------------
-- returns settings string
-- object must be a named object, e.g. MyButton
-- MyButton.active=1
-- My Calendar.date={YYYY,MM,DD}
object name = 0
object dt
if string(self) then
name = self
self = vlookup(self,registry,4,1)
end if
object val = 0
object txt = {}
integer x = find(self,vslice(registry,1))
ifdef SETTINGS then
display("SELF [] []",{x,self})
display(registry[x])
end ifdef
switch class_id(self) do
-- this decides which value is the important one to save;
-- and stores the control's current value into the registry;
case GtkEntry,GtkEntryBuffer then property = "text"
case GtkCheckButton,GtkRadioButton, GtkToggleButton,
GtkSwitch,GtkComboBox,GtkComboBoxText,
GtkCheckMenuItem,GtkToggleToolButton, GtkSearchEntry
then property = "active"
case GtkPopover then property = "position"
case GtkFontButton then property = "font name"
case GtkAdjustment,GtkSpinButton,GtkScaleButton,GtkVolumeButton,
GtkModelButton,GtkScale
then property = "value"
case GtkEntryCompletion then property = "model"
case GtkLinkButton then property = "uri"
case GtkMenuItem then property = "sensitive"
case GtkPaned then property = "position"
case GtkFileChooser, GtkFileChooserButton, GtkFileChooserWidget, GtkFileChooserDialog
then property = "filename"
case GtkFontChooser, GtkFontChooserWidget, GtkFontChooserDialog then
property = "font"
case GtkCalendar then
dt = get(self,"datetime",0)
registry[x][5] = {"date",dt[1..3]}
txt &= text:format(fmt,{registry[x][4],"date",dt[1..3]})
return txt
case GtkColorButton,GtkColorChooser,GtkColorChooserWidget,
GtkColorChooserDialog then
registry[x][5] = {"rgba",get(self,"rgba",1)}
txt &= text:format(fmt,{registry[x][4],"rgba",get(self,"rgba",1)})
return txt
end switch
if atom(property) then
return txt
end if
val = get(self,property)
registry[x][5] = {property,val}
txt &= text:format(fmt,{registry[x][4],property,val})
return txt
end function

16
mandy.exw Normal file
View File

@ -0,0 +1,16 @@
include "eugtk/GtkEngine.e"
include eugtk/GtkAboutDialog.e
include eugtk/GtkFileSelector.e
include eugtk/GtkEvents.e
include std/io.e
function nigger ()
atom clown1 = create(GdkPixbuf, 80,80,1)
Warn(0,,"You are getting a fucking warning from jitty", "but this is normal",,clown1,clown1)
return 0
end function
nigger()

8800
tools/WEE/EuGTK/GtkEngine.e Normal file

File diff suppressed because it is too large Load Diff

1441
tools/WEE/EuGTK/GtkEnums.e Normal file

File diff suppressed because it is too large Load Diff

222
tools/WEE/EuGTK/GtkEvents.e Normal file
View File

@ -0,0 +1,222 @@
namespace events
--Thanks to Pete Eberlein for helping with this!
include GtkEngine.e
include std/convert.e
-- Maps keys from keypad to match same keys on keyboard,
-- maps control/arrow keys to negative numbers, so they
-- can be differentiated from the same ascii character
-- values;
constant keyvalues = {
{8,-8}, -- bksp
{9,-9}, -- tab
{20,-20}, -- scroll lock
{27,27}, -- escape
{80,-80}, -- home 'P'
{81,-81}, -- left arrow 'Q'
{82,-82}, -- up arrow 'R'
{83,-83}, -- right arrow 'S'
{84,-84}, -- down arrow 'T'
{85,-85}, -- page up 'U'
{86,-86}, -- page dn 'V'
{87,-87}, -- end 'W'
{99,-99}, -- insert 'c'
{103,-103},
{127,-127}, -- num lock
{141,13}, -- keypad Enter, with or w/o numlock;
-- keypad keys w/o numlock;
{149,-149}, -- keypad home
{150,-150}, -- keypad left
{151,-151}, -- keypad up
{152,-152}, -- keypad right
{153,-153}, -- keypad down
{154,-154}, -- keypad pg up
{155,-155}, -- keypad pg dn
{156,-156}, -- keypad end
{157,-157}, -- keypad 5
{158,-158}, -- keypad ins
{159,-159}, -- keypad del
-- keypad keys with numlock - return ascii 0..9
{170,'*'},{171,'+'},{173,'-'},{175,'/'},
{176,48},{177,49},{178,50},{179,51},{180,52}, -- keypad numbers 0..4
{181,53},{182,54},{183,55},{184,56},{185,57}, -- keypad numbers 5..9
-- F keys;
{190,-190}, -- F1
{191,-191}, -- F2
{192,-192}, -- F3
{193,-193}, -- F4
{194,-194}, -- F5
{195,-195}, -- F6
{196,-196}, -- F7
{197,-197}, -- F8
{198,-198}, -- F9
{199,-199}, -- F10
{200,-200}, -- F11
{201,-201}, -- F12
{227,-227}, -- left ctl
{228,-228}, -- right ctl
{229,-229},
{225,-225}, -- left shift
{226,-226}, -- right shift
{228,-228},
{233,-233}, -- left alt
{234,-234}, -- right alt
{236,-236},
{255,-255}, -- delete
$}
constant shiftkeys = {
{32,-9}, -- shift tab
$}
----------------------------------------------------------------------
export function key(atom event) -- get key pressed;
----------------------------------------------------------------------
integer k = peek(event+16)
integer z = peek(event+17)
integer s = state(event)
ifdef BITS64 then
k = peek(event+28)
z = peek(event+29)
end ifdef
switch z do
case 0 then return k
case 255 then return vlookup(k,keyvalues,1,2,k)
case 254 then return vlookup(k,shiftkeys,1,2,k)
end switch
return 0
end function
---------------------------------------------------------------------
export function id(atom event)
---------------------------------------------------------------------
return peek4u(event)
end function
----------------------------------------------------------------------
export function state(atom event)
----------------------------------------------------------------------
ifdef BITS64 then
return peek(event+24)
end ifdef
return peek(event+12)
end function
----------------------------------------------------------------------
export function hwcode(atom event)
----------------------------------------------------------------------
ifdef BITS64 then
return peek({event+28,2})
end ifdef
return peek({event+16,2})
end function
---------------------------------------------------------------------
export function button(atom event) -- get mouse button clicked;
---------------------------------------------------------------------
ifdef BITS64 then
return peek(event+52)
end ifdef
return peek(event+40)
end function
--(32/64)struct GdkEventButton
-- 0 0 GdkEventType type
-- 4 8 GtkWindow *window
-- 8 16 gint8 send_event
-- 12 20 guint32 time
-- 16 24 gdouble x
-- 24 32 gdouble y
-- 32 40 gdouble *axes
-- 36 48 guint state
-- 40 52 guint button
-- 44 56 GdkDevice *device
-- 48 64 gdouble x_root, y_root
---------------------------------------------------------------------
export function window(atom event) -- get event window
---------------------------------------------------------------------
ifdef BITS64 then
return peek8u(event + 8)
end ifdef
return peek4u(event + 4)
end function
---------------------------------------------------------------------
export function time(atom event) -- get event time
---------------------------------------------------------------------
ifdef BITS64 then
return peek4u(event + 20)
end ifdef
return peek4u(event + 12)
end function
---------------------------------------------------------------------
export function xy(atom event) -- get mouse button x y;
---------------------------------------------------------------------
ifdef BITS64 then
return {
float64_to_atom(peek({event + 24, 8})),
float64_to_atom(peek({event + 32, 8}))}
end ifdef
return {
float64_to_atom(peek({event + 16, 8})),
float64_to_atom(peek({event + 24, 8}))}
end function
---------------------------------------------------------------------
export function clicks(atom event)
---------------------------------------------------------------------
atom ct = allocate(64)
object result
if gtk_func("gdk_event_get_click_count",{P,I},{event,ct}) then
result = peek4u(ct)
else
result = -1
end if
free(ct)
return result
end function
---------------------------------------------------------------------
export function scroll_dir(atom event)
---------------------------------------------------------------------
atom dir = allocate(64)
object result
if gtk_func("gdk_event_get_scroll_direction",{P,I},{event,dir}) then
result = peek4u(dir)
else
result = -1
end if
free(dir)
return result
end function
------------------------------------------------------------------------
-- following routine traps the enter key when Entry is activated,
-- and uses it like the tab key - so it works like people expect.
-- in Glade, connect each entry's 'activate' signal to
-- trap_enter_key
------------------------------------------------------------------------
constant gsig = define_proc("g_signal_emit_by_name",{P,P,P})
constant fsig = allocate_string("move-focus")
------------------------------------------------------------------------
global function trap_enter_key(atom ctl, atom event)
-----------------------------------------------------------------------
if classid(ctl) = GtkEntry then
if event = 0 then
c_proc(gsig,{ctl,allocate_string("move-focus"),0})
return 1
end if
end if
return 0
end function

View File

@ -0,0 +1,487 @@
------------------
namespace printer
------------------
constant version = "4.9.4"
include GtkEngine.e
include std/datetime.e
--------------------------------------------------------------------------------
-- This version handles most common printing needs, but it will not yet respect
-- 'marked up' a.k.a. 'rich' text, i.e. text with colors and styles such as
-- set by test59. It just prints them as plain text.
-- However, it DOES print text marked up with GTK's HTML subset, so you can use
-- <b>, <i>, <u>, <span ... etc. in your printouts!
--------------------------------------------------------------------------------
-- The following exported variables can be modified before calling the
-- print routines;
public object header = "[1]\n"
public object subheader = 0
public object footer = "<small>\n<i>Printed by EuGTK [8] on [9]'s computer</i></small>"
export integer
n_pages = 0, -- number of pages to print (0=all)
n_copies = 1,
collate = FALSE,
duplex = 0,
number_up = 1,
number_up_layout = 1,
units = GTK_UNIT_INCH,
use_line_numbers = TRUE,
use_color = TRUE, -- print eu comments in red if true
lines_per_page = 60,
wrap_at = 0,
track_status = TRUE,
show_progress = TRUE, -- enable the built-in progressbar
embed_page_setup = FALSE,
orientation = 0,
order = 0,
confirm = FALSE,
sourcecode = TRUE,
use_full_page = FALSE, -- ignore margins
has_selection = FALSE,
support_selection = FALSE,
quality = GTK_PRINT_QUALITY_DRAFT,
action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG
export atom
scale = 100,
top_margin = 0.25, -- in inch units
left_margin = 0.25,
right_margin = 0.25,
bottom_margin = 0.25,
parent = 0,
signal_status_changed = call_back(routine_id("show_status")),
signal_begin_print = call_back(routine_id("begin_print")),
signal_draw_page = call_back(routine_id("draw_page")),
signal_end_print = call_back(routine_id("end_print")),
signal_request_page_setup = 0,
signal_done = 0,
signal_ready = 0,
signal_got_page_size = 0
export object
name = 0,
font = "Ubuntu Mono 8",
jobname = 0,
settings_file = 0,
setup_file = 0,
export_file = 0,
page_ranges = 0,
page_set = GTK_PAGE_SET_ALL,
custom_tab_hook = 0,
custom_tab_label = 0,
custom_tab_func = 0
ifdef WINDOWS then font = "Courier New 16" end ifdef
export object
line_number_format = "[:4] []\n", -- controls line # format AND code line!
paper_name = "na_letter", -- 8.5x11.0"
tabs = " ", -- replace tab chars with 2 spaces
file_name = 0,
short_name = 0,
page_title = 0,
sub_title = 0
export atom
progress = create(GtkProgressBar),
settings = create(GtkPrintSettings)
--For use in header and footer;
-- 1 = page title (for first page)
-- 2 = sub title (for subsequent pages - leave null to use page title (1) on all pgs)
-- 3 = file name
-- 4 = short name (file name w/o path)
-- 5 = current page number
-- 6 = n_pages printed e.g. pg 1 of n
-- 7 = n_copies requested
-- 8 = today's date in date_format
-- 9 = user name
--10 = user's real name
--11 = font name used for this print job
--12 = file length
--13 = file timestamp
--14 = exported filename
-- use date and time formats in std/datetime.e;
export sequence date_format = "%A, %B %d %Y %l:%M %p"
sequence user
ifdef WINDOWS then
user = "User"
elsedef
user = proper(getenv("USER"))
end ifdef
-- for local use;
atom fontdesc
integer filesize = 0
object timestamp = 0
sequence text
sequence today = datetime:format(datetime:now(),date_format)
------------------------------------------------------------------------
export function PrintFile(object f=0, object x=0)
------------------------------------------------------------------------
if string(f) and string(x) then
page_title = f
file_name = canonical_path(x)
text = read_file(file_name)
text = process_text(text)
timestamp = file_timestamp(file_name)
filesize = file_length(file_name)
short_name = filebase(file_name)
setup_printer()
return 1
end if
if string(f) and atom(x) and x = 0 then
f = canonical_path(f)
file_name = f
timestamp = file_timestamp(f)
filesize = file_length(f)
short_name = filebase(f)
page_title = filename(f)
text = read_file(f)
text = process_text(text)
setup_printer()
return 1
end if
if string(f) and atom(x) and x < 100 then
page_title = f
short_name = f
file_name = f
text = read_file(x)
text = process_text(text)
setup_printer()
return 1
end if
if atom(f) and atom(x) and x < 101 then
text = read_file(x)
text = process_text(text)
if atom(file_name) then
file_name = ""
end if
if atom(short_name) then
short_name = ""
end if
if atom(page_title) then
page_title = ""
end if
setup_printer()
return 1
end if
if atom(f) and atom(x) then
x = unpack(x)
x = canonical_path(x)
file_name = x
short_name = filebase(x)
page_title = filename(x)
text = read_file(x)
text = process_text(text)
setup_printer()
return 1
end if
return 1
end function
export constant print_file = call_back(routine_id("PrintFile"))
------------------------------------------------------------------------
export function PrintText(object f=0, object x=0)
------------------------------------------------------------------------
if string(f) and string(x) then
page_title = f
text = process_text(x)
setup_printer()
return 1
end if
if atom(f) and string(x) then
text = process_text(x)
setup_printer()
return 1
end if
if atom(f) and atom(x) then
if atom(page_title) and page_title = 0 then
page_title = ""
end if
text = unpack(x)
text = process_text(text)
setup_printer()
return 1
end if
return 0
end function
export constant print_text = call_back(routine_id("PrintText"))
integer status_code
sequence status_string
-----------------------------------------------
export function show_status(atom op)
-----------------------------------------------
atom
fn1 = define_func("gtk_print_operation_get_status",{P},I),
fn2 = define_func("gtk_print_operation_get_status_string",{P},S)
status_code = c_func(fn1,{op})
status_string = peek_string(c_func(fn2,{op}))
ifdef PRINT then display("Status [] []",{status_code,status_string}) end ifdef
if show_progress then
set(progress,"text",status_string)
end if
ifdef DELAY then sleep(0.15) end ifdef
return 1
end function
------------------------------------------------------
export function begin_print(atom op, atom context)
------------------------------------------------------
ifdef PRINT then display("Begin printing [] pages ",length(text)) end ifdef
fontdesc = create(PangoFontDescription,font)
-- Some settings may have been changed by the user in the
-- setup dialog, so we should retrieve any we are interested
-- in at this point, before printing starts;
-- For example, modify the lines_per_page to fit different
-- paper sizes and orientations, scale, etc.
-- Figuring out how to do this is beyond my skill level :p
-- I just set the options in my program which calls the
-- print routine.
set(op,"n pages",n_pages)
-- important, as a new value for n_pages is computed
-- based on the length of the file being read, unless a set number
-- has been provided from the calling program.
if show_progress then -- turn on the progress dialog in the calling program
show_all(progress)
end if
return 1
end function
----------------------------------------------------------------------------
export function draw_page(atom op, atom context, integer pg, atom data)
----------------------------------------------------------------------------
atom fn6 = define_func("gtk_print_context_get_cairo_context",{P},P)
atom cr = c_func(fn6,{context})
atom pl = create(PangoCairoLayout,cr)
set(pl,"font description",fontdesc)
pg += 1
if pg > length(text) then
set(progress,"text","Printing complete")
return 0
end if
if show_progress then
set(progress,"text",sprintf("Printing page %d",pg))
set(progress,"fraction",pg/n_pages)
end if
ifdef DELAY then sleep(0.25) end ifdef
object details = {
page_title,sub_title,file_name,short_name,
pg,n_pages,n_copies,
today,user,real_name,font,filesize,timestamp,export_file
}
object page
if atom(header) then header = "<b><u>[1]</u> page [5] of [6]</b>\n\n" end if
if pg = 1 or atom(subheader) then
page = text:format(header,details)
& flatten(text[pg])
& text:format(footer,details)
else
page = text:format(subheader,details)
& flatten(text[pg])
& text:format(footer,details)
end if
set(pl,"markup",page,length(page))
set(pl,"update layout",cr)
set(pl,"show layout",cr)
ifdef PRINT then printf(1,"Page %d\n",pg) end ifdef
return 1
end function
------------------------------------------------------------------------
function process_text(object txt)
------------------------------------------------------------------------
txt = split(txt,'\n')
integer comment
object a,b
object test
for i = 1 to length(txt) do -- replace chars which will confuse markup
txt[i] = join(split(txt[i],'&'),"&amp;")
txt[i] = join(split(txt[i],"&amp;amp;"),"&amp;")
if sourcecode then
txt[i] = join(split(txt[i],'<'),"&lt;")
txt[i] = join(split(txt[i],'>'),"&gt;")
end if
if use_color then
comment = match("--",txt[i])
if comment then
comment -=1
txt[i] = txt[i][1..comment] & "<span color='red'>" & txt[i][comment+1..$] & "</span>"
end if
end if
if use_line_numbers then
txt[i] = text:format(line_number_format,{i,txt[i]})
else
txt[i] &= '\n'
end if
end for
txt = breakup(txt,lines_per_page)
if n_pages = 0 then -- no selection
n_pages = length(txt)
end if
return txt
end function
------------------------------------------------------------------------
export function end_print()
------------------------------------------------------------------------
status_string = "Printing complete"
ifdef PRINT then display(status_string) end ifdef
return 1
end function
---------------------------------------------------------------
export function setup_printer()
---------------------------------------------------------------
atom _size = create(GtkPaperSize,paper_name)
atom err = allocate(16) err = 0
object results = 0
atom fn7 = define_func("gtk_print_operation_run",{P,I,P,P},I)
atom fn8 = define_func("gtk_print_run_page_setup_dialog",{P,P,P},P)
set(settings,"paper size",_size,units)
set(settings,"n copies",n_copies)
set(settings,"collate",collate)
set(settings,"duplex",duplex)
set(settings,"reverse",order)
set(settings,"scale",scale)
set(settings,"quality",quality)
set(settings,"number up",number_up)
set(settings,"number up layout",number_up_layout)
if string(name) then
set(settings,"printer",name)
end if
atom setup = create(GtkPageSetup)
set(setup,"paper size",_size)
set(setup,"orientation",orientation)
set(setup,"left margin",left_margin,units)
set(setup,"right margin",right_margin,units)
set(setup,"top margin",top_margin,units)
set(setup,"bottom margin",bottom_margin,units)
atom printop = create(GtkPrintOperation)
set(printop,"print settings",settings)
set(printop,"default page setup",setup)
set(printop,"show progress",show_progress)
set(printop,"track print status",track_status)
set(printop,"embed page setup",embed_page_setup)
set(printop,"support selection",support_selection)
set(printop,"has selection",has_selection)
set(printop,"use full page",use_full_page)
if action = GTK_PRINT_OPERATION_ACTION_EXPORT then
export_file = canonical_path(export_file)
set(printop,"export filename",export_file)
end if
if string(jobname) then
set(printop,"job name",jobname)
end if
if custom_tab_hook != 0 then
set(printop,"custom tab label",custom_tab_label)
connect(printop,"create-custom-widget",custom_tab_func,printop)
connect(printop,"custom-widget-apply",custom_tab_hook)
end if
connect(printop,"status-changed",signal_status_changed)
connect(printop,"begin-print",signal_begin_print)
connect(printop,"draw-page",signal_draw_page)
connect(printop,"end-print",signal_end_print)
connect(printop,"request-page-setup",signal_request_page_setup)
connect(printop,"done",signal_done)
connect(printop,"ready",signal_ready)
connect(printop,"got-page-size",signal_got_page_size)
c_func(fn7,{printop,action,parent,err}) -- start the print process;
if string(settings_file) then
get(settings,"to file",settings_file)
end if
if string(setup_file) then
get(setup,"to file",setup_file)
end if
object jobname = get(printop,"job name")
if confirm then
if action = GTK_PRINT_OPERATION_ACTION_EXPORT then
if Question(0,"PDF Written",
sprintf("%s\n<small>Folder: %s</small>",
{filename(export_file),pathname(export_file)}),
sprintf("%s\nStatus: %d\n%s\nClick Yes to view",{jobname,status_code,status_string})
,,,"cups") then
show_uri(export_file)
end if
else
Info(0,"Print Job",jobname,
sprintf("Status: %d %s",{status_code,status_string})
,,"cups")
end if
end if
page_title = 0
n_pages = 0
n_copies = 1
action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG
return 1
end function
header = "<b><u>[1]</u></b>\n\n"
-------------------------
-- © 2015 by Irv Mullins
-------------------------

View File

@ -0,0 +1,4 @@
GTK Library for Euphoria 4.0
by Irv Mullins
https://sites.google.com/site/euphoriagtk/Home

View File

@ -0,0 +1,17 @@
LGPL ~ GNU Lesser General Public License version 3.0
This library is free software; you can redistribute it
and/or modify it under the terms of the GNU Lesser General
Public License as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later
version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Pl, Suite 330, Boston, MA 02111-1307 USA

22
tools/WEE/LICENSE Normal file
View File

@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2015 peberlein
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

21
tools/WEE/README.md Normal file
View File

@ -0,0 +1,21 @@
# WEE
A small code-aware editor for Euphoria programming
### Featuring
* [Scintilla](http://www.scintilla.org/) editor control with syntax highlighting
* subroutines list
* automatic if/while/for/procedure/function expansion
* code identifier completion
* jump to subroutine declaration
* ex.err monitoring
* show subroutine arguments
Supports Windows
Supports Linux and Mac OS using [EuGTK](https://sites.google.com/site/euphoriagtk/Home)
Requires [Euphoria 4.1.0 Beta 2](http://openeuphoria.org/wiki/view/DownloadEuphoria.wc) or later.
### How to Get It
Create a folder called "Wee" and download [updater.ex](https://github.com/peberlein/WEE/raw/master/updater.ex). Run "eui updater.ex" to download/update the files for your platform. Run "eui wee" to run the editor, or compile/bind/shroud it for convenience.

66
tools/WEE/manifest.ex Normal file
View File

@ -0,0 +1,66 @@
include std/pretty.e
include std/io.e
include std/hash.e
include std/os.e
include std/pipeio.e
sequence files
files = {
-- platform independent
{"wee.exw", 0, 0, 0},
{"scintilla.e", 0, 0, 0},
{"parser.e", 0, 0, 0},
{"updater.ex", 0, 0, 0},
{"weeicon.e", 0, 0, 0},
-- windows
{"ui_win.e", 0, 0, 0, WINDOWS},
{"window.ew", 0, 0, 0, WINDOWS},
-- GTK
{"ui_gtk.e", 0, 0, 0, LINUX, OSX},
{"EuGTK/GtkEngine.e", 0, 0, 0, LINUX, OSX},
{"EuGTK/GtkEnums.e", 0, 0, 0, LINUX, OSX},
{"EuGTK/GtkPrinter.e", 0, 0, 0, LINUX, OSX},
{"EuGTK/GtkEvents.e", 0, 0, 0, LINUX, OSX},
{"EuGTK/README.txt", 0, 0, 0, LINUX, OSX},
{"EuGTK/license.txt", 0, 0, 0, LINUX, OSX},
-- scintilla
{"scintilla/SciLexer.dll", 0, 0, 32, WINDOWS},
{"scintilla/SciLexer64.dll", 0, 0, 64, WINDOWS},
{"scintilla/scintilla32.so", 0, 0, 32, LINUX},
{"scintilla/scintilla64.so", 0, 0, 64, LINUX},
{"scintilla/scintillaOSX.dylib", 0, 0, 64, OSX},
{"scintilla/scintilla32armhf.so", 0, 0, 32, LINUX},
{"scintilla/License.txt", 0, 0, 0}
}
object file, p
-- returns
function read_until_eof(object pipe)
sequence result = {}
object o = pipeio:read(pipe, 1024)
while sequence(o) and length(o) do
result &= o
o = pipeio:read(pipe, 1024)
end while
return result
end function
for i = 1 to length(files) do
files[i][2] = hash(read_file(files[i][1]), HSIEH30)
-- git log -n 1 --format=oneline -- ui_gtk.e
p = pipeio:exec("git log -n1 --format=oneline -- "&files[i][1], pipeio:create())
files[i][3] = pipeio:read(p[pipeio:STDOUT], 10)
pipeio:kill(p)
p = pipeio:exec("git show "&files[i][3]&":"&files[i][1], pipeio:create())
object h = hash(read_until_eof(p[pipeio:STDOUT]), HSIEH30)
pipeio:kill(p)
printf(1, "%s %s %d %d\n", {files[i][1], files[i][3], files[i][2], h})
files[i][2] = h
end for
--display(files)
? write_file("manifest.json", pretty_sprint(files, {2}))

150
tools/WEE/manifest.json Normal file
View File

@ -0,0 +1,150 @@
{
{
"wee.exw",
334537086,
"0dcf6d4cb0",
0
},
{
"scintilla.e",
13846666,
"e3cc5860ac",
0
},
{
"parser.e",
215958451,
"87365ad72b",
0
},
{
"updater.ex",
273638869,
"befd7e9c4a",
0
},
{
"weeicon.e",
39797371,
"fdc3db69d4",
0
},
{
"ui_win.e",
740860035,
"839c798be8",
0,
2
},
{
"window.ew",
904400105,
"87365ad72b",
0,
2
},
{
"ui_gtk.e",
59538677,
"839c798be8",
0,
3,
4
},
{
"EuGTK/GtkEngine.e",
132693288,
"4df40ce0cd",
0,
3,
4
},
{
"EuGTK/GtkEnums.e",
202551058,
"506cdc498b",
0,
3,
4
},
{
"EuGTK/GtkPrinter.e",
443615540,
"506cdc498b",
0,
3,
4
},
{
"EuGTK/GtkEvents.e",
1050187785,
"506cdc498b",
0,
3,
4
},
{
"EuGTK/README.txt",
332011652,
"04aa6ff6c9",
0,
3,
4
},
{
"EuGTK/license.txt",
70721840,
"506cdc498b",
0,
3,
4
},
{
"scintilla/SciLexer.dll",
376057439,
"b6035dbac0",
32,
2
},
{
"scintilla/SciLexer64.dll",
971949613,
"683bd7ddbf",
64,
2
},
{
"scintilla/scintilla32.so",
794231462,
"b6035dbac0",
32,
3
},
{
"scintilla/scintilla64.so",
778289070,
"b6035dbac0",
64,
3
},
{
"scintilla/scintillaOSX.dylib",
510448282,
"b6035dbac0",
64,
4
},
{
"scintilla/scintilla32armhf.so",
572289041,
"e3cc5860ac",
32,
3
},
{
"scintilla/License.txt",
662502963,
"b6035dbac0",
0
}
}

BIN
tools/WEE/mongoose-wee.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

2959
tools/WEE/parser.e Normal file

File diff suppressed because it is too large Load Diff

2802
tools/WEE/scintilla.e Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,20 @@
License for Scintilla and SciTE
Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation.
NEIL HODGSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS, IN NO EVENT SHALL NEIL HODGSON BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
OR PERFORMANCE OF THIS SOFTWARE.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,110 @@
# Make file for Scintilla on Linux or compatible OS
# Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
# The License.txt file describes the conditions under which this software may be distributed.
# This makefile assumes GCC 4.3 is used and changes will be needed to use other compilers.
# GNU make does not like \r\n line endings so should be saved to CVS in binary form.
# Builds for GTK+ 2 and no longer supports GTK+ 1.
# Also works with ming32-make on Windows.
.SUFFIXES: .cxx .c .o .h .a
ifdef CLANG
CXX = clang++ -Wno-deprecated-register
CC = clang
# Can choose aspect to sanitize: address and undefined can simply change SANITIZE but for
# thread also need to create Position Independent Executable -> search online documentation
SANITIZE = address
#SANITIZE = undefined
endif
RANLIB = touch
ifdef GTK3
GTKVERSION=gtk+-3.0
else
GTKVERSION=gtk+-2.0
endif
# Environment variable windir always defined on Win32
ifndef windir
ifeq ($(shell uname),Darwin)
RANLIB = ranlib
endif
endif
ifdef windir
DEL = del /q
COMPLIB=..\bin\scintilla.a
else
DEL = rm -f
COMPLIB=../bin/scintilla.a
SOLIB=../bin/scintilla.so
endif
vpath %.h ../src ../include ../lexlib
vpath %.cxx ../src ../lexlib ../lexers
INCLUDEDIRS=-I ../include -I ../src -I ../lexlib
ifdef CHECK_DEPRECATED
DEPRECATED=-DGDK_PIXBUF_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DDISABLE_GDK_FONT
endif
CXXBASEFLAGS=-Wall -pedantic -DGTK -DSCI_LEXER $(INCLUDEDIRS) $(DEPRECATED) -fPIC
ifdef NOTHREADS
THREADFLAGS=-DG_THREADS_IMPL_NONE
else
THREADFLAGS=
endif
ifdef CXX11_REGEX
REFLAGS=-DCXX11_REGEX
endif
ifdef DEBUG
ifdef CLANG
CTFLAGS=-DDEBUG -g -fsanitize=$(SANITIZE) $(CXXBASEFLAGS) $(THREADFLAGS)
else
CTFLAGS=-DDEBUG -g $(CXXBASEFLAGS) $(THREADFLAGS)
endif
else
CTFLAGS=-DNDEBUG -Os $(CXXBASEFLAGS) $(THREADFLAGS)
endif
CFLAGS:=$(CTFLAGS)
CXXTFLAGS:=--std=c++0x $(CTFLAGS) $(REFLAGS)
CONFIGFLAGS:=$(shell pkg-config --cflags $(GTKVERSION))
MARSHALLER=scintilla-marshal.o
.cxx.o:
$(CXX) $(CONFIGFLAGS) $(CXXTFLAGS) $(CXXFLAGS) -c $<
.c.o:
$(CC) $(CONFIGFLAGS) $(CFLAGS) -w -c $<
LEXOBJS:=$(addsuffix .o,$(basename $(notdir $(wildcard ../lexers/Lex*.cxx))))
all: $(COMPLIB) $(SOLIB)
clean:
$(DEL) *.o $(COMPLIB) *.plist
analyze:
clang --analyze $(CONFIGFLAGS) $(CXXTFLAGS) $(CXXFLAGS) *.cxx ../src/*.cxx ../lexlib/*.cxx ../lexers/*.cxx
deps:
$(CXX) -MM $(CONFIGFLAGS) $(CXXTFLAGS) *.cxx ../src/*.cxx ../lexlib/*.cxx ../lexers/*.cxx | sed -e 's/\/usr.* //' | grep [a-zA-Z] >deps.mak
COMPLIBS=Accessor.o CharacterSet.o LexerBase.o LexerModule.o LexerSimple.o StyleContext.o WordList.o \
CharClassify.o Decoration.o Document.o PerLine.o Catalogue.o CallTip.o CaseConvert.o CaseFolder.o \
ScintillaBase.o ContractionState.o EditModel.o Editor.o EditView.o ExternalLexer.o MarginView.o \
PropSetSimple.o PlatGTK.o \
KeyMap.o LineMarker.o PositionCache.o ScintillaGTK.o CellBuffer.o CharacterCategory.o ViewStyle.o \
RESearch.o RunStyles.o Selection.o Style.o Indicator.o AutoComplete.o UniConversion.o XPM.o \
$(MARSHALLER) $(LEXOBJS)
$(COMPLIB): $(COMPLIBS)
$(AR) rc $@ $^
$(RANLIB) $@
$(SOLIB): $(COMPLIBS)
$(CC) $(CFLAGS) -shared -o $@ $^ -lm -lstdc++ `pkg-config --libs $(GTKVERSION) gthread-2.0 gmodule-2.0`
# Automatically generate header dependencies with "make deps"
include deps.mak

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

1504
tools/WEE/ui_gtk.e Normal file

File diff suppressed because it is too large Load Diff

1866
tools/WEE/ui_win.e Normal file

File diff suppressed because it is too large Load Diff

106
tools/WEE/updater.ex Normal file
View File

@ -0,0 +1,106 @@
-- WEE source code updater
include std/console.e
include std/net/http.e
include std/io.e
include std/get.e
include std/filesys.e
include std/hash.e
puts(1, "=== WEE Source Code Updater ===\n"&
"This will overwrite any local changes to the source files.\n"&
"Press a key to continue, or 'q' to quit.\n")
if wait_key() = 'q' then
abort(0)
end if
constant
repo = "peberlein/WEE/",
base_url = "http://cdn.rawgit.com/" & repo -- & "commit/filename"
-- this needs to be .json since rawgit.com has a whitelist of extensions
-- otherwise it will just redirect to https://raw.githubusercontent.com
-- and http_get doesn't support https: protocol
constant
manifest = http_get("http://rawgit.com/"& repo &"master/manifest.json")
procedure fail(sequence fmt, object args={})
printf(1, fmt, args)
puts(1, "\nPress any key to exit, then try updating again.\n")
wait_key()
abort(1)
end procedure
if atom(manifest) or not equal(manifest[1][1][2], "200") then
display(manifest)
fail("Failed to download manifest.json\n")
end if
-- manifest format
-- {
-- {"pathname", hash, "commit-tag", platform-bits, platforms...}
-- }
sequence files, name, commit_tag
files = value(manifest[2])
--display(files)
if files[1] != 0 then
fail("Failed to parse manifest\n")
end if
files = files[2]
ifdef BITS64 then
constant PLATFORM_BITS = 64
elsedef
constant PLATFORM_BITS = 32
end ifdef
integer platform_bits
sequence platforms, subdir
object result, hashcode
for i = 1 to length(files) do
if length(files[i]) < 4 then
fail("Manifest file has invalid format.\n")
end if
name = files[i][1]
hashcode = files[i][2]
commit_tag = files[i][3]
platform_bits = files[i][4]
platforms = files[i][5..$]
if length(platforms) and not find(platform(), platforms) then
-- file not used on this platform
elsif platform_bits != 0 and platform_bits != PLATFORM_BITS then
-- file not compatible with 32/64-bit platform
elsif equal(hashcode, hash(read_file(name), HSIEH30)) then
-- file hash is ok
printf(1, "%s is up-to-date.\n", {name})
else
printf(1, "Updating %s...\n", {name})
result = http_get(base_url & commit_tag & "/" & name)
if atom(result) or not equal(result[1][1][2], "200") then
display(result)
fail("Failed to download %s\n", {name})
elsif not equal(hashcode, hash(result[2], HSIEH30)) then
fail("Failed to validate %s\n", {name})
else
subdir = dirname(name)
if length(subdir) and atom(dir(subdir)) then
printf(1, "Creating directory %s\n", {subdir})
create_directory(subdir)
end if
if write_file(name, result[2]) = -1 then
printf(1, "Failed to write_file %s\n", {name})
end if
end if
end if
end for
puts(1, "Done. Press any key to exit.\n")
wait_key()

BIN
tools/WEE/wee Executable file

Binary file not shown.

2879
tools/WEE/wee.exw Normal file

File diff suppressed because it is too large Load Diff

BIN
tools/WEE/wee.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

507
tools/WEE/weeicon.e Normal file
View File

@ -0,0 +1,507 @@
-- wee icons in XPM format
export constant wee_xpm = {
"32 32 60 1",
" c None",
". c #FF6600",
"+ c #FFFFFF",
"@ c #FED8BF",
"# c #FED3B6",
"$ c #FEEADD",
"% c #FED3B7",
"& c #FE6601",
"* c #FEA56B",
"= c #FEE5D5",
"- c #FEF9F6",
"; c #FEEADE",
"> c #FEA76D",
", c #FE8738",
"' c #FEE9DC",
") c #FE6C0C",
"! c #FEFAF8",
"~ c #FE7A23",
"{ c #FE6B0A",
"] c #FEF5F0",
"^ c #FE7114",
"/ c #FEA469",
"( c #FE6B09",
"_ c #FE9651",
": c #FEE7D8",
"< c #FE8230",
"[ c #FE9854",
"} c #FEA468",
"| c #FE9B5A",
"1 c #FED7BD",
"2 c #FEE6D6",
"3 c #FED9C0",
"4 c #FEAE7A",
"5 c #FEB584",
"6 c #FEC7A3",
"7 c #FECFB0",
"8 c #FECEAE",
"9 c #FED1B3",
"0 c #FEA56A",
"a c #FEF8F5",
"b c #FEF2EB",
"c c #FE771D",
"d c #FEFDFD",
"e c #FEE8DA",
"f c #FEF3EC",
"g c #FE7820",
"h c #FEF6F1",
"i c #FEF9F7",
"j c #FE7419",
"k c #FE6D0D",
"l c #FEDEC9",
"m c #FECBA9",
"n c #FEDAC3",
"o c #FEA870",
"p c #FEB787",
"q c #FEDAC2",
"r c #FE9E5E",
"s c #FEE4D4",
"t c #FEF2EA",
"u c #FE7418",
" ......... ",
" .............. ",
" .................. ",
" .................... ",
" ...................... ",
" ........................ ",
" .......................... ",
" ............................ ",
" ............................ ",
" .............................. ",
" .............................. ",
"............................... ",
"................................",
"...+++@.#$.%++&*=-;>..&*=-;>....",
"...,+'.)!+~{]^>+/(>+_.>+/(>+_...",
"....:+<[++}|1.2+(.{+3.2+(.{+3...",
"....4+567+890.a+++++b.a+++++b...",
"....cdefghhij.2+k.....2+k.......",
".....1+l.m+n..o+pk)>q.o+pk)>q...",
".....r+4.|+o..&>s-tmu.&>s-tmu...",
" .............................. ",
" .............................. ",
" .............................. ",
" ............................ ",
" ............................ ",
" .......................... ",
" ........................ ",
" ...................... ",
" .................... ",
" .................. ",
" .............. ",
" ........ "}
export constant
a_xpm = `/* XPM */
"16 16 28 1",
" c None",
". c #3300CC",
"+ c #FFFFFF",
"@ c #FBFBFD",
"# c #E6E1F8",
"$ c #AD99EA",
"% c #4011CE",
"& c #7553DB",
"* c #3807CC",
"= c #8061DE",
"- c #B3A1EB",
"; c #3503CC",
"> c #EBE7F9",
", c #4A1DD1",
"' c #B9A8ED",
") c #FDFDFD",
"! c #CBBEF1",
"~ c #947AE3",
"{ c #3A0ACD",
"] c #F6F4FC",
"^ c #3A09CD",
"/ c #DAD2F5",
"( c #7958DD",
"_ c #3908CC",
": c #8E72E2",
"< c #5F38D6",
"[ c #DAD1F5",
"} c #8162DF",
" ...... ",
" .......... ",
" ............ ",
" .............. ",
" ....++@#$%.... ",
".....+&*=+-.....",
"........;+>.....",
"....,'>)+++.....",
"....!+~{.++.....",
"....]+^.;++.....",
"..../+(_:++.....",
" ...<[]/}+++... ",
" .............. ",
" ............ ",
" .......... ",
" ...... "};`,
c_xpm = `/* XPM */
static char * c_xpm[] = {
"16 16 33 1",
" c None",
". c #3399CC",
"+ c #6EB6DA",
"@ c #D1E7F3",
"# c #F7FAFC",
"$ c #F2F8FB",
"% c #C3E0EF",
"& c #6AB4D9",
"* c #FDFDFD",
"= c #BFDFEE",
"- c #46A2D0",
"; c #42A0CF",
"> c #BBDDED",
", c #FFFFFF",
"' c #D0E7F2",
") c #55A9D3",
"! c #4AA4D1",
"~ c #F6FAFC",
"{ c #3A9CCD",
"] c #D2E8F3",
"^ c #56AAD4",
"/ c #4BA4D1",
"( c #E1EFF6",
"_ c #72B8DB",
": c #C1DFEF",
"< c #43A0CF",
"[ c #93C8E3",
"} c #73B8DB",
"| c #D4E9F3",
"1 c #F8FBFC",
"2 c #EBF4F9",
"3 c #A4D1E8",
"4 c #3599CC",
" ...... ",
" .......... ",
" ............ ",
" .............. ",
" ....+@#$%&.... ",
"....+*=-;>,.....",
"....',)..!,.....",
"....~,{.........",
"....~,{.........",
"....],^../(.....",
"...._,:-<=[.....",
" ....}|1234.... ",
" .............. ",
" ............ ",
" .......... ",
" ...... "};`,
e_xpm = `/* XPM */
static char * e_xpm[] = {
"16 16 37 1",
" c None",
". c #CC0099",
"+ c #D844B3",
"@ c #F1C0E5",
"# c #FBF3F9",
"$ c #FCF6FA",
"% c #F3C8E8",
"& c #DA4EB7",
"* c #D945B4",
"= c #FDFCFD",
"- c #E684CD",
"; c #CE0E9E",
"> c #CE0F9E",
", c #E688CF",
"' c #FDFDFD",
") c #D73BB0",
"! c #F2C3E6",
"~ c #FFFFFF",
"{ c #CD0C9D",
"] c #F0B8E2",
"^ c #FCF5FA",
"/ c #F9E9F5",
"( c #CD0B9C",
"_ c #F2C5E7",
": c #D637AE",
"< c #D42DAA",
"[ c #F5D2EC",
"} c #DA4AB6",
"| c #F3C7E8",
"1 c #D32BA9",
"2 c #CC089B",
"3 c #D534AD",
"4 c #F4D0EB",
"5 c #DE5EBE",
"6 c #D948B5",
"7 c #F4CFEB",
"8 c #DE60BF",
" ...... ",
" .......... ",
" ............ ",
" .............. ",
" ....+@#$%&.... ",
"....*=-;>,')....",
"....!~{..;~]....",
"....^~~~~~~/....",
"....^~(.........",
"...._~:...<[....",
"....}'|12345....",
" ....6@##78.... ",
" .............. ",
" ............ ",
" .......... ",
" ...... "};`,
f_xpm = `/* XPM */
static char * f_xpm[] = {
"16 16 11 1",
" c None",
". c #0044FF",
"+ c #2A62FE",
"@ c #BDCEFE",
"# c #F2F5FE",
"$ c #FFFFFF",
"% c #CBD8FE",
"& c #3A6EFE",
"* c #366BFE",
"= c #FAFBFE",
"- c #0044FE",
" ...... ",
" .......... ",
" ............ ",
" .....+@#$$.... ",
" .....%$&*$.... ",
"......=$-.......",
".....$$$$$......",
"......$$........",
"......$$........",
"......$$........",
"......$$........",
" .....$$....... ",
" .....$$....... ",
" ...$$$$..... ",
" .......... ",
" ...... "};`,
i_xpm = `/* XPM */
static char * i_xpm[] = {
"16 16 6 1",
" c None",
". c #CC0033",
"+ c #F2C4CF",
"@ c #F2C3CF",
"# c #F3C6D1",
"$ c #FFFFFF",
" ...... ",
" .......... ",
" .....+@..... ",
" ......#+...... ",
" .............. ",
"......$$$.......",
".......$$.......",
".......$$.......",
".......$$.......",
".......$$.......",
".......$$.......",
" ......$$...... ",
" .....$$$$..... ",
" ............ ",
" .......... ",
" ...... "};`,
n_xpm = `/* XPM */
static char * n_xpm[] = {
"16 16 13 1",
" c None",
". c #CCCCCC",
"+ c #C9C9C9",
"@ c #CBCBCB",
"# c #CACACA",
"$ c #E9E9E9",
"% c #FFFFFF",
"& c #E4E4E4",
"* c #EEEEEE",
"= c #DFDFDF",
"- c #CDCDCD",
"; c #FEFEFE",
"> c #D7D7D7",
" ...... ",
" .......... ",
" ............ ",
" .............. ",
" ...+++@++..... ",
"...#$%%&*%=.....",
"....+%%-+%;+....",
"....+%%++%%+....",
"....+%%++%%+....",
"....+%%++%%+....",
"...#$%%$>%%$....",
" ...++++@+++... ",
" .............. ",
" ............ ",
" .......... ",
" ...... "};
`,
o_xpm = `/* XPM */
static char * o_xpm[] = {
"16 16 20 1",
" c None",
". c #00CC99",
"+ c #45D9B4",
"@ c #C2F2E6",
"# c #F5FCFA",
"$ c #FCFDFD",
"% c #A8EDDB",
"& c #16CFA1",
"* c #14CFA0",
"= c #A3ECD9",
"- c #C3F2E6",
"; c #FFFFFF",
"> c #23D2A6",
", c #22D2A6",
"' c #04CC9A",
") c #03CC99",
"! c #A6ECDB",
"~ c #15CFA0",
"{ c #A5ECDA",
"] c #44D8B3",
" ...... ",
" .......... ",
" ............ ",
" .............. ",
" ....+@##@+.... ",
"....+$%&*=$+....",
"....-;>..,;@....",
"....#;'..);#....",
"....#;)..';#....",
"....@;>..>;@....",
"....+$!~*{$]....",
" ....+-##-+.... ",
" .............. ",
" ............ ",
" .......... ",
" ...... "};`,
p_xpm = `/* XPM */
static char * p_xpm[] = {
"16 16 25 1",
" c None",
". c #FF6600",
"+ c #FFFFFF",
"@ c #FEA66C",
"# c #FEEDE3",
"$ c #FEFAF8",
"% c #FEE3D1",
"& c #FE9854",
"* c #FECAA8",
"= c #FE7216",
"- c #FE7215",
"; c #FE8D42",
"> c #FE7A22",
", c #FE7B24",
"' c #FED8BF",
") c #FE6703",
"! c #FE6804",
"~ c #FEF3EC",
"{ c #FEC9A6",
"] c #FECAA7",
"^ c #FE8E43",
"/ c #FEEEE4",
"( c #FEFBF9",
"_ c #FEE3D2",
": c #FE9A57",
" ...... ",
" .......... ",
" ............ ",
" ...+++@#$%&... ",
" ....++*=-*+;.. ",
".....++>..,+'...",
".....++)..!+~...",
".....++)..!+~...",
".....++>..,+'...",
".....++{--]+^...",
".....++@/(_:....",
" ....++........ ",
" ....++........ ",
" ..++++...... ",
" .......... ",
" ...... "};`,
s_xpm = `/* XPM */
static char * s_xpm[] = {
"16 16 34 1",
" c None",
". c #33CC00",
"+ c #4BD11F",
"@ c #B6ECA4",
"# c #E8F8E3",
"$ c #FAFDF9",
"% c #FFFFFF",
"& c #D2F3C7",
"* c #7BDD5B",
"= c #38CC07",
"- c #4AD11D",
"; c #C0EEB1",
"> c #F7FCF6",
", c #6AD945",
"' c #35CC03",
") c #CAF1BD",
"! c #F9FCF8",
"~ c #E0F6D9",
"{ c #A4E78D",
"] c #41CE12",
"^ c #44CF16",
"/ c #EBF9E7",
"( c #CBF1BE",
"_ c #4ED222",
": c #3DCD0D",
"< c #77DC55",
"[ c #F6FCF4",
"} c #C8F0BB",
"| c #37CC06",
"1 c #78DC57",
"2 c #D3F3C9",
"3 c #FCFDFC",
"4 c #ECF9E8",
"5 c #BCEDAC",
" ...... ",
" .......... ",
" ............ ",
" .............. ",
" ....+@#$%%%... ",
".....&%*=-;%....",
".....>%,'.-%....",
".....)%%!~{]....",
".....^@/%%%(....",
".....%_.:<%[....",
".....%}_|1%2....",
" ....%%%345+... ",
" .............. ",
" ............ ",
" .......... ",
" ...... "};`,
t_xpm = `/* XPM */
static char * t_xpm[] = {
"16 16 11 1",
" c None",
". c #CC9900",
"+ c #FFFFFF",
"@ c #F9F4E6",
"# c #D2A622",
"$ c #D5AD34",
"% c #DEBF60",
"& c #F8F2E1",
"* c #FDFCF9",
"= c #F8F3E3",
"- c #DEBE5E",
" ...... ",
" .......... ",
" ............ ",
" .....++....... ",
" .....++....... ",
".....+++++......",
"......++........",
"......++........",
"......++........",
"......++........",
"......++........",
" .....@+#$@.... ",
" .....%&*=-.... ",
" ............ ",
" .......... ",
" ...... "};`

2341
tools/WEE/window.ew Normal file

File diff suppressed because it is too large Load Diff

200
tools/euphoria-manager Executable file
View File

@ -0,0 +1,200 @@
#!/bin/bash
###############################################################################
## ISC LICENSE:
##
## Permission to use, copy, modify, and/or distribute this software for
## any purpose with or without fee is hereby granted, provided that the above
## copyright notice and this permission notice appear in all copies.
##
## THE SOFTWARE IS PROVIDED “AS IS” AND ISC DISCLAIMS ALL WARRANTIES WITH
## REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
## AND FITNESS.
## IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
## OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
## USE, DATA OR PROFITS,
## WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
################################################################################
## [META Info]
##
## Title: geuphoria.sh
## Version: 0.03
## Description: manage installation and removal of Euphoria Programming Language
## Author: Mollusk
## #############################################################################
name="euphoria"
version="4.1.0"
state="beta2"
arch="x64"
fext="tar.gz"
extcmd="tar"
deps="curl"
target_dir="/usr/local"
url="http://nbtelecom.dl.sourceforge.net/project/rapideuphoria/Euphoria/${version}-${state}/${name}-${version}-Linux-${arch}-57179171dbed.${fext}"
tmpdir="/tmp"
check_deps(){
get_path=$(which curl)
if [ ! ${get_path} ];then
printf "Please install: ${deps}\n"
exit 0;
else
printf "Deps passed checks..moving on\n"
fi
}
check_root(){
if [[ $EUID -ne 0 ]]; then
printf "${LRED}This script must be run as root${NC}\n" 1>&2
exit 1
fi
}
check_install(){
if [ ! -d ${target_dir}/${name}-${version}-Linux-${arch} ];then
printf "Install check passed...moving on...\n"
else
printf "${0}: ${name}-${version} is already installed\n"
exit 0;
fi
}
download_pkgs(){
if [ ! -f ${tmpdir}/${name}-${version}.${fext} ];then
curl -o ${tmpdir}/${name}-${version}.${fext} ${url}
else
printf "The archive already exists..moving to extraction phase\n"
fi
}
extract_files(){
cd ${tmpdir}
if [ ! -f ${name}-${version}.${fext} ];then
printf "${0}: ${tmpdir}/${name}-${version}.${fext}: no such file\n"
else
${extcmd} xvzf ${name}-${version}.${fext}
fi
}
install_build(){
cd ${tmpdir}
if [ ! -d ${name}-${version}-Linux-${arch} ];then
printf "${0}: ${name}-${version}-Linux-${arch}: No such firectory\n"
else
cp -r ${tmpdir}/${name}-${version}-Linux-${arch} ${target_dir}/
fi
}
post_install(){
ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/eui /usr/bin
ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/euc /usr/bin
ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/eutest /usr/bin
ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/eudist /usr/bin
ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/eudoc /usr/bin
ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/eushroud /usr/bin
ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/euloc /usr/bin
ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/eudis /usr/bin
ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/eubind /usr/bin
ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/eub /usr/bin
ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/echoversion /usr/bin
ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/creole /usr/bin
ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/eucoverage /usr/bin
}
uninstall_pkg(){
if [ ! -d ${target_dir}/${name}-${version}-Linux-${arch} ];then
printf "${name}-${version} is not installed\n"
else
rm -v -r ${target_dir}/${name}-${version}-Linux-${arch}
rm -v /usr/bin/eui
rm -v /usr/bin/euc
rm -v /usr/bin/eutest
rm -v /usr/bin/eudist
rm -v /usr/bin/eudoc
rm -v /usr/bin/eushroud
rm -v /usr/bin/euloc
rm -v /usr/bin/eudis
rm -v /usr/bin/eubind
rm -v /usr/bin/eub
rm -v /usr/bin/echoversion
rm -v /usr/bin/creole
rm -v /usr/bin/eucoverage
if [ ! -d ${target_dir}/${name}-${version}-Linux-${arch} ];then
echo
printf "${name}-${version} is uninstalled\n"
else
printf "${name}-${version} still exists on the system\n"
printf "Location: ${target_dir}/${name}-${version}-Linux-${arch}\n"
fi
fi
}
remove_tmp(){
echo
printf "Do you want to remove ${tmpdir}/${name}-${version}-Linux-${arch} and ${tmpdir}/${name}-${version}.${fext}"
printf "[y/n]: "
read choice
if [ "${choice}" = "y" ];then
rm -v -r ${tmpdir}/${name}-${version}-Linux-${arch}
rm -v -r ${tmpdir}/${name}-${version}.${fext}
if [ ! -d ${tmpdir}/${name}-${version}-Linux-${arch} ] && [ ! -f ${tmpdir}/${name}-${version}.${fext} ];then
printf "${tmpdir} cleared\n"
else
printf "Failed to remove files\n"
fi
elif [ "${choice}" = "n" ];then
printf "Exiting...\n"
exit 0;
else
printf "Skipping and exiting...\n"
exit 0;
fi
}
case $1 in
install | i)
check_root
check_deps
check_install
download_pkgs
extract_files
install_build
post_install
;;
remove | r)
check_root
uninstall_pkg
;;
clean | c)
remove_tmp
;;
*)
printf """
[SYNOPSIS]
${0} <option>
[OPTIONS]
install | i Install ${name}-${version}
remove | r Uninstall ${name}-${version}
clean | c Clear out ${name} downloads in ${tmpdir}
"""
;;
esac