Skip to content

Commit

Permalink
v1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
aplsimple committed Dec 6, 2023
1 parent a9df744 commit c9874ef
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 15 deletions.
55 changes: 41 additions & 14 deletions aloupe.tcl
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
#! /usr/bin/env tclsh
# _______________________________________________________________________ #
#
# This is a screen loupe.
#
# Scripted by Alex Plotnikov (https://aplsimple.github.io).
#
# See README.md for details.
#
###########################################################
# Name: aloupe.tcl
# Author: Alex Plotnikov ([email protected])
# Date: Feb 26, 2021
# Brief: Handles a screen loupe.
# License: MIT.
# _______________________________________________________________________ #
###########################################################

# _________________________ aloupe ________________________ #

package require Tk

package provide aloupe 1.2

namespace eval ::aloupe {
variable solo [expr {[info exist ::argv0] && [file normalize $::argv0] eq [file normalize [info script]]}]
}
if {$::aloupe::solo} {wm withdraw .}

# _____ Remove installed (perhaps) packages used here _____ #

Expand All @@ -41,18 +43,39 @@ if {$::aloupe::solo} {
}
}

package require treectrl
package require Img
# ________________________ Run solo at need _________________________ #

::msgcat::mcload [file join [file dirname [info script]] msgs]
proc ::aloupe::RunSolo {} {
# Runs aloupe as a sole Tcl script.
# When aloupe runs from tclkit, it may fail. So try it with tclsh deployed.

package provide aloupe 1.0
set tclsh [auto_execok tclsh]
set tclexe [info nameofexecutable]
# tclsh may be sort of "tcl.sh" to run a tclkit
if {[file exists $tclsh] && [file size $tclsh]>1024 && $tclsh ne $tclexe} {
if {$::aloupe::solo} {set aar $::argv} {set aar {}}
exec -- $tclsh $::aloupe::aloupescript {*}$aar &
} else {
puts "aloupe: $::aloupe::runerr"
}

}
set ::aloupe::aloupescript [info script]
set ::aloupe::starterr [catch {package require treectrl; package require Img} ::aloupe::runerr]
if {$::aloupe::solo && $::aloupe::starterr} {
::aloupe::RunSolo
exit
}

# ________________________ Variables _________________________ #

::msgcat::mcload [file join [file dirname [info script]] msgs]

namespace eval ::aloupe {
variable filename {}
namespace eval my {
variable HOMEDIR ~
if {[info exists ::env(HOME)]} {set HOMEDIR $::env(HOME)}
variable size 26
variable zoom 8
variable pause 0
Expand All @@ -70,7 +93,7 @@ namespace eval ::aloupe {
-geometry "" \
-parent "" \
-save yes \
-inifile "~/.config/aloupe.conf" \
-inifile [file join $HOMEDIR .config aloupe.conf] \
-locale "" \
-apavedir "" \
-cs -2 \
Expand Down Expand Up @@ -595,6 +618,10 @@ proc ::aloupe::run {args} {
# Runs the loupe.
# args - options of the loupe

if {$::aloupe::starterr} {
RunSolo
return
}
variable my::data
variable my::size
variable my::zoom
Expand Down
2 changes: 1 addition & 1 deletion pkgIndex.tcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

package ifneeded aloupe 1.0 [list source [file join $dir aloupe.tcl]]
package ifneeded aloupe 1.2 [list source [file join $dir aloupe.tcl]]


# A short intro (for Ruff! docs generator:)
Expand Down

0 comments on commit c9874ef

Please sign in to comment.