in reply to Why Findnext does not works?

In your find function:
my $result = $t->FindNext(-forwards, -exact, -nocase, "the"); # /^\
You have the argument '-forwards'. The possible options are documented as '-forward' and '-reverse'.

Note that Tk/Text.pm actually uses the following code:

eval { if ($direction eq '-forward') { $w->markSet('insert', 'sel.last'); $w->markSet('current', 'sel.last'); } else { $w->markSet('insert', 'sel.first'); $w->markSet('current', 'sel.first'); } };
So effectively anything not '-forward' is treated as '-reverse'.

Update - I should have looked further.

After the bit of code I copied above, FindNext calls the Text's search method with $direction as the first parameter. The search method is documented as using '-forwards' or '-backwards'. The C source at tkText.c agrees: the TextSearchCmd function does not mention '-reverse'.

The relevant C is:

arg = argv[i]; ... length = strlen(arg); ... c = arg[1]; if ((c == 'b') && (strncmp(argv[i], "-backwards", length) == 0)) { backwards = 1; ... } else if ((c == 'f') && (strncmp(argv[i], "-forwards", length) == 0)) + { backwards = 0;
Because of the use of strncmp with 'length', either '-forward' or '-forwards' will work correctly in the call to search.

Final answer: in FindNext use '-forward', '-backward', or '-backwards'. Do not use '-reverse' as documented, or '-forwards' like search.

When using search, '-forward', '-forwards', '-backward', or '-backwards' are all acceptable.


Update2: bug report forwarded to slaven@rezic.de. Tk::Text bug report

Update 2010-02-02: Patches in the Perl/Tk subversion repo as r13796.