Changeset 23500

Show
Ignore:
Timestamp:
11/13/08 08:45:51 (5 years ago)
Author:
syo68k
Message:

URL変換のUndo実装、選択範囲のURL短縮変換を再実装、範囲選択時の変換はURLエンコードするように(日本語を含むURL対策)、選択していない場合はすべてのURLを短縮変換、メニューの「自動判定」を「圧縮サービス自動選択」に変更

Location:
lang/vb2005/Tween/Tween
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • lang/vb2005/Tween/Tween/Resources/ChangeLog.txt

    r23370 r23500  
    66-発言詳細が隠せなくなっていた問題を修正 
    77-起動時のアップデート処理でエラーが発生する問題を再修正 
    8 -コマンドメニューのURL短縮変換サブメニューに「自動判定」を追加。Tinyurlから応答がないときはis.gdを試します。 
    9 -CTRL+LをURL短縮変換の「自動判定」に割り当て。 
     8-コマンドメニューのURL短縮変換サブメニューに「短縮サービス自動選択」を追加。Tinyurlから応答がないときはis.gdを試します。 
     9-CTRL+LをURL短縮変換の「短縮サービス自動選択」に割り当て。 
     10-入力欄で範囲選択をしている場合は、その選択範囲をURLとみなして変換するようにした。(日本語がURLに含まれる場合はこちらをどうぞ。httpで始まっているかどうか、以外のURL妥当性検証は意図的に行っていません) 
     11-コマンドメニューのURL短縮変換サブメニューに「元に戻す」を追加。POST動作をするまでの間の変換を元に戻せます。 
    1012***Ver0.1.0.1(2008/11/11) 
    1113-「操作」メニューに「返信先ステータスを開く」を追加。ショートカットキーはCTRL+Iです。 
  • lang/vb2005/Tween/Tween/Tween.Designer.vb

    r23370 r23500  
    121121        Me.MenuItemCommand = New System.Windows.Forms.ToolStripMenuItem 
    122122        Me.TinyUrlConvertToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem 
     123        Me.UrlConvertAutoToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem 
     124        Me.UrlUndoToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem 
    123125        Me.TinyURLToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem 
    124126        Me.IsgdToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem 
     
    136138        Me.ToolStripSeparator7 = New System.Windows.Forms.ToolStripSeparator 
    137139        Me.AboutMenuItem = New System.Windows.Forms.ToolStripMenuItem 
    138         Me.UrlConvertAutoToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem 
    139140        Me.ContextMenuStrip3.SuspendLayout() 
    140141        Me.ContextMenuTabProperty.SuspendLayout() 
     
    469470        Me.ContextMenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.SettingStripMenuItem, Me.ToolStripSeparator9, Me.SaveLogMenuItem, Me.ToolStripSeparator17, Me.NewPostPopMenuItem, Me.PlaySoundMenuItem, Me.ListLockMenuItem, Me.ToolStripSeparator15, Me.MultiLineMenuItem, Me.ToolStripSeparator21, Me.EndToolStripMenuItem}) 
    470471        Me.ContextMenuStrip1.Name = "ContextMenuStrip1" 
     472        Me.ContextMenuStrip1.OwnerItem = Me.MenuItemFile 
    471473        Me.ContextMenuStrip1.ShowCheckMargin = True 
    472474        Me.ContextMenuStrip1.ShowImageMargin = False 
     
    852854        'TinyUrlConvertToolStripMenuItem 
    853855        ' 
    854         Me.TinyUrlConvertToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.UrlConvertAutoToolStripMenuItem, Me.TinyURLToolStripMenuItem, Me.IsgdToolStripMenuItem}) 
     856        Me.TinyUrlConvertToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.UrlConvertAutoToolStripMenuItem, Me.UrlUndoToolStripMenuItem, Me.TinyURLToolStripMenuItem, Me.IsgdToolStripMenuItem}) 
    855857        Me.TinyUrlConvertToolStripMenuItem.Name = "TinyUrlConvertToolStripMenuItem" 
    856858        Me.TinyUrlConvertToolStripMenuItem.Size = New System.Drawing.Size(220, 22) 
    857859        Me.TinyUrlConvertToolStripMenuItem.Text = "入力欄のURLを短縮変換" 
    858860        ' 
     861        'UrlConvertAutoToolStripMenuItem 
     862        ' 
     863        Me.UrlConvertAutoToolStripMenuItem.Name = "UrlConvertAutoToolStripMenuItem" 
     864        Me.UrlConvertAutoToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.L), System.Windows.Forms.Keys) 
     865        Me.UrlConvertAutoToolStripMenuItem.Size = New System.Drawing.Size(242, 22) 
     866        Me.UrlConvertAutoToolStripMenuItem.Text = "短縮サービス自動選択" 
     867        ' 
     868        'UrlUndoToolStripMenuItem 
     869        ' 
     870        Me.UrlUndoToolStripMenuItem.Enabled = False 
     871        Me.UrlUndoToolStripMenuItem.Name = "UrlUndoToolStripMenuItem" 
     872        Me.UrlUndoToolStripMenuItem.Size = New System.Drawing.Size(218, 22) 
     873        Me.UrlUndoToolStripMenuItem.Text = "元に戻す" 
     874        ' 
    859875        'TinyURLToolStripMenuItem 
    860876        ' 
    861877        Me.TinyURLToolStripMenuItem.Name = "TinyURLToolStripMenuItem" 
    862         Me.TinyURLToolStripMenuItem.Size = New System.Drawing.Size(170, 22) 
     878        Me.TinyURLToolStripMenuItem.Size = New System.Drawing.Size(218, 22) 
    863879        Me.TinyURLToolStripMenuItem.Text = "TinyURL" 
    864880        ' 
     
    866882        ' 
    867883        Me.IsgdToolStripMenuItem.Name = "IsgdToolStripMenuItem" 
    868         Me.IsgdToolStripMenuItem.Size = New System.Drawing.Size(170, 22) 
     884        Me.IsgdToolStripMenuItem.Size = New System.Drawing.Size(218, 22) 
    869885        Me.IsgdToolStripMenuItem.Text = "is.gd" 
    870886        ' 
     
    943959        Me.AboutMenuItem.Size = New System.Drawing.Size(217, 22) 
    944960        Me.AboutMenuItem.Text = "Tweenについて(&A)" 
    945         ' 
    946         'UrlConvertAutoToolStripMenuItem 
    947         ' 
    948         Me.UrlConvertAutoToolStripMenuItem.Name = "UrlConvertAutoToolStripMenuItem" 
    949         Me.UrlConvertAutoToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.L), System.Windows.Forms.Keys) 
    950         Me.UrlConvertAutoToolStripMenuItem.Size = New System.Drawing.Size(170, 22) 
    951         Me.UrlConvertAutoToolStripMenuItem.Text = "自動判定" 
    952961        ' 
    953962        'TweenMain 
     
    11011110    Friend WithEvents IsgdToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem 
    11021111    Friend WithEvents UrlConvertAutoToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem 
     1112    Friend WithEvents UrlUndoToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem 
    11031113 
    11041114End Class 
  • lang/vb2005/Tween/Tween/Tween.vb

    r23370 r23500  
    60916091        Dim args As New GetWorkerArg() 
    60926092 
     6093        UrlUndoToolStripMenuItem.Enabled = False  'Undoをできないように設定 Twitter.vb側でUndoバッファはクリアしているはず 
     6094 
    60936095        TimerRefreshIcon.Enabled = False 
    60946096        If My.Computer.Network.IsAvailable Then 
     
    69686970        End If 
    69696971    End Sub 
     6972 
     6973    Private Sub UrlUndoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UrlUndoToolStripMenuItem.Click 
     6974        clsTw.doUrlUndo() 
     6975    End Sub 
    69706976End Class 
    69716977 
  • lang/vb2005/Tween/Tween/Twitter.vb

    r23370 r23500  
    22Imports System.Xml 
    33Imports System.Text 
     4Imports System.Collections 
    45Imports System.Text.RegularExpressions 
    56 
     
    134135        GET_DMSNT 
    135136    End Enum 
     137 
    136138    Public Enum UrlConverter 
    137139        TinyUrl 
    138140        Isgd 
    139141    End Enum 
     142 
     143    Private Class urlUndo 
     144        Public Before As String 
     145        Public After As String 
     146    End Class 
     147 
     148    Private urlUndoBuffer As Generic.List(Of urlUndo) = Nothing 
    140149 
    141150 
     
    12311240 
    12321241        If resStatus.StartsWith("OK") Then 
     1242            urlUndoBuffer = Nothing 
    12331243            Return "" 
    12341244        Else 
     
    17621772        Dim result As String = "" 
    17631773        Dim url As Regex = New Regex("https?://[-_.!~*'()a-zA-Z0-9;/?:@&=+$,%#]+") 
     1774 
    17641775        Dim urls As RegularExpressions.MatchCollection = Nothing 
    17651776        Dim src As String = "" 
     
    17671778        urls = url.Matches(TweenMain.StatusText.Text) 
    17681779 
    1769         ' 正規表現にマッチしたURL文字列をtinyurl化 
    1770         For Each tmp2 As Match In urls 
    1771             Dim tmp As String = tmp2.ToString 
    1772  
    1773             ' ExcludeStringで指定された文字列で始まる場合は対象としない 
    1774             If tmp.StartsWith(ExcludeString) Then 
     1780        If TweenMain.StatusText.SelectionLength > 0 Then 
     1781            Dim tmp As String = TweenMain.StatusText.SelectedText 
     1782            ' httpから始まらない場合、ExcludeStringで指定された文字列で始まる場合は対象としない 
     1783            If Not tmp.StartsWith("http") OrElse tmp.StartsWith(ExcludeString) Then 
    17751784                ' Nothing 
    17761785            Else 
    1777                 '選んだURLを選択(?) 
    1778                 TweenMain.StatusText.Select(TweenMain.StatusText.Text.IndexOf(tmp), tmp.Length) 
    1779  
    1780                 'tinyurl変換 
    1781                 result = MakeShortUrl(Converter_Type, TweenMain.StatusText.SelectedText) 
     1786                ' 文字列が選択されている場合はその文字列について処理 
     1787 
     1788                '短縮URL変換 日本語を含むかもしれないのでURLエンコードする 
     1789                result = MakeShortUrl(Converter_Type, HttpUtility.UrlEncode(TweenMain.StatusText.SelectedText)) 
    17821790 
    17831791                If result.Equals("Can't convert") Then 
     
    17861794 
    17871795                If Not result = "" Then 
     1796                    Dim undotmp As New urlUndo 
     1797 
    17881798                    TweenMain.StatusText.Select(TweenMain.StatusText.Text.IndexOf(tmp), tmp.Length) 
    17891799                    TweenMain.StatusText.SelectedText = result 
     1800 
     1801                    'undoバッファにセット 
     1802                    undotmp.Before = tmp 
     1803                    undotmp.After = result 
     1804 
     1805                    If urlUndoBuffer Is Nothing Then 
     1806                        urlUndoBuffer = New List(Of urlUndo) 
     1807                        TweenMain.UrlUndoToolStripMenuItem.Enabled = True 
     1808                    End If 
     1809 
     1810                    urlUndoBuffer.Add(undotmp) 
    17901811                End If 
    1791  
    17921812            End If 
    1793         Next 
    1794  
    1795         Return True 
     1813        Else 
     1814            ' 正規表現にマッチしたURL文字列をtinyurl化 
     1815            For Each tmp2 As Match In urls 
     1816                Dim tmp As String = tmp2.ToString 
     1817                Dim undotmp As New urlUndo 
     1818 
     1819                ' ExcludeStringで指定された文字列で始まる場合は対象としない 
     1820                If tmp.StartsWith(ExcludeString) Then 
     1821                    ' Nothing 
     1822                Else 
     1823                    '選んだURLを選択(?) 
     1824                    TweenMain.StatusText.Select(TweenMain.StatusText.Text.IndexOf(tmp), tmp.Length) 
     1825 
     1826                    '短縮URL変換 
     1827                    result = MakeShortUrl(Converter_Type, TweenMain.StatusText.SelectedText) 
     1828 
     1829                    If result.Equals("Can't convert") Then 
     1830                        Return False 
     1831                    End If 
     1832 
     1833                    If Not result = "" Then 
     1834                        TweenMain.StatusText.Select(TweenMain.StatusText.Text.IndexOf(tmp), tmp.Length) 
     1835                        TweenMain.StatusText.SelectedText = result 
     1836                        'undoバッファにセット 
     1837                        undotmp.Before = tmp 
     1838                        undotmp.After = result 
     1839 
     1840                        If urlUndoBuffer Is Nothing Then 
     1841                            urlUndoBuffer = New List(Of urlUndo) 
     1842                            TweenMain.UrlUndoToolStripMenuItem.Enabled = True 
     1843                        End If 
     1844 
     1845                        urlUndoBuffer.Add(undotmp) 
     1846                    End If 
     1847 
     1848                End If 
     1849            Next 
     1850 
     1851 
     1852        End If 
     1853 
     1854 
     1855            Return True 
    17961856 
    17971857    End Function 
    1798  
     1858    Public Sub doUrlUndo() 
     1859        If urlUndoBuffer IsNot Nothing Then 
     1860            Dim tmp As String = TweenMain.StatusText.Text 
     1861            For Each data As urlUndo In urlUndoBuffer 
     1862                tmp = tmp.Replace(data.After, data.Before) 
     1863            Next 
     1864            TweenMain.StatusText.Text = tmp 
     1865            urlUndoBuffer = Nothing 
     1866            TweenMain.UrlUndoToolStripMenuItem.Enabled = False 
     1867        End If 
     1868    End Sub 
    17991869#If DEBUG Then 
    18001870    Public Sub GenerateAnalyzeKey()