parent
2c40d239f0
commit
adc6a5175c
6 changed files with 80 additions and 94 deletions
@ -0,0 +1,48 @@ |
|||||||
|
import * as consoleFrames from '../console/frames'; |
||||||
|
import * as histories from '../content/histories'; |
||||||
|
import * as scrolls from '../content/scrolls'; |
||||||
|
import Follow from '../content/follow'; |
||||||
|
import actions from '../actions'; |
||||||
|
|
||||||
|
export default function reducer(state, action = {}) { |
||||||
|
switch (action.type) { |
||||||
|
case actions.CMD_OPEN: |
||||||
|
return consoleFrames.showCommand(''); |
||||||
|
case actions.CMD_TABS_OPEN: |
||||||
|
if (action.alter) { |
||||||
|
// alter url
|
||||||
|
return consoleFrames.showCommand('open ' + window.location.href); |
||||||
|
} else { |
||||||
|
return consoleFrames.showCommand('open '); |
||||||
|
} |
||||||
|
case actions.CMD_BUFFER: |
||||||
|
return consoleFrames.showCommand('buffer '); |
||||||
|
case actions.SCROLL_LINES: |
||||||
|
scrolls.scrollLines(window, action.count); |
||||||
|
break; |
||||||
|
case actions.SCROLL_PAGES: |
||||||
|
scrolls.scrollPages(window, action.count); |
||||||
|
break; |
||||||
|
case actions.SCROLL_TOP: |
||||||
|
scrolls.scrollTop(window); |
||||||
|
break; |
||||||
|
case actions.SCROLL_BOTTOM: |
||||||
|
scrolls.scrollBottom(window); |
||||||
|
break; |
||||||
|
case actions.SCROLL_LEFT: |
||||||
|
scrolls.scrollLeft(window); |
||||||
|
break; |
||||||
|
case actions.SCROLL_RIGHT: |
||||||
|
scrolls.scrollRight(window); |
||||||
|
break; |
||||||
|
case actions.FOLLOW_START: |
||||||
|
new Follow(window.document, action.newTab); |
||||||
|
break; |
||||||
|
case actions.HISTORY_PREV: |
||||||
|
histories.prev(window); |
||||||
|
break; |
||||||
|
case actions.HISTORY_NEXT: |
||||||
|
histories.next(window); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
@ -1,31 +0,0 @@ |
|||||||
export const CMD_OPEN = 'cmd.open'; |
|
||||||
export const CMD_TABS_OPEN = 'cmd.tabs.open'; |
|
||||||
export const CMD_BUFFER = 'cmd.buffer'; |
|
||||||
export const SCROLL_LINES = 'scroll.lines'; |
|
||||||
export const SCROLL_PAGES = 'scroll.pages'; |
|
||||||
export const SCROLL_TOP = 'scroll.top'; |
|
||||||
export const SCROLL_BOTTOM = 'scroll.bottom'; |
|
||||||
export const SCROLL_LEFT= 'scroll.left'; |
|
||||||
export const SCROLL_RIGHT= 'scroll.right'; |
|
||||||
export const FOLLOW_START = 'follow.start'; |
|
||||||
export const HISTORY_PREV = 'history.prev'; |
|
||||||
export const HISTORY_NEXT = 'history.next'; |
|
||||||
|
|
||||||
const CONTENT_ACTION_SET = new Set([ |
|
||||||
CMD_OPEN, |
|
||||||
CMD_TABS_OPEN, |
|
||||||
CMD_BUFFER, |
|
||||||
SCROLL_LINES, |
|
||||||
SCROLL_PAGES, |
|
||||||
SCROLL_TOP, |
|
||||||
SCROLL_BOTTOM, |
|
||||||
SCROLL_LEFT, |
|
||||||
SCROLL_RIGHT, |
|
||||||
FOLLOW_START, |
|
||||||
HISTORY_PREV, |
|
||||||
HISTORY_NEXT |
|
||||||
]); |
|
||||||
|
|
||||||
export const isContentAction = (action) => { |
|
||||||
return CONTENT_ACTION_SET.has(action); |
|
||||||
}; |
|
Reference in new issue