[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
newlispfanclub.alh.net • View topic - Passing unconditioned text to a TK Text widget

Passing unconditioned text to a TK Text widget

Q&A's, tips, howto's

Passing unconditioned text to a TK Text widget

Postby CaveGuy » Mon Oct 21, 2002 8:23 pm

CaveGuy
 
Posts: 112
Joined: Sun Oct 13, 2002 3:00 pm
Location: Columbus Ohio

Postby Lutz » Tue Oct 22, 2002 7:07 pm

Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Postby CaveGuy » Tue Oct 22, 2002 7:49 pm

CaveGuy
 
Posts: 112
Joined: Sun Oct 13, 2002 3:00 pm
Location: Columbus Ohio

Postby Lutz » Tue Oct 22, 2002 9:48 pm

Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Postby CaveGuy » Tue Oct 22, 2002 10:25 pm

Thanks for the clues, they help ...
I think it may be a mental block, but I do still have a problem.

(set 'line "My address is [66.35.72.10]")
in the previous example results in
an invalid command 66.35.72.10 error :(

also what is with (string '(1 2 3)) => "\r\n(1 2 3)" it makes
creating "(setq a '(1 2 3))" real hard.
CaveGuy
 
Posts: 112
Joined: Sun Oct 13, 2002 3:00 pm
Location: Columbus Ohio

Postby Lutz » Tue Oct 22, 2002 10:54 pm

That is a bug, which will be fixed in the next release. But creating statements still works:

(set 's (string "(setq a '" '(1 2 3) ")")) => "(setq a '\r\n(1 2 3))"

(eval-string s) => (1 2 3)

Note, that 'string' after the bug fix will still embed line breaks, but trim the leading "\r\n". 'string' is doing pretty-print on the expressions passed to it.

>> (set 'line "My address is [66.35.72.10]")

let me think about it

Lutz
Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Postby Lutz » Tue Oct 22, 2002 11:06 pm

the following will work:

(set 'line "My address is \\[66.35.72.10\\]")
(tk "toplevel .txtdemo; pack [text .txtdemo.txt]")
(tk ".txtdemo.txt insert end [subst {" line "\\n}]")

again 'subts' is doing the trick. What you would have todo with your lines before passing them is a general replace of offending stuff:

(replace "[" line "\\[")
(replace "]" line "\\]")
(replace "$" line "\\$")

The same you would have to do for other characters confusing the issue. {,} braces go through fine but $ doesn't:


Lutz
Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Postby CaveGuy » Tue Oct 22, 2002 11:19 pm

(setq a '(1 2 3))
(setq fh (open "test.file" "w"))
(write-line (append "(set '" (string 'a) " '" (string a)))
(close fh)

an open readline of test.file retuens => "(setq 'a '"
a second read-line returns => "(1 2 3))"

myload has to doo a double read-line for each symbol.

Thanks for the fix, it about drove me nuts till I figured out what it was doing.
CaveGuy
 
Posts: 112
Joined: Sun Oct 13, 2002 3:00 pm
Location: Columbus Ohio

Postby Lutz » Wed Oct 23, 2002 12:51 am

instead of:

(append (string x) (string y) (string z))

you can do:

(string x y z)

'string' not only converts but also appends, if given more than one argument. Use 'append' if all arguments are already strings, in which instance it is faster than using string.

Also, just finished the fix for 'string' no pretty-printing at all will be done in 'string'. This will avoid any problem of unwanted/unforseen line-feeds.

Lutz
Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Postby CaveGuy » Wed Oct 23, 2002 1:39 am

Got two fresh stumbling block this time :)

(directory 'mydir) subber reaily needs to accept a file mask. Unless of course you already have a directory to list box widget example :)


Now that I can build and fill text widgets nicely, how do I "clear" one ?

My next task is to work out the callbacks, I am sure I will have questions in that area soon.
CaveGuy
 
Posts: 112
Joined: Sun Oct 13, 2002 3:00 pm
Location: Columbus Ohio

Postby Lutz » Wed Oct 23, 2002 5:01 pm

Try this for the directoty mask:

(filter (lambda (x) (ends-with x ".bat" nil)) (directory "c:/"))


This would print a list ofl files ending with ".bat" or ".BAT" in the root of C (note the legal forward slash, although on Windows). The 'nil' in the 'ends-with' function tells it to be case insensitive.

I also have good news, there are file dialogboxes standard in the normal Tcl/Tk, so it is builtin and accessible from newLISP-tk, they are called 'tk_getOpenFile' or 'tk_getSaveFile'. Just try the following in newLISP:

(tk "tk_getOpenFile")

select a file and hit return. The return val;ue of the function will be the path-file-string of the file selected. There are zillions of options for filetype masks, dialogbox title, etc. Look it up in some Tcl/Tk book. BTW I am pretty happy with the "'Reilly Tcl/Tk Pocket Reference", where I have it from.

There is also a 'tk_chooseColor', and a 'tk_dialog', which can be configured with buttons and a 'tk_messageBox'.

To delete a text window:

(tk ".mywin.mytxt delete 1.0 end")

Lutz
Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Postby CaveGuy » Wed Oct 23, 2002 8:21 pm

Thanks for the hints. I'l be back :)
CaveGuy
 
Posts: 112
Joined: Sun Oct 13, 2002 3:00 pm
Location: Columbus Ohio


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 1 guest

cron