Skip to content

Commit

Permalink
add resize handling - fix #65 (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanjudis authored Aug 7, 2016
1 parent 649fd8e commit bf02e96
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
5 changes: 5 additions & 0 deletions app/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ function createWindow( event, hash ) {

emitAll( 'repos updated', repos );
} );

rpc.on( 'set terminal size', ( { uid, cols, rows } ) => {
sessions.get( uid ).resize( { cols, rows } );
} );
} );


Expand All @@ -255,6 +259,7 @@ function createWindow( event, hash ) {
rpc.removeAllListeners( 'add repo' );
rpc.removeAllListeners( 'update repo' );
rpc.removeAllListeners( 'remove repo' );
rpc.removeAllListeners( 'set terminal size' );

session.removeAllListeners();
session.destroy();
Expand Down
20 changes: 7 additions & 13 deletions app/src/components/RepoView/CommandOutput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
position : relative;
height : 100%;
padding : 0 1em;
padding : 0 .5em;
> iframe {
width : calc( 100% - 2em ) !important;
Expand Down Expand Up @@ -117,16 +117,6 @@
<path d="M0 0h24v24H0z" fill="none"/>
</svg>
</div>

<!--<div v-if="terminationStatus">
<div v-if="terminationStatus === 'killed'" class="u-flexVerticalCenter">
<svg class="u-fillRed" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
<path d="M11.99 2C6.47 2 2 6.47 2 12s4.47 10 9.99 10S22 17.53 22 12 17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm4.18-12.24l-1.06 1.06-1.06-1.06L13 8.82l1.06 1.06L13 10.94 14.06 12l1.06-1.06L16.18 12l1.06-1.06-1.06-1.06 1.06-1.06zM7.82 12l1.06-1.06L9.94 12 11 10.94 9.94 9.88 11 8.82 9.94 7.76 8.88 8.82 7.82 7.76 6.76 8.82l1.06 1.06-1.06 1.06zM12 14c-2.33 0-4.31 1.46-5.11 3.5h10.22c-.8-2.04-2.78-3.5-5.11-3.5z"/>
<path d="M0 0h24v24H0z" fill="none"/>
</svg>
<span class="u-marginLeftSmall">Killed.</span> <button type="button" class="script--output--btn u-marginLeftSmall" @click="runScript( lastScript )">Run again!</button>
</div>
</div>-->
</div>
<div class="u-marginLeftAuto">
<button type="button" class="o-icon" @click="close()">
Expand All @@ -147,7 +137,7 @@

<script>
import { getAppSettings, getSessionOutput } from '../../vuex/getters';
import { clearSessionData, execSessionCmd, writeSessionData } from '../../vuex/actions';
import { clearSessionData, execSessionCmd, setTerminalSize, writeSessionData } from '../../vuex/actions';
import hterm from '../../modules/HTerm';
export default {
Expand All @@ -159,8 +149,11 @@
if ( key === '' ) {
return this.close();
}
};
io.onTerminalResize = function( cols, rows ) {
this.setTerminalSize( cols, rows );
}.bind( this );
}.bind( this );
this.term.prefs_.set( 'background-color', '#2a333c' );
Expand Down Expand Up @@ -246,6 +239,7 @@
actions : {
clearSessionData,
execSessionCmd,
setTerminalSize,
writeSessionData
},
getters : {
Expand Down
1 change: 1 addition & 0 deletions app/src/modules/Hterm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { hterm, lib } from 'hterm-umdjs';

hterm.defaultStorage = new lib.Storage.Memory();

hterm.Terminal.prototype.overlaySize = function () {};

// passthrough all the commands that are meant to control
// hyperterm and not the terminal itself
Expand Down
6 changes: 6 additions & 0 deletions app/src/vuex/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,9 @@ export const clearSessionData = function( { dispatch, state }, data ) {
export const updateSessionOutput = function( { dispatch }, data ) {
dispatch( 'UPDATE_SESSION_OUTPUT', data );
};

export const setTerminalSize = function( { dispatch, state }, cols, rows ) {
window.rpc.emit(
'set terminal size', { uid : state.session.uid, cols, rows }
);
};

0 comments on commit bf02e96

Please sign in to comment.