Tkabber contrib

Check-in [cace7a6531]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Juick plugin (tkabber-0.11.1 branch): * Add support for markdown-style links.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | plugins-0.11.1
Files: files | file ages | folders
SHA1:cace7a65317203edb9c6292667f3a292e271e395
User & Date: toktonada 2014-04-27 04:57:32
Context
2014-04-27
05:11
Juick plugin (tkabber-0.11.1 branch): * Update BUGS and TODO files. check-in: 46c07c85ea user: toktonada tags: plugins-0.11.1
04:57
Juick plugin (tkabber-0.11.1 branch): * Add support for markdown-style links. check-in: cace7a6531 user: toktonada tags: plugins-0.11.1
2014-02-01
18:12
Juick plugin (tkabber-0.11.1 branch): * Fix URL for open Juick tags. * Change "open in browser" message. * Update context menu labels and Russian translations. check-in: f8c41e41d4 user: toktonada tags: plugins-0.11.1
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to juick/juick.tcl.

14
15
16
17
18
19
20

21
22
23
24
25
26
27
..
55
56
57
58
59
60
61





























62
63
64
65
66
67
68
..
93
94
95
96
97
98
99






100
101
102
103
104
105
106
...
678
679
680
681
682
683
684


























685
686
687
688
689
690
691
...
700
701
702
703
704
705
706






707
708
709
710
711
712
713
...
731
732
733
734
735
736
737







738
739


740
741
742
743
744
745
746
...
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823

    catch {source [file join $scriptdir \
        tkabber-0.11.1-compatibility.tcl]} \
        source_compatibility_file_result
}

namespace eval juick {

variable options
variable juick_nicknames
variable chat_things

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

if {![::plugins::is_registered juick]} {
................................................................................
    -type boolean

proc load {} {
    ::richtext::entity_state juick_numbers 1
    ::richtext::entity_state citing 1
    ::richtext::entity_state juick 1
    ::richtext::entity_state juick_ligth 1






























    hook::add draw_message_hook        \
        [namespace current]::ignore_server_messages 0

    hook::add draw_message_hook        \
        [namespace current]::handle_message 21

................................................................................
        [namespace current]::get_juick_nick 99

    hook::add generate_completions_hook \
        [namespace current]::juick_commands_comps 99
}

proc unload {} {






    hook::remove draw_message_hook        \
        [namespace current]::ignore_server_messages 0

    hook::remove draw_message_hook        \
        [namespace current]::handle_message 21

    hook::remove chat_window_click_hook   \
................................................................................

    if {!$matched} { return false }

    upvar 1 $startVar uStart $endVar uEnd
    lassign $bounds uStart uEnd
    return true
}



























proc process_juick {atLevel accName} {
    if {[::richtext::property_exists {JUICK}]} {
        return [process $atLevel $accName juick]
    }
}

................................................................................
}

proc process_juick_ligth {atLevel accName} {
    if {[::richtext::property_exists {JUICK}]} {
       return [process $atLevel $accName juick_ligth]
    }
}







proc process {atLevel accName what} {
    upvar #$atLevel $accName chunks

    set out {}

    foreach {s type tags} $chunks {
................................................................................
                # Write out text before current thing, if any:
                lappend out \
                    [string range $s $index [expr {$uStart - 1}]] \
                    $type $tags
            }

            set thing [string range $s $uStart $uEnd]







            # Write out current thing:
            lappend out $thing $what $tags


            set index [expr {$uEnd + 1}]
        }
        # Write out text after the last thing, if any:
        if {[string length $s] - $index > 0} {
            lappend out [string range $s $index end] $type $tags
        }
    }
................................................................................

proc render_juick_ligth {w type thing tags args} {
    set id JLIGTH-$thing
    $w insert end $thing [lfuse $tags [list $id $type JLIGTH]]
    return $id
}

::richtext::register_entity juick_numbers \
    -configurator [namespace current]::configure_juick_numbers \
    -parser [namespace current]::process_juick_numbers \
    -renderer [namespace current]::render_juick \
    -parser-priority 54

::richtext::register_entity juick_ligth \
    -configurator [namespace current]::configure_juick_ligth \
    -parser [namespace current]::process_juick_ligth \
    -renderer [namespace current]::render_juick_ligth \
    -parser-priority 81

::richtext::register_entity citing \
    -configurator [namespace current]::configure_citing \
    -parser [namespace current]::process_citing \
    -renderer [namespace current]::render_citing \
    -parser-priority 82

::richtext::register_entity juick \
    -configurator [namespace current]::configure_juick \
    -parser [namespace current]::process_juick \
    -renderer [namespace current]::render_juick \
    -parser-priority 85
}
# vi:ts=4:et







>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>







 







>
>
>
>
>
>
>
|
|
>
>







 







|
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
..
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
...
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
...
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
...
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
...
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
...
869
870
871
872
873
874
875
876




877


















878

    catch {source [file join $scriptdir \
        tkabber-0.11.1-compatibility.tcl]} \
        source_compatibility_file_result
}

namespace eval juick {

variable options
variable juick_nicknames
variable chat_things

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

if {![::plugins::is_registered juick]} {
................................................................................
    -type boolean

proc load {} {
    ::richtext::entity_state juick_numbers 1
    ::richtext::entity_state citing 1
    ::richtext::entity_state juick 1
    ::richtext::entity_state juick_ligth 1
    ::richtext::entity_state markdown_url 1

    ::richtext::register_entity juick_numbers \
        -configurator [namespace current]::configure_juick_numbers \
        -parser [namespace current]::process_juick_numbers \
        -renderer [namespace current]::render_juick \
        -parser-priority 54

    ::richtext::register_entity juick_ligth \
        -configurator [namespace current]::configure_juick_ligth \
        -parser [namespace current]::process_juick_ligth \
        -renderer [namespace current]::render_juick_ligth \
        -parser-priority 81

    ::richtext::register_entity citing \
        -configurator [namespace current]::configure_citing \
        -parser [namespace current]::process_citing \
        -renderer [namespace current]::render_citing \
        -parser-priority 82

    ::richtext::register_entity juick \
        -configurator [namespace current]::configure_juick \
        -parser [namespace current]::process_juick \
        -renderer [namespace current]::render_juick \
        -parser-priority 85

    ::richtext::register_entity markdown_url \
	    -parser [namespace current]::process_markdown_urls \
	    -parser-priority 49

    hook::add draw_message_hook        \
        [namespace current]::ignore_server_messages 0

    hook::add draw_message_hook        \
        [namespace current]::handle_message 21

................................................................................
        [namespace current]::get_juick_nick 99

    hook::add generate_completions_hook \
        [namespace current]::juick_commands_comps 99
}

proc unload {} {
    ::richtext::unregister_entity juick_numbers
    ::richtext::unregister_entity citing
    ::richtext::unregister_entity juick
    ::richtext::unregister_entity juick_ligth
    ::richtext::unregister_entity process_markdown_urls

    hook::remove draw_message_hook        \
        [namespace current]::ignore_server_messages 0

    hook::remove draw_message_hook        \
        [namespace current]::handle_message 21

    hook::remove chat_window_click_hook   \
................................................................................

    if {!$matched} { return false }

    upvar 1 $startVar uStart $endVar uEnd
    lassign $bounds uStart uEnd
    return true
}

proc spot_markdown_url {what at startVar endVar} {
    variable ::plugins::urls::url_regexp

    set matched [regexp -indices -start $at -- \
        {(\[([^\]]+)\]\[([^\]]+)\])} $what -> \
        bounds title_bounds url_bounds]

    if {!$matched} { return false }

    lassign $url_bounds us ue
    set url [string range $what $us $ue]
    set md_url_regexp [format "^%s$" $::plugins::urls::url_regexp]
    set matched [regexp -expanded -nocase -- $md_url_regexp $url]

    if {!$matched} { return false }

    upvar 1 $startVar uStart $endVar uEnd
    lassign $bounds uStart uEnd
    upvar 1 title_start title_start title_end title_end
    lassign $title_bounds title_start title_end
    upvar 1 url_start url_start url_end url_end
    lassign $url_bounds url_start url_end

    return true
}

proc process_juick {atLevel accName} {
    if {[::richtext::property_exists {JUICK}]} {
        return [process $atLevel $accName juick]
    }
}

................................................................................
}

proc process_juick_ligth {atLevel accName} {
    if {[::richtext::property_exists {JUICK}]} {
       return [process $atLevel $accName juick_ligth]
    }
}

proc process_markdown_urls {atLevel accName} {
    if {[::richtext::property_exists {JUICK}]} {
       return [process $atLevel $accName markdown_url]
    }
}

proc process {atLevel accName what} {
    upvar #$atLevel $accName chunks

    set out {}

    foreach {s type tags} $chunks {
................................................................................
                # Write out text before current thing, if any:
                lappend out \
                    [string range $s $index [expr {$uStart - 1}]] \
                    $type $tags
            }

            set thing [string range $s $uStart $uEnd]

            if {[string equal $what markdown_url]} {
                set title [string range $s $title_start $title_end]
                set url [string range $s $url_start $url_end]
                lappend out $url url $tags
                ::richtext::property_update url:title,$url $title
            } else {
                # Write out current thing:
                lappend out $thing $what $tags
            }

            set index [expr {$uEnd + 1}]
        }
        # Write out text after the last thing, if any:
        if {[string length $s] - $index > 0} {
            lappend out [string range $s $index end] $type $tags
        }
    }
................................................................................

proc render_juick_ligth {w type thing tags args} {
    set id JLIGTH-$thing
    $w insert end $thing [lfuse $tags [list $id $type JLIGTH]]
    return $id
}

# namespace eval juick




}


















# vi:ts=4:et