Ticket #7739: backspace-eia-708-2.patch

File backspace-eia-708-2.patch, 2.3 KB (added by Clayton Smith <argilo@…>, 14 years ago)

Another attempt at adding support for backspaces in EIA-708 closed captions

  • libs/libmythtv/cc708window.h

     
    119119
    120120    void AddChar(QChar);
    121121    void IncrPenLocation(void);
     122    void DecrPenLocation(void);
    122123    void SetPenLocation(uint, uint);
    123124    void LimitPenLocation(void);
    124125
  • libs/libmythtv/cc708window.cpp

     
    305305        return;
    306306    }
    307307
     308    if (ch.toAscii() == 0x08)
     309    {
     310        DecrPenLocation();
     311        GetCCChar().attr      = pen.attr;
     312        GetCCChar().character = QChar(' ');
     313        return;
     314    }
     315
    308316    GetCCChar().attr      = pen.attr;
    309317    GetCCChar().character = ch;
    310318    int c = pen.column;
     
    389397    LimitPenLocation();
    390398}
    391399
     400void CC708Window::DecrPenLocation(void)
     401{
     402    // TODO: Scroll direction and up/down printing,
     403    // and word wrap not handled yet...
     404    int new_column = pen.column, new_row = pen.row;
     405
     406    new_column -= (print_dir == k708DirLeftToRight) ? +1 : 0;
     407    new_column -= (print_dir == k708DirRightToLeft) ? -1 : 0;
     408    new_row    -= (print_dir == k708DirTopToBottom) ? +1 : 0;
     409    new_row    -= (print_dir == k708DirBottomToTop) ? -1 : 0;
     410
     411#if 0
     412    VERBOSE(VB_VBI, QString("DecrPen dir%1: (c %2, r %3) -> (%4,%5)")
     413            .arg(print_dir).arg(pen.column).arg(pen.row)
     414            .arg(new_column).arg(new_row));
     415#endif
     416
     417    if (k708DirLeftToRight == print_dir || k708DirRightToLeft == print_dir)
     418    {
     419        // basic wrapping for l->r, r->l languages
     420        if (!row_lock && column_lock && (new_column >= (int)true_column_count))
     421        {
     422            new_column  = 0;
     423            new_row    += 1;
     424        }
     425        else if (!row_lock && column_lock && (new_column < 0))
     426        {
     427            new_column  = (int)true_column_count - 1;
     428            new_row    -= 1;
     429        }
     430        Scroll(new_row, new_column);
     431    }
     432    else
     433    {
     434        pen.column = max(new_column, 0);
     435        pen.row    = max(new_row,    0);
     436    }
     437    // TODO implement other 2 scroll directions...
     438
     439    LimitPenLocation();
     440}
     441
    392442void CC708Window::SetPenLocation(uint row, uint column)
    393443{
    394444    Scroll(row, column);