sergei karhof | 9 Feb 10:53
Picon

Simple EditBox widget

Hi everyone,

I am looking for a simple EditBox (a.k.a. TextBox) widget within which
to edit plain text. Basically, a text window to use in a program. Not
much is required: cursor movements via arrows (left, right, up an
down) and, possibly, text selection via shift+arrows (like in
Windows).
Both a text-based solution (ncurses-like) and a GUI-based solution
would be fine.
My priority its simplicity of use at the programming stage.

Thanks

sergei

rahul sharma | 9 Feb 10:09
Picon
Gravatar

How to follow 80 Column format in Lua

Hi,

I am facing problems in following 80 columns format in lua. I tried to add "\\n" to break the line but its not working.
Usually we add \ and then \n to break the line into two parts, but in Lua, this standard doesn't work by default. Can you help me in getting some way using which I can do this?

logger:info("Case: (Flow_Entry=Nil and direction=SERVER_TO_CLIENT): \
Wrong packet received. Flow_entry not there for flow and packet received from \
server.")

The above written fxn is in lua, but it doesn't print the message in one line.

Regards
Rahul

Jay Carlson | 8 Feb 16:18

Unicode and UTF-8 the Lua way, mid-discussion (was Re: What do you miss most in Lua)

On Wed, Feb 8, 2012 at 4:16 AM, Miles Bader <miles <at> gnu.org> wrote:
> Jay Carlson <nop <at> nop.com> writes:
>>  But computers are already pervasive in Japan and the Republic of
>> Korea too, and the People's Republic of China is on its way--and the
>> CJK written languages are difficult to handle in unextended Lua.
>
> Wait... how are CJK "hard to handle in unextended Lua" ...?

>   >    for file in lfs.dir (os.getenv ("HOME").."/"..tanka_dir) do
>   >       author = string.match (file, "^(.*)[.]txt$")

Fails when the filesystem is not UTF-8. Won't affect you, because you
know this is not true, and this is a fairly safe assumption in your
environment.

>   >          for line in io.lines (tanka_dir.."/"..file) do
>   >             print ("   "..line)

Oh dear, who put that that SJIS fie in that directory?

Given how many of string.* operations are closed over the formal
language of valid UTF-8[1], it should not be surprising that a lot of
us are already using UTF-8 in small apps without a smidgen of magic.
This works because a) we're pretty fanatic about keeping *everything*
in UTF-8 and b) we know which string operations are not closed and
avoid them or arrange for other preconditions. The question then is
whether errors should be silent or loud, and when. It's part b that
really worries me, because I'm going to blow it at some point; I'm not
perfect and I still think in ASCII.

In that example (and nobody expects throwaway examples on mailing
lists to be comprehensive) you do not significantly destructure text
aside from splitting on newlines. I agree this is a good example of
"you don't do the complicated stuff much" but at some point this
begins to shift to "you don't do the complicated stuff much because
you restructure your problems to avoid non-ASCII/non-literal-match
manipulation". In my copious free time, I'd like to look through PiL's
string manipulation and see what does and doesn't work, and what works
with which fixups and assumptions. Uh, and maybe look at email not
related to this. :-)

I avoid programming in C because I find it an anxious experience. So
much of C programming failure ends in the form "...behavior is
undefined, and usually brings down the runtime in the near future. If
you're lucky." This is perhaps the strongest argument against C and
C++ as teaching languages: programming mistakes result in
unpredictable failure modes.

Lua does not have that failure mode, but propagation of encoding
errors can work out that way with increasing levels of "what the heck
happened?" I would rather not have Lua UTF-8 handling be the same way.

Manual localization of errors is the easiest, but the assert_utf8()
tool is missing. Is it a battery? Marketing and educational issues
aside, there seems to be a very efficient memoization implementation
available only in core, attaching the tristate { unknown, valid,
invalid } to the string itself; perhaps then wrap string.* in asserts
on the Lua side?[2] And stepping back from the specfifics of UTF-8, a
validity marker would be useful in EUC as well.

I hope it is apparent I am exploring what a minimal implementation
might be. There are all kinds of other doodads I contemplate
associated with strings because this is an instance of a general
problem I wish my programming languages would help me with. I'm trying
to focus on to the UTF-8 problem since it is most likely to be
generally seen as a problem. The "no changes needed" alternative is
also to say that ANSI C already has UTF-8 support, and as a result so
does Lua. I find this dissatisfying.

Jay

[1]: Why yes, if UTF-8 processing is how we do Unicode processing, and
we don't have the character property tables, we've reduced this to a
trivial case of the whole "strings have types; will your language help
you?" question. It's just a very simple language.

[2]: Patterns look very difficult to fix up on the Lua side though.

saito yutaka | 8 Feb 11:35
Picon
Gravatar

lua_getglobal function argument

Hello .
I am trying to read lua.c to want know how lua works.
And I want to ask about lua_getglobal function.

I find a this code .
  lua_getglobal(L, firstline ? "_PROMPT" : "_PROMPT2");

I know that this code means get a value PROMPT("> ") or PROMPT2(">> ") .
But why does it use underscore [ _ ] front of global names ?

Thanks.
Yutaka

http://saitolog.blogspot.com/

Adam Strzelecki | 7 Feb 23:23
Picon
Favicon
Gravatar

[LuaJIT] JIT bug when passing many function arguments?

During playing with different methods of multiplying 4x4 matrices in LuaJIT, I think I encountered
strange problem with JIT. I got mmul function that takes 2x16 = 32 arguments and returns 16 arguments -
multiplying two 4x4 matrices. See attached source code.

For testing I am multiplying A = A * B, where A is initially identity matrix) and B is PI/2 rotation matrix.
Every 4 iterations A should be back to identity, however when JIT kicks in then a11 mysteriously changes to
0 (ZERO) and remains 0, when I turn off JIT the result is just fine I got identity every 4 iterations.

$ luajit -joff luajit-mmul.lua 
done in 0.000395 seconds
1	0	0	0
0	1	0	0
0	0	1	0
0	0	0	1

$ luajit -jon luajit-mmul.lua 
done in 0.000219 seconds
0	0	0	0
0	1	0	0
0	0	1	0
0	0	0	1

Also there's something weird in this example, if I set iter=20000000 (20 million) then it needs below <0.5
second to complete whole loop, when GCC compiled example using SSE intrinsics needs over 2 seconds to do
the same and intrinsics free implementation needs over 2.2 seconds.

FYI I have also LuaJIT FFI struct based implementation using MT operators and it needs over 5 seconds to do 20
million iterations (probably due allocations discussed on other thread) but that implementation has no
such JIT problem.
--

-- 
Adam Strzelecki
Attachment (luajit-mmul.lua): application/octet-stream, 2079 bytes
Alex | 7 Feb 16:27
Picon
Gravatar

[LuaJIT] Bitwise Operations on 64-bit FFI Integers?

I need to xor a couple of 64 bit long integers, specifically to seed a
pseudo-random number generator with a combination of a couple of
values. However, the bit library does not appear to support cdata
objects. I could truncate the integer and convert it to a Lua number
then use the bit library on it, but I would rather have the full range
of a long for the seed. I could also implement the bitwise methods
inside of a C library and load it via FFI, but that means another DLL
I have to load and another C file to take care of, and probably a
performance hit too. So I ask, is there a way to preform bitwise
operations on 64 bit integers in native LuaJIT, and if so, how? Or if
not, is it planned and when can I expect it?

Thanks, Alex.

John Tan | 7 Feb 10:15
Picon
Gravatar

Bug using Lua 5.2.0 in VS2005

The following codes could perform the bug

//C Source Code
#include "lua.hpp"
int f1(lua_State *L) {
printf("%d\n", lua_tonumber(L, 1));
return 0;
}
int main (int argc, char* argv[]) {
lua_State *L = luaL_newstate();
luaL_openlibs(L);
lua_pushcfunction(L, f1);
lua_setglobal(L, "f1");
lua_getglobal(L, "f1");
lua_pushnumber(L, 1);
lua_call(L, 1, 0);
return 0;
}

After executing it,f1 will print 0 on the screen which indicates that it gets nil on stack when it is called.
I don't know if there is anybody else meeting the same problem...
Hope to know what has happened...THX
Marko Lindqvist | 7 Feb 08:57
Picon
Gravatar

lua-5.1 restorestack memory handling bug

Freeciv ( http://www.freeciv.org/ ) source tree includes copy of
lua-5.1. We got a bug report about build failure, and this might be a
real bug (at least on some platforms and compiler options)

I managed to reproduce myself building with clang, and I think this
error message describes problem best:

dependencies/lua-5.1/src/ldebug.c:620:21: error: cast
from 'char ' to 'TValue ' (aka 'struct lua_TValue *') increases required
alignment from 1 to 8 [-Werror,-Wcast-align]
StkId errfunc = restorestack(L, L->errfunc);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from
../../../../../src.patched/dependencies/lua-5.1/src/ldebug.c:21:
../../../../../src.patched/dependencies/lua-5.1/src/ldo.h:25:28: note:
instantiated from:
#define restorestack(L,n) ((TValue )((char )L->stack + (n)))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

So, "L->stack + (n)" is calculated as char (1 byte space reserved),
but then cast to pointer (8 bytes). In theory that pointer now has 7*8
of its bits in undefined state.

Original bug report: http://gna.org/bugs/?18481

 - ML

leaf corcoran | 7 Feb 00:27
Picon
Gravatar

Lua buildpack for Heroku

I created a buildpack for running Lua web apps on heroku
(http://www.heroku.com/), the cloud hosting service. It's free to run
simple apps.

The build pack is here: https://github.com/leafo/heroku-buildpack-lua

I also wrote a tutorial post on how to use it:
http://leafo.net/posts/lua_on_heroku.html

I haven't tried any database connectivity yet. Just tried running a
simple webapp powered by Xavante. I messed around running orbit as
well.

The whole process was pretty smooth, my method is describing
dependencies is pretty sloppy though.

Check it out and tell me what you think.

-- Leaf

Picon

Help learning Lua for Make-A-Wish Foundation

Can someone in the Massachusetts area help with the request below?
If so, please contact them directly. Thanks.
--lhf

----- Forwarded message -----

Hello,

My name is Dana and I am a Wish Program Coordinator for the Make-A-Wish
Foundation of Massachusetts and Rhode Island. I am currently working with
a teenage boy who has wished for have private tutoring lessons in the
computer language, Lua. I know you are based in Brazil but I was curious
if you had any suggestions where I could go about finding someone who knew
the language in the Massachusetts area. Any thoughts or suggestions would
be greatly appreciated!

Best,
Dana

Dana Butler
Wish Program Coordinator
Make-A-Wish Foundation of Massachusetts and Rhode Island
181 Park Avenue, Suite 12
West Springfield, MA 01089
413-733-9474 - phone
413-731-9658 - fax

----- End forwarded message -----

HyperHacker | 6 Feb 14:22
Picon

LuaGTK using pointers from C?

I have a C library that creates widgets in GTK. I want to be able to
return these widgets to Lua and add them to windows created using
LuaGTK. Is this possible? LuaGTK won't accept the widget pointers as
userdata.

--

-- 
Sent from my toaster.


Gmane