1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
|
# FvwmScript File Editor with Help for Fvwm-Crystal
# Copyright Dominique Michel <dominique_libre@users.sourceforge.net> 2014
# Released under the GNU GPL license v3 or later
# Usage: SetEnv FileEditWithHelp <file_name>
# Include scripts/FileEditors/<file_name>-Help
# Script scripts/FileEditors/FileEditWithHelp
#
# or simpler: LaunchFileWithHelp <file_name>
#
# where <file_name> is the name of the preeference file (must be in $FVWM_USERDIR/preferences)
# A help file with name <file_name-help> must exist in the same direectory than this script.
# The environmental variable is unset whn quiting the script.
# $FileEditWithHelp = <file_name>
# Header ̣{{{1
UseGettext {$FVWM_USERDIR/locale;fvwm-crystal-script:$FVWM_SYSTEMDIR/locale;fvwm-crystal-script:+}
WindowLocaleTitle {FVWM-Crystal File Editor}
WindowSize 800 400
#WindowPosition 300 300
Colorset 1
# Dont change it or the text titles will be shorted:
Font "xft:$[panel_font]:pixelsize:$[panel_font_size]:style:$[panel_font_style]"
# Initialisation {{{1
Init
Begin
Set $FDIR = (GetOutput {echo "$FVWM_USERDIR"} 1 -1)
Set $PDIR = $FDIR {/preferences/}
# Load file
Set $mfile = $PDIR {$FileEditWithHelp}
Set $cmd = {cat }$mfile{ | tr '\n' '|'}
ChangeTitle 1 (GetOutput $cmd 1 -1)
Set $mediad = (GetTitle 1)
Set $cmd = {echo }$mfile
ChangeTitle 2 (GetOutput $cmd 1 -1)
End
# Periodic Tasks {{{1
PeriodicTasks
Begin
# use a timer for flickering {{{2
If (RemainderOfDiv (GetTime) 1) == 0 Then
Begin
# faster if we do nothing here
Do Nop
End
End
# Quit Function {{{1
QuitFunc
Begin
Do {UnsetEnv FileEditWithHelp}
# Do {Echo The font: }$SetFont{ is xft:}$FontName{:pixelsize=}$Size{:}$Style
End
# Main {{{1
Widget 1
Property
Flags NoReliefString
Position 130 45
Size 480 315
Type List
# Font "xft:$[panel_font]:size=10:$[panel_font_style]"
Title { }
Main
Case message of
SingleClic :
Begin
Set $mediad = (GetTitle 1)
Set $mindex = (GetValue 1)
Set $cmd = {exec echo "}$mediad{"|cut -d '|' -f }$mindex
Set $Mstring = (GetOutput $cmd 1 -1)
Set $oldMstring = $Mstring
HideWidget 14
ChangeTitle 14 $Mstring
ShowWidget 14
End
End
# Label
Widget 2
Property
Flags NoReliefString Center
Position 130 5
Size 465 35
Type ItemDraw
Title { }
Main
Case message of
SingleClic :
Begin
Do Nop
End
End
# Label
Widget 10
Property
Flags NoReliefString Center
Position 5 5
Size 120 35
Type ItemDraw
LocaleTitle {File}
Main
Case message of
SingleClic :
Begin
Do Nop
End
End
# Launch the Help
Widget 110
Property
Flags NoReliefString
Position 5 45
Size 120 35
Type PushButton
LocaleTitle {Help}
Main
Case message of
SingleClic :
Begin
Set $cmd = {echo $FileEditWithHelp}
Set $HelpFile = (GetOutput $cmd 1 -1)
Set $cmd = {Module FvwmForm }$HelpFile{-Dialog}
Do $cmd
End
End
# Add line
Widget 12
Property
Flags NoReliefString
Position 625 320
Size 170 35
Type PushButton
LocaleTitle {Add line}
Main
Case message of
SingleClic :
Begin
Set $cmd = {echo "}$mediad{"|sed -e "s:^.*$:&}$Mstring{|:"}
Set $mediad = (GetOutput $cmd 1 -1)
HideWidget 1
ChangeTitle 1 $mediad
ShowWidget 1
Set $oldMstring = $Mstring
End
End
# Save media dirs
Widget 13
Property
Flags NoReliefString
Position 625 280
Size 170 35
Type PushButton
LocaleTitle {Save}
Main
Case message of
SingleClic :
Begin
Set $cmd = {PipeRead "printf %s \"}$mediad{\"| tr '|' '\\n' > }$mfile{"}
Do $cmd
End
End
# Edit entry
Widget 14
Property
Flags NoReliefString
Position 130 365
Size 480 35
Type TextField
Title { }
#Value 1
Main
Case message of
SingleClic :
Begin
Set $Mstring = (GetTitle 14)
End
1 :
Begin
Set $Mstring = (GetTitle 14)
End
End
# Remove string
Widget 15
Property
Flags NoReliefString
Position 5 360
Size 120 35
Type PushButton
LocaleTitle {Remove}
Main
Case message of
SingleClic :
Begin
Set $cmd = {echo "}$mediad{"|sed -e "s:}$oldMstring{|::"}
Set $mediad = (GetOutput $cmd 1 -1)
HideWidget 1
ChangeTitle 1 $mediad
ShowWidget 1
End
End
# Update string
Widget 16
Property
Flags NoReliefString
Position 625 360
Size 170 35
Type PushButton
LocaleTitle {Update}
Main
Case message of
SingleClic :
Begin
Set $cmd = {echo "}$mediad{"|sed -e "s:}$oldMstring{:}$Mstring{:"}
# Do {Echo cmd=}$cmd
Set $mediad = (GetOutput $cmd 1 -1)
HideWidget 1
ChangeTitle 1 $mediad
ShowWidget 1
Set $oldMstring = $Mstring
End
End
# vim:ft=fvwm
|