summaryrefslogtreecommitdiffstats
path: root/src/modules/perlcore/KVIrc.xs
blob: 72ee5fd3c4cda5c3fe1a49351ca0fb42dc60e908 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
MODULE = KVIrc		PACKAGE = KVIrc
		
void echo(text,colorset = 0,windowid = 0)
	char * text
	int colorset
	char * windowid
	CODE:
		if(g_pCurrentKvsContext && text)
		{
			KviWindow * pWnd;
			if(windowid)
			{
				pWnd = g_pApp->findWindow(windowid);
				if(!pWnd)pWnd = g_pCurrentKvsContext->window();
			} else {
				pWnd = g_pCurrentKvsContext->window();
			}
			pWnd->outputNoFmt(colorset,TQString::fromUtf8(text));
		}
		
void say(text,windowid = 0)
	char * text
	char * windowid
	CODE:
		if(g_pCurrentKvsContext && text)
		{
			KviWindow * pWnd;
			if(windowid)
			{
				pWnd = g_pApp->findWindow(windowid);
				if(!pWnd)pWnd = g_pCurrentKvsContext->window();
			} else {
				pWnd = g_pCurrentKvsContext->window();
			}
			TQString tmp = TQString::fromUtf8(text);
			KviUserInput::parse(tmp,pWnd);
		}

void warning(text)
	char * text
	CODE:
		if((!g_bExecuteQuiet) && g_pCurrentKvsContext)
			g_pCurrentKvsContext->warning(text);

void internalWarning(text)
	char * text
	CODE:
		if(!g_bExecuteQuiet)
			g_lWarningList.append(TQString(text));


char * getLocal(varname)
	char * varname
	CODE:
		TQString tmp;
		KviStr hack;
		if(g_pCurrentKvsContext)
		{
			KviKvsVariant * pVar = g_pCurrentKvsContext->localVariables()->tqfind(varname);
			if(pVar)
			{
				pVar->asString(tmp);
				hack = tmp;
				RETVAL = hack.ptr();
			} else RETVAL = "";
		}
	OUTPUT:
		RETVAL

void setLocal(varname,value)
	char * varname
	char * value
	CODE:
		if(g_pCurrentKvsContext)
		{
			if(value && *value)
			{
				KviKvsVariant * pVar = g_pCurrentKvsContext->localVariables()->get(varname);
				pVar->setString(value);
			} else {
				g_pCurrentKvsContext->localVariables()->unset(varname);
			}
		}

char * getGlobal(varname)
	char * varname
	CODE:
		TQString tmp;
		KviStr hack;
		if(g_pCurrentKvsContext)
		{
			KviKvsVariant * pVar = g_pCurrentKvsContext->globalVariables()->tqfind(varname);
			if(pVar)
			{
				pVar->asString(tmp);
				hack = tmp;
				RETVAL = hack.ptr();
			} else RETVAL = "";
		}
	OUTPUT:
		RETVAL

void setGlobal(varname,value)
	char * varname
	char * value
	CODE:
		if(g_pCurrentKvsContext)
		{
			if(value && *value)
			{
				KviKvsVariant * pVar = g_pCurrentKvsContext->globalVariables()->get(varname);
				pVar->setString(value);
			} else {
				g_pCurrentKvsContext->localVariables()->unset(varname);
			}
		}


char * eval(code)
	char * code
	CODE:
		if(g_pCurrentKvsContext && code)
		{
			KviKvsVariant ret;
			if(KviKvsScript::run(TQString::fromUtf8(code),g_pCurrentKvsContext->window(),0,&ret))
			{
				TQString tmp;
				ret.asString(tmp);
				g_szLastReturnValue = tmp;
			} else {
				g_szLastReturnValue = "";
			}
			RETVAL = g_szLastReturnValue.ptr();
		} else {
			RETVAL = "";
		}
	OUTPUT:
		RETVAL