forked from ariez-xyz/LuaBox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainPage.xaml.cpp
62 lines (49 loc) · 1.44 KB
/
MainPage.xaml.cpp
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
//
// MainPage.xaml.cpp
// Implementation of the MainPage class.
//
#include "pch.h"
#include "MainPage.xaml.h"
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
using namespace LuaBox;
using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls::Primitives;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
LuaState luaState;
lua_State* L;
MainPage::MainPage()
{
InitializeComponent();
state.result = "fugg";
L = luaL_newstate();
luaL_openlibs(L);
}
void LuaBox::MainPage::Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
this->runREPL();
}
void LuaBox::MainPage::InputLine_KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e)
{
if (e->Key == Windows::System::VirtualKey::Enter)
this->runREPL();
}
void LuaBox::MainPage::runREPL() {
Platform::String^ input = InputLine->Text;
wchar_t const* wchars = input->Data();
char line[2560];
sprintf(line, "%ws", wchars);
int error;
doREPL(L, line);
ResultLabel->Text = luaState.result;
InputLine->Text = "";
}