Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
neoe committed Aug 10, 2023
1 parent 64cdf54 commit 798e0df
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 23 deletions.
Binary file modified dist/neoeedit.jar
Binary file not shown.
13 changes: 6 additions & 7 deletions src/neoe/ne/Console.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ public class Console {
private EditorPanel parentUI ;
private File dir ;

public Console ( String cmd , OutputStream out , InputStream stdout ,
InputStream stderr , Process proc , EditorPanel uiComp ,
File dir ) {
public Console ( String cmd , OutputStream out , InputStream stdout , InputStream stderr , Process proc ,
EditorPanel uiComp , File dir , boolean follow ) {
this . cmd = cmd ;
this . out = out ;
this . stdout = stdout ;
this . stderr = stderr ;
this . proc = proc ;
this . parentUI = uiComp ;
this . dir = dir ;
this . follow = follow ;
}

public void start ( ) throws Exception {
Expand All @@ -53,11 +53,10 @@ public void start ( ) throws Exception {
new Thread ( ( ) -> {
try {
proc . waitFor ( ) ;
pp . pageData . editRec . appendLines ( Arrays . asList (
String . format ( "\nExit(%s) in about %,d ms for\n%s" , proc . exitValue ( ) ,
System . currentTimeMillis ( ) - t1 , id ) . split ( "\n" ) ) ) ;
pp . pageData . editRec . appendLines ( Arrays . asList ( String . format ( "\nExit(%s) in about %,d ms for\n%s" ,
proc . exitValue ( ) , System . currentTimeMillis ( ) - t1 , id ) . split ( "\n" ) ) ) ;
pp . pageData . editRec . appendLine ( "" ) ;
pp . cursor . setSafePos ( 0 , Integer . MAX_VALUE ) ; //go last line
pp . cursor . setSafePos ( 0 , Integer . MAX_VALUE ) ; // go last line
finished = true ;
pp . adjustCursor ( ) ;
pp . uiComp . repaint ( ) ;
Expand Down
33 changes: 21 additions & 12 deletions src/neoe/ne/PlainPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,14 @@ private static boolean isButtonDown ( int i , MouseEvent evt ) {

int selectstartx , selectstarty , selectstopx , selectstopy ;

int showLineCnt ;
int showLineCnt , showLineCnt2 ;
int sx , sy ;

int toolbarHeight = 25 ;

public Paint ui = new Paint ( ) ;
public EditorPanel uiComp ;
boolean follow ;

private PlainPage ( ) {
}
Expand All @@ -98,6 +99,7 @@ public PlainPage ( EditorPanel editor , PageData data , PlainPage parent ) throw
fontList = Conf . defaultFontList ;
workPath = parent . workPath ;
showLineCnt = parent . showLineCnt ;
follow = parent . follow ;
if ( parent . env != null )
env = new LinkedHashMap < > ( parent . env ) ;
} else
Expand Down Expand Up @@ -221,11 +223,11 @@ public void doMoveViewUp ( ) {
}

public void doMoveViewPageDown ( ) {
sy = Math . min ( sy + showLineCnt , pageData . roLines . getLinesize ( ) - 1 ) ;
sy = Math . min ( sy + showLineCnt2 , pageData . roLines . getLinesize ( ) - 1 ) ;
}

public void doMoveViewPageUp ( ) {
sy = Math . max ( 0 , sy - showLineCnt ) ;
sy = Math . max ( 0 , sy - showLineCnt2 ) ;
}

/* let cursor get see */
Expand All @@ -235,10 +237,13 @@ public void focusCursor ( ) {

/** change cursor to middle of page */
public void adjustCursor ( ) {
if ( showLineCnt == 0 ) { // not yet painted, \
showLineCnt = Math
. round ( ( uiComp . getSize ( ) . height - toolbarHeight ) / ( ( ui . lineHeight + ui . lineGap ) * ui . scalev ) ) ; // not
// work?
if ( showLineCnt == 0 ) { // not yet painted,
showLineCnt = ( int ) Math
. ceil ( ( uiComp . getSize ( ) . height - toolbarHeight ) / ( ( ui . lineHeight + ui . lineGap ) * ui . scalev ) ) ;
showLineCnt2 = ( int ) Math
. floor ( ( uiComp . getSize ( ) . height - toolbarHeight ) / ( ( ui . lineHeight + ui . lineGap ) * ui . scalev ) ) ;
if ( showLineCnt2 <= 0 )
showLineCnt2 = 1 ;
}
int sc = Math . max ( 5 , showLineCnt ) ;
sy = Math . max ( 0 , cy - sc / 2 + 1 ) ;
Expand Down Expand Up @@ -553,6 +558,7 @@ void processCommand ( Commands cmd ) throws Exception {
case toggleFollowExec :
if ( console != null ) {
console . follow = ! console . follow ;
follow = console . follow ;
ui . message ( "follow the console:" + console . follow ) ;
}
break ;
Expand Down Expand Up @@ -1953,7 +1959,10 @@ public void run ( ) {
}

// g2.setFont(font);
showLineCnt = Math . round ( ( size . height - toolbarHeight ) / ( ( lineHeight + lineGap ) * scalev ) ) ;
showLineCnt = ( int ) Math . ceil ( ( size . height - toolbarHeight ) / ( ( lineHeight + lineGap ) * scalev ) ) ;
showLineCnt2 = ( int ) Math . floor ( ( size . height - toolbarHeight ) / ( ( lineHeight + lineGap ) * scalev ) ) ;
if ( showLineCnt2 <= 0 )
showLineCnt2 = 1 ;
final int maxw = dim . width - gutterWidth ;
final int maxw2 = ( int ) ( maxw / scalev ) ;
{ // change cy if needed
Expand All @@ -1978,8 +1987,9 @@ public void run ( ) {
drawGutter ( g2 ) ;
g2 . scale ( scalev , scalev ) ;
// draw text
g2 . translate ( gutterWidth / scalev , 0 ) ;
g2 . setClip ( 0 , 0 , maxw2 , ( int ) ( dim . height / scalev ) ) ;
int gws = ( int ) ( gutterWidth / scalev ) ;
g2 . translate ( gws , 0 ) ;
g2 . setClip ( - gws , 0 , maxw2 + gws , ( int ) ( dim . height / scalev ) ) ;

Graphics2D g0 = ( Graphics2D ) g2 . create ( ) ;
g0 . setClip ( 0 , 0 , 0 , 0 ) ; // quick hack to not do real draw
Expand All @@ -2001,8 +2011,7 @@ public void run ( ) {
cy = sy + my / ( lineHeight + lineGap ) ;
if ( cy >= pageData . roLines . getLinesize ( ) ) {
// add a empty line for sake
if ( ! readonly && pageData . roLines . getline ( pageData . roLines . getLinesize ( ) - 1 )
. length ( ) > 0 ) {
if ( ! readonly && pageData . roLines . getline ( pageData . roLines . getLinesize ( ) - 1 ) . length ( ) > 0 ) {
pageData . editRec . insertEmptyLine ( cy ) ;
}
cy = pageData . roLines . getLinesize ( ) - 1 ;
Expand Down
5 changes: 2 additions & 3 deletions src/neoe/ne/U.java
Original file line number Diff line number Diff line change
Expand Up @@ -803,8 +803,7 @@ public static void exec ( PlainPage pp , String cmd ) throws Exception {
PageData . fromTitle ( String . format ( "[cmd][%s] %s #%s" , dir . getAbsolutePath ( ) , cmd , U . randomID ( ) ) ) , pp ) ;
pp2 . workPath = dir . getAbsolutePath ( ) ;
pp2 . ptSelection . selectAll ( ) ;

new Console ( cmd , out , stdout , stderr , proc , pp . uiComp , dir ) . start ( ) ;
new Console ( cmd , out , stdout , stderr , proc , pp . uiComp , dir , pp . follow ) . start ( ) ;
}

private static void addCmdHistory ( String cmd , String path ) throws IOException {
Expand Down Expand Up @@ -1106,7 +1105,7 @@ private static String guessByBOM ( byte [ ] src ) {

static void guessComment ( PlainPage page ) {
List < String > comment = new ArrayList < String > ( ) ;
String [ ] commentchars = { "/*" , "<!--" , "#" , "%" , "//" , "!" , ";" , "--" , } ;
String [ ] commentchars = { "/*" , "<!--" , "#" , "%" , "//" , "! " , "; " , "--" , } ;
int [ ] cnts = new int [ commentchars . length ] ;
int maxLines = Math . min ( 1000 , page . pageData . roLines . getLinesize ( ) ) ;
for ( int i = 0 ; i < maxLines ; i ++ ) {
Expand Down
2 changes: 1 addition & 1 deletion src/neoe/ne/Version.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package neoe . ne ;

public class Version {
public static final String REV = "v383" . toString ( ) ; // β
public static final String REV = "v384rc4" . toString ( ) ; // β
public static final String CONFIG_FN = "/data.py.ver42" . toString ( ) ;
}

0 comments on commit 798e0df

Please sign in to comment.