R/anRpackage-internal.R

Defines functions .rgedit.lastline2clipboard

.Random.seed <-
c(403L, 386L, -1557724240L, 1793248573L, -1304006625L, 1943691685L, 
-1057263302L, 1106609429L, -2116790104L, -193588224L, -1238455458L, 
-1830233908L, -1749938298L, -641175617L, 603687729L, -1505521318L, 
-2079011293L, 1604716111L, 1081785599L, -689022485L, 1610950231L, 
-2094141673L, -155399097L, 1818463025L, 874465900L, -1162041733L, 
697418026L, -752676940L, 116074702L, 671362871L, -849835026L, 
245261898L, -1064738460L, -1318058559L, -669441739L, 1767585755L, 
-633928797L, 385085759L, -261902939L, 2069689325L, 1712226900L, 
1997325582L, 1847218141L, -1403076149L, -1223851799L, 66220900L, 
2144239645L, 1850372374L, 579722322L, -926262244L, 1383340713L, 
442824231L, -184258497L, -868846934L, 2053140720L, 1869973616L, 
841655619L, 1409298452L, -482896681L, 1282917874L, 256008804L, 
1535515434L, -92091840L, 471804395L, 1789822336L, -2109319419L, 
302668340L, 472937112L, 213039990L, -176605051L, 631332196L, 
-1449634260L, 683955832L, -866667275L, -1355509174L, -331512361L, 
-44097603L, -1502857277L, 1425548387L, -220527226L, -1147169516L, 
1714782430L, 1082411168L, 1301220178L, -1582152890L, 2129912382L, 
1609045797L, 327451454L, -93811080L, -1212586109L, 229318613L, 
1049837354L, -874375916L, -1508920436L, 1610085231L, 497016867L, 
-603798789L, -2089886944L, 428002730L, 1829581810L, 1119628937L, 
-2065299315L, -1423515623L, 894736281L, 385838228L, -1448869283L, 
-739868498L, -281078756L, -1475633381L, 466287492L, -2111576629L, 
885231541L, -2112377412L, 1878799443L, -1805034217L, 147298866L, 
-1290934953L, 54620070L, 746931534L, 565328583L, 1411771547L, 
1644646578L, 1055975137L, -1610982825L, 536343706L, -972544988L, 
-1357119655L, 799653184L, 1320760433L, -230265335L, -574439048L, 
318182013L, 576276085L, 1714539973L, 854634549L, 192092999L, 
1657602049L, 215562510L, 1788697253L, -842742289L, -481387753L, 
-1643691729L, 112547680L, 1650660100L, 939806907L, -1273665055L, 
-106972173L, 11894824L, 2016532359L, 1931269155L, -272058485L, 
-1986645689L, -746425665L, 1228906259L, -1154073153L, 730529519L, 
-1446574103L, 116926074L, 1603975672L, 1452552195L, -1726865933L, 
-1745457540L, 182226036L, 418640911L, 660488797L, 1526045577L, 
-1375126300L, 803269951L, -1747156564L, -46388270L, 1472510212L, 
1260274673L, -1378585176L, 199142030L, 1827073882L, -2111410830L, 
1735167515L, -612941686L, 1063050321L, -553108202L, 1103544168L, 
2132085400L, 413611759L, -922779174L, -1627453391L, 1627592858L, 
1023845556L, -976652133L, -1634132986L, 1652052132L, -197611160L, 
-2139869615L, 1256854660L, 1393889070L, -1859745190L, 723007639L, 
90949510L, 1901331077L, -2111468550L, 1257702790L, 1931019206L, 
1347754163L, 1514085299L, -1533987420L, 1357929271L, -1833654153L, 
2012527225L, -1041906055L, -1069083399L, 1012367880L, -396019746L, 
-1535462240L, -1799461907L, -1498304959L, 1182323461L, -2098972912L, 
2047734789L, 1054193492L, 261433004L, 1313555707L, 405506562L, 
-1939612380L, 104462583L, 1516158706L, -2098452322L, 1672193380L, 
340399392L, 707085103L, -1058236688L, 1207656325L, 175225009L, 
1166579578L, 1380917842L, -828196015L, 1258250583L, 848802562L, 
235181153L, -1151023304L, -463204049L, -2004406583L, -1277269744L, 
-963762386L, -666436388L, -1861235777L, -942470472L, -107953828L, 
1532969899L, 1801860502L, 1074055524L, 1303499891L, -949961563L, 
1255421267L, 908361950L, 742967943L, -687829626L, -2002696586L, 
1640602163L, -2052894048L, 1698275589L, 1648381827L, 845623049L, 
-1137287318L, -1248794012L, -2001834890L, -850567627L, -2046429029L, 
1548627495L, 794552771L, 165816776L, -532963652L, -384068704L, 
-621613034L, -697464141L, -352767219L, -62997053L, 1646425652L, 
-1762384908L, 2039098818L, -721096660L, -1733354429L, -196619708L, 
-1297473669L, -2073502102L, 1218736523L, -192641892L, -1878839665L, 
-1121301893L, 795108502L, 1174011245L, -2064584546L, -995479954L, 
-248516674L, 290213765L, -1330337995L, 208629544L, -1568143878L, 
1187144290L, -1149172567L, -1942291840L, 413611265L, -58834149L, 
-1880017239L, 106988764L, 279723739L, 2040643441L, -422922497L, 
-568440138L, -1409499310L, -888916890L, 1337760189L, -1897743028L, 
-1173940923L, 1372033010L, -1992794587L, -1895759725L, -1350599016L, 
1049886845L, 551754804L, -564940725L, 467019329L, -829915031L, 
-641394333L, 1483840834L, -884290945L, -1853331674L, 1357514979L, 
-1476360414L, -12564434L, -1897783864L, 87012156L, -1555324643L, 
-384432511L, 537144520L, 1525476991L, -117512174L, 655156758L, 
2022294175L, 2062259344L, -901697846L, 559702966L, -914448195L, 
2112798778L, 2004742371L, -1781999751L, 134165790L, 93899851L, 
-782940000L, 1197326431L, 1874355361L, 2040132139L, -319659209L, 
1203512286L, -1561784935L, 1513716645L, 1794979943L, 1834756204L, 
-346799166L, 278847532L, -2016065733L, -1567033496L, 469257295L, 
1678519533L, -1552661200L, -1324221222L, -2067152738L, 849139231L, 
226715260L, -476602134L, 1669153062L, -176006111L, -743704948L, 
564257042L, -1597418041L, -1041043529L, 1494618455L, -1584098696L, 
1099649361L, 1076241341L, 759415263L, -662566620L, 1597499710L, 
279509499L, -962071777L, 62962473L, -866806353L, -267975367L, 
-66690878L, -136407050L, 797440769L, -1319576856L, -565036239L, 
-976449767L, -1868406297L, -1148516721L, -1986428537L, -423495403L, 
207301021L, 774324838L, -2090373523L, 1685271309L, 1784748336L, 
-6434272L, 1841959732L, 119554765L, 1377910242L, 173966457L, 
198515123L, -1455759718L, 935651379L, -1384640502L, -603138975L, 
2071765078L, 837777603L, -269561483L, 1170169559L, -954022104L, 
-1403342795L, -1051161840L, -166617741L, 281308624L, -900408084L, 
-604526307L, 1891740252L, 807386666L, -1129250380L, -316291142L, 
-246861949L, -537110402L, 1268848339L, 197167193L, 1987780169L, 
1231462231L, -478390644L, 186998991L, -2071719645L, -50348006L, 
1077663025L, -660738878L, 927101216L, -1467826153L, -823841570L, 
246384489L, -214225988L, -1818486869L, 617196629L, -1144062914L, 
597564268L, 1065628966L, -876049459L, -2107328243L, -35446784L, 
2064900661L, 802134326L, 16218514L, 2021626094L, -206624141L, 
-1714896160L, -1268904888L, -697939033L, 560149296L, 1063988984L, 
1906442309L, 538364169L, -1562849527L, -2061946037L, -1548575553L, 
1370274651L, 506103847L, 729610522L, -246681190L, -1400024031L, 
-559991474L, 974125130L, 2135845789L, 760427228L, 168391121L, 
-131160229L, -599040800L, -395978273L, -1865615829L, -799557888L, 
685278708L, -353482815L, -830762552L, -580218804L, 1394310707L, 
871818873L, 269221218L, -404649576L, -1834017765L, 319855047L, 
-840704767L, -630866719L, 1804068017L, -1647666092L, -1566684940L, 
1445459357L, 1242704561L, 677358447L, -300377216L, -967076222L, 
1520485691L, 1486152466L, 1716586172L, -955805951L, -294294714L, 
222496585L, 479239602L, 1790681282L, -1340785384L, 751539882L, 
1090464823L, -690323630L, 424250825L, 1945824357L, 76886970L, 
1053681810L, -1387676620L, 218721946L, -686476396L, 1358809054L, 
425774749L, 2093189004L, 1096675298L, 1608433632L, -830129850L, 
582697186L, -1478209618L, 364119318L, -163459815L, -1844661997L, 
-1639515418L, 1020743656L, -1714131113L, -1047934366L, 1226280035L, 
2033331942L, 338114330L, -2028078654L, 1360051820L, 1687896095L, 
598200590L, -1259191240L, 1455097382L, -1301837965L, -1513776129L, 
1004142737L, 386042493L, -743479988L, -578708391L, 1437923559L, 
1409598622L, 1673508939L, 381647825L, 1121065068L, -974874046L, 
-1187089510L, 1139403751L, -2041284500L, 1870634062L, 1877625521L, 
936380475L, 1316204764L, 224406166L, 2008115105L, 1417183505L, 
-818221552L, -1121804965L, -1524029353L, -2124775045L, 1203470247L, 
1793017906L, -256665769L, -1614116252L, -224465150L, 303217963L, 
137475925L, -1408811104L, -165809434L, 629521036L, -855016034L, 
1941163622L, 1769142442L, 1253127598L, 1608338281L, 1860856634L, 
1647868741L, -547144663L, 951664915L, -1044027267L, 1031077540L, 
-1741292504L, -1661379946L, 271383892L, -264680590L, -709998644L, 
539710931L, 1028226497L, 225423581L, 1002084025L, -1401011451L, 
602687757L, -1355235224L, 1674903740L, -873284207L, -736202384L, 
-526814739L, 1910163578L, 1615583704L, 2011948505L, 1177292950L, 
2035914661L, -451053439L, -1722864784L, 1080847481L, -1708165809L, 
1665756230L, 233529221L, -2034589237L, -651817547L, 2035230513L, 
1182805386L, -2109453882L, -1178296945L, 1902659828L, -1829441611L
)
.rgedit.lastline2clipboard <-
function( clipboard.command = "xclip" ) 
{
  # The possible clipboard commands:
  clipboard.commands <- c( "xclip", "xsel", "pbcopy" );
  # The correct command line depending on the option used:
  pipe.commands <- c( "xclip -i -selection clipboard", "xsel --clipboard", "pbcopy" );
  names(pipe.commands) <- clipboard.commands;

  # Try to detect which clipboard commands are installed in the system:
  available.clipboard.commands <- c( FALSE, FALSE, FALSE ); names(available.clipboard.commands) <- clipboard.commands;
  for( i in 1:length(available.clipboard.commands) )
  {
    available.clipboard.commands[i] <- length(system( paste( "command -v ", names(available.clipboard.commands)[i], sep=""), intern=TRUE )) > 0;
  } 
  if( sum(available.clipboard.commands) == 0 )
  {
    stop( "No cpliboard manipulation programs installed on your machine! Please install xclip or xsel (on *nix) and pbcopy (on MacOSX)!\n" );
  }

  # Try to satisfly the user's preference:
  if( sum(clipboard.command == names(pipe.commands)) == 0 )
  {
    # Unknown clipboard command: print a warning and try your best:
    cat( "Warning: unknown option ", clipboard.command );
    clipboard.command = (names(available.clipboard.commands)[available.clipboard.commands])[1];
    cat( " -- using ", clipboard.command, " instead...\n" );
  }
  else if( !available.clipboard.commands[clipboard.command] )
  {
    # Preferred command not installed: print a warning and try your best:
    cat( "Warning: requested command ", clipboard.command );
    clipboard.command = (names(available.clipboard.commands)[available.clipboard.commands])[1];
    cat( " -- using ", clipboard.command, " instead...\n" );
  }

  # Save whole shitory to temporaty file:
  hist.file <- tempfile( "Rhistory" );
  savehistory( hist.file );
  full.hist <- readLines( hist.file );
  unlink( hist.file );

  # Read the last line before this one:
  last.line <- full.hist[ length(full.hist)-1 ];
 
  # And copy it to the clipboard: 
  clipboard.pipe <- pipe( pipe.commands[clipboard.command], "w" );
  cat( paste(last.line,"\n",sep=""), file=clipboard.pipe );
  close( clipboard.pipe );
  
  # Restore the history without the last command:
  hist.file <- tempfile( "Rhistory" );
  writeLines( full.hist[ -length(full.hist) ], hist.file );
  loadhistory( hist.file );
  unlink( hist.file );
}

.Traceback <-
NULL

Try the CommEcol package in your browser

Any scripts or data that you put into this service are public.

CommEcol documentation built on March 16, 2021, 9:07 a.m.