1#!/usr/bin/env perl 2 3# Example STFL Program 4# 5# Authors: 6# Davor Ocelic, docelic-stfl@spinlocksolutions.com 7# http://www.spinlocksolutions.com/ 8# 9# License: 10# GPL 11 12use warnings; 13use strict; 14use stfl; 15 16my $layout = <<EOT; 17table 18 list[list] 19 .expand:h 20 .border:lrtb 21 pos[listpos]:0 22 pos_name[listposname]:li0 23 listitem[li0] text[li0text]:"ListItem 0" 24 listitem[li1] text[li1text]:"ListItem 1" 25 listitem[li2] text[li2text]:"ListItem 2" 26 tablebr 27 label[label] 28 .expand:h 29 .border:lrtb 30 text[labeltext]: 31EOT 32 33my $stfl = stfl::create $layout; 34 35while (1) { 36 my $event = $stfl->run(0); 37 my $focus = $stfl->get_focus; 38 my $pos = $stfl->get('listpos'); 39 my $pos_name = $stfl->get('listposname'); 40 my $text = $stfl->get("${pos_name}text"); 41 42 $stfl->set('labeltext', "List is at position $pos, name $pos_name, text '$text'"); 43 44 next unless $event; 45 46 stfl::redraw if $event eq '^L'; 47 last if $event eq 'ESC'; 48} 49