Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A few fixes for GeanyLua #39

Merged
merged 2 commits into from
Jun 16, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions geanylua/glspi.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ extern GeanyFunctions *glspi_geany_functions;

#ifdef NEED_FAIL_ARG_TYPE
/* Pushes an error message onto Lua stack if script passes a wrong arg type */
static gint glspi_fail_arg_type(lua_State *L, const gchar *func, gint argnum, gchar *type)
static gint glspi_fail_arg_type(lua_State *L, const gchar *func, gint argnum, const gchar *type)
{
lua_pushfstring(L, _("Error in module \"%s\" at function %s():\n"
" expected type \"%s\" for argument #%d\n"),
Expand All @@ -109,7 +109,7 @@ static gint glspi_fail_arg_type(lua_State *L, const gchar *func, gint argnum, gc
#ifdef NEED_FAIL_ARG_TYPES
/* Same as above, but for two overloaded types, eg "string" OR "number" */
static gint glspi_fail_arg_types(
lua_State *L, const gchar *func, gint argnum, gchar *type1, gchar *type2)
lua_State *L, const gchar *func, gint argnum, const gchar *type1, const gchar *type2)
{
lua_pushfstring(L, _("Error in module \"%s\" at function %s():\n"
" expected type \"%s\" or \"%s\" for argument #%d\n"),
Expand All @@ -123,7 +123,7 @@ static gint glspi_fail_arg_types(
#ifdef NEED_FAIL_ELEM_TYPE
/*Pushes an error message onto Lua stack if table contains wrong element type*/
static gint glspi_fail_elem_type(
lua_State *L, const gchar *func, gint argnum, gint idx, gchar *type)
lua_State *L, const gchar *func, gint argnum, gint idx, const gchar *type)
{
lua_pushfstring(L, _("Error in module \"%s\" at function %s():\n"
" invalid table in argument #%d:\n"
Expand Down
13 changes: 7 additions & 6 deletions geanylua/glspi_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static gint glspi_project(lua_State* L)
}
}

static gchar *glspi_script_dir = NULL;
static const gchar *glspi_script_dir = NULL;

static gint glspi_appinfo(lua_State* L)
{
Expand Down Expand Up @@ -109,7 +109,7 @@ static gint glspi_xsel(lua_State* L)
{
if (lua_gettop(L)>0) {
if (lua_isstring(L,1)) {
guint len;
gsize len;
const gchar*txt=lua_tolstring(L,1,&len);
gtk_clipboard_set_text(CLIPBOARD,txt,len);
} else {
Expand Down Expand Up @@ -192,7 +192,7 @@ static gint glspi_stat(lua_State* L)
if (!lua_isstring(L,1)) { return FAIL_STRING_ARG(1); }
fn=lua_tostring(L,1);
if (sf(fn,&st)==0) {
gchar *ft=NULL;
const gchar *ft=NULL;
switch ( st.st_mode & S_IFMT) {
case S_IFBLK:ft="b"; break;
case S_IFCHR:ft="c"; break;
Expand Down Expand Up @@ -347,7 +347,8 @@ static void glspi_init_key_cmd_hash(void)
key_cmd_hash=g_hash_table_new(g_str_hash,g_str_equal);
for (i=0;key_cmd_hash_entries[i].name; i++) {
g_hash_table_insert(
key_cmd_hash,key_cmd_hash_entries[i].name,&key_cmd_hash_entries[i]);
key_cmd_hash,(gpointer) key_cmd_hash_entries[i].name,
&key_cmd_hash_entries[i]);
}
}

Expand Down Expand Up @@ -579,7 +580,7 @@ static gint glspi_keygrab(lua_State* L)
if (prompt && doc && doc->is_valid ) {
gint fvl=scintilla_send_message(doc->editor->sci,SCI_GETFIRSTVISIBLELINE, 0,0);
gint pos=sci_get_position_from_line(doc->editor->sci, fvl+1);
scintilla_send_message(doc->editor->sci,SCI_CALLTIPSHOW,pos+3, (gint)prompt);
scintilla_send_message(doc->editor->sci,SCI_CALLTIPSHOW,pos+3, (glong)prompt);
}
gdk_window_add_filter(main_widgets->window->window, keygrab_cb, &km);
do {
Expand Down Expand Up @@ -620,7 +621,7 @@ static const struct luaL_reg glspi_app_funcs[] = {
{NULL,NULL}
};

void glspi_init_app_funcs(lua_State *L, gchar*script_dir) {
void glspi_init_app_funcs(lua_State *L, const gchar*script_dir) {
glspi_script_dir = script_dir;
luaL_register(L, NULL,glspi_app_funcs);
}
6 changes: 3 additions & 3 deletions geanylua/glspi_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static struct {



extern void glspi_run_script(gchar *script_file, gint caller, GKeyFile*proj, gchar *script_dir);
extern void glspi_run_script(const gchar *script_file, gint caller, GKeyFile*proj, const gchar *script_dir);


/* Called by Geany, run a script associated with a keybinding. */
Expand Down Expand Up @@ -322,7 +322,7 @@ static void assign_accel(GtkWidget*w, char*fn)



static GtkWidget* new_menu(GtkWidget *parent, gchar* script_dir, gchar*title);
static GtkWidget* new_menu(GtkWidget *parent, const gchar* script_dir, const gchar*title);

/* GSList "for each" callback to create a menu item for each found script */
static void init_menu(gpointer data, gpointer user_data)
Expand Down Expand Up @@ -363,7 +363,7 @@ static void init_menu(gpointer data, gpointer user_data)



static GtkWidget* new_menu(GtkWidget *parent, gchar* script_dir, gchar*title)
static GtkWidget* new_menu(GtkWidget *parent, const gchar* script_dir, const gchar*title)
{
GSList *script_names=utils_get_file_list_full(script_dir, TRUE, TRUE, NULL);
if (script_names) {
Expand Down
2 changes: 1 addition & 1 deletion geanylua/glspi_keycmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


typedef struct _KeyCmdHashEntry {
gchar *name;
const gchar *name;
guint group;
guint key_id;
} KeyCmdHashEntry;
Expand Down
22 changes: 11 additions & 11 deletions geanylua/glspi_run.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extern void glspi_init_doc_funcs(lua_State *L);
/* basic dialog box functions */
extern void glspi_init_dlg_funcs(lua_State *L, GsDlgRunHook hook);
/* application functions */
extern void glspi_init_app_funcs(lua_State *L, gchar*script_dir);
extern void glspi_init_app_funcs(lua_State *L, const gchar*script_dir);
/* menu functions */
void glspi_init_mnu_funcs(lua_State *L);

Expand Down Expand Up @@ -53,7 +53,7 @@ static void repaint_scintilla(void)


/* Internal yes-or-no question box (not used by scripts) */
static gboolean glspi_show_question(gchar*title, gchar*question, gboolean default_result)
static gboolean glspi_show_question(const gchar*title, const gchar*question, gboolean default_result)
{
GtkWidget *dialog, *yes_btn, *no_btn;
GtkResponseType dv, rv;
Expand All @@ -76,7 +76,7 @@ static gboolean glspi_show_question(gchar*title, gchar*question, gboolean defaul
}


static gboolean glspi_goto_error(gchar *fn, gint line)
static gboolean glspi_goto_error(const gchar *fn, gint line)
{
GeanyDocument *doc=document_open_file(fn, FALSE, NULL, NULL);
if (doc) {
Expand All @@ -103,7 +103,7 @@ static gboolean glspi_goto_error(gchar *fn, gint line)
give the user an option to automatically open the file and scroll to
the offending line.
*/
static void glspi_script_error(gchar *script_file, const gchar *msg, gboolean need_name, gint line)
static void glspi_script_error(const gchar *script_file, const gchar *msg, gboolean need_name, gint line)
{
GtkWidget *dialog;
if (need_name) {
Expand Down Expand Up @@ -336,7 +336,7 @@ static gint glspi_traceback(lua_State *L)
The set_*_token functions assign default values for module-level variables
*/

static void set_string_token(lua_State *L, gchar*name, gchar*value)
static void set_string_token(lua_State *L, const gchar*name, const gchar*value)
{
lua_getglobal(L, LUA_MODULE_NAME);
if (lua_istable(L, -1)) {
Expand All @@ -350,7 +350,7 @@ static void set_string_token(lua_State *L, gchar*name, gchar*value)



static void set_numeric_token(lua_State *L, gchar*name, gint value)
static void set_numeric_token(lua_State *L, const gchar*name, gint value)
{
lua_getglobal(L, LUA_MODULE_NAME);
if (lua_istable(L, -1)) {
Expand All @@ -364,7 +364,7 @@ static void set_numeric_token(lua_State *L, gchar*name, gint value)



static void set_boolean_token(lua_State *L, gchar*name, gboolean value)
static void set_boolean_token(lua_State *L, const gchar*name, gboolean value)
{
lua_getglobal(L, LUA_MODULE_NAME);
if (lua_istable(L, -1)) {
Expand All @@ -378,7 +378,7 @@ static void set_boolean_token(lua_State *L, gchar*name, gboolean value)



static void set_keyfile_token(lua_State *L, gchar*name, GKeyFile* value)
static void set_keyfile_token(lua_State *L, const gchar*name, GKeyFile* value)
{
if (!value) {return;}
lua_getglobal(L, LUA_MODULE_NAME);
Expand All @@ -393,7 +393,7 @@ static void set_keyfile_token(lua_State *L, gchar*name, GKeyFile* value)



static void show_error(lua_State *L, gchar *script_file)
static void show_error(lua_State *L, const gchar *script_file)
{
gint line=-1;
gchar *fn = glspi_get_error_info(L, &line);
Expand All @@ -413,7 +413,7 @@ static void show_error(lua_State *L, gchar *script_file)



static gint glspi_init_module(lua_State *L, gchar *script_file, gint caller, GKeyFile*proj, gchar*script_dir)
static gint glspi_init_module(lua_State *L, const gchar *script_file, gint caller, GKeyFile*proj, const gchar*script_dir)
{
luaL_openlib(L, LUA_MODULE_NAME, glspi_timer_funcs, 0);
glspi_init_sci_funcs(L);
Expand Down Expand Up @@ -450,7 +450,7 @@ gint luaopen_libgeanylua(lua_State *L)


/* Load and run the script */
void glspi_run_script(gchar *script_file, gint caller, GKeyFile*proj, gchar *script_dir)
void glspi_run_script(const gchar *script_file, gint caller, GKeyFile*proj, const gchar *script_dir)
{
gint status;
lua_State *L = glspi_state_new();
Expand Down
9 changes: 5 additions & 4 deletions geanylua/glspi_sci.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ static gint glspi_copy(lua_State* L)
if (!lua_isstring(L,1)) {return FAIL_STRING_ARG(1);}
content=lua_tostring(L,1);
len=strlen(content);
if (len) { scintilla_send_message(doc->editor->sci,SCI_COPYTEXT,len,(gint)content); }
if (len) { scintilla_send_message(doc->editor->sci,SCI_COPYTEXT,len,(glong)content); }
push_number(L, len);
return 1;
default:
Expand Down Expand Up @@ -561,7 +561,8 @@ static void glspi_init_sci_cmd_hash(void)
sci_cmd_hash=g_hash_table_new(g_str_hash,g_str_equal);
for (i=0; sci_cmd_hash_entries[i].name; i++) {
g_hash_table_insert(
sci_cmd_hash,sci_cmd_hash_entries[i].name,&sci_cmd_hash_entries[i]);
sci_cmd_hash,
(gpointer) sci_cmd_hash_entries[i].name,&sci_cmd_hash_entries[i]);
}
}

Expand Down Expand Up @@ -596,7 +597,7 @@ static SciCmdHashEntry* lookup_cmd_id(gint cmd)



static gint glspi_fail_not_implemented(lua_State* L, const gchar*funcname, gchar*cmdname)
static gint glspi_fail_not_implemented(lua_State* L, const gchar*funcname, const gchar*cmdname)
{
lua_pushfstring(
L, _( "Error in module \"%s\" at function %s():\n"
Expand All @@ -607,7 +608,7 @@ static gint glspi_fail_not_implemented(lua_State* L, const gchar*funcname, gchar
}


static gint glspi_fail_arg_count(lua_State* L, const gchar*funcname, gchar*cmdname)
static gint glspi_fail_arg_count(lua_State* L, const gchar*funcname, const gchar*cmdname)
{
lua_pushfstring(
L, _( "Error in module \"%s\" at function %s():\n"
Expand Down
2 changes: 1 addition & 1 deletion geanylua/glspi_sci.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ typedef enum {


typedef struct _SciCmdHashEntry {
gchar *name;
const gchar *name;
GlspiType result;
gint msgid;
GlspiType wparam;
Expand Down
4 changes: 2 additions & 2 deletions geanylua/gsdlg_lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static gint adjust_argnum(lua_State *L, gint argnum) {


/* Pushes an error message onto Lua stack if script passes a wrong arg type */
static gint fail_arg_type(lua_State *L, const gchar *func, gint argnum, gchar *type)
static gint fail_arg_type(lua_State *L, const gchar *func, gint argnum, const gchar *type)
{
lua_pushfstring(L, _("Error in module \"%s\" at function %s():\n"
" expected type \"%s\" for argument #%d\n"),
Expand All @@ -103,7 +103,7 @@ static gint fail_arg_type(lua_State *L, const gchar *func, gint argnum, gchar *t

/*Pushes an error message onto Lua stack if table contains wrong element type*/
static gint gsdl_fail_elem_type(
lua_State *L, const gchar *func, gint argnum, gint idx, gchar *type)
lua_State *L, const gchar *func, gint argnum, gint idx, const gchar *type)
{
lua_pushfstring(L, _("Error in module \"%s\" at function %s():\n"
" invalid table in argument #%d:\n"
Expand Down