<commit_before>class Drawable extends Sprite{
  static var DRAGMODE=0;
  static var DRAWMODE=1;
  static var ERASEMODE=2;
  var mMode:Number;
  var mSelectBox:Sprite;
  var mMouseCount;
  function Drawable(parent:MovieClip,layer:Number) {
     super(parent,layer);
     this.mMode=DRAWMODE;
     //this.mMode=DRAGMODE;
     //this.mMode=ERASEMODE;
  }
  function _mouseFunction(boxColor:Number) {
         mSelectBox.clear();
         var worldPos=new Point(_root._xmouse,_root._ymouse);
         mSelectBox.drawBoxOutline(mSelectBox.localToWorld(new Point(0,0)),
                                   new Point(_root._xmouse,_root._ymouse),
                                   1,
                                   boxColor,
                                   100,
                                   boxColor,
                                   25);
  }
  function commitBox(topLeft:Point, botRight:Point, doErase:Boolean) {
    if (doErase) {
      drawBoxOutline(topLeft,botRight,
                                     1,
                                     0xffffff,
                                     0,
                                     0xffffff,
                                     100);
    }else {
      drawBoxOutline(topLeft,botRight,
                                     1,
                                     0xffffff,
                                     0,
                                     0x00ffff,
                                     25);
    }
  }
  function onPress():Void {
     if (this.mMode==DRAGMODE) {
         mSurface.startDrag(false,-16384,-16384,16384,16834);
         var lobe=this;
         mSurface.onMouseUp=function()
         {
            lobe.mSurface.onMouseUp=function(){};
            lobe.mSurface.stopDrag();
         }
     }else if (this.mMode==DRAWMODE||this.mMode==ERASEMODE) {
         var mousePos=new Point(_root._xmouse,_root._ymouse)
         mSelectBox=new Sprite(mSurface,mSurface.getNextHighestDepth());
         var localMousePos=worldToLocal(mousePos);
         mSelectBox.setPosition(localMousePos);
         mSelectBox.penTo(mousePos);
         var lobe=this;
         var doErase=(this.mMode==ERASEMODE);
         var tempBoxColor=0x0000ff;
         if (doErase) {
            this.mMode=DRAWMODE;///<-- FIXME: this alternates between draw and erase modes until we have global selection process
            tempBoxColor=0xff0000;
         }else { 
            this.mMode=ERASEMODE;
         }
         mSurface.onMouseMove=function(){lobe._mouseFunction(tempBoxColor);};
         mSurface.onMouseUp=function()
         {
            lobe.mSurface.onMouseUp=function(){};
            lobe.mSurface.onMouseMove=function(){};
            lobe.commitBox(lobe.localToWorld(lobe.mSelectBox.getPosition()),new Point(_root._xmouse,_root._ymouse),doErase);
            lobe.mSelectBox.remove();
            lobe.mSelectBox=null;
         }
     }
  }
  function onRelease():Void {
  }
}<commit_msg>Made mode be static so that the current drawing mode is a global idea rather than a per-drawable idea.<commit_after>class Drawable extends Sprite{
  static var DRAGMODE=0;
  static var DRAWMODE=1;
  static var ERASEMODE=2;
  static var mMode:Number;
  var mSelectBox:Sprite;
  var mMouseCount;
  function Drawable(parent:MovieClip,layer:Number) {
     super(parent,layer);
     mMode=DRAWMODE;
     //mMode=DRAGMODE;
     //mMode=ERASEMODE;
  }
  function _mouseFunction(boxColor:Number) {
         mSelectBox.clear();
         var worldPos=new Point(_root._xmouse,_root._ymouse);
         mSelectBox.drawBoxOutline(mSelectBox.localToWorld(new Point(0,0)),
                                   new Point(_root._xmouse,_root._ymouse),
                                   1,
                                   boxColor,
                                   100,
                                   boxColor,
                                   25);
  }
  function commitBox(topLeft:Point, botRight:Point, doErase:Boolean) {
    if (doErase) {
    ///FIXME we probably want to call refresh and redraw everything so that a doughnut with a hole in the middle isn't actually a round bread with a painted white in the middle
      drawBoxOutline(topLeft,botRight,
                                     1,
                                     0xffffff,
                                     0,
                                     0xffffff,
                                     100);
    }else {
      drawBoxOutline(topLeft,botRight,
                                     1,
                                     0xffffff,
                                     0,
                                     0x00ffff,
                                     25);
    }
  }
  function onPress():Void {
     if (mMode==DRAGMODE) {
         mSurface.startDrag(false,-16384,-16384,16384,16834);
         var lobe=this;
         mSurface.onMouseUp=function()
         {
            lobe.mSurface.onMouseUp=function(){};
            lobe.mSurface.stopDrag();
         }
     }else if (mMode==DRAWMODE||mMode==ERASEMODE) {
         var mousePos=new Point(_root._xmouse,_root._ymouse)
         mSelectBox=new Sprite(mSurface,mSurface.getNextHighestDepth());
         var localMousePos=worldToLocal(mousePos);
         mSelectBox.setPosition(localMousePos);
         mSelectBox.penTo(mousePos);
         var lobe=this;
         var doErase=(mMode==ERASEMODE);
         var tempBoxColor=0x0000ff;
         if (doErase) {
            mMode=DRAWMODE;///<-- FIXME: this alternates between draw and erase modes until we have global selection process
            tempBoxColor=0xff0000;
         }else { 
            mMode=ERASEMODE;
         }
         mSurface.onMouseMove=function(){lobe._mouseFunction(tempBoxColor);};
         mSurface.onMouseUp=function()
         {
            lobe.mSurface.onMouseUp=function(){};
            lobe.mSurface.onMouseMove=function(){};
            lobe.commitBox(lobe.localToWorld(lobe.mSelectBox.getPosition()),new Point(_root._xmouse,_root._ymouse),doErase);
            lobe.mSelectBox.remove();
            lobe.mSelectBox=null;
         }
     }
  }
  function onRelease():Void {
  }
}
{'fraction_non_alphanumeric': 0.09299674267100977, 'fraction_numerical': 0.018241042345276872, 'mean_word_length': 1.5188679245283019, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 32, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4404001', 'n_tokens_mistral': 1794, 'n_tokens_neox': 1719, 'n_words': 285}