<commit_before>/*
 * Copyright (c) 2017 Robert 'Bobby' Zenz
 * 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */

package org.bonsaimind.arbitrarylines;

import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;

/**
 * The {@link LinePainter} is the main class which does paint the lines.
 */
public class LinePainter implements PaintListener {
	/** The shared instance which should be used whenever possible. */
	public static final LinePainter INSTANCE = new LinePainter();
	
	/**
	 * Creates a new instance of {@link LinePainter}.
	 */
	public LinePainter() {
		super();
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public void paintControl(PaintEvent event) {
		if (event.getSource() instanceof StyledText) {
			StyledText styledText = (StyledText)event.getSource();
			
			// TODO Draw the lines here.
		}
	}
}<commit_msg>Added a simple test line at 80 columns.<commit_after>/*
 * Copyright (c) 2017 Robert 'Bobby' Zenz
 * 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */

package org.bonsaimind.arbitrarylines;

import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Rectangle;

/**
 * The {@link LinePainter} is the main class which does paint the lines.
 */
public class LinePainter implements PaintListener {
	/** The shared instance which should be used whenever possible. */
	public static final LinePainter INSTANCE = new LinePainter();
	
	/**
	 * Creates a new instance of {@link LinePainter}.
	 */
	public LinePainter() {
		super();
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public void paintControl(PaintEvent event) {
		if (event.getSource() instanceof StyledText) {
			StyledText styledText = (StyledText)event.getSource();
			
			int charWidth = event.gc.getAdvanceWidth('B');
			int linePosition = charWidth * 80;
			
			Rectangle clipping = event.gc.getClipping();
			
			if ((styledText.getHorizontalPixel() + clipping.x) <= linePosition
					&& (styledText.getHorizontalPixel() + clipping.x + clipping.width) >= linePosition) {
				
				event.gc.drawLine(
						linePosition - styledText.getHorizontalPixel(),
						clipping.y,
						linePosition - styledText.getHorizontalPixel(),
						clipping.y + clipping.height);
			}
			
			// TODO Draw the lines here.
		}
	}
}
{'fraction_non_alphanumeric': 0.10922855082912761, 'fraction_numerical': 0.007209805335255948, 'mean_word_length': 3.6954314720812182, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '5319521', 'n_tokens_mistral': 943, 'n_tokens_neox': 809, 'n_words': 247}