From joerg at alea.gnuu.de Sat Jun 3 18:05:20 2006 From: joerg at alea.gnuu.de (=?iso-8859-1?Q?J=F6rg?= Sommer) Date: Tue Jan 30 08:52:10 2007 Subject: [slang-users] iterate the elements of an assoc_array in sorted order Message-ID: Hi, how is it possible to iterate through an Assoc_Array in sorted order. This is ugly: foreach ( assoc_get_keys(templates)[array_sort(assoc_get_keys(templates))] ) Bye, J?rg. -- Da w?rde ich auch lieber den Panzerf?hrerschein machen als den MCSE. Bringt mehr, d?rfte das gleiche kosten und macht sicher mehr Spa?. Jens Dittmar in de.comp.security From joerg at alea.gnuu.de Sat Jun 3 17:01:49 2006 From: joerg at alea.gnuu.de (=?iso-8859-1?Q?J=F6rg?= Sommer) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] foreach in one array dimension Message-ID: Hi, is it possible to iterate only in one array dimension? #v+ define g() { foreach( () ) message(string(typeof( () ))); } g([ ["foo"], ["foo"] ]); #v- This sould give "Array_Type Array_Type". It works, if the outer container is a list "{ [], [] }", but it looks more like a workaround. Bye, J?rg. -- Prof. in der Mathematikvorlesung zu einem vergessenen \phi in der Gleichung: "Klein-\phi macht auch Mist." From davis at space.mit.edu Sat Jun 3 18:45:47 2006 From: davis at space.mit.edu (John E. Davis) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] foreach in one array dimension In-Reply-To: References: Message-ID: <200606032245.k53MjlMN007941@aluche.mit.edu> J?rg Sommer wrote: >g([ ["foo"], ["foo"] ]); This does not define an array of two arrays. Rather, it defines an array of String_Type[2]. If you want an array of arrays, then you will have to explicitely create it: a = Array_Type[2]; a[0] = ["foo"]; a[1] = ["bar"]; --John From davis at space.mit.edu Sat Jun 3 18:57:16 2006 From: davis at space.mit.edu (John E. Davis) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] iterate the elements of an assoc_array in sorted order In-Reply-To: References: Message-ID: <200606032257.k53MvGG6007959@aluche.mit.edu> J?rg Sommer wrote: >how is it possible to iterate through an Assoc_Array in sorted order. >This is ugly: > >foreach ( assoc_get_keys(templates)[array_sort(assoc_get_keys(templates))] ) You will have to perform a sort as you have done. I would write the above as keys = assoc_get_keys (templates); foreach k (keys[array_sort(keys)]) {...} which I find somewhat more readable. --John From joerg at alea.gnuu.de Sat Jun 3 19:42:51 2006 From: joerg at alea.gnuu.de (=?iso-8859-1?Q?J=F6rg?= Sommer) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] iterate the elements of an assoc_array in sorted order References: <200606032257.k53MvGG6007959@aluche.mit.edu> Message-ID: Hallo John, "John E. Davis" wrote: > J?rg Sommer wrote: >>how is it possible to iterate through an Assoc_Array in sorted order. >>This is ugly: >> >>foreach ( assoc_get_keys(templates)[array_sort(assoc_get_keys(templates))] ) > > You will have to perform a sort as you have done. I would write the > above as > > keys = assoc_get_keys (templates); > foreach k (keys[array_sort(keys)]) {...} > > which I find somewhat more readable. Indeed. Why foreach do not output the elements of an assoc_array in sorted order? Isn't it implemented as a tree and do foreach not traverse the tree in-order? Bye, J?rg. -- Der Kl?gere gibt so lange nach bis er der Dumme ist. From davis at space.mit.edu Sat Jun 3 21:53:13 2006 From: davis at space.mit.edu (John E. Davis) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] iterate the elements of an assoc_array in sorted order In-Reply-To: References: <200606032257.k53MvGG6007959@aluche.mit.edu> Message-ID: <200606040153.k541rDS1003725@aluche.mit.edu> J?rg Sommer wrote: >Indeed. Why foreach do not output the elements of an assoc_array in >sorted order? Isn't it implemented as a tree and do foreach not traverse >the tree in-order? The current implementation uses a double-hashing scheme. The foreach-method simply walks the hash-table. It makes no attempt to sort the keys. --John From joerg at alea.gnuu.de Wed Jun 7 11:37:34 2006 From: joerg at alea.gnuu.de (=?iso-8859-1?Q?J=F6rg?= Sommer) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] Bug in try-finally Message-ID: Hi, can someone explain this behaviour? #v+ define g_message() { try { message("before return"); return "boogie message"; } finally { message("finally"); } message("before return dflt"); return "default message"; } define msg(arg) { message(arg); } define g_msg() { try { msg("before return"); return "boogie msg"; } finally { msg("finally"); } msg("before return dflt"); return "default message"; } message( g_message("xxx") ); message("--------------"); message( g_msg("xxx") ); #v- #v+ % slsh /tmp/test.sl before return finally boogie message -------------- before return finally before return dflt default message % slsh --version slsh version 0.7.5-0 S-Lang Library Version: 2.0.6 #v- Why g_msg() continues after the finally? Bye, J?rg. -- Gott hat den Menschen erschaffen, weil er vom Affen entt?uscht war. Danach hat er auf weitere Experimente verzichtet. (Mark Twain) From davis at space.mit.edu Wed Jun 7 12:08:43 2006 From: davis at space.mit.edu (John E. Davis) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] Bug in try-finally In-Reply-To: References: Message-ID: <200606071608.k57G8hNo014393@aluche.mit.edu> J?rg Sommer wrote: >can someone explain this behaviour? It is fixed in the latest development snapshot. You can grab it from the svn repository: http://jedsoft@opensvn.csie.org/jedsoft/slang/trunk Thanks, --John From jmrobert5 at mchsi.com Wed Jun 7 14:53:09 2006 From: jmrobert5 at mchsi.com (jmrobert5@mchsi.com) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] Anyone got a serial i/o module? Message-ID: <060720061853.9394.4487209500069FF2000024B2219792676103010CD2079C080C03BFCA9B9D0A0D019D0306@mchsi.com> Hi everyone, Does anyone have a general serial I/O module for Slang? I have a project where we (at first) want to write text out a serial port in a certain pattern. I figure what better way than a slang script? I didn't find one, so I figured I'd ask first. Otherwise look for a serial io module in a few days. Thanks, -- Joe Robertson Yamaha YZF600R Thundercat http://home.mchsi.com/~jmrobert5/ From davis at space.mit.edu Thu Jun 8 00:11:59 2006 From: davis at space.mit.edu (John E. Davis) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] Anyone got a serial i/o module? In-Reply-To: <060720061853.9394.4487209500069FF2000024B2219792676103010CD2079C080C03BFCA9B9D0A0D019D0306@mchsi.com> References: <060720061853.9394.4487209500069FF2000024B2219792676103010CD2079C080C03BFCA9B9D0A0D019D0306@mchsi.com> Message-ID: <200606080411.k584BxG1024927@aluche.mit.edu> jmrobert5@mchsi.com wrote: >Does anyone have a general serial I/O module for Slang? How general do you want it and for what OS? In the past, I have manipulated a modem attached to a serial port using the termios and select modules. For a while I was using the modem's caller ID ability to map incoming numbers to musical tunes allowing me to identify the caller by the tune that was played. >I have a project where we (at first) want to write text out a serial port in a >certain pattern. I figure what better way than a slang script? The termios module (for Unix/POSIX) should work for setting up the serial port. I noticed that it was lacking functions for manipulating the baud-rate so I added those tonight and checked the changes into the svn repository. The basic idea is that you would open the serial port using, e.g., fd = open ("/dev/ttyS0", O_RDWR|O_NONBLOCK); and then use the termios module to set it up. For the modem, I used: tty = tcgetattr (fd); termios_set_cflag (tty, CRTSCTS|CLOCAL|CREAD | termios_get_cflag (tty)); termios_set_lflag (tty, 0); termios_set_oflag (tty, 0); termios_set_iflag (tty, IGNBRK|ICRNL); () = tcsetattr (fd, TCSANOW, tty); Once you have it set up, use the read/write functions to interact with it. I can send you my caller-id script if you want more information. Thanks, --John From jmrobert5 at mchsi.com Thu Jun 8 09:10:26 2006 From: jmrobert5 at mchsi.com (jmrobert5@mchsi.com) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] Anyone got a serial i/o module? Message-ID: <060820061310.18288.448821C20003E3BD00004770219792474103010CD2079C080C03BFCA9B9D0A0D019D0306@mchsi.com> Hi, Linux primarily, maybe win32 if it will work there. What we want to do is send simulated GPS NMEA text messages out the serial port. No modem, just ascii on the line. So it looks like the termios is most of it. Thanks! -- Joe Robertson Yamaha YZF600R Thundercat http://home.mchsi.com/~jmrobert5/ > jmrobert5@mchsi.com wrote: > >Does anyone have a general serial I/O module for Slang? > > How general do you want it and for what OS? In the past, I have > manipulated a modem attached to a serial port using the termios and > select modules. For a while I was using the modem's caller ID ability > to map incoming numbers to musical tunes allowing me to identify the > caller by the tune that was played. > > >I have a project where we (at first) want to write text out a serial port in a > >certain pattern. I figure what better way than a slang script? > > The termios module (for Unix/POSIX) should work for setting up the > serial port. I noticed that it was lacking functions for manipulating > the baud-rate so I added those tonight and checked the changes into > the svn repository. > > The basic idea is that you would open the serial port using, e.g., > > fd = open ("/dev/ttyS0", O_RDWR|O_NONBLOCK); > > and then use the termios module to set it up. For the modem, I used: > > tty = tcgetattr (fd); > termios_set_cflag (tty, CRTSCTS|CLOCAL|CREAD | termios_get_cflag (tty)); > termios_set_lflag (tty, 0); > termios_set_oflag (tty, 0); > termios_set_iflag (tty, IGNBRK|ICRNL); > () = tcsetattr (fd, TCSANOW, tty); > > Once you have it set up, use the read/write functions to interact with > it. > > I can send you my caller-id script if you want more information. > > Thanks, > --John From ben at versaccounting.com Thu Jun 8 15:49:30 2006 From: ben at versaccounting.com (Ben Duncan) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] Ok, I guess I will ask this here .... Message-ID: <44887F4A.4040604@versaccounting.com> I am busily writing away on my multi-key,multi user, variable field, variable length embeded database engine for my SLAG project. Keep in mind, SLAGDB is going to be a string based file manager, so everthing is stored as a string. I am cutting/ripping/borrowing code form many different FOSS projects. Now , one of the things that is puzzling me, is the usage & management of variable length keys in a NODE. I know that you have a heap size that is pretty fixed to use inside of a NODE, but how does one go about easily working with the strings and using them as a key in such an environment ? OR maybe, I should just go with a fixed array size of say 30-60 bytes for each key value (not the NODE pointer stuff) and be done with it since NODES are just roadmaps .... Any and ALL HELP would be GREATLY appreciated ... Thanks ... -- Ben Duncan - Business Network Solutions, Inc. 336 Elton Road Jackson MS, 39212 "Never attribute to malice, that which can be adequately explained by stupidity" - Hanlon's Razor From joerg at alea.gnuu.de Sat Jun 10 10:32:07 2006 From: joerg at alea.gnuu.de (=?iso-8859-1?Q?J=F6rg?= Sommer) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] Optimizer Message-ID: Hi, does SLang have an optimizer? I often write statements like do_check(); cleanup(); if ( () ) stkcheck reports in these cases many false positives which makes it difficult to find real stack zombies. Can SLang optimze variable tmp = do_check(); cleanup(); if (tmp) to the code above? Bye, J?rg. -- Erfahrung hei?t gar nichts. Man kann seine Sache auch 35 Jahre schlecht machen. (Kurt Tucholsky) From joerg at alea.gnuu.de Sat Jun 10 11:20:14 2006 From: joerg at alea.gnuu.de (=?iso-8859-1?Q?J=F6rg?= Sommer) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] Enhancements Message-ID: Hi, firstly this: --- slsh/lib/require.sl (Revision 27) +++ slsh/lib/require.sl (Arbeitskopie) @@ -74,8 +74,8 @@ %#v+ % require ("histogram"); % require ("histogram", "foo"); -% require ("histogram,"foo","/home/bob/hist.sl"); -% require ("histogram,,"/home/bob/hist.sl"); +% require ("histogram", "foo", "/home/bob/hist.sl"); +% require ("histogram", , "/home/bob/hist.sl"); %#v- %\notes % "feature" is an abstract quantity that is undefined here. and secondly the page http://www.s-lang.org/download.html misses a link to the SVN repository like given at http://www.jedsoft.org/slang/download.html Bye, J?rg. -- "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." (Rich Cook) From joerg at alea.gnuu.de Sat Jun 10 14:33:52 2006 From: joerg at alea.gnuu.de (=?iso-8859-1?Q?J=F6rg?= Sommer) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] BTS for slang and jed? Message-ID: Hi John, do you have a BTS for slang and jed? Bye, J?rg. -- Wer einen Traum verwirklichen will, muss erst aufwachen. From joerg at alea.gnuu.de Sat Jun 10 16:37:45 2006 From: joerg at alea.gnuu.de (=?iso-8859-1?Q?J=F6rg?= Sommer) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] try does not run require Message-ID: Hi, what goes wrong here: #v+ % cat /tmp/test.sl try { require("stkcheck"); enable_stack_check(); } catch OpenError: {} % stkcheck not in path % slsh /tmp/test.sl enable_stack_check is undefined /tmp/test.sl:4::Undefined Name zsh: exit 38 slsh /tmp/test.sl % cat /tmp/test.sl % try { require("stkcheck"); enable_stack_check(); } % catch OpenError: {} % stkcheck not in path % slsh /tmp/test.sl % #v- Bye, J?rg. -- Du kannst einem Schwein einen goldenen Ring durch die Nase ziehen, deswegen bleibt es trozdem ein Schwein! From davis at space.mit.edu Sat Jun 10 23:32:35 2006 From: davis at space.mit.edu (John E. Davis) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] BTS for slang and jed? In-Reply-To: References: Message-ID: <200606110332.k5B3WZ9h006898@aluche.mit.edu> J??rg Sommer wrote: >do you have a BTS for slang and jed? Nothing formal. Just post problems to the appropriate list. Thanks, --John From davis at space.mit.edu Sat Jun 10 23:36:24 2006 From: davis at space.mit.edu (John E. Davis) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] Enhancements In-Reply-To: References: Message-ID: <200606110336.k5B3aOo1006915@aluche.mit.edu> J??rg Sommer wrote: >--- slsh/lib/require.sl (Revision 27) >+++ slsh/lib/require.sl (Arbeitskopie) Thanks. >and secondly the page http://www.s-lang.org/download.html misses a link >to the SVN repository like given at http://www.jedsoft.org/slang/download.html I have no control over s-lang.org, which mirrors jedsoft.org/slang/. Since the mirror is a bit flakey I no longer reference it. --John From davis at space.mit.edu Sat Jun 10 23:40:09 2006 From: davis at space.mit.edu (John E. Davis) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] Optimizer In-Reply-To: References: Message-ID: <200606110340.k5B3e9pn006950@aluche.mit.edu> J??rg Sommer wrote: >do_check(); >cleanup(); >if ( () ) > >stkcheck reports in these cases many false positives which makes it >difficult to find real stack zombies. Can SLang optimze > >variable tmp = do_check(); >cleanup(); >if (tmp) > >to the code above? In general, no. For example, slang has no way of knowing what if (()) is refering to: a value left by do_check, or one left by cleanup. I think that you will be better served in the long run by using the latter form. Also I believe that tic/toc will show you that very little is gained by the former. --John From davis at space.mit.edu Sat Jun 10 23:45:42 2006 From: davis at space.mit.edu (John E. Davis) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] try does not run require In-Reply-To: References: Message-ID: <200606110345.k5B3jgiP006972@aluche.mit.edu> J??rg Sommer wrote: >#v+ >% cat /tmp/test.sl >try >{ > require("stkcheck"); > enable_stack_check(); >} >catch OpenError: {} % stkcheck not in path This fails because slang makes no attempt to execute the code in the statement until the statement is complete. As a result, enable_stack_check is referenced before it has been defined. --John From joerg at alea.gnuu.de Sun Jun 11 12:54:48 2006 From: joerg at alea.gnuu.de (=?iso-8859-1?Q?J=F6rg?= Sommer) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] Optimizer References: <200606110340.k5B3e9pn006950@aluche.mit.edu> Message-ID: Hallo John, "John E. Davis" wrote: > J??rg Sommer wrote: >>do_check(); >>cleanup(); >>if ( () ) >> >>stkcheck reports in these cases many false positives which makes it >>difficult to find real stack zombies. Can SLang optimze >> >>variable tmp = do_check(); >>cleanup(); >>if (tmp) >> >>to the code above? > > In general, no. For example, slang has no way of knowing what if (()) > is refering to: a value left by do_check, or one left by cleanup. No. I thought of a transformation that makes the above form from the below. But your are right. If the cleanup() would leave something on the stack the above would fail. Bye, J?rg. -- Es liegt in der Natur des Menschen, vern?nftig zu denken und unlogisch zu handeln! Das Gesagte ist nicht das Gemeinte und das Geh?rte nicht das Verstandene! From joerg at alea.gnuu.de Sun Jun 11 13:07:48 2006 From: joerg at alea.gnuu.de (=?iso-8859-1?Q?J=F6rg?= Sommer) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] try does not run require References: <200606110345.k5B3jgiP006972@aluche.mit.edu> Message-ID: Hallo John, "John E. Davis" wrote: > J??rg Sommer wrote: >>#v+ >>% cat /tmp/test.sl >>try >>{ >> require("stkcheck"); >> enable_stack_check(); >>} >>catch OpenError: {} % stkcheck not in path > > This fails because slang makes no attempt to execute the code in the > statement until the statement is complete. As a result, > enable_stack_check is referenced before it has been defined. Interessting. Really interesting. Everyday something new. I ever thought SLang does a just in time resolving of the symbols. Have you ever written a language specification for SLang? Something with a grammar and a definition of the scope of variables? I can't construct an example, but I have seen code like this that failed, because a variable of the same name is defined. #v+ do { variable foo = 2; message("bla"); } while (0); variable foo = 3; #v- J?rg. -- Objektivit?t ist die Wahnvorstellung, Beobachtungen k?nnten ohne Beobachter gemacht werden - Heinz v. Foerster From davis at space.mit.edu Sun Jun 11 15:08:54 2006 From: davis at space.mit.edu (John E. Davis) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] try does not run require In-Reply-To: References: <200606110345.k5B3jgiP006972@aluche.mit.edu> Message-ID: <200606111908.k5BJ8scV020190@aluche.mit.edu> J?rg Sommer wrote: >Have you ever written a language specification for SLang? Something with >a grammar and a definition of the scope of variables? I can't construct slang/doc/grammar.txt specifies the grammar, although it may be somewhat incomplete. Variables are either global, local to a namespace or file, or local to a function. I have not added, and probably will not add block-local variables. >an example, but I have seen code like this that failed, because a >variable of the same name is defined. > >#v+ >do >{ > variable foo = 2; > message("bla"); >} >while (0); > >variable foo = 3; Right-- as stated above the variable in the do-while loop shares the same scope as the latter declaration. Someday I _may_ add block-local variables, but probably not because I have seen them abused too much in C to the point that some code is no longer easily maintainable. Some C programmers may be tempted to write variable i; variable j = 0; for (i = 0; i < n; i++) { variable j; for (j = 0; j < M; j++) ... } and would be suprised to find that j is not 0 at the end of this code fragment. For this reason, slang flags the duplicate declaration of j as an error. But it only generates this error when the code occurs in a function. It does not do so for global variables, so that code such as if (0 == is_defined ("Some_Variable")) variable Some_Variable = Some_Default_Value; may be used in a file to permit customization by a user. You can think of this as something akin to jed's custom_variable function. --John From joerg at alea.gnuu.de Mon Jun 12 09:14:53 2006 From: joerg at alea.gnuu.de (=?iso-8859-1?Q?J=F6rg?= Sommer) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] try does not run require References: <200606110345.k5B3jgiP006972@aluche.mit.edu> <200606111908.k5BJ8scV020190@aluche.mit.edu> Message-ID: Hallo John, "John E. Davis" wrote: > variable i; > variable j = 0; > for (i = 0; i < n; i++) > { > variable j; > for (j = 0; j < M; j++) ... > } ACK. This is ugly. But if you specify that only global variables can be overridden, because they are still accassable through Global->, than this could not happen. > and would be suprised to find that j is not 0 at the end of this code > fragment. For this reason, slang flags the duplicate declaration of j > as an error. Right, because in your example a variable within the same namespace is redefined in an inner scope. But an error in this example: if (...) { variable i; ... } ... while (...) { if (...) { variable i; } } is not really intuitive. > But it only generates this error when the code occurs in a function. > It does not do so for global variables, so that code such as Which is IMO not really consistent. Have a nice day, J?rg. -- Roesen's Law (http://www.bruhaha.de/laws.html): Sobald ein Troll, DAU oder Elch im Lauf eines Threads auf heftige Kritik st??t, argumentiert er mit der Arroganz des Kritikers. Dies kann auch vorsorglich erfolgen. From leslie.polzer at gmx.net Tue Jun 27 12:12:02 2006 From: leslie.polzer at gmx.net (leslie.polzer@gmx.net) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] Keyboard modifiers Message-ID: <20060627161202.GA14138@wintermute> Good day, I would like to get the state of keyboard modifiers with the SLang C library, to discern between TAB and Shift+TAB. Is this possible? If yes, how? Thanks, Leslie -- gpg --keyserver pgp.mit.edu --recv-keys 0x52D70289 http://nic-nac-project.de/~skypher/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 191 bytes Desc: not available Url : http://mailman.jtan.com/pipermail/slang-users-l/attachments/20060627/7eda23f8/attachment.bin From davis at space.mit.edu Tue Jun 27 22:58:10 2006 From: davis at space.mit.edu (John E. Davis) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] Keyboard modifiers In-Reply-To: <20060627161202.GA14138@wintermute> References: <20060627161202.GA14138@wintermute> Message-ID: <200606280258.k5S2wAUO031315@aluche.mit.edu> leslie.polzer@gmx.net wrote: > I would like to get the state of keyboard modifiers with the SLang C >library, to discern between TAB and Shift+TAB. Under windows, such support could be added because the win32 API provides that information. Under other systems the answer depends upon the terminal and its ability to provide slang a unique key-sequence for Shift-TAB. I see that in the version of rxvt that I am using, Shift-TAB generates the 3 character sequence "ESC [ Z". So, I could exploit that in the slang apps that I use by binding the key-sequence "\e[Z" to some function. --John From leslie.polzer at gmx.net Wed Jun 28 05:33:28 2006 From: leslie.polzer at gmx.net (leslie.polzer@gmx.net) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] Keyboard modifiers In-Reply-To: <200606280258.k5S2wAUO031315@aluche.mit.edu> References: <20060627161202.GA14138@wintermute> <200606280258.k5S2wAUO031315@aluche.mit.edu> Message-ID: <20060628093327.GA8108@wintermute> On Tue, Jun 27, 2006 at 10:58:10PM -0400, John E. Davis wrote: > leslie.polzer@gmx.net wrote: > > > I would like to get the state of keyboard modifiers with the SLang > >C library, to discern between TAB and Shift+TAB. > > Under windows, such support could be added because the win32 API > provides that information. Under other systems the answer depends upon > the terminal and its ability to provide slang a unique key-sequence > for Shift-TAB. I see that in the version of rxvt that I am using, > Shift-TAB generates the 3 character sequence "ESC [ Z". So, I could > exploit that in the slang apps that I use by binding the key-sequence > "\e[Z" to some function. Shift+TAB returns the same value as TAB with the terminals I have tested. Is there any way to change this behaviour, apart from switching terminals? As a side note, Shift+TAB is working perfectly with some Curses application I tested. Any guess on how they'd do that? Leslie -- gpg --keyserver pgp.mit.edu --recv-keys 0x52D70289 http://nic-nac-project.de/~skypher/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 191 bytes Desc: not available Url : http://mailman.jtan.com/pipermail/slang-users-l/attachments/20060628/ab84d764/attachment.bin From leslie.polzer at gmx.net Wed Jun 28 06:35:48 2006 From: leslie.polzer at gmx.net (leslie.polzer@gmx.net) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] Refresh problem Message-ID: <20060628103548.GA10981@wintermute> Hello again, I noticed that, in my applicatoin, Slang refreshes the whole screen instead of only the one character that was changed. In 80x25 this is not visible, but at 115x47 (happens to be the maximized terminal window size in my environment) one can see the cursor sweeping across the whole screen, causing a lot of flickering. What can I do to avoid the full screen update? Leslie -- gpg --keyserver pgp.mit.edu --recv-keys 0x52D70289 http://nic-nac-project.de/~skypher/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 191 bytes Desc: not available Url : http://mailman.jtan.com/pipermail/slang-users-l/attachments/20060628/138234fc/attachment.bin From davis at space.mit.edu Wed Jun 28 11:47:25 2006 From: davis at space.mit.edu (John E. Davis) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] Refresh problem In-Reply-To: <20060628103548.GA10981@wintermute> References: <20060628103548.GA10981@wintermute> Message-ID: <200606281547.k5SFlPxj009072@aluche.mit.edu> leslie.polzer@gmx.net wrote: > I noticed that, in my applicatoin, Slang refreshes the whole screen >instead of only the one character that was changed. In 80x25 this is >not visible, but at 115x47 (happens to be the maximized terminal window >size in my environment) one can see the cursor sweeping across the >whole screen, causing a lot of flickering. > > What can I do to avoid the full screen update? The screen update is smart and should update only that part of the display that has changed. Are you invalidating the lines on the screen using, e.g., SLsmg_touch_lines or SLsmg_touch_screen? Thanks, --John From leslie.polzer at gmx.net Wed Jun 28 13:57:55 2006 From: leslie.polzer at gmx.net (leslie.polzer@gmx.net) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] Refresh problem In-Reply-To: <200606281547.k5SFlPxj009072@aluche.mit.edu> References: <20060628103548.GA10981@wintermute> <200606281547.k5SFlPxj009072@aluche.mit.edu> Message-ID: <20060628175755.GA21256@wintermute> On Wed, Jun 28, 2006 at 11:47:25AM -0400, John E. Davis wrote: > The screen update is smart and should update only that part of the > display that has changed. Are you invalidating the lines on the screen > using, e.g., SLsmg_touch_lines or SLsmg_touch_screen? No, nothing like that. The relevant code snippet is very simple: --- SLtt_set_color(200, NULL, "white", "cyan"); SLsmg_set_color(200); SLsmg_gotorc(1, 1); SLsmg_write_nstring(NULL, 10); SLsmg_gotorc(1, 1); SLsmg_printf("%s", "some string"); SLsmg_refresh(); --- Leslie -- gpg --keyserver pgp.mit.edu --recv-keys 0x52D70289 http://nic-nac-project.de/~skypher/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 191 bytes Desc: not available Url : http://mailman.jtan.com/pipermail/slang-users-l/attachments/20060628/c515e64b/attachment.bin From davis at space.mit.edu Thu Jun 29 00:16:28 2006 From: davis at space.mit.edu (John E. Davis) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] Refresh problem Message-ID: <200606290416.k5T4GSUc019991@aluche.mit.edu> On Wed, 28 Jun 2006 19:57:55 +0200, leslie.polzer@gmx.net said: >No, nothing like that. The relevant code snippet is very simple: > >--- > SLtt_set_color(200, NULL, "white", "cyan"); > > SLsmg_set_color(200); > > SLsmg_gotorc(1, 1); > SLsmg_write_nstring(NULL, 10); > > SLsmg_gotorc(1, 1); > SLsmg_printf("%s", "some string"); > > SLsmg_refresh(); The SLtt_set_color function is a "setup" type of function that should not be called everytime you want to update the screen. As you know, it is a function that associates a foreground/background color with a color object (an integer--- 200 in this case). Note that it is part of the lower-level SLtt interface--- not the higher-level SLsmg interface. When you call SLtt_set_color, it informs the SLsmg interface that color object 200 has been changed causing SLsmg to invalidate the display. This is the effect that you are seeing. I may change the code in SLtt_set_color to do nothing if the specified color object already has the requested attributes. However, I encourage you to move the call to SLtt_set_color to some sort of initialization function that you call once. For example, in main use: int main (...) { /* Setup color objects */ SLtt_set_color (200, NULL, "white", "cyan"); . . main_loop (); return 0; } void main_loop (void) { while (1) { . . draw_screen (); SLsmg_refresh (); . . } } --John From davis at space.mit.edu Thu Jun 29 00:26:19 2006 From: davis at space.mit.edu (John E. Davis) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] Keyboard modifiers Message-ID: <200606290426.k5T4QJKT020048@aluche.mit.edu> On Wed, 28 Jun 2006 11:33:28 +0200, leslie.polzer@gmx.net said: >Shift+TAB returns the same value as TAB with the terminals I have tested. > Is there any way to change this behaviour, apart from switching >terminals? It depends upon the terminal. If using xterm, try playing with the "translations" resource. > As a side note, Shift+TAB is working perfectly with some Curses >application I tested. Any guess on how they'd do that? It depends upon the terminal and OS. If using the linux console, an ioctl exists that gives the *current* shift state. However, that is not very robust since it gives the *current* shift state and not the shift state at the time when the key that is currently being processed was pressed. --John From leslie.polzer at gmx.net Thu Jun 29 03:17:06 2006 From: leslie.polzer at gmx.net (leslie.polzer@gmx.net) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] Refresh problem In-Reply-To: <200606290416.k5T4GSUc019991@aluche.mit.edu> References: <200606290416.k5T4GSUc019991@aluche.mit.edu> Message-ID: <20060629071706.GA19763@wintermute> On Thu, Jun 29, 2006 at 12:16:28AM -0400, John E. Davis wrote: > The SLtt_set_color function is a "setup" type of function that > should not be called everytime you want to update the screen. You are right, of course. The line there will go away in production state anyway. Maybe put up a note in the docs about it? Thanks a lot! Leslie -- gpg --keyserver pgp.mit.edu --recv-keys 0x52D70289 http://nic-nac-project.de/~skypher/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://mailman.jtan.com/pipermail/slang-users-l/attachments/20060629/efeac59a/attachment.bin From leslie.polzer at gmx.net Thu Jun 29 16:03:05 2006 From: leslie.polzer at gmx.net (leslie.polzer@gmx.net) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] Keyboard modifiers In-Reply-To: <200606290426.k5T4QJKT020048@aluche.mit.edu> References: <200606290426.k5T4QJKT020048@aluche.mit.edu> Message-ID: <20060629200304.GA28442@wintermute> On Thu, Jun 29, 2006 at 12:26:19AM -0400, John E. Davis wrote: > It depends upon the terminal and OS. If using the linux console, an > ioctl exists that gives the *current* shift state. However, that is > not very robust since it gives the *current* shift state and not > the shift state at the time when the key that is currently being > processed was pressed. After gathering up on the mess of Linux keyboard stuff via various documents and the Midnight Commander source, I found there is no other way than using the ioctl for Linux VTs and XQueryPointer for X. Thanks for the info, John! Leslie -- gpg --keyserver pgp.mit.edu --recv-keys 0x52D70289 http://nic-nac-project.de/~skypher/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://mailman.jtan.com/pipermail/slang-users-l/attachments/20060629/9510119d/attachment.bin From veronatif at free.fr Fri Jun 30 11:39:48 2006 From: veronatif at free.fr (Alain Bench) Date: Tue Jan 30 08:52:11 2007 Subject: [slang-users] Keyboard modifiers In-Reply-To: <20060628093327.GA8108@wintermute> References: <20060627161202.GA14138@wintermute> <200606280258.k5S2wAUO031315@aluche.mit.edu> <20060628093327.GA8108@wintermute> Message-ID: <20060630153948.GA22177@free.fr> Hello Leslie, On Wednesday, June 28, 2006 at 11:33:28 +0200, Leslie Polzer wrote: > Shift+TAB returns the same value as TAB with the terminals I have > tested. Is there any way to change this behaviour, apart from > switching terminals? For the Linux console, the usual way to add the key support is by loading an additional keymap at startup: | # loadkeys /etc/kbd/backtab.map | # | Shift keycode 15 = F100 # Shift-Tab (or BackTab) | string F100 = "\033[Z" It's so common that it's even already accounted in the official terminfo database linux entries: They declare "kcbt=\E[Z". Ready for binding thru the "" symbolic name in Slrn, Mutt, USW... Bye! Alain. -- When you want to reply to a mailing list, please avoid doing so from a digest. This often builds incorrect references and breaks threads.