<commit_before>// -*- coding: us-ascii-unix -*-
// Copyright 2013 <NAME>
//
// Licensed under the Apache License, Version 2.0 (the "License"); you
// may not use this file except in compliance with the License. You
// may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.

#include <sstream>
#include "app/app-context.hh"
#include "app/canvas.hh"
#include "python/mapped-type.hh"
#include "python/py-add-type-object.hh"
#include "python/py-include.hh"
#include "python/py-grid.hh"
#include "python/py-ugly-forward.hh"
#include "util/grid.hh"
#include "util/optional.hh"

namespace faint{

Canvas& CanvasGrid::GetCanvas() const{
  return targetActive ?
    ctx.app.GetActiveCanvas() : ctx.app.GetCanvas(canvasId);
}

Grid CanvasGrid::GetGrid() const{
  return GetCanvas().GetGrid();
}

void CanvasGrid::SetGrid(const Grid& g) const{
  Canvas& c = GetCanvas();
  c.SetGrid(g);
  ctx.py.QueueRefresh(c);
}

extern PyTypeObject GridType;

struct gridObject {
  // Fixme: Move into impl..
  PyObject_HEAD
  PyFuncContext* ctx;
  bool targetActive;
  CanvasId canvasId;
};

static bool grid_ok_no_error(gridObject* self){
  if (self->targetActive){
    // The grid for the active canvas is the target, there should always be
    // at least one canvas.<commit_msg>Removed outdated fixme.<commit_after>// -*- coding: us-ascii-unix -*-
// Copyright 2013 <NAME>
//
// Licensed under the Apache License, Version 2.0 (the "License"); you
// may not use this file except in compliance with the License. You
// may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.

#include <sstream>
#include "app/app-context.hh"
#include "app/canvas.hh"
#include "python/mapped-type.hh"
#include "python/py-add-type-object.hh"
#include "python/py-include.hh"
#include "python/py-grid.hh"
#include "python/py-ugly-forward.hh"
#include "util/grid.hh"
#include "util/optional.hh"

namespace faint{

Canvas& CanvasGrid::GetCanvas() const{
  return targetActive ?
    ctx.app.GetActiveCanvas() : ctx.app.GetCanvas(canvasId);
}

Grid CanvasGrid::GetGrid() const{
  return GetCanvas().GetGrid();
}

void CanvasGrid::SetGrid(const Grid& g) const{
  Canvas& c = GetCanvas();
  c.SetGrid(g);
  ctx.py.QueueRefresh(c);
}

extern PyTypeObject GridType;

struct gridObject {
  PyObject_HEAD
  PyFuncContext* ctx;
  bool targetActive;
  CanvasId canvasId;
};

static bool grid_ok_no_error(gridObject* self){
  if (self->targetActive){
    // The grid for the active canvas is the target, there should always be
    // at least one canvas.
{'fraction_non_alphanumeric': 0.1253507951356408, 'fraction_numerical': 0.004989086373557842, 'mean_word_length': 3.989113530326594, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6915610', 'n_tokens_mistral': 1005, 'n_tokens_neox': 987, 'n_words': 331}