Author Topic: Color active tab text in bufftabs.e  (Read 1734 times)

MindprisM

  • Senior Community Member
  • Posts: 127
  • Hero Points: 8
Color active tab text in bufftabs.e
« on: June 29, 2013, 04:06:35 am »
SlickEdit 2012 (v17.0.3.0 64-bit)

I do not know about your installation, but on mine the only way to see which tab is active is to look for the one that is dropped down by 2 pixels. This suboptimal situation compelled me to dig into bufftabs.e with the naive hope that it would "only be a couple of lines". Right??

Took about an hour and a half, but well worth it in my book. So here is the function and the tie-ins... all code goes in bufftabs.e...


Code: [Select]
static int color_active(CTL_SSTAB sstabwid){
  tabs_data* ptabsdata = sstabwid.getFileTabsData();
  ptabsdata->change_refresh = true;
  _str c=_default_color(CFG_MODIFIED_FILE_TAB);
  typeless mc;
  parse c with mc .;
  int at=sstabwid.p_ActiveTab;
  for (x:=0;x<ptabsdata->tab_order._length();x++) {
    sstabwid.p_ActiveTab = x;
     tabs_t *ptab = &ptabsdata->buffid_order[ptabsdata->tab_order[x]];
     if (isTabDataNull(*ptab)) continue;
     if (ptab->modified && ((substr(ptab->buffname,1,1)) != '.')) {
       if (_mdi.p_child) {
         if (_mdi.p_child.p_buf_name==ptab->buffname) {
           sstabwid.p_ActiveColor = 0x000066FF;//orange
         }else{
           sstabwid.p_ActiveColor = mc;//default
         }
       }
     } else {
       if (_mdi.p_child) {
         if (_mdi.p_child.p_buf_name==ptab->buffname) {
           sstabwid.p_ActiveColor = 0x0000FFAA;//yellowish
         }else{
            sstabwid.p_ActiveColor = 0x80000008;//system default
         }
       }
     }
  }
  sstabwid.p_ActiveTab=at;
  ptabsdata->change_refresh = false;
  return 0;
}

Tie-in #1 in: void ctlsstab1.on_change(int reason, int arg1 = 0, int arg2 = 0)
Code: [Select]
         int status = edit('+Q +BI ' :+ (ptabsdata->tab_order[p_ActiveTab]),EDIT_DEFAULT_FLAGS|EDIT_NOEXITSCROLL);
         if (status) {
            sstabWid.tab_refresh();
         }
         //m.c.r+ HERE!
         color_active(sstabWid);
         //m.c.r-

Tie-in #2 in:  void _update_mod_file_status()
Code: [Select]
      if (orig_view_id != "") {
         for (x = 0; x<ptabsdata->tab_order._length(); ++x) {
            p_buf_id = ptabsdata->tab_order[x];
            _update_modified(sstabwid, x);
         }
         p_buf_id = orig_buf_id;
         //m.c.r+  HERE!!
         color_active(sstabwid);
         //m.c.r-
      }


Change the colors to suit. You should see yellow for active tab, but orange when active tab is modified, and the default (usually red) when non-active modified.

Let me know if there are any issues.