<commit_before>###
React component that describes a single cell
###

misc_page = require('../misc_page')

{React, ReactDOM, rclass, rtypes}  = require('../smc-react')

{Loading}    = require('../r_misc')

{CellInput}  = require('./cell-input')
{CellOutput} = require('./cell-output')

{CellTiming} = require('./cell-output-time')

exports.Cell = rclass
    propTypes :
        actions          : rtypes.object   # not defined = read only
        id               : rtypes.string.isRequired
        cm_options       : rtypes.object.isRequired
        cell             : rtypes.immutable.Map.isRequired
        is_current       : rtypes.bool
        is_selected      : rtypes.bool
        is_markdown_edit : rtypes.bool
        mode             : rtypes.string.isRequired    # the mode -- 'edit' or 'escape'
        font_size        : rtypes.number
        project_id       : rtypes.string
        directory        : rtypes.string
        complete         : rtypes.immutable.Map
        is_focused       : rtypes.bool
        more_output      : rtypes.immutable.Map   # if given, is info for *this* cell

    shouldComponentUpdate: (next) ->   # note: we assume project_id and directory don't change
        return next.id               != @props.id or \
               next.cm_options       != @props.cm_options or \
               next.cell             != @props.cell or \
               next.is_current       != @props.is_current or\
               next.is_selected      != @props.is_selected or \
               next.is_markdown_edit != @props.is_markdown_edit or \
               next.mode             != @props.mode or \
               next.font_size        != @props.font_size or \
               next.is_focused       != @props.is_focused or \
               next.more_output      != @props.more_output or \
               (next.complete        != @props.complete and (next.is_current or @props.is_current))  # only worry about complete when editing this cell

    render_cell_input: (cell) ->
        <CellInput
            key              = 'in'
            cell             = {cell}
            actions          = {@props.actions}
            cm_options       = {@props.cm_options}
            is_markdown_edit = {@props.is_markdown_edit}
            is_focused       = {@props.is_current and @props.mode == 'edit'}
            is_current       = {@props.is_current}
            id               = {@props.id}
            font_size        = {@props.font_size}
            project_id       = {@props.project_id}
            directory        = {@props.directory}
            complete         = {@props.complete if @props.is_current}
            />

    render_cell_output: (cell) ->
        <CellOutput
            key         = 'out'
            cell        = {cell}
            actions     = {@props.actions}
            id          = {@props.id}
            project_id  = {@props.project_id}
            directory   = {@props.directory}
            more_output = {@props.more_output}
            />

    render_time: (cell) ->
        if cell.get('start')?
            <div style={position:'relative', zIndex: 1, right: 0, width: '100%', paddingLeft:'5px'}, className='pull-right'>
                <div style={color:'#999', fontSize:'8pt', position:'absolute', right:'5px', lineHeight: 1.25, top: '1px', textAlign:'right'}>
                    <CellTiming
                        start = {cell.get('start')}
                        end   = {cell.get('end')}
                        state = {cell.get('state')}
                     />
                </div>
            </div>

    click_on_cell: (event) ->
        if not @props.actions?
            return
        if event.shiftKey
            misc_page.clear_selection()
            @props.actions.select_cell_range(@props.id)<commit_msg>make it so shift click in edit mode does not clear selection<commit_after>###
React component that describes a single cell
###

misc_page = require('../misc_page')

{React, ReactDOM, rclass, rtypes}  = require('../smc-react')

{Loading}    = require('../r_misc')

{CellInput}  = require('./cell-input')
{CellOutput} = require('./cell-output')

{CellTiming} = require('./cell-output-time')

exports.Cell = rclass
    propTypes :
        actions          : rtypes.object   # not defined = read only
        id               : rtypes.string.isRequired
        cm_options       : rtypes.object.isRequired
        cell             : rtypes.immutable.Map.isRequired
        is_current       : rtypes.bool
        is_selected      : rtypes.bool
        is_markdown_edit : rtypes.bool
        mode             : rtypes.string.isRequired    # the mode -- 'edit' or 'escape'
        font_size        : rtypes.number
        project_id       : rtypes.string
        directory        : rtypes.string
        complete         : rtypes.immutable.Map
        is_focused       : rtypes.bool
        more_output      : rtypes.immutable.Map   # if given, is info for *this* cell

    shouldComponentUpdate: (next) ->   # note: we assume project_id and directory don't change
        return next.id               != @props.id or \
               next.cm_options       != @props.cm_options or \
               next.cell             != @props.cell or \
               next.is_current       != @props.is_current or\
               next.is_selected      != @props.is_selected or \
               next.is_markdown_edit != @props.is_markdown_edit or \
               next.mode             != @props.mode or \
               next.font_size        != @props.font_size or \
               next.is_focused       != @props.is_focused or \
               next.more_output      != @props.more_output or \
               (next.complete        != @props.complete and (next.is_current or @props.is_current))  # only worry about complete when editing this cell

    render_cell_input: (cell) ->
        <CellInput
            key              = 'in'
            cell             = {cell}
            actions          = {@props.actions}
            cm_options       = {@props.cm_options}
            is_markdown_edit = {@props.is_markdown_edit}
            is_focused       = {@props.is_current and @props.mode == 'edit'}
            is_current       = {@props.is_current}
            id               = {@props.id}
            font_size        = {@props.font_size}
            project_id       = {@props.project_id}
            directory        = {@props.directory}
            complete         = {@props.complete if @props.is_current}
            />

    render_cell_output: (cell) ->
        <CellOutput
            key         = 'out'
            cell        = {cell}
            actions     = {@props.actions}
            id          = {@props.id}
            project_id  = {@props.project_id}
            directory   = {@props.directory}
            more_output = {@props.more_output}
            />

    render_time: (cell) ->
        if cell.get('start')?
            <div style={position:'relative', zIndex: 1, right: 0, width: '100%', paddingLeft:'5px'}, className='pull-right'>
                <div style={color:'#999', fontSize:'8pt', position:'absolute', right:'5px', lineHeight: 1.25, top: '1px', textAlign:'right'}>
                    <CellTiming
                        start = {cell.get('start')}
                        end   = {cell.get('end')}
                        state = {cell.get('state')}
                     />
                </div>
            </div>

    click_on_cell: (event) ->
        if not @props.actions?
            return
        if event.shiftKey and not @props.is_current
            misc_page.clear_selection()
            @props.actions.select_cell_range(@props.id)
{'fraction_non_alphanumeric': 0.11387622149837133, 'fraction_numerical': 0.003908794788273616, 'mean_word_length': 1.4777275661717237, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2865388', 'n_tokens_mistral': 2148, 'n_tokens_neox': 2088, 'n_words': 447}