From 04e9f8b1650363c1296d9e3e7a7e6c75bfd0ea63 Mon Sep 17 00:00:00 2001 From: Paul M Date: Sun, 1 Nov 2020 21:27:47 -0600 Subject: [PATCH] Add files via upload Initial upload along with example plugin and some docs. --- The Offical KAKE PAD Macro Tutorial.doc | Bin 0 -> 29184 bytes kpad.pl | 375 ++++++++++++++++++++++++ normal.kpd | 3 + 3 files changed, 378 insertions(+) create mode 100644 The Offical KAKE PAD Macro Tutorial.doc create mode 100644 kpad.pl create mode 100644 normal.kpd diff --git a/The Offical KAKE PAD Macro Tutorial.doc b/The Offical KAKE PAD Macro Tutorial.doc new file mode 100644 index 0000000000000000000000000000000000000000..e8385295ae32354bbb94c2e5674b341a246d1f4b GIT binary patch literal 29184 zcmeI5e~cZ~b;s}i#>N|Cei*{942!`w?5=leehbg% zXX#^%xsYe&y*D*ArR?(n9`o=qlE52Zf7)CyxUAinH;?^CDbW}-OF;3vK55J+%<#>_ zHy_%3XtT|o^|P#fwdq-7%%h)4VArZy#qUc@O|6{HTj)8faF>19Eb}5LZhp@4=Elb> zBMn!kZNJf#WXu<<{xg&-&g%c#a%29E^uMR=jx>I9nK7;4`5v*tQeuQ@-h%#hG~C{8 z%p~a_(*6YExgnFs_m7%elBDPIoz=@?;cX5XzAVn#XLYjl&uF)r%-w1Gxv}umg=u|d z?dIZ@e40asr#Wva&sl#me8O`q4d>$fTuLwFBa4?pW4<~WzN~*QVlOMG_~zSZe&^nc zo=vUKn9S}DrEFWXk>&vU&%x1BI7pe=~8G&dO~eKbiezan`?u;;da3 zXLz%8)=qS8B2)eBA#R6{lZZ3@kb8ekeYOe_D=5dT3gz z#%zNxiK@AtXsez=t7&Pfo#f@exdd_vG)rKp>^XZ%CBNXi73b=$SMPB4Zr$$etu#jb z+D*INLKrwhjW`G??!F=P_K2)R#wp;^PIBh7M)5^8*xApIEA3-^IR1p(T2KZE3yQ^ z;|iRTHx2{Tikw|e&GU+m+EqL^bQ<-3m~3te{#wCvU?VO&p;z+4FlpdM&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i@4t&8d}m$IFfR z5u=xX&f~U)zz)PIE+*P=CU#!7yO2HXYD(B#!CIYTt~OhN9a#Ndp0*S3rlf#f20Rb3 z|A~2;u~MO%aU?TO37z~mm%xW3f%ow3INkRl!v&gG?);0lezB)~%p+eu%AC9QTQ6-S z?=A{7BvpPlpqAQAXf8MiXtFyDXaV&Kz-(*Y0OZhr4rugg=g!P)P9@gJSx3waY_=0K z#hbmvEIZ6i#JFJVqqUN$la`;|Ps|ly)`0b{K9`T`AvyNiTM~d^1OCXm( zE`eMExdd_vYc0hz2)@*J+=1cI+xd(y!QRt%WI#nGkpCYKsxW{a-!YSYu|qopnE(g11dk2 z_%uNKY3<`3;0&M#P`UQyX8~seIvZaHtOw2kRNhP62lN9QfQ`T=U^Afd{{}8dpOqHm zVQ~rQ4qjltyx74#yqFtE6G(9BVKui$G77Sx&SkPDV-DC~KHX>v^=%j0{~6^X@+Q;# z?c9Qjfg=seP3ts$@v#&#N9( zuz=fO4SPp2`_?6?vH0)F(3iwDZkI}581?@)DRgk7QdD&hQ@Y=U6_hMb%89wbrf+W+ z4(pCU{$~nZ+W(IC_56eJb20Sgx72rqg*lxmIaiM<{T8#09#&1=?BQ1F%`=sj_;f7Z zGohUPF0t7WP+A!Cknew(-title=> "kPad"); #Generates the main window + +$menubar = $main->Frame()->pack(-side => "top", -fill => "x"); #Notice I create the menu bar as +# a frame not a Tk::Menu menubar, this makes things easier + +#Below I define all the DialogBoxes,note they can be globaly used + +$about = $main->DialogBox(-title=>"About...",-buttons=>["OK"]); #Creates the about Dialog +$aabout = $about->add("Label",-text=>"kPad\n by Paul Malcher\nVersion 6 Release\n")->pack; #Adds a label to $about +#$kweabt = $main->DialogBox(-title=>"About kWebedit...",-buttons=>["OK"]); #Creates the About kWebedit Dialog +#$akweabt =$kweabt->add("Label",-text=>"kWebedit v.2.0\nby Paul Malcher\nBased on kWebedit v.1.0.3 by Chris Litwin ")->pack; #That's the about for kWebedit. +$help = $main->DialogBox(-title=>"Help Topics",-buttons=>["OK"]); #Creates Help Dialog +$ahelp = $help->add("Label",-text=>"Help topics for KPAD\nWell, this is a text/file editor mainly meant for scripting and programming use. +Like notepad but made for the programmer.")->pack; +$nsave = $main->DialogBox(-title=>"Warning File Has changed!",-buttons=>["Save","Exit"]); +$ansave = $nsave->add("Label",-text=>"The documents contents have changed since you opened.\nDo you wish to save?.")->pack; +$nimp = $main->DialogBox(-title=>"Non-implementation Error",-buttons=>["OK"]); +$animp = $nimp->add("Label",-text=>"This function is not yet implemented!")->pack; + +$fetch = $main->DialogBox(-title =>'HTML Source Fetch',-buttons=>["OK"]); +$afetch = $fetch->add("Label",-text=>'Fetch what:')->pack; +$bfetch = $fetch->add("Entry",-text=>'http://')->pack; + +$dummy = $main->DialogBox(-title=>'Dummy Box'); +$adummy = $dummy->add("Text")->pack; + +$ftapp = $main->DialogBox(-title =>'File Has Changed!',-buttons=>["Yes","No"]); +$aftapp = $ftapp->add("Label", -text=>"File contents have changed, save now?!")->pack; +$track = "init"; + +# Begin new Kpad 4.0 features +# Plugin/Macros or whatever you want to call them +# First we find and autoload plugin, yes we use grep, makes life good + +$pls = 0; +# Heck with lets do it all in one loop + +while(<*.kpd>){ +push(@plugins,$_); +open pin,"<$_"; +@gn = split "::" , ; +if(@gn[2] eq "auto"){ +@n[$pls] = "auto"; +}else{ +@n[$pls] = @gn[1]; +} +$pls++; +} +# determin the number of plugins, so we can size the list accordingly +$nop = scalar(@n); #notice @n does not get shortend, this is important later on +foreach(@n) { +if($_ eq "auto"){ +$nop--; # make sure auto plugins are not listed +} +} + +# Build the menu with list box +$plugin = $main->DialogBox(-title=>'Macro Execution Menu',-buttons=>["Close"]); +$bplugin = $plugin->add("Label",-text=>'Double Click To Execute Macro')->pack; +$aplugin = $plugin->Listbox("-width"=>40, "-height"=> $nop)->pack; +foreach(@n) { +if($_ eq "auto"){ +$arun = 0; +}else{ +$aplugin->insert('end', "$_"); +} +} +$aplugin->bind('' , \&eplugin); # Plugin name now can be different from the file name + +$filemenu = $menubar->Menubutton(-text => 'File', -underline => 0,-tearoff => 0)->pack(-side=>'left'); #This puts +#the file button on the frame used for the menu bar + +#Below are the commands for that button +#note How I included the subs into the command function + +$filemenu->command(-label => 'New',-command => sub{ +$text->delete('1.0','end'); +}); + +$filemenu->command(-label => 'Open',-command => sub{ +$text->delete('1.0','end'); +my $types = [ + ['Perl Scripts', '.pl'], + ['All Files', '*', ], + ]; + +$open = $main->getOpenFile(-filetypes=>$types); +#open FILE, "<$open"; #took weeks to get this right,its there so te whole file loads correctly +# and only 3 sec to comment out for the 5.0 release +$text->Load($open); +$text ->pack; +}); + +$filemenu->command(-label => 'Save',-command => sub{ +$data = $text->get('1.0','end'); #Saving for widget to file is a piece of cake +if($ar eq ""){ +$text->Save($open); +# Easy indeed +}else{ +$text->Save($ar); +} +}); + +$filemenu->command(-label => 'Save As',-command => sub{ +#my $types = [['All Files', '*', ],]; +my $types = [ +['Perl Scripts', '.pl' ], + ['All Files', '.*', ], + ]; +my $save = $main->getSaveFile(-filetypes=>$types); +$text->Save($save); +$open = $save; +}); + +$filemenu->separator; + +$filemenu->command(-label => 'Exit',-command => sub{ +tapp(); +}); + +$editmenu = $menubar->Menubutton(-text => 'Edit', -underline => 0,-tearoff => 0)->pack(-side=>'left'); + +$editmenu->command(-label => 'Undo',-command => sub{ +my ($w) = @_; +$text->undo; +}); + +$editmenu->command(-label => 'Redo',-command => sub{ +my ($w) = @_; +$text->redo; +}); + +$editmenu->separator; + +$editmenu->command(-label => 'Cut',-command => sub{ +my ($w) = @_; +$text->Column_Copy_or_Cut(1); +}); + +$editmenu->command(-label => 'Copy',-command => sub{ +my ($w) = @_; +$text->Column_Copy_or_Cut(0); +}); + +$editmenu->command(-label => 'Paste',-command => sub{ +$text->clipboardColumnPaste(); +}); + +$editmenu->separator; + +$editmenu->command(-label => 'Select All',-command => sub{ +$text->selectAll(); +}); + +$editmenu->command(-label => 'Unselect All',-command => sub{ +$text->unselectAll(); +}); + +$editmenu->separator; + +$editmenu->command(-label => 'Find',-command => sub{ +$text->findandreplacepopup(1); +}); + +$editmenu->command(-label => 'Find and Replace',-command => sub{ +$text->findandreplacepopup(0); +}); + +$viewmenu = $menubar->Menubutton(-text=>'View',-underline => 0,-tearoff => 0)->pack(-side=>'left'); +$vm = $viewmenu->cascade(-label => 'Wrap',-underline => 0,-tearoff => 0); +$vm->radiobutton(-label => "Word", -command => sub { $text->configure(-wrap => 'word'); } ); +$vm->radiobutton(-label => "Char",-command => sub { $text->configure(-wrap => 'char'); } ); +$vm->radiobutton(-label => "None",-command => sub { $text->configure(-wrap => 'none'); } ); + +$toolsmenu = $menubar->Menubutton(-text => 'Tools', -underline => 0,-tearoff => 0)->pack(-side=>'left'); + +$toolsmenu->command(-label => 'Goto Line',-command => sub{ +$text->GotoLineNumberPopUp(); +}); + +$toolsmenu->command(-label => 'Which Line?',-command => sub{ +$text->WhatLineNumberPopUp(); +}); + +$htmlmenu = $menubar->Menubutton(-text => 'HTML', -underline => 0,-tearoff => 0)->pack(-side=>'left'); + +$htmlmenu->command(-label => 'Fetch a web resource...',-command => sub{#$fdisc->Show; +$fetch->Show; +$htm = $bfetch->get; +$contents = get($htm); +open ttt, ">temp.dat"; +print ttt "$contents"; +close ttt; +open FILE, "delete('1.0','end'); +while (! eof FILE){ +$text->insert('end',FILE -> getline); +} +close FILE; +unlink(); +$text ->pack; +}); + +$pluginmenu = $menubar->Menubutton(-text => 'Macros', -underline => 0,-tearoff => 0)->pack(-side=>'left'); + +$pluginmenu->command(-label => 'Execute Macro',-command => sub{$plugin->Show;}); + +$aboutmenu = $menubar->Menubutton(-text => 'Help', -underline => 0,-tearoff => 0)->pack(-side=>'left'); + +$aboutmenu->command(-label => 'Help Topics...',-command => sub{$help->Show;}); + +$aboutmenu->command(-label => 'About KPAD...',-command => sub{$about->Show;}); + +#$aboutmenu->command(-label => 'About kWebedit...',-command => sub{$kweabt->Show;}); + +# Text widget and configs +$statbar = $main->Frame()->pack(-side => "bottom", -fill => "x"); +$statinfo = $statbar->Label(-text =>'Info: ')->pack(-side=>'left'); +$statln = $statbar->Label(-text =>'Line: 0')->pack(-side=>'left'); +$text = $main->Scrolled(TextUndo,-scrollbars=>'osoe',-background=>'white', -wrap => 'word')->pack(-fill=>'both',-expand=>1); #Scrolled Text + + +#widget that adapts to the size of the window +$main->protocol('WM_DELETE_WINDOW', \&tapp); +# This replaces $track +$text->bind('<>' => sub{ +$track = $text->get('1.0','end'); +my ($w)=$text; +my ($line,$col) = split(/\./,$w->index('insert')); +#$statln = $statbar->Label(-text =>"Line $line")->pack(-side=>'left'); +$statln->configure(-text =>"Line $line"); +}); + +if($ar ne ""){ +$text->Load($ar); +$text ->pack; +} + +sub eplugin { # Plugin executor, non-auto +$v = $aplugin->get('active'); +# Fix for plugin vs. filename fix +# @plugins @n +$fp = 0; +while(@n[$fp] ne $v){ # assume the names in @plugin match with @n +# which they will unless you screw with the way plugins are handled +$fp++; +} +$v = @plugins[$fp]; +# Hope it works +open pe, "<$basedir/$v"; # presto it does +# The same damn bug in Tk again, yes the one that took weeks to work around +# I got to do this the hard way +$adummy->delete('1.0','end'); +while (! eof pe){ +$adummy->insert('end', pe -> getline); +} +$tdata = $adummy->get('2.0','end'); # this is the only way to load an entire plugin into a var the right way +eval ( $tdata ); +if($@){ # Only way to to make so it can trap multiple errors without the app having a fatal error itself +$error = $@; +&merr($error); +} +} + +sub aeplugin { # Auto plugin executor +$apc = 0; +while(@n[$apc] ne ""){ +if(@n[$apc] eq "auto"){ +$v = @plugins[$apc]; +# Hope it works +open pe, "<$basedir/$v"; # presto it does +# The same damn bug in Tk again, yes the one that took weeks to work around +# I got to do this the hard way +$adummy->delete('1.0','end'); +while (! eof pe){ +$adummy->insert('end', pe -> getline); +} +$tdata = $adummy->get('2.0','end'); # this is the only way to load an entire plugin into a var the right way +eval ( $tdata ); +if($@){ # Only way to to make so it can trap multiple errors without the app having a fatal error itself +$error = $@; +&merr($error); +} +} +$apc++; +} +$arun = 1; +} + +sub merr { # merr, macro/plugins error +$merr = $main->DialogBox(-title =>'Macro Error',-buttons=>["OK"]); +$amerr = $merr->add("Label", -text=>"Error: $error")->pack; +$merr->Show; +undef $merr; +} + +if($arun eq "0"){ +&aeplugin(); +} + +sub tapp { # shutdown handler +if($track ne "init"){ +$result = $ftapp->Show; +if($result eq "No"){ +exit(0); +} +if($open){ +$text->Save($open); +$saved = 1; +} +if($save){ +$text->Save($save); +$saved = 1; +} +if($ar){ +$text->Save($ar); +$saved = 1; +}else{ +if($saved ne "1"){ +my $types = [ +['Perl Scripts', '.pl' ], + ['All Files', '.*', ], + ]; +my $save = $main->getSaveFile(-filetypes=>$types); +$text->Save($save); +} +} +} +exit(0); +} + +MainLoop; #The main processing loop \ No newline at end of file diff --git a/normal.kpd b/normal.kpd new file mode 100644 index 0000000..840a797 --- /dev/null +++ b/normal.kpd @@ -0,0 +1,3 @@ +::Normal:: # You got the line is parsed by splitting by the :: +$text->insert('end', "Hi"); # $text, if you look at KAKE PADs code it the text widget +