Skip to content

Commit

Permalink
v1.3 - updated readme, assembler code changed for executable and test…
Browse files Browse the repository at this point in the history
…ed with virustotal, reduced to 1024 bytes exe file
  • Loading branch information
vhanla committed Apr 14, 2018
1 parent 2aba088 commit 2b7e2cd
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 167 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2013 vhanla

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
10 changes: 0 additions & 10 deletions License.txt

This file was deleted.

75 changes: 63 additions & 12 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
SublimeText Transparent
=======================
`Package Name : Transparency`

Overview
--------
This simple plugin for Sublime Text 2 and Sublime Text 3 provides contextual menues to modify the application's opacity.
This simple plugin for Sublime Text 2 and Sublime Text 3 provides contextual menues and hotkeys to modify the application's opacity.

**This is only for Windows Operating System.**
**This is only for SublimeText under Windows.**


Install
Expand All @@ -14,40 +15,63 @@ You may install `SublimeTextTrans` via git with the below commands:

**Windows only**

For Sublime Installed:
**For Sublime Installed:**

git clone https://github.com/vhanla/SublimeTextTrans.git "%APPDATA%\Sublime Text 2\Packages\SublimeTextTrans"

For Sublime Portable:
**Notice** that this location might change on each SublimeText version, _you can find the correct path by going to menu **Preferences - Browse Packages**_

git clone https://github.com/vhanla/SublimeTextTrans.git "C:\SUBLIME2\Data\Packages\SublimeTextTrans""
**For Sublime as Portable:**

git clone https://github.com/vhanla/SublimeTextTrans.git "C:\Sublime\Data\Packages\SublimeTextTrans""

*Where* ***C:\Sublime*** *is the portable's path. So change accordingly.*

You can also get it zipped from the [Releases](https://github.com/vhanla/SublimeTextTrans/releases) section.

Remember, there must be inside its own directory within packages directory where you will unzip it.
Remember, this plugin must be inside its own directory within packages directory where you will unzip it.

**Alternative using Package Installer:**

Ctrl+Shift+P - Install Package - Transparency

Usage:
-------
There are three methods to set transparency:

1. Visit `View > Window's Transparency` submenu to set the opacity
2. You can use the hotkeys Ctrl+Shift+[1,2,3,4,5,6]
2. You can use the hotkeys `Ctrl+Shift+[1,2,3,4,5,6]`
3. Or you can right click and use the contextual menu

![Snapshot]
(https://github.com/vhanla/SublimeTextTrans/raw/master/snapshot.png?raw=true "Snapshot")
![](https://github.com/vhanla/SublimeTextTrans/raw/master/snapshot.png?raw=true)

Limitations:
------------
- Only 6 levels of transparency, [0 = invisible <-> 255 = solid] customizable on settings file.
- It requires another executable to change Sublime Text's window style mode to allow translucency.
However, you don't need to install it or launch manually, the plugin does it for you. Executable is only a `1024 bytes` and source code is included, which is in assembler language, hence that's why it is so small. Also, it is launched only once each time you start Sublime Text, and it closes itself after changing style, so no memory is used afterwards.


Changelog:
----------
- 15-24-2015
[14-04-2018] v1.3

- Modified `SetSublimeLayered.asm` to make it smaller and to avoid false positives (tested on [VirusTotal](https://www.virustotal.com/#/file/66b72c28f54728c6df3995b0ae026aa1aeeca96911d5b484673a502ec6592f2a/detection))

These are `SetSublimeLayered.exe`hashes:

- SHA-256 66b72c28f54728c6df3995b0ae026aa1aeeca96911d5b484673a502ec6592f2a
- CRC32 54612762
- MD5 E113BDC6FA08BC054F7A89E7B24411BD
- SHA-1 376707D5579384B42586D0616BB03BBB993C6050

[15-24-2015] v1.2

- Onload transparency (95% working due to ST API limitations)
- Remember chosen transparency level
- Support for user settings

- 12-06-2013
[12-06-2013] v1.0

- Added support for Sublime Text 3

Expand All @@ -61,7 +85,7 @@ There you can modify the transparency levels, by adding the following and adjust
{

// If you like to have a different transparency level
// modify this array of options in your user preferences
// modify this array of options in your user preferences
// i.e. just add (copy/paste) this array and modify at wish
// IMPORTANT: Level of opacity varies from 0 to 255
// 0 = Totally transparent, 255 = Fully opaque
Expand All @@ -75,8 +99,35 @@ There you can modify the transparency levels, by adding the following and adjust
]
}

You can see other options on `Settings - Default` file.

Author & Contributors
----------------------
[Victor Alberto Gil](http://profiles.google.com/vhanla) - Hope you like my work.

License
-------
The MIT License (MIT)



Copyright (c) 2013 Victor Alberto Gil <vhanla>



Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
62 changes: 31 additions & 31 deletions SublimeTrans.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
SW_HIDE = 0
SW_SHOW = 5

STT_VERSION = "1.2"
#default global variables , needed to use plugin_loaded function in order to work on ST3
STT_VERSION = "1.3"
#default global variables , needed to use plugin_loaded function in order to work on ST3
stt_settings_filename = "SublimeTextTrans.sublime-settings"
stt_settings = None
stt_about_message = ("SublimeTextTrans plugin v%s\n"
Expand All @@ -93,12 +93,12 @@
stt_level3 = 0
stt_level4 = 0
stt_level5 = 0
exe_file = ""
exe_file = ""
sublime_3 = True

def sublime_opacity(opacity):
if stt_settings is None:
return
return
#LHDesktop = GetDesktopWindow(None)
LHDesktop = GetDesktopWindow()
LHWindow = GetWindow(LHDesktop,GW_CHILD)
Expand All @@ -116,10 +116,10 @@ def sublime_opacity(opacity):
try:
parametro = str(LHWindow)+' '+ str(wl)
ShellExecute(LHDesktop,"open", exe_file,parametro,None,SW_HIDE)
if opacity is not None:
SetLayeredWindowAttributes(LHWindow,0,opacity, LWA_ALPHA)
if opacity is not None:
SetLayeredWindowAttributes(LHWindow,0,opacity, LWA_ALPHA)
stt_settings.set("opacity", opacity)
persist_settings()
persist_settings()
break
except ValueError:
print("Error! ")
Expand All @@ -128,15 +128,15 @@ def sublime_opacity(opacity):

def sublime_opaque(level):
global stt_opacity
if not stt_opacity == level:
if not stt_opacity == level:
stt_opacity = level
sublime_opacity(stt_opacity)


class SetOpacityHalfCommand(sublime_plugin.WindowCommand):
def run(self):
def run(self):
reload_settings() #update with user settings, incase user settings was changed
sublime_opaque(stt_level1)
sublime_opaque(stt_level1)
def is_checked(self):
return stt_opacity == stt_level1

Expand Down Expand Up @@ -179,36 +179,36 @@ class SubTransAbout(sublime_plugin.WindowCommand):
def run(sef):
sublime.message_dialog(stt_about_message)

class SublimeTextTransListener(sublime_plugin.EventListener):
#these for ST3 only
def on_new_async(self, view):
if stt_autoapply:
class SublimeTextTransListener(sublime_plugin.EventListener):
#these for ST3 only
def on_new_async(self, view):
if stt_autoapply:
sublime_opacity(stt_opacity)
#let's insist twice, specially for new sublime's window instance
sublime.set_timeout(sublime_opacity(stt_opacity), 250)
sublime.set_timeout(sublime_opacity(stt_opacity), 500)
sublime.set_timeout(sublime_opacity(stt_opacity), 500)

def on_activated_async(self, view):
if stt_autoapply:
def on_activated_async(self, view):
if stt_autoapply:
sublime_opacity(stt_opacity)
# there is no async method on ST2
def on_new(self, view):
def on_new(self, view):
if stt_autoapply and not sublime_3:
sublime_opacity(stt_opacity)

# this event works on ST2. Delayed "hack" in plugin_loaded is only for ST3
def on_load(self, view):
def on_load(self, view):
if stt_autoapply and not sublime_3:
sublime_opacity(stt_opacity)
sublime_opacity(stt_opacity)

def on_clone(self, view):
def on_clone(self, view):
if stt_autoapply and not sublime_3:
sublime_opacity(stt_opacity)

def on_activated(self, view):
def on_activated(self, view):
if stt_autoapply and not sublime_3:
sublime_opacity(stt_opacity)

def reload_settings():
#opacity levels
global stt_level0, stt_level1, stt_level2, stt_level3, stt_level4, stt_level5
Expand All @@ -229,9 +229,9 @@ def reload_settings():

def plugin_loaded():
#print('Loading settings...')
#Load settings
#Load settings
reload_settings()

#Python fails calling SetWindowLong from Windows and crashes the entire Sublimetext,
#so we will use an exe file to set layered mode the sublimetext running app
lib_folder = os.path.join(os.path.dirname(os.path.abspath(__file__)),'lib')
Expand All @@ -240,23 +240,23 @@ def plugin_loaded():
exe_file = os.path.join(lib_folder,'SetSublimeLayered.exe')
has_exe = os.path.exists(exe_file)
if os.name == 'nt' and (not has_lib or not has_exe):
sublime.error_message(u'SetSublimeLayered.exe is not found!')
sublime.error_message(u'SetSublimeLayered.exe is not found!')
if stt_autoapply:
sublime_opacity(stt_opacity)
sublime.set_timeout(focus_active_view, 250)

#print('Done!')

# This delayed procedure will change focused view and call sublime_opacity
# This delayed procedure will change focused view and call sublime_opacity
# in order to apply on sublime's startup
def focus_active_view():
winds = sublime.active_window()
winds = sublime.active_window()
if winds:
fview = winds.views()
fview = winds.views()
aview = winds.active_view()
if fview and aview:
# focus to the first view
winds.focus_view(fview[0])
winds.focus_view(fview[0])
# return to the initial active view
winds.focus_view(aview)
#try again "hack" for ST3
Expand Down
Loading

0 comments on commit 2b7e2cd

Please sign in to comment.