Giter Site home page Giter Site logo

junga-com / bg-atom-ui-font-sizer Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 50 KB

Atom plugin that allows user to adjust the font size (aka zoom) of various UI components

License: MIT License

JavaScript 93.46% Less 6.54%
font-size atom tabs tree zoom

bg-atom-ui-font-sizer's Introduction

bg-ui-font-sizer package

2020-09 Update

This project uses the bg-atom-utils npm package which now installs a number of extensions to the atom.* API objects. I think that they are unlikely to cause problems, but if you experience any, please take the time to create an issue on this package to let me know. I am very interested in addressing any issues quickly.

Summary

Change the size of fonts in Atom UI.

This package adds commands that dynamically change font size of the bundled Tree-view and the Pane Item Tab controls that appear on each of the WorkspaceCenter, LeftDock, RightDock, and BottomDock areas. The effect of changing these font sizes is to zoom in and out.

This is particularly useful for the tree-view where you can zoom in or out to see your project tree at different levels. I find this works well in conjunction with the bg-pane-navigation package so that I can navigate around the workspace with the keyboard and zoom in/out of where ever I am at with the keyboard.

Note that some themes, such as the dark themes bundled with Atom have a configuration to set the UI font size. If you just want to increase the readability on a high resolution monitor those themes offer a good solution. Aside from addressing that issue on themes that do not offer configurable font size like the light themes bundled with Atom, this package is useful to be able to adjust the tab sizes of the 4 different places where PaneItem tabs appear independently. I generally make the WorkspaceCenter tabs bigger and the Dock tabs smaller.

If you find yourself with so many editor tabs open that there is not enough of the names visible to tell them apart, you can temporarily make the tab font for the WorkspaceCenter very small to seem more of the names. With your focus in an editor window execute the bg-tabs:decrease-font-size' command (ctrl-_ by default -- note that _ is shift minus).

I have only tested this on my linux workstation using the bundled Atom themes. Create an issue if you have problems in your environment because I would like it to work well in all environments.

Commands

There are two sets of commands -- those for the tree-view and those for tabs. For each, you can increase/decrease the font size and also increase/decrease the line height. You can also reset the font and line height to its original styling. The tab commands also have a modal dialog that can be opened to enter a mode to adjust the tabs. This was necessary because its not practical to find non-conflicting keystrokes for all the tabs in any context you could adjust them in.

Command KeyMap Description
'bg-ui-font-sizer:run-tutorial' Start the tutorial for this package again
--- --- ---
'bg-tree-view:decrease-font-size' .tree-view: 'ctrl--': zoom tree-view out
'bg-tree-view:increase-font-size' .tree-view: 'ctrl-=': zoom tree-view in
'bg-tree-view:decrease-line-height' .tree-view: 'ctrl-up': squeeze tree-view vertically
'bg-tree-view:increase-line-height' .tree-view: 'ctrl-down': stretch tree-view vertically
'bg-tree-view:reset-font-size' .tree-view: 'ctrl-0': remove styling so that theme default applies to tree-view fonts
--- --- ---
'bg-tabs:decrease-font-size' ctrl-_ zoom out tabs of focused dock/center
'bg-tabs:increase-font-size' ctrl-+ zoom in tabs of focused dock/center
'bg-tabs:increase-line-height' stretch focused tabs vertically
'bg-tabs:decrease-line-height' squeeze focused tabs vertically
'bg-tabs:reset-font-size' ctrl-) remove styling so that theme default applies
'bg-tabs:toggle-size-dialog' ctrl-alt-_
ctrl-alt-+
opens a model dialog to adjust all the tab sizes.
'bg-tabs:size-dialog-next' in modal dialog, cycle through tab locations
'bg-tabs:size-dialog-previous' in modal dialog, cycle through tab locations

Note that the 'bg-tabs:...' commands are context sensitive. They apply to the Dock or WorkspaceCenter that currently has the user's focus. If the bg-tabs:size-dialog is open, they apply to the location that is currently highlighted in the dialog. When all locations are highlighted (cycle to that with the tab key), the commands act on all the tab locations at once.

The 'bg-tree-view:...' commands are not context sensitive but the default keymaps for those commands are only active when the focus is in the tree-view.

Note that I registered the commands from this package under the 'bg-tree-view:' and 'bg-tabs' prefixes because I wanted you to find them in the command palette when searching for those things for which they apply to. I included the bg- prefix so that you can tell that they are not native to the tree-view and tabs package. The downside is that they are not as strongly associated with this package but hopefully the bg- prefix is enough to lead back here if needed.

Keymaps

In general, my packages provide only keymap suggestions that you need to put in your keymap.cson because I believe that it does more harm than good to assume the keystrokes you should use. This package does provide a keymap, though, for two reasons. First, it provides keymaps for its modal size-dialog which can not conflict with anything else. The whole purpose of that modal dialog is to avoid keymap conflicts my providing a mode that the user enters while adjusting tab sizes. Second, the other keymaps it provides seem pretty safe. There is a config setting to selectively disable the keymaps that are not associated with the modal dialog.

Here is the .atom/pacakges/bg-ui-font-sizer/keymaps/bg-ui-font-sizer.cson file copied reference.

# by adding shift and alt to the keystrokes that typically zoom in/out, we open the modal dialog
# note that these are shift keystrokes because _ and + are shift characters on their keys
'.platform-linux atom-workspace':
  'ctrl-alt-_':   'bg-tabs:toggle-size-dialog'
  'ctrl-alt-+':   'bg-tabs:toggle-size-dialog'

# once the modal dialog is open, we can control the keyboard without risk keystroke conflict. (so these are aways safe)
".bg-ui-font-sizer-dialog":
  'ctrl-+':     'bg-tabs:increase-font-size'
  'ctrl-=':     'bg-tabs:increase-font-size'
  'ctrl-_':     'bg-tabs:decrease-font-size'
  'ctrl--':     'bg-tabs:decrease-font-size'
  'ctrl-down':  'bg-tabs:increase-line-height'
  'ctrl-up':    'bg-tabs:decrease-line-height'
  'ctrl-0':     'bg-tabs:reset-font-size'
  'ctrl-)':     'bg-tabs:reset-font-size'
  'escape':     'bg-tabs:toggle-size-dialog'
  'tab':        'bg-tabs:size-dialog-next'
  'shift-tab':  'bg-tabs:size-dialog-previous'

# add context sensitive zoom to tree-view. By default, Atom will zoom the text editor with ctrl-+/- even when the focus is
# in the tree view. This seems like a safe change because I think that it makes it more intuitive to zoom the thing where your
# focus is.  ctrl-up/down are also mapped for to vertically squeeze and expand the tree items (line height adjustment).
# LMK by creating an issue if this caused problems for you. I'd like to know.
'.platform-linux .tree-view':
  'ctrl-0':     'bg-tree-view:reset-font-size'
  'ctrl--':     'bg-tree-view:decrease-font-size'
  'ctrl-=':     'bg-tree-view:increase-font-size'
  'ctrl-up':    'bg-tree-view:decrease-line-height'
  'ctrl-down':  'bg-tree-view:increase-line-height'

How it works

The main thing that the commands do is sets the font-size css property on a container node of the thing being zoomed in or out.

this.treeViewEl = document.querySelector('.tree-view.tool-panel');
this.treeViewEl.style.fontSize = '18px'

But there are two problems with this. Atom's themes css include a very specific rule that hardcodes .list-items line-height to 25px and the selection highlight bar (implemented as ::before content) height to 25px.

This package uses the bg-atom-utils NPM node_module's BGStylesheet class to dynamically add more specific styles that override those rules from the theme.

You could probably figure out static rules that make those properties relative to font-size but I decided to use dynamic rules so that I could also dynamically change the font-size to line-height proportions.

The default atom-light-ui theme (at least on my workstation) makes the tree-view list items very small with a lot of space inbetween them. (11px font and 25px line-height = 230%). I personally find that odd, but think more people would find this package useful if it allowed keeping that 230% line height if desired. Thats really why I incuded the line height adjustment but now that its done, I find that I use it all the time to squeeze a whole folder into view when needed.

The reset command removes all the dynamic styling so that the Atom theme defaults apply again. After doing a reset (or before issuing one of the other package commands), this package will be dormant and not mess with your styles at all.

Hacking Tip

If you want to play around with this package in ways that are not exposed through the commands, open devtools console (window:toggle-dev-tools) and explore the bg... global variable. Start typing the bg... to see what mechanisms are available to explore.

  • bg.BGAtomPlugins.logStatus() : list the packages that use the BGPlugin style
  • bg.BGAtomPlugins.get(pkgName) : get a reference to a package plugin instance to explore
  • bg.PolyfillObjectMixin.logStatus() : list the Atom polyfills that are installed (these add features to Atom API)

When you complete a command that returns an object, it will be logged in the console where you can expand it to explore its current state. You can autocomplete further to navigate to the sub-objects and if you assign an object to a variable in the console, you can invoke its methods and see what they do.

> pkg = bg.BGAtomPlugin.get('<packageName>')
> pkg.addCommand(...)

bg-atom-ui-font-sizer's People

Contributors

bobjunga avatar

Stargazers

 avatar

Watchers

 avatar  avatar

bg-atom-ui-font-sizer's Issues

Failed to activate the bg-ui-font-sizer package

[Enter steps to reproduce:]

  1. ...
  2. ...

Atom: 1.53.0 x64
Electron: 6.1.12
OS: Microsoft Windows 10 Home
Thrown From: bg-ui-font-sizer package 2.0.0

Stack Trace

Failed to activate the bg-ui-font-sizer package

At Unexpected token {

C:\Users\DrChin\.atom\packages\bg-ui-font-sizer\lib\UIFontSizerTutorial.js:1
import { Tutorial,dedent } from 'bg-atom-utils';

SyntaxError: Unexpected token {
    at new Script (vm.js:83:7)
    at Object.<anonymous> (C:\Users\DrChin\.atom\packages\bg-ui-font-sizer\lib\bg-ui-font-sizer.js:1)
    at Generator.next (<anonymous>)

Commands

Non-Core Packages

asciidoc-image-helper 1.0.1 
atom-beautify 0.33.4 
atom-browser 1.10.0 
atom-clock 0.1.18 
atom-image-resize 0.3.0 
atom-to-codepen 0.0.0 
bg-ui-font-sizer 2.0.0 
browse 3.2.0 
CodePress 0.3.0 
emmet 2.4.3 
emmet-simplified 2.6.0 
emmet-snippets-compatibility 1.0.6 
font-size-changer 2.0.0 
hugo-image 0.0.8 
ibm-cloud-developer-tools 0.1.2 
image-copipe 0.3.1 
imagemin 1.6.1 
latex-image-paste 0.5.0 
local-storage 0.12.3 
markdown-image-paste 2.5.2 
open-html-in-browser 0.2.1 
open-in-browser 0.5.2 
open-in-developer-mode 0.3.0 
open-package 0.2.0 
package-developer-toolbar 1.2.1 
platformio-ide-debugger 1.2.6 
reload-workspace-button 0.1.2 
satisfy-dependencies 0.4.3 
tool-bar 1.4.2 
Webfont 1.1.0 
xatom-debug 1.6.11 
xatom-debug-nodejs 0.9.3 

Uncaught TypeError: Cannot read property 'test' of undefined

[Enter steps to reproduce:]

  1. ...
  2. ...

Atom: 1.52.0 x64
Electron: 6.1.12
OS: "Red Hat
Thrown From: bg-ui-font-sizer package 2.0.0

Stack Trace

Uncaught TypeError: Cannot read property 'test' of undefined

At /home/abenson/.atom/packages/bg-ui-font-sizer/node_modules/bg-atom-utils/polyfill-workspace.js:98

TypeError: Cannot read property 'test' of undefined
    at /packages/bg-ui-font-sizer/node_modules/bg-atom-utils/polyfill-workspace.js:98:47
    at Array.filter (<anonymous>)
    at Workspace.getItemsByURI (/packages/bg-ui-font-sizer/node_modules/bg-atom-utils/polyfill-workspace.js:98:16)
    at Workspace.hide (/packages/bg-ui-font-sizer/node_modules/bg-atom-utils/polyfill-workspace.js:109:27)
    at Workspace.toggle (/arm/tools/atom/atom/1.52.0/linux64/share/atom/resources/app/static/<embedded>:11:433223)
    at TreeView.toggle (/arm/tools/atom/atom/1.52.0/linux64/share/atom/resources/app/static/<embedded>:14:953779)
    at HTMLElement.tree-view:toggle (/arm/tools/atom/atom/1.52.0/linux64/share/atom/resources/app/static/<embedded>:11:1153379)
    at CommandRegistry.handleCommandEvent (/arm/tools/atom/atom/1.52.0/linux64/share/atom/resources/app/static/<embedded>:11:349963)
    at KeymapManager.dispatchCommandEvent (/arm/tools/atom/atom/1.52.0/linux64/share/atom/resources/app/static/<embedded>:11:1231297)
    at KeymapManager.handleKeyboardEvent (/arm/tools/atom/atom/1.52.0/linux64/share/atom/resources/app/static/<embedded>:11:1227431)
    at WindowEventHandler.handleDocumentKeyEvent (/arm/tools/atom/atom/1.52.0/linux64/share/atom/resources/app/static/<embedded>:11:284820)

Commands

  2x -8:20.6.0 core:backspace (input.hidden-input)
     -5:19.2.0 core:save (input.hidden-input)
     -4:54.4.0 editor:newline (input.hidden-input)
  2x -4:52 core:backspace (input.hidden-input)
     -4:50.3.0 core:save (input.hidden-input)
     -1:08.5.0 tree-view:toggle (input.hidden-input)

Non-Core Packages

accents-ui 1.3.0 
advanced-open-file 0.16.8 
aligner 1.2.4 
aligner-javascript 1.3.0 
aligner-python 1.2.0 
aligner-verilog 1.0.0 
apio-linter-verilog 0.7.2 
atom-alignment 0.13.0 
atom-beautify 0.33.4 
atom-brackets-glow 0.6.0 
atom-clock 0.1.18 
atom-ctags 5.1.2 
atom-cursor-indent 0.3.3 
atom-dark-solarized-ui 0.55.0 
atom-file-icons 0.7.1 
atom-fuzzy-grep 0.17.2 
atom-html-preview 0.2.6 
atom-icons 0.2.2 
atom-ide-datatip 0.20.4 
atom-ide-debugger-python 0.7.3 
atom-ide-definitions 0.4.0 
atom-ide-hyperclick 1.0.9 
atom-ide-markdown-service 1.6.0 
atom-keyboard-macros 0.12.1 
atom-material-ui 2.1.3 
atom-ncvlog-linter 0.3.0 
atom-overtype-mode 0.4.0 
atom-show-project-name 0.1.4 
autocomplete 0.47.0 
autocomplete-clang 0.13.1 
autosave-onchange 1.5.1 
bg-ui-font-sizer 2.0.0 
block-cursor 0.13.3 
busy 0.7.0 
busy-signal 2.0.1 
city-lights-syntax 1.1.8 
city-lights-ui 1.5.3 
color-picker 2.3.0 
color-tabs 0.1.8 
color-tabs-byproject 1.3.0 
color-tabs-regex 0.2.5 
copy-with-style 1.1.0 
custom-window-title-baincd 1.1.0 
dash-syntax 0.4.2 
dash-ui 0.4.4 
Delete-Whitelines 0.6.4 
favorites 1.1.0 
file-icons 2.1.45 
file-type-icons 1.3.4 
file-watcher 2.0.0 
find-selection 0.16.0 
fonts 3.12.0 
git-log 0.4.1 
git-plus 8.7.1 
git-status 0.3.4 
git-time-machine 2.1.0 
goto-definition 1.3.4 
hackify-ui 0.3.0 
hacking-the-kernel-ui 1.8.5 
hey-pane 1.2.0 
hidpi 0.14.0 
highlight-colors 0.9.0 
highlight-selected 0.17.0 
hyperclick 0.1.5 
ide-python 1.6.2 
indent-guide-improved 1.4.13 
intentions 1.1.5 
ip-status 0.1.0 
isotope-ui 2.8.5 
keyword-pair-matcher 0.2.2 
language-diff 0.7.0 
language-fish-shell 1.1.0 
language-ini 1.23.0 
language-powershell 5.0.0 
language-systemverilog 0.12.2 
language-tcl 0.1.2 
language-verilog 0.4.0 
linter 3.1.1 
linter-gcc 0.9.0 
linter-pyflakes 0.3.2 
linter-shellcheck 1.6.0 
linter-ui-default 2.1.5 
linter-verilator 0.3.0 
linter-verilog 0.7.0 
linter-veriloghdl 1.1.1 
logo-file-icons 1.13.0 
mono-pro-ui 1.0.0 
monokai 0.27.0 
monokai-dark 1.5.0 
multi-cursor-plus 1.2.0 
multi-file-open 0.1.1 
narrow 0.65.2 
open-this 0.5.0 
plain-simple 1.1.0 
prime-file-icons 0.3.0 
project-manager 3.3.8 
project-plus 1.0.0 
project-view 0.6.5 
project-viewer 1.4.0 
project-viewer-plus 0.0.11 
python-autopep8 0.1.3 
python-debugger 0.2.0 
python-linters 0.0.5 
quick-highlight 0.13.0 
recent-files-fuzzy-finder 1.0.0 
revert-buffer 0.6.0 
script 3.26.0 
simple-panes 1.2.0 
snow-flakes 0.1.0 
solarized-dark-ui 0.3.2 
solarkai-syntax 1.2.0 
sorted-tab-history 1.1.4 
split-diff 1.6.1 
styri-syntax 1.0.0 
sublime-block-comment 0.5.1 
Sublime-Style-Column-Selection 1.7.5 
symbols-tree-view 0.14.0 
sync-settings 5.0.10 
tabs-to-spaces 1.0.5 
terminus 4.0.6 
toggle-packages 1.1.0 
toggle-quotes 1.1.4 
tool-bar 1.4.2 
trashman 0.2.0 
tree-view-auto-collapse 1.0.3 
tree-view-auto-fold 1.3.0 
tree-view-autoadjust 3.0.0 
tree-view-sort 0.12.1 
verilog-auto-module-init 2.0.0 
verilog-tools 0.1.0 
white-cursor 0.7.0 
window-focus 1.0.0 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.