Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/gui/gui.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const GUIComponent = props => {
rubyTabVisible,
stageSizeMode,
tipsLibraryVisible,
rubyCode,
vm,
...componentProps
} = omit(props, 'dispatch');
Expand Down Expand Up @@ -257,7 +258,7 @@ const GUIComponent = props => {
{soundsTabVisible ? <SoundTab vm={vm} /> : null}
</TabPanel>
<TabPanel className={tabClassNames.tabPanel}>
{rubyTabVisible ? <RubyTab /> : null}
{rubyTabVisible ? <RubyTab rubyCode={rubyCode}/> : null}
</TabPanel>
</Tabs>
{backpackOptions.visible ? (
Expand Down Expand Up @@ -319,6 +320,7 @@ GUIComponent.propTypes = {
stageSizeMode: PropTypes.oneOf(Object.keys(STAGE_SIZE_MODES)),
targetIsStage: PropTypes.bool,
tipsLibraryVisible: PropTypes.bool,
rubyCode: PropTypes.string,
vm: PropTypes.instanceOf(VM).isRequired
};
GUIComponent.defaultProps = {
Expand Down
3 changes: 2 additions & 1 deletion src/containers/gui.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ const mapStateToProps = state => ({
),
soundsTabVisible: state.scratchGui.editorTab.activeTabIndex === SOUNDS_TAB_INDEX,
rubyTabVisible: state.scratchGui.editorTab.activeTabIndex === RUBY_TAB_INDEX,
tipsLibraryVisible: state.scratchGui.modals.tipsLibrary
tipsLibraryVisible: state.scratchGui.modals.tipsLibrary,
rubyCode: state.scratchGui.rubyCode
});

const mapDispatchToProps = dispatch => ({
Expand Down
7 changes: 6 additions & 1 deletion src/containers/ruby-tab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import 'brace/mode/ruby';
import 'brace/theme/clouds';

export class RubyTab extends React.Component {
constructor (props) {
super(props);
}

render(){
return(
<AceEditor
Expand All @@ -15,6 +19,7 @@ export class RubyTab extends React.Component {
fontSize={16}
width="100%"
height="inherit"
value={this.props.rubyCode.rubyCode}
editorProps={{ $blockScrolling: true }}
setOptions={{
tabSize: 2,
Expand All @@ -24,4 +29,4 @@ export class RubyTab extends React.Component {
/>
)
}
}
}
5 changes: 4 additions & 1 deletion src/reducers/gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import stageSizeReducer, {stageSizeInitialState} from './stage-size';
import targetReducer, {targetsInitialState} from './targets';
import toolboxReducer, {toolboxInitialState} from './toolbox';
import vmReducer, {vmInitialState} from './vm';
import rubyCodeReducer, {rubyCodeInitialState} from './ruby-code';
import throttle from 'redux-throttle';

const guiMiddleware = compose(applyMiddleware(throttle(300, {leading: true, trailing: true})));
Expand All @@ -35,7 +36,8 @@ const guiInitialState = {
monitorLayout: monitorLayoutInitialState,
targets: targetsInitialState,
toolbox: toolboxInitialState,
vm: vmInitialState
vm: vmInitialState,
rubyCode: rubyCodeInitialState
};

const initPlayer = function (currentState) {
Expand Down Expand Up @@ -75,6 +77,7 @@ const guiReducer = combineReducers({
monitorLayout: monitorLayoutReducer,
targets: targetReducer,
toolbox: toolboxReducer,
rubyCode: rubyCodeReducer,
vm: vmReducer
});

Expand Down
13 changes: 13 additions & 0 deletions src/reducers/ruby-code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const initialState = {
rubyCode: `p 'hello World'`
};

const reducer = function (state, action) {
if (typeof state === 'undefined') state = initialState;
return state;
};

export {
reducer as default,
initialState as rubyCodeInitialState
};